Changeset 6e9d48a in git
- Timestamp:
- Apr 3, 2005, 10:31:37 PM (18 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- f52515c83a11c2bf5c2744c7a7775df92a8eb725
- Parents:
- 0582696e2e59bf0b8bc20c14d1424a96c802fec2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/control.lib
r058269 r6e9d48a 1 version="$Id: control.lib,v 1.2 6 2005-03-17 18:42:48 levandovExp $";1 version="$Id: control.lib,v 1.27 2005-04-03 20:31:37 plural Exp $"; 2 2 category="Applications"; 3 3 info=" … … 13 13 14 14 PROCEDURES: 15 control (R); analysis of controllability-related properties of R (using Ext modules), 16 control2 (R); analysis of controllability-related properties of R (using dimension), 17 autonom (R); analysis of autonomy-related properties of R (using Ext modules), 18 autonom2 (R); analysis of autonomy-related properties of R (using dimension), 19 LeftKernel (R); a left kernel of R, 20 RightKernel (R); a right kernel of R, 21 LeftInverse (R); a left inverse of R, 22 RightInverse (R); a right inverse of R, 23 smith (M); a Smith form of a module M, 24 rank (M); a column rank of M as of matrix, 25 genericity (M); analysis of the genericity of parameters, 26 canonize (L); Groebnerification for modules in the output of control/autonomy procs, 27 FindTorsion (R, I); generators of the submodule of a module R, annihilated by the ideal I. 15 control (R); analysis of controllability-related properties of R (using Ext modules), 16 control2 (R); analysis of controllability-related properties of R (using dimension), 17 autonom (R); analysis of autonomy-related properties of R (using Ext modules), 18 autonom2 (R); analysis of autonomy-related properties of R (using dimension), 19 LeftKernel (R); a left kernel of R, 20 RightKernel (R); a right kernel of R, 21 LeftInverse (R); a left inverse of R, 22 RightInverse (R); a right inverse of R, 23 smith (M); a Smith form of a module M, 24 colrank (M); a column rank of M as of matrix, 25 genericity (M); analysis of the genericity of parameters, 26 canonize (L); Groebnerification for modules in the output of control/autonomy procs, 27 iostruct (R); computes an I/O-structure of behavior given by a module R 28 FindTorsion (R, I); generators of the submodule of a module R, annihilated by the ideal I. 28 29 29 30 … … 60 61 // static control_output(); Generating the output for the procedure 'control' 61 62 // static autonom_output(); Generating the output for the procedure 'autonom' and 'autonom2' 63 // static extgcd_Our(poly p, poly q) Computes extgcd of p and q. for versions ealier than 2006 extgcd has a bug and is therefore not used 64 // static normalize_Our(matrix N, matrix Q) normalizes the columns of N and divides the columns of Q through the leading coefficients of the columns of N 62 65 63 66 LIB "homolog.lib"; … … 539 542 " 540 543 { 541 if( nrows(R) != rank(transpose(R)) )544 if( nrows(R) != colrank(transpose(R)) ) 542 545 { 543 546 return ("control2 cannot be applied, since R does not have full row rank"); 544 547 } 545 intvec v= option(get);548 intvec v=Opt_Our(); 546 549 module R_std=std(R); 547 550 int d=dim_Our(R_std); 548 551 int NVars=nvars(basering); 549 552 int i=NVars-d; 550 module Ext_1; 551 552 if(i==1) 553 { 554 Ext_1=std(Ext_Our(1,R_std)); 555 } 553 module Ext_1=std(Ext_Our(1,R_std)); 556 554 matrix T=lift(R,R_std); 557 555 list l=genericity(T); … … 572 570 }; 573 571 //------------------------------------------------------------------------ 574 proc rank(module M)575 "USAGE: proc rank(M), M a matrix/module572 proc colrank(module M) 573 "USAGE: proc colrank(M), M a matrix/module 576 574 PURPOSE: compute the column rank of M as of matrix 577 575 RETURN: int 578 NOTE: this procedure uses bareiss-algorithm which might not terminate 576 NOTE: this procedure uses bareiss-algorithm which might not terminate in some cases 579 577 " 580 578 { … … 592 590 [-D(2),D(1),0]; 593 591 R=transpose(R); 594 rank(R);592 colrank(R); 595 593 }; 596 594 … … 602 600 NVars: integer, number of variables in a base ring 603 601 RC: module, kernel-representation of controllable part of the system 604 R_rank: integer, rank of the representation matrix602 R_rank: integer, column rank of the representation matrix 605 603 PURPOSE: compute all the autonomy properties of the system which is to be returned in 'autonom' procedure 606 604 RETURN: list … … 618 616 "kernel representation for controllable part", 619 617 RC, 620 "column -rank of the matrix",618 "column rank of the matrix", 621 619 R_rank, 622 620 DofS, … … 692 690 { 693 691 RC=LeftKernel(RightKernel(R)); 694 R_rank= rank(R);692 R_rank=colrank(R); 695 693 } 696 694 return( autonom_output(i,NVars,RC,R_rank) ); … … 731 729 { 732 730 RC=LeftKernel(RightKernel(R)); 733 R_rank= rank(R);731 R_rank=colrank(R); 734 732 } 735 733 return(autonom_output(i,NVars,RC,R_rank)); … … 1143 1141 view(CC); 1144 1142 } 1143 1144 //---------------------------------------------------------------- 1145 1146 static proc elementof (int i, intvec v) 1147 { 1148 int b=0; 1149 for(int j=1;j<=nrows(v);j++) 1150 { 1151 if(v[j]==i) 1152 { 1153 b=1; 1154 return (b); 1155 } 1156 } 1157 return (b); 1158 } 1159 //----------------------------------------------------------------- 1160 proc iostruct(module R) 1161 "USAGE: iostruct( R ); R a module 1162 RETURN: list L with entries: string s, intvec v, module P and module Q 1163 PURPOSE: if R is the kernel-representation-matrix of some system, then we output a input-ouput representation Py=Qu of the system, the components that have been chosen as outputs(intvec v) and a comment s 1164 NOTE: the procedure uses Bareiss algorithm which might not terminate in some cases 1165 EXAMPLE: example iostruct; shows an example 1166 " 1167 { 1168 list L = bareiss(R); 1169 int R_rank = ncols(L[1]); 1170 int NCols=ncols(R); 1171 intvec v=L[2]; 1172 int temp; 1173 int NRows=nrows(v); 1174 int i,j; 1175 int b=1; 1176 module P; 1177 module Q; 1178 int n=0; 1179 1180 while(b==1) //sort v through bubblesort 1181 { 1182 b=0; 1183 for(i=1;i<NRows;i++) 1184 { 1185 if(v[i]>v[i+1]) 1186 { 1187 temp=v[i]; 1188 v[i]=v[i+1]; 1189 v[i+1]=temp; 1190 b=1; 1191 } 1192 } 1193 } 1194 P=R[v]; //generate P 1195 for(i=1;i<=NCols;i++) //generate Q 1196 { 1197 if(elementof(i,v)==1) 1198 { 1199 i++; 1200 continue; 1201 } 1202 Q=Q,R[i]; 1203 } 1204 Q=simplify(Q,2); 1205 string s="The following components have been chosen as outputs: "; 1206 return (list(s,v,P,Q)); 1207 } 1208 example 1209 {"EXAMPLE:";echo = 2; 1210 //Example Antenna 1211 ring r = (0, K1, K2, Te, Kp, Kc),(Dt, delta), (c,dp); 1212 1213 module RR; 1214 RR = [Dt, -K1, 0, 0, 0, 0, 0, 0, 0], 1215 [0, Dt+K2/Te, 0, 0, 0, 0, -Kp/Te*delta, -Kc/Te*delta, -Kc/Te*delta], 1216 [0, 0, Dt, -K1, 0, 0, 0, 0, 0], 1217 [0, 0, 0, Dt+K2/Te, 0, 0, -Kc/Te*delta, -Kp/Te*delta, -Kc/Te*delta], 1218 [0, 0, 0, 0, Dt, -K1, 0, 0, 0], 1219 [0, 0, 0, 0, 0, Dt+K2/Te, -Kc/Te*delta, -Kc/Te*delta, -Kp/Te*delta]; 1220 module R = transpose(RR); 1221 view(R); 1222 view(iostruct(R)); 1223 }; 1224 1145 1225 //--------------------------------------------------------------- 1146 1226 static proc smdeg(matrix N) … … 1218 1298 } 1219 1299 //--------------------------------------------------------------- 1220 static proc Our_extgcd(poly p, poly q)1300 static proc extgcd_Our(poly p, poly q) 1221 1301 { 1222 1302 ideal J; //for extgcd-computations … … 1248 1328 return(L); 1249 1329 } 1330 static proc normalize_Our(matrix N, matrix Q) 1331 "USAGE: normalize_Our(N,Q), N, Q are two matrices 1332 PURPOSE: normalizes N and divides the columns of Q through the leading coefficients of the columns of N 1333 RETURN: normalized matrix N and altered Q(according to the scheme mentioned in purpose). If number of columns of N and Q do not coincide, N and Q are returned unchanged 1334 NOTE: number of columns of N and Q must coincide. 1335 " 1336 { 1337 if(ncols(N) != ncols(Q)) 1338 { 1339 return (N,Q); 1340 } 1341 module M = module(N); 1342 module S = module(Q); 1343 int NCols = ncols(N); 1344 number n; 1345 for(int i=1;i<=NCols;i++) 1346 { 1347 n = leadcoef(M[i]); 1348 if( n != 0 ) 1349 { 1350 M[i]=M[i]/n; 1351 S[i]=S[i]/n; 1352 } 1353 } 1354 N = matrix(M); 1355 Q = matrix(S); 1356 return (N,Q); 1357 } 1358 1250 1359 //--------------------------------------------------------------- 1251 1360 proc smith( module M ) … … 1257 1366 @* [3]: a unimodular matrix U, 1258 1367 @* [4]: a unimodular matrix V, 1259 such that U*M*V=S. An empty listis returned when no Smith Form exists.1260 NOTE: The Smith form only exists over PIDs (principal ideal domains). 1368 such that U*M*V=S. An warning is returned when no Smith Form exists. 1369 NOTE: The Smith form only exists over PIDs (principal ideal domains). Use global ordering for computations! 1261 1370 " 1262 1371 { 1263 1372 if (nvars(basering)>1) //if more than one variable, return empty list 1264 1373 { 1265 list @L;1266 return ( @L);1374 string s="The Smith-Form only exists for principal ideal domains"; 1375 return (s); 1267 1376 } 1268 1377 matrix N = matrix(M); //Typecasting … … 1321 1430 for(ii=k+1;ii<=n;ii++) 1322 1431 { 1323 N = addrow(N,k,-lambda[1,ii]*var(1)^f[1,ii],ii); 1324 N = normalize(N); 1432 N = addrow(N,k,-lambda[1,ii]*var(1)^f[1,ii],ii); 1325 1433 P = addrow(P,k,-lambda[1,ii]*var(1)^f[1,ii],ii); 1434 N,Q=normalize_Our(N,Q); 1326 1435 } 1327 1436 } … … 1345 1454 { 1346 1455 N=addcol(N,k,-mu[1,ii]*var(1)^g[1,ii],ii); 1347 N=normalize(N);1348 1456 Q=addcol(Q,k,-mu[1,ii]*var(1)^g[1,ii],ii); 1457 N,Q=normalize_Our(N,Q); 1349 1458 } 1350 1459 } 1351 1460 if( (k!=1) && (k<n) && (k<m) ) 1352 1461 { 1353 L = Our_extgcd(N[k-1,k-1],N[k,k]);1462 L = extgcd_Our(N[k-1,k-1],N[k,k]); 1354 1463 if ( N[k-1,k-1]!=L[1] ) //means that N[k-1,k-1] is not a divisor of N[k,k] 1355 1464 { 1356 1465 N=addrow(N,k-1,L[2],k); 1357 normalize(N);1358 1466 P=addrow(P,k-1,L[2],k); 1467 N,Q=normalize_Our(N,Q); 1359 1468 1360 N=addcol(N,k,-L[3],k-1); 1361 N=normalize(N); 1469 N=addcol(N,k,-L[3],k-1); 1362 1470 Q=addcol(Q,k,-L[3],k-1); 1471 N,Q=normalize_Our(N,Q); 1363 1472 k=k-2; 1364 1473 } … … 1387 1496 matrix N=matrix(M); 1388 1497 matrix B=L[3]*N*L[4]; 1389 B=normalize(std(B));1390 1498 print(B); 1391 1499 //------- and yet another example -------------- … … 1396 1504 matrix N2=matrix(M2); 1397 1505 matrix B2=P[3]*N2*P[4]; 1398 print(B2);1399 B2=normalize(std(B2));1400 1506 print(B2); 1401 1507 } … … 1477 1583 "USAGE: FindTorsion(R, I); R an ideal/matrix/module, I an ideal 1478 1584 PURPOSE: computes the Groebner basis of the submodule of R, annihilated by I 1479 RETURN: module1585 ETURN: module 1480 1586 NOTE: especially helpful, when I is the annihilator of the t(R) - the torsion submodule of R. In this case, the result is the explicit presentation of t(R) as 1481 1587 the submodule of R
Note: See TracChangeset
for help on using the changeset viewer.