Changeset d5f9d98 in git
- Timestamp:
- Feb 25, 2005, 11:45:27 AM (19 years ago)
- Branches:
- (u'spielwiese', 'ec94ef7a30b928574c0c3daf41f6804dff5f6b69')
- Children:
- dc6b576eab156ea960b83a3ed8a822d14adab0b7
- Parents:
- cbea7991f06987b6fda55b7d0836fa40b140110d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/control.lib
rcbea799 rd5f9d98 1 version="$Id: control.lib,v 1.2 1 2005-02-18 17:38:45levandov Exp $";1 version="$Id: control.lib,v 1.22 2005-02-25 10:45:27 levandov Exp $"; 2 2 category="Applications"; 3 3 info=" … … 13 13 14 14 PROCEDURES: 15 control(module R); analysis of controllability-related properties of R, 16 autonom(module R); analysis of autonomy-related properties of R (using Ext modules), 17 autonom2(module R); analysis of autonomy-related properties of R (using dimension), 18 19 LeftKernel(module R); a left kernel of R, 20 RightKernel(module R); a right kernel of R, 21 LeftInverse(module R) a left inverse of matrix (module), 22 23 smith(module M); a Smith form of a module M, 24 25 genericity(module M); analysis of the genericity of parameters, 26 27 canonize(list L); Groebnerification for modules in the output of control/autonomy procs. 15 control (R); analysis of controllability-related properties of R, 16 autonom (R); analysis of autonomy-related properties of R (using Ext modules), 17 autonom2 (R); analysis of autonomy-related properties of R (using dimension), 18 LeftKernel (R); a left kernel of R, 19 RightKernel (R); a right kernel of R, 20 LeftInverse (R) a left inverse of R, 21 smith (M); a Smith form of a module M, 22 genericity (M); analysis of the genericity of parameters, 23 canonize (L); Groebnerification for modules in the output of control/autonomy procs. 28 24 29 25 AUXILIARY PROCEDURES: 30 declare( string NameOfRing, Variables[,string Parameters, Ordering]); defines the ring, optional parametes are strings of parameters and ordering,31 view(); Well-formatted output of lists, modules and matrices26 declare(NameOfRing,Variables [,Parameters, Ordering]); define the ring easily 27 view(); well-formatted output of lists, modules and matrices 32 28 33 29 NOTE (EXAMPLES): In order to use examples below, execute the commands 34 30 @* def A = exAntenna(); setring A; 35 @* Thus A will become a basering from the example with the predefined module R (transposed), corresponding to the system. 36 After that you can just type in 31 @* Thus A will become a basering from the example with the predefined module R (transposed), corresponding to the system. After that you can just type in 37 32 @* control(R); //respectively autonom(R); 38 33 and check the result. … … 40 35 41 36 EXAMPLES (AUTONOMY): 42 43 37 exCauchy(); example of 1-dimensional Cauchy equation, 44 38 exCauchy2(); example of 2-dimensional Cauchy equation, … … 46 40 47 41 EXAMPLES (CONTROLLABILITY): 48 49 42 ex1(); example of noncontrollable system, 50 43 ex2(); example of controllable system , … … 52 45 exEinstein(); Einstein equations, 53 46 exFlexibleRod(); Flexible Rod, 54 exTwoPendula(); Two Pendula ,47 exTwoPendula(); Two Pendula mounted on a cart, 55 48 exWindTunnel(); Wind Tunnel. 56 49 "; … … 88 81 proc declare(string NameOfRing, string Variables, list #) 89 82 "USAGE: declare(NameOfRing, Variables,[Parameters, Ordering]); 90 NameOfRing: string with name of ring,91 Variables: string with names of variables separated by commas(e.g. "x,y,z"),92 [Parameters, Ordering]: optional, strings: 93 Parameters: string of parameters in the ring separated by commas(e.g. "a,b,c"), 94 Ordering: string with name of ordering(by default the ordering "dp,C" is used) 83 @* NameOfRing: string with name of ring, 84 @* Variables: string with names of variables separated by commas(e.g. \"x,y,z\"), 85 @* Parameters: string of parameters in the ring separated by commas(e.g. \"a,b,c\"), 86 @* Ordering: string with name of ordering (by default, the ordering \"dp,C\" is used) 87 PURPOSE: define the ring easily 95 88 RETURN: no return value 96 89 EXAMPLE: example declare; shows an example … … 183 176 " 184 177 { 178 // to be replaced with something more feasible 185 179 if ( (typeof(M)=="module")||(typeof(M)=="matrix") ) 186 180 { … … 254 248 proc RightKernel(matrix M) 255 249 "USAGE: RightKernel(M); M a matrix 256 RETURN: right kernel of matrix M, i.e., the module of all elements v such that Mv=0 250 PURPOSE: computes the right kernel of matrix M (a module of all elements v such that Mv=0) 251 RETURN: module 257 252 NOTE: in the noncommutative case RightKernel is a right module 258 EXAMPLE: 253 EXAMPLE: example RightKernel; shows an example 259 254 " 260 255 { … … 274 269 proc LeftKernel(matrix M) 275 270 "USAGE: LeftKernel(M); M a matrix 276 RETURN: left kernel of matrix M, i.e. the module of all elements v such that vM=0 271 PURPOSE: computes left kernel of matrix M (a module of all elements v such that vM=0) 272 RETURN: module 277 273 EXAMPLE: example LeftKernel; shows an example 278 274 " … … 293 289 proc LeftInverse(module M) 294 290 "USAGE: LeftInverse(M); M a module 295 RETURN: matrix L such that LM == Id; 291 PURPOSE: computes such a matrix L, that LM == Id; 292 RETURN: module 296 293 EXAMPLE: example LeftInverse; shows an example 297 294 NOTE: exists only in the case when Id \subseteq M! … … 350 347 //----------------------------------------------------------------------- 351 348 proc RightInverse(module R) 349 "USAGE: RightInverse(M); M a module 350 PURPOSE: computes such a matrix L, that ML == Id; 351 RETURN: module 352 EXAMPLE: example RightInverse; shows an example 353 NOTE: exists only in the case when Id \subseteq M! 354 " 352 355 { 353 356 return(transpose(LeftInverse(transpose(R)))); 354 357 } 358 example 359 { // trivial example: 360 "EXAMPLE:";echo =2; 361 ring r = 0,(x,z),dp; 362 matrix M[1][2] = 1,x2+z; 363 print(M); 364 print( RightInverse(M) ); 365 kill r; 366 // derived from the exTwoPendula 367 ring r=(0,m1,m2,M,g,L1,L2),Dt,dp; 368 matrix U[1][3]; 369 U[1,1]=(-L2)*Dt^4+(g)*Dt^2; 370 U[1,2]=(-L1)*Dt^4+(g)*Dt^2; 371 U[1,3]=(L1*L2)*Dt^4+(-g*L1-g*L2)*Dt^2+(g^2); 372 module M = module(U); 373 module L = RightInverse(M); 374 print(L); 375 }; 355 376 //----------------------------------------------------------------------- 356 377 static proc dim_Our(module R) … … 420 441 "USAGE: control_output(i, NVars, R, Ext_1), where 421 442 i: integer, number of first nonzero Ext or 422 justnumber of variables in a base ring + 1 in case that all the Exts are zero,443 just a number of variables in a base ring + 1 in case that all the Exts are zero, 423 444 NVars: integer, number of variables in a base ring, 424 445 R: module R (cokernel representation), … … 503 524 504 525 proc control(module R) 505 "USAGE: control(R); R a module (R is the matrix of the system of equations which is to be investigated) 506 RETURN: list of all the properties concerning controllability of the system (behavior) represented by the matrix R 526 "USAGE: control(R); R a module (R is the matrix of the system of equations to be investigated) 527 PURPOSE: compute the list of all the properties concerning controllability of the system (behavior), represented by the matrix R 528 RETURN: list 507 529 EXAMPLE: example control; shows an example 508 530 " … … 546 568 //------------------------------------------------------------------------------------------ 547 569 proc control2(module R) 548 "USAGE: control2(R); R a module (R is the matrix of the system of equations which is to be investigated) 549 RETURN: list of all the properties concerning controllability of the system (behavior) represented by the matrix R 570 "USAGE: control2(R); R a module (R is the matrix of the system of equations to be investigated) 571 PURPOSE: computes list of all the properties concerning controllability of the system (behavior), represented by the matrix R 572 RETURN: list 550 573 EXAMPLE: example control; shows an example 551 574 NOTE: same as control(R); but using dimensions … … 657 680 proc autonom2(module R) 658 681 "USAGE: autonom2(R); R a module (R is a matrix of the system of equations which is to be investigated) 659 RETURN: list of all the properties concerning autonomy of the system (behavior) represented by the matrix R 660 NOTE: this procedure is an analogue to 'autonom' using dimension calculations 682 PURPOSE: computes the list of all the properties concerning autonomy of the system (behavior), represented by the matrix R 683 RETURN: list 684 NOTE: this procedure is analogous to 'autonom' but uses dimension calculations 661 685 EXAMPLE: example autonom2; shows an example 662 686 " … … 872 896 proc genericity(matrix M) 873 897 "USAGE: genericity(M), M is a module/matrix 874 RETURN: list of strings with expressions, which have been assumed to be non-zero in the process of computing the Groebner basis 898 PURPOSE: determine parametric expressions which have been assumed to be non-zero in the process of computing the Groebner basis 899 RETURN: list (of strings) 875 900 NOTE: we strongly recommend to switch on the redSB and redTail options; 876 the procedure is effective with the lift procedure for modules with parameters901 @* the procedure is effective with the lift procedure for modules with parameters 877 902 EXAMPLE: example genericity; shows an example 878 903 " 879 904 { 905 // returns nothing, if there are no parameters! 906 if (npars(basering)==0) 907 { 908 return(""); 909 } 910 int plevel = printlevel-voice+2; 880 911 // M is a matrix over a ring with params and vars; 881 912 ideal I = ideal(M); // a list of entries … … 890 921 intvec ZeroVec; ZeroVec[nvars(basering)] = 0; 891 922 intvec W; 923 ideal Numero, Denomiro; 924 int cNu=0; int cDe=0; 892 925 for (i=1; i<=s; i++) 893 926 { … … 898 931 { 899 932 num = denominator(leadcoef(p)); // from poly.lib 900 p = p*num; 901 NM[cl] = p; 933 NM[cl] = numerator(leadcoef(p)); 934 dbprint(p,"numerator:"); 935 dbprint(p, string(NM[cl])); 936 cNu++; Numero[cNu]= NM[cl]; 902 937 cl++; 903 NM[cl] = num; 938 NM[cl] = num; // denominator 939 dbprint(p,"denominator:"); 940 dbprint(p, string(NM[cl])); 941 cDe++; Denomiro[cDe]= NM[cl]; 904 942 cl++; 905 943 p = p - lead(p); // for the next cycle … … 910 948 p = p/num; 911 949 NM[cl] = denominator(num); 950 dbprint(p,"content denominator:"); 951 dbprint(p, string(NM[cl])); 952 cNu++; Numero[cNu]= NM[cl]; 912 953 cl++; 913 954 NM[cl] = numerator(num); 955 dbprint(p,"content numerator:"); 956 dbprint(p, string(NM[cl])); 957 cDe++; Denomiro[cDe]= NM[cl]; 914 958 cl++; 915 959 } 960 // it seems that the next elements will not have real influence 916 961 while( p != 0) 917 962 { 918 NM[cl] = leadcoef(p); // should be all integer 963 NM[cl] = leadcoef(p); // should be all integer, i.e. non-rational 964 dbprint(p,"coef:"); 965 dbprint(p, string(NM[cl])); 919 966 cl++; 920 967 p = p - lead(p); … … 944 991 cf = 1; 945 992 // factorize every polynomial 946 // throw away every non-monomial993 // throw away every monomial from factorization (also constants from above ring) 947 994 for (j=1; j<=size(F);j++) 948 995 { … … 957 1004 } 958 1005 // return the result [in string-format] 959 @L = simplify(@L,2+4 ); // skip zeroes and double entries1006 @L = simplify(@L,2+4+8); // skip zeroes, doubled and entries, diff. by a constant 960 1007 list SL; 961 1008 for (j=1; j<=size(@L);j++) … … 989 1036 proc canonize(list L) 990 1037 "USAGE: canonize(L), L a list 1038 PURPOSE: modules in the list are canonized by computing their reduced minimal (= unique in the given ordering) Groebner bases 1039 RETURN: list 991 1040 ASSUME: L is the output of control/autonomy procedures 992 RETURN: a canonized list, where modules are canonized by computing993 their reduced minimal (= unique in the given ordering) Groebner bases994 1041 EXAMPLE: example canonize; shows an example 995 1042 " … … 1083 1130 } 1084 1131 } 1085 1132 //--------------------------------------------------------------- 1086 1133 static proc NoNon0Pol(vector v) 1087 1134 // returns 1, if there is only one non-zero element in v and 0 else … … 1102 1149 return(i); 1103 1150 } 1104 1105 1151 //--------------------------------------------------------------- 1106 1152 proc smith( module M ) 1107 1153 "USAGE: smith(M), M a module or a matrix, 1154 PURPOSE: computes the Smith form of a matrix 1108 1155 RETURN: a list of length 4 with the following entries: 1109 [1]: The Smith-Form S of M,1110 [2]: the rank of M,1111 [3]: a unimodular matrix U,1112 [4]: a unimodular matrix V,1156 @* [1]: The Smith-Form S of M, 1157 @* [2]: the rank of M, 1158 @* [3]: a unimodular matrix U, 1159 @* [4]: a unimodular matrix V, 1113 1160 such that U*M*V=S. An empty list is returned when no Smith Form exists. 1114 1161 NOTE: The Smith form only exists over PIDs (principal ideal domains). … … 1256 1303 print(B2); 1257 1304 } 1305 //--------------------------------------------------------------- 1306 proc list_tex(list L, string name, link l) 1307 "USAGE: control_tex(l), where l is a list 1308 PURPOSE: writes the content of list L in a tex-file 'name' 1309 RETURN: nothing 1310 " 1311 { 1312 if(size(L)==0) 1313 { 1314 } 1315 else 1316 { 1317 string t; 1318 for (int i=1;i<=size(L);i++) 1319 { 1320 while(1) 1321 { 1322 if(typeof(L[i])=="string") 1323 { 1324 t=L[i]; 1325 write(l,t,"\\par"); 1326 break; 1327 } 1328 if(typeof(L[i])=="module") 1329 { 1330 texobj(s,matrix(L[i])); 1331 break; 1332 } 1333 texobj(s,L[i]); 1334 write(l,"\\par"); 1335 break; 1336 } 1337 } 1338 } 1339 } 1340 //--------------------------------------------------------------- 1341 proc verbatim_tex(string s, link l) 1342 "USAGE: verbatim_tex(s,l), where s is a string and l a link 1343 PURPOSE: writes the content of s in verbatim-environment in the file 1344 specified by link 1345 RETURN: nothing 1346 " 1347 { 1348 write(l,"\\begin{verbatim}"); 1349 write(l,s); 1350 write(l,"\\end{verbatim}"); 1351 write(l,"\\par"); 1352 }
Note: See TracChangeset
for help on using the changeset viewer.