Changeset 0c824aa in git
- Timestamp:
- Mar 17, 2005, 7:42:48 PM (18 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
- Children:
- ce6c4df83cce5d4f8fcff0bdd37452a4649eef33
- Parents:
- b687a30f0e0e5c6b27bb1b68424088f6ea28d02d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/control.lib
rb687a3 r0c824aa 1 version="$Id: control.lib,v 1.2 5 2005-03-16 22:16:53levandov Exp $";1 version="$Id: control.lib,v 1.26 2005-03-17 18:42:48 levandov 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 18 autonom2 (R); 19 LeftKernel 20 RightKernel (R); 21 LeftInverse (R); 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 22 RightInverse (R); a right inverse of R, 23 smith (M); a Smith form of a module M, 24 genericity (M); analysis of the genericity of parameters, 25 canonize (L); Groebnerification for modules in the output of control/autonomy procs. 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. 28 26 29 27 30 AUXILIARY PROCEDURES: … … 62 65 LIB "primdec.lib"; 63 66 LIB "matrix.lib"; 64 // -- noncommutative procs:65 LIB "ncalg.lib";66 LIB "nctools.lib";67 LIB "nchomolog.lib";68 LIB "gkdim.lib";69 67 70 68 //--------------------------------------------------------------- … … 81 79 return (v); 82 80 } 81 //--------------------------------------------------------------- 83 82 proc declare(string NameOfRing, string Variables, list #) 84 83 "USAGE: declare(NameOfRing, Variables,[Parameters, Ordering]); … … 252 251 PURPOSE: computes the right kernel of matrix M (a module of all elements v such that Mv=0) 253 252 RETURN: module 254 NOTE: in the noncommutative case RightKernel is a right module255 253 EXAMPLE: example RightKernel; shows an example 256 254 " … … 297 295 " 298 296 { 299 // now it works also for the NC case; 300 // two approaches are possible; 301 // the older one is commented out 297 // it works also for the NC case; 302 298 int NCols = ncols(M); 303 299 module Id = freemodule(NCols); … … 307 303 matrix T; 308 304 // check the correctness (Id \subseteq M) 309 // via dimension: {dim/GKdim}(M) = -1!305 // via dimension: dim (M) = -1! 310 306 int d = dim_Our(N); 311 307 if (d != -1) 312 308 { 313 // "No left inverse exists";309 // No left inverse exists 314 310 return(matrix(0)); 315 311 } 316 // module N = liftstd(M, T);317 // ideal TT = ideal(NF(N,Id));318 // TT = simplify(TT,2);319 // if (TT[1]!=0)320 // {321 // "No left inverse exists";322 // return(matrix(0));323 // }324 312 matrix T2 = lift(N, Id); 325 // T2 = transpose(T2)*transpose(T);326 313 T2 = transpose(T2); 327 // set options back 328 option(set,old_opt); 314 option(set,old_opt); // set the options back 329 315 return(T2); 330 316 } … … 359 345 } 360 346 example 361 { // trivial example:362 "EXAMPLE:";echo =2; 347 { "EXAMPLE:";echo =2; 348 // trivial example: 363 349 ring r = 0,(x,z),dp; 364 350 matrix M[1][2] = 1,x2+z; … … 384 370 R = std(R); 385 371 } 386 // if (Is_NC())387 // {388 // d = GKdim(R);389 // }390 // else { d = dim(R); }391 372 d = dim(R); 392 373 return(d); … … 395 376 static proc Ann_Our(module R) 396 377 { 397 // if (Is_NC())398 // {399 // // TODO: use preAnn, that is an annihilator of the generators400 // // what is a left ideal!401 // return(-1);402 // }403 // else404 // {405 // return(Ann(R));406 // }407 378 return(Ann(R)); 408 379 } 409 380 //----------------------------------------------------------------------- 410 381 static proc Ext_Our(int i, module R, list #) 411 // mimicking 'Ext_R' from "homolog.lib" in commutative case 412 { 413 // int ISNC = Is_NC(); 382 { 383 // mimicking 'Ext_R' from homolog.lib 414 384 int ExtraArg = ( size(#)>0 ); 415 // if (ISNC)416 // {417 // // ExtraArg not yet implemented and thus ignored418 // return( ncExt_R(i,R) );419 // }420 // the commutative case:421 385 if (ExtraArg) 422 386 { … … 430 394 //------------------------------------------------------------------------ 431 395 static proc is_zero_Our 432 //just a copy of 'is_zero' from "poly.lib" patched with GKdim 433 { 396 { 397 //just a copy of 'is_zero' from "poly.lib" patched with GKdim 434 398 int d = dim_Our(std(#[1])); 435 399 int a = ( d==-1 ); … … 452 416 { 453 417 // TODO: NVars to be replaced with the global hom. dimension of basering!!! 418 // Is not clear what to do with gl.dim of qrings 454 419 string DofS = "dimension of the system:"; 455 420 string Fn = "number of first nonzero Ext:"; 456 string Gen_mes = " The following parameter constellations might lead to a non-controllable system:";421 string Gen_mes = "Parameter constellations which might lead to a non-controllable system:"; 457 422 458 423 module RK = RightKernel(R); … … 539 504 module R_std=std(R); 540 505 module Ext_1 = std(Ext_Our(1,R_std)); 541 // module Ext_1 = std(Ext_Our(1,R));542 506 543 507 ExtIsZero=is_zero_Our(Ext_1); … … 547 511 i++; 548 512 ExtIsZero = is_zero_Our( Ext_Our(i,R_std) ); 549 // ExtIsZero = is_zero_Our( Ext_Our(i,R) );550 513 }; 551 514 matrix T=lift(R,R_std); … … 554 517 555 518 return( control_output( i, NVars, R, Ext_1, l ) ); 556 // return( control_output( i, NVars, R, Ext_1 ) );557 519 } 558 520 example … … 568 530 view(control(R)); 569 531 }; 570 //-------------------------------------------------------------------------- ----------------532 //-------------------------------------------------------------------------- 571 533 proc control2(module R) 572 534 "USAGE: control2(R); R a module (R is the matrix of the system of equations to be investigated) … … 574 536 RETURN: list 575 537 EXAMPLE: example control2; shows an example 576 NOTE: same as control(R); but using dimensions 538 NOTE: same as control(R); but using dimensions, this procedure only works for full row rank matrices 577 539 " 578 540 { … … 623 585 example 624 586 {"EXAMPLE: ";echo = 2; 625 // deRham complex587 // de Rham complex 626 588 ring r=0,(D(1..3)),dp; 627 589 module R; … … 635 597 //------------------------------------------------------------------------ 636 598 static proc autonom_output( int i, int NVars, module RC, int R_rank ) 637 //static proc autonom_output( int i, int NVars, module RC )638 //static proc autonom_output( int i, int NVars )639 599 "USAGE: proc autonom_output(i, NVars, RC, R_rank) 640 600 i: integer, number of first nonzero Ext or … … 724 684 int d; 725 685 int NVars = nvars(basering); 726 // R = transpose(R);727 // d = dim_Our( std(R) );728 // return( autonom_output(NVars-d,NVars) );729 686 module RT = transpose(R); 730 687 module RC; //for computation of controllable part if if exists 688 int R_rank = ncols(R); 731 689 d = dim_Our( std(RT) ); //this is the dimension of the system 732 690 int i = NVars-d; //First non-zero Ext … … 734 692 { 735 693 RC=LeftKernel(RightKernel(R)); 736 } 737 return( autonom_output(i,NVars,RC) ); 694 R_rank=rank(R); 695 } 696 return( autonom_output(i,NVars,RC,R_rank) ); 738 697 } 739 698 example … … 763 722 int R_rank=ncols(R); 764 723 ExtIsZero=is_zero_Our(Ext_Our(0,RT)); 765 // R=transpose(R);766 // ExtIsZero=is_zero_Our(Ext_Our(0,R));767 724 int i=0; 768 725 while( (ExtIsZero)&&(i<=NVars) ) … … 770 727 i++; 771 728 ExtIsZero = is_zero_Our(Ext_Our(i,RT)); 772 // ExtIsZero = is_zero_Our(Ext_Our(i,R));773 729 }; 774 if (i==0)775 776 777 778 730 if (i==0) 731 { 732 RC=LeftKernel(RightKernel(R)); 733 R_rank=rank(R); 734 } 779 735 return(autonom_output(i,NVars,RC,R_rank)); 780 // return(autonom_output(i,NVars,RC));781 // return(autonom_output(i,NVars));782 736 } 783 737 example 784 738 {"EXAMPLE:"; echo = 2; 785 // Cauchy739 // Cauchy 786 740 ring r=0,(s1,s2,s3,s4),dp; 787 741 module R= [s1,-s2], … … 834 788 //---------------------------------------------------------- 835 789 //control 836 // 790 //---------------------------------------------------------- 837 791 proc ex1() 838 792 { … … 849 803 ring @r=0,(s1,s2,s3),dp; 850 804 module R=[0,-s3,s2], 851 852 805 [s3,0,-s1], 806 [-s2,s1,0]; 853 807 R=transpose(R); 854 808 export R; … … 894 848 }; 895 849 896 897 850 //---------------------------------------------------------- 898 899 851 proc exFlexibleRod() 900 852 { … … 934 886 //---------------------------------------------------------- 935 887 proc genericity(matrix M) 936 "USAGE: genericity(M), M is a m odule/matrix888 "USAGE: genericity(M), M is a matrix/module 937 889 PURPOSE: determine parametric expressions which have been assumed to be non-zero in the process of computing the Groebner basis 938 890 RETURN: list (of strings) … … 947 899 return("-"); 948 900 } 949 list RT = evas_genericity(M); 901 list RT = evas_genericity(M); // list of strings 902 if ((size(RT)==1) && (RT[1] == "")) 903 { 904 return("-"); 905 } 950 906 return(RT); 951 907 } … … 971 927 } 972 928 //--------------------------------------------------------------- 973 proc victors_genericity(matrix M) 974 "USAGE: genericity(M), M is a module/matrix 975 PURPOSE: determine parametric expressions which have been assumed to be non-zero in the process of computing the Groebner basis 976 RETURN: list (of strings) 977 NOTE: we strongly recommend to switch on the redSB and redTail options; 978 @* the procedure is effective with the lift procedure for modules with parameters 979 EXAMPLE: example genericity; shows an example 980 " 929 static proc victors_genericity(matrix M) 981 930 { 982 931 // returns "-", if there are no parameters! … … 1090 1039 return(SL); 1091 1040 } 1092 example 1093 { // TwoPendula 1094 "EXAMPLE:"; echo = 2; 1095 ring r=(0,m1,m2,M,g,L1,L2),Dt,dp; 1096 module RR = 1097 [m1*L1*Dt^2, m2*L2*Dt^2, -1, (M+m1+m2)*Dt^2], 1098 [m1*L1^2*Dt^2-m1*L1*g, 0, 0, m1*L1*Dt^2], 1099 [0, m2*L2^2*Dt^2-m2*L2*g, 0, m2*L2*Dt^2]; 1100 module R = transpose(RR); 1101 module SR = std(R); 1102 matrix T = lift(R,SR); 1103 genericity(T); 1104 //-- The result might be different when computing reduced bases: 1105 matrix T2; 1106 option(redSB); 1107 option(redTail); 1108 module SR2 = std(R); 1109 T2 = lift(R,SR2); 1110 genericity(T2); 1111 } 1041 //--------------------------------------------------------------- 1042 static proc evas_genericity(matrix M) 1043 { 1044 // called from the main genericity proc 1045 ideal I = ideal(M); 1046 I = simplify(I,2+4); 1047 int s = size(I); 1048 ideal Den; 1049 poly p; 1050 int i; 1051 for (i=1; i<=s; i++) 1052 { 1053 p = I[i]; 1054 while (p !=0) 1055 { 1056 Den = Den, denominator(leadcoef(p)); 1057 p = p-lead(p); 1058 } 1059 } 1060 Den = simplify(Den,2+4); 1061 string newvars = parstr(basering); 1062 def save = basering; 1063 string NewRing = "ring @NR =" +string(char(basering))+",("+newvars+"),Dp;"; 1064 execute(NewRing); 1065 ideal F; 1066 ideal Den = imap(save,Den); 1067 Den = simplify(Den,2); 1068 int s1 = size(Den); 1069 for (i=1; i<=s1; i++) 1070 { 1071 if (Den[i] !=1) 1072 { 1073 F= F, factorize(Den[i],1); 1074 } 1075 } 1076 F = simplify(F, 2+4+8); 1077 ideal @L = F; 1078 list SL; 1079 int c,j; 1080 string Mono; 1081 c = 1; 1082 for (j=1; j<=size(@L);j++) 1083 { 1084 if (leadcoef(@L[j]) <0) 1085 { 1086 @L[j] = -1*@L[j]; 1087 } 1088 if ( (@L[j] - lead(@L[j]))==0 ) //@L[j] is a monomial 1089 { 1090 Mono = Mono + string(@L[j])+ ","; // concatenation 1091 } 1092 else 1093 { 1094 c++; 1095 SL[c] = string(@L[j]); 1096 } 1097 } 1098 if (Mono!="") 1099 { 1100 Mono = Mono[1..size(Mono)-1]; // delete the last semicolon 1101 } 1102 SL[1] = Mono; 1103 setring save; 1104 return(SL); 1105 } 1106 1112 1107 //--------------------------------------------------------------- 1113 1108 proc canonize(list L) … … 1121 1116 list M = L; 1122 1117 intvec v=Opt_Our(); 1123 // option(redSB);1124 // option(redTail);1125 1118 int s = size(L); 1126 1119 int i; … … 1135 1128 } 1136 1129 option(set, v); //set old values back 1137 // option(noredTail); // set the initial option back1138 1130 return(M); 1139 1131 } … … 1161 1153 int i,j; // counter 1162 1154 1163 if (N==0)1164 { 1165 v =1,1;1155 if (N==0) 1156 { 1157 v = 1,1; 1166 1158 return(v); 1167 1159 } 1168 1160 1169 for(i=1;i<=n;i++) // hier wird ein Element ausgewaehlt(!=0) und mit dessen Grad gestartet 1170 { 1171 for(j=1;j<=m;j++) 1161 for (i=1; i<=n; i++) 1162 // hier wird ein Element ausgewaehlt(!=0) und mit dessen Grad gestartet 1163 { 1164 for (j=1; j<=m; j++) 1172 1165 { 1173 1166 if( deg(N[i,j])!=-1 ) 1174 1167 { 1175 1176 1168 d=deg(N[i,j]); 1169 break; 1177 1170 } 1178 1171 } 1179 if (d!=-1)1172 if (d != -1) 1180 1173 { 1181 1174 break; 1182 1175 } 1183 1176 } 1184 for(i 1185 { 1186 for(j=1; j<=m;j++)1177 for(i=1; i<=n; i++) 1178 { 1179 for(j=1; j<=m; j++) 1187 1180 { 1188 1181 d_temp = deg(N[i,j]); 1189 if ( (d_temp < d) && (N[i,j]!=0) )1182 if ( (d_temp < d) && (N[i,j]!=0) ) 1190 1183 { 1191 1184 d=d_temp; 1192 1185 } 1193 1186 } … … 1195 1188 for (i=1; i<=n; i++) 1196 1189 { 1197 for (j 1190 for (j=1; j<=m;j++) 1198 1191 { 1199 1192 if ( (deg(N[i,j]) == d) && (N[i,j]!=0) ) 1200 1193 { 1201 1202 1194 v = i,j; 1195 return(v); 1203 1196 } 1204 1197 } … … 1211 1204 int i,j; 1212 1205 int n = nrows(v); 1213 for( j=1; j<=n;j++)1214 { 1215 if (v[j]!=0)1206 for( j=1; j<=n; j++) 1207 { 1208 if (v[j] != 0) 1216 1209 { 1217 1210 i++; … … 1223 1216 } 1224 1217 return(i); 1218 } 1219 //--------------------------------------------------------------- 1220 static proc Our_extgcd(poly p, poly q) 1221 { 1222 ideal J; //for extgcd-computations 1223 matrix T; //----------"------------ 1224 list L; 1225 // the extgcd-command has a bug in versions before 2-0-7 1226 if ( system("version")<=2006 ) 1227 { 1228 J = p,q; // J = N[k-1,k-1],N[k,k]; //J is of type ideal 1229 L[1] = liftstd(J,T); //T is of type matrix 1230 if(J[1]==p) //this is just for the case the SINGULAR swaps the 1231 // two elements due to ordering 1232 { 1233 L[2] = T[1,1]; 1234 L[3] = T[2,1]; 1235 } 1236 else 1237 { 1238 L[2] = T[2,1]; 1239 L[3] = T[1,1]; 1240 } 1241 } 1242 else 1243 { 1244 L=extgcd(p,q); 1245 // L=extgcd(N[k-1,k-1],N[k,k]); 1246 //one can use this line if extgcd-bug is fixed 1247 } 1248 return(L); 1225 1249 } 1226 1250 //--------------------------------------------------------------- … … 1238 1262 { 1239 1263 if (nvars(basering)>1) //if more than one variable, return empty list 1240 1241 1242 1243 1264 { 1265 list @L; 1266 return (@L); 1267 } 1244 1268 matrix N = matrix(M); //Typecasting 1245 1269 int n = nrows(N); … … 1264 1288 while(k<=m ) //inner while-loop for row-operations 1265 1289 { 1266 1267 1268 1269 1270 1271 1272 1290 if( (n>m) && (k < n) && (k<m)) 1291 { 1292 if( simplify((ideal(submat(N,k+1..n,k+1..m))),2)== 0) 1293 { 1294 return(N,k-1,P,Q); 1295 } 1296 } 1273 1297 i,j = smdeg(submat(N,k..n,k..m)); //choose smallest degree in the remaining submatrix 1274 1298 i=i+(k-1); //indices adjusted to the whole matrix … … 1298 1322 { 1299 1323 N = addrow(N,k,-lambda[1,ii]*var(1)^f[1,ii],ii); 1300 1324 N = normalize(N); 1301 1325 P = addrow(P,k,-lambda[1,ii]*var(1)^f[1,ii],ii); 1302 1326 } 1303 1327 } 1304 1328 if (k>n) 1305 1329 { 1306 1330 break; 1307 1331 } 1308 1332 if(NoNon0Pol(transpose(N)[k])==1) … … 1327 1351 if( (k!=1) && (k<n) && (k<m) ) 1328 1352 { 1329 L=extgcd(N[k-1,k-1],N[k,k]); //one can use this line if extgcd-bug is fixed 1330 1331 if(!(N[k-1,k-1]==L[1])) //means that N[k-1,k-1] is not a divisor of N[k,k] 1332 { 1333 N=addrow(N,k-1,L[2],k); 1334 normalize(N); 1335 P=addrow(P,k-1,L[2],k); 1336 1337 N=addcol(N,k,-L[3],k-1); 1338 N=normalize(N); 1339 Q=addcol(Q,k,-L[3],k-1); 1340 k=k-2; 1341 } 1353 L = Our_extgcd(N[k-1,k-1],N[k,k]); 1354 if ( N[k-1,k-1]!=L[1] ) //means that N[k-1,k-1] is not a divisor of N[k,k] 1355 { 1356 N=addrow(N,k-1,L[2],k); 1357 normalize(N); 1358 P=addrow(P,k-1,L[2],k); 1359 1360 N=addcol(N,k,-L[3],k-1); 1361 N=normalize(N); 1362 Q=addcol(Q,k,-L[3],k-1); 1363 k=k-2; 1364 } 1342 1365 } 1343 1366 } 1344 1367 if( (k<=n) && (k<=m) ) 1345 1346 1347 1348 1349 1350 1368 { 1369 if( N[k,k]==0) 1370 { 1371 return(N,k-1,P,Q); 1372 } 1373 } 1351 1374 return(N,k,P,Q); 1352 1375 } … … 1357 1380 option(redTail); 1358 1381 ring r=0,x,dp; 1359 // This example is trivial, but we want to see, 1360 // that nothing is changed, when the matrix is already in Smith-Form! 1382 // see what happens when the matrix is already in Smith-Form 1361 1383 module M = [x,0,0],[0,x2,0],[0,0,x3]; 1362 1384 print(M); … … 1475 1497 } 1476 1498 int nc = ncols(S); 1477 module Tmp = AS*freemodule(nc); 1478 module To = modulo(Tmp,S); 1479 To = NF(std(To+S),S); 1480 To = simplify(To,2); 1481 To = std(To); 1499 module To = quotient(S,AS); 1500 To = std(NF(To,S)); 1482 1501 return(To); 1483 1502 } … … 1490 1509 module RR = transpose(R); 1491 1510 list L = control(RR); 1492 view(L);1493 1511 // here, we have the annihilator: 1494 1512 ideal LAnn = D1; // = L[10] … … 1497 1515 print(Tr); // generators of the torsion submodule 1498 1516 } 1499 //---------------------------------------------------------------1500 proc evas_genericity(matrix M)1501 {1502 ideal I=ideal(M);1503 I=simplify(I,2+4);1504 int s = size(I);1505 ideal Den;1506 poly p;1507 int i;1508 for (i=1; i<=s; i++)1509 {1510 p=I[i];1511 while (p !=0)1512 { Den=Den,denominator(leadcoef(p));1513 p=p-lead(p);1514 }1515 }1516 Den=simplify(Den,2+4);1517 string newvars = parstr(basering);1518 def save = basering;1519 string NewRing = "ring @NR =" +string(char(basering))+",("+newvars+"),Dp;";1520 execute(NewRing);1521 ideal F;1522 ideal Den = imap(save,Den);1523 Den=simplify(Den,1);1524 int s1=size(Den);1525 for (i=1;i<=s1; i++)1526 {1527 if (Den[i] !=1)1528 {1529 F=F,factorize(Den[i],1);1530 }1531 }1532 F=simplify(F,2+4+8);1533 // print(F);1534 ideal @L = F;1535 list SL;1536 int j;1537 for (j=1; j<=size(@L);j++)1538 {1539 SL[j] = string(@L[j]);1540 }1541 setring save;1542 return(SL);1543 }
Note: See TracChangeset
for help on using the changeset viewer.