Changeset 2b9b32 in git
- Timestamp:
- Mar 16, 2005, 11:16:53 PM (18 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
- Children:
- 42d5aa6a6beb385d8854055d86c22cf5fd0d3670
- Parents:
- eccbb153088fe98a0348384fdd90e9bf6414e860
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/control.lib
reccbb1 r2b9b32 1 version="$Id: control.lib,v 1.2 4 2005-03-16 16:15:14levandov Exp $";1 version="$Id: control.lib,v 1.25 2005-03-16 22:16:53 levandov Exp $"; 2 2 category="Applications"; 3 3 info=" … … 577 577 " 578 578 { 579 if( nrows(R) != rank(transpose(R)) ) 580 { 581 return ("control2 cannot be applied, since R does not have full row rank"); 582 } 579 583 intvec v=option(get); 580 584 module R_std=std(R); … … 607 611 //------------------------------------------------------------------------ 608 612 proc rank(module M) 609 { 610 module M_red=bareiss(M)[1]; 611 int NCols_red=ncols(M_red); 613 "USAGE: proc rank(M), M a matrix/module 614 PURPOSE: compute the column rank of M as of matrix 615 RETURN: int 616 NOTE: this procedure uses bareiss-algorithm which might not terminate 617 " 618 { 619 module M_red = bareiss(M)[1]; 620 int NCols_red = ncols(M_red); 612 621 return (NCols_red); 613 622 } 623 example 624 {"EXAMPLE: ";echo = 2; 625 //deRham complex 626 ring r=0,(D(1..3)),dp; 627 module R; 628 R=[0,-D(3),D(2)], 629 [D(3),0,-D(1)], 630 [-D(2),D(1),0]; 631 R=transpose(R); 632 rank(R); 633 }; 634 614 635 //------------------------------------------------------------------------ 615 636 static proc autonom_output( int i, int NVars, module RC, int R_rank ) 616 637 //static proc autonom_output( int i, int NVars, module RC ) 617 638 //static proc autonom_output( int i, int NVars ) 618 "USAGE: proc autonom_output(i, NVars )639 "USAGE: proc autonom_output(i, NVars, RC, R_rank) 619 640 i: integer, number of first nonzero Ext or 620 641 just number of variables in a base ring + 1 in case that all the Exts are zero 621 642 NVars: integer, number of variables in a base ring 622 RETURN: list with all the autonomy properties of the system which is to be returned in 'autonom' procedure 643 RC: module, kernel-representation of controllable part of the system 644 R_rank: integer, rank of the representation matrix 645 PURPOSE: compute all the autonomy properties of the system which is to be returned in 'autonom' procedure 646 RETURN: list 623 647 NOTE: this procedure is used in 'autonom' procedure 624 648 " … … 705 729 module RT = transpose(R); 706 730 module RC; //for computation of controllable part if if exists 707 d = dim_Our( std(RT) ); //this is the dimension of the system708 int i =NVars-d; //First non-zero Ext709 if( d==0)731 d = dim_Our( std(RT) ); //this is the dimension of the system 732 int i = NVars-d; //First non-zero Ext 733 if( d==0 ) 710 734 { 711 735 RC=LeftKernel(RightKernel(R)); … … 728 752 proc autonom(module R) 729 753 "USAGE: autonom(R); R a module (R is a matrix of the system of equations which is to be investigated) 730 RETURN: list of all the properties concerning autonomy of the system (behavior) represented by the matrix R 731 EXAMPLE: example autonom; shows an example 754 PURPOSE: find all the properties concerning autonomy of the system (behavior) represented by the matrix R 755 RETURN: list 756 EXAMPLE: example autonom; shows an example 732 757 " 733 758 { … … 908 933 }; 909 934 //---------------------------------------------------------- 910 911 935 proc genericity(matrix M) 912 936 "USAGE: genericity(M), M is a module/matrix … … 923 947 return("-"); 924 948 } 925 int plevel = printlevel-voice+2; 926 // M is a matrix over a ring with params and vars; 927 ideal I = ideal(M); // a list of entries 928 I = simplify(I,2); // delete 0's 929 // decompose every coeff in every poly 930 int i; 931 int s = size(I); 932 ideal NM; 933 poly p; 934 number num; 935 int cl=1; 936 intvec ZeroVec; ZeroVec[nvars(basering)] = 0; 937 intvec W; 938 ideal Numero, Denomiro; 939 int cNu=0; int cDe=0; 940 for (i=1; i<=s; i++) 941 { 942 // remove contents and add them as polys 943 p = I[i]; 944 W = leadexp(p); 945 if (W == ZeroVec) // i.e. just a coef 946 { 947 num = denominator(leadcoef(p)); // from poly.lib 948 NM[cl] = numerator(leadcoef(p)); 949 dbprint(p,"numerator:"); 950 dbprint(p, string(NM[cl])); 951 cNu++; Numero[cNu]= NM[cl]; 952 cl++; 953 NM[cl] = num; // denominator 954 dbprint(p,"denominator:"); 955 dbprint(p, string(NM[cl])); 956 cDe++; Denomiro[cDe]= NM[cl]; 957 cl++; 958 p = p - lead(p); // for the next cycle 959 } 960 if ( p!= 0) 961 { 962 num = content(p); 963 p = p/num; 964 NM[cl] = denominator(num); 965 dbprint(p,"content denominator:"); 966 dbprint(p, string(NM[cl])); 967 cNu++; Numero[cNu]= NM[cl]; 968 cl++; 969 NM[cl] = numerator(num); 970 dbprint(p,"content numerator:"); 971 dbprint(p, string(NM[cl])); 972 cDe++; Denomiro[cDe]= NM[cl]; 973 cl++; 974 } 975 // it seems that the next elements will not have real influence 976 while( p != 0) 977 { 978 NM[cl] = leadcoef(p); // should be all integer, i.e. non-rational 979 dbprint(p,"coef:"); 980 dbprint(p, string(NM[cl])); 981 cl++; 982 p = p - lead(p); 983 } 984 } 985 NM = simplify(NM,4); // delete identical 986 string newvars = parstr(basering); 987 def save = basering; 988 string NewRing = "ring @NR =" +string(char(basering))+",("+newvars+"),Dp;"; 989 execute(NewRing); 990 // get params as variables 991 // create a list of non-monomials 992 ideal @L; 993 ideal F; 994 ideal NM = imap(save,NM); 995 NM = simplify(NM,8); //delete multiples 996 poly p,q; 997 cl = 1; 998 int j, cf; 999 for(i=1; i<=size(NM);i++) 1000 { 1001 p = NM[i] - lead(NM[i]); 1002 if (p!=0) 1003 { 1004 // L[cl] = p; 1005 F = factorize(NM[i],1); //non-constant factors only 1006 cf = 1; 1007 // factorize every polynomial 1008 // throw away every monomial from factorization (also constants from above ring) 1009 for (j=1; j<=size(F);j++) 1010 { 1011 q = F[j]-lead(F[j]); 1012 if (q!=0) 1013 { 1014 @L[cl] = F[j]; 1015 cl++; 1016 } 1017 } 1018 } 1019 } 1020 // return the result [in string-format] 1021 @L = simplify(@L,2+4+8); // skip zeroes, doubled and entries, diff. by a constant 1022 list SL; 1023 for (j=1; j<=size(@L);j++) 1024 { 1025 SL[j] = string(@L[j]); 1026 } 1027 setring save; 1028 return(SL); 949 list RT = evas_genericity(M); 950 return(RT); 1029 951 } 1030 952 example … … 1049 971 } 1050 972 //--------------------------------------------------------------- 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 " 981 { 982 // returns "-", if there are no parameters! 983 if (npars(basering)==0) 984 { 985 return("-"); 986 } 987 int plevel = printlevel-voice+2; 988 // M is a matrix over a ring with params and vars; 989 ideal I = ideal(M); // a list of entries 990 I = simplify(I,2); // delete 0's 991 // decompose every coeff in every poly 992 int i; 993 int s = size(I); 994 ideal NM; 995 poly p; 996 number num; 997 int cl=1; 998 intvec ZeroVec; ZeroVec[nvars(basering)] = 0; 999 intvec W; 1000 ideal Numero, Denomiro; 1001 int cNu=0; int cDe=0; 1002 for (i=1; i<=s; i++) 1003 { 1004 // remove contents and add them as polys 1005 p = I[i]; 1006 W = leadexp(p); 1007 if (W == ZeroVec) // i.e. just a coef 1008 { 1009 num = denominator(leadcoef(p)); // from poly.lib 1010 NM[cl] = numerator(leadcoef(p)); 1011 dbprint(p,"numerator:"); 1012 dbprint(p, string(NM[cl])); 1013 cNu++; Numero[cNu]= NM[cl]; 1014 cl++; 1015 NM[cl] = num; // denominator 1016 dbprint(p,"denominator:"); 1017 dbprint(p, string(NM[cl])); 1018 cDe++; Denomiro[cDe]= NM[cl]; 1019 cl++; 1020 p = p - lead(p); // for the next cycle 1021 } 1022 if ( p!= 0) 1023 { 1024 num = content(p); 1025 p = p/num; 1026 NM[cl] = denominator(num); 1027 dbprint(p,"content denominator:"); 1028 dbprint(p, string(NM[cl])); 1029 cNu++; Numero[cNu]= NM[cl]; 1030 cl++; 1031 NM[cl] = numerator(num); 1032 dbprint(p,"content numerator:"); 1033 dbprint(p, string(NM[cl])); 1034 cDe++; Denomiro[cDe]= NM[cl]; 1035 cl++; 1036 } 1037 // it seems that the next elements will not have real influence 1038 while( p != 0) 1039 { 1040 NM[cl] = leadcoef(p); // should be all integer, i.e. non-rational 1041 dbprint(p,"coef:"); 1042 dbprint(p, string(NM[cl])); 1043 cl++; 1044 p = p - lead(p); 1045 } 1046 } 1047 NM = simplify(NM,4); // delete identical 1048 string newvars = parstr(basering); 1049 def save = basering; 1050 string NewRing = "ring @NR =" +string(char(basering))+",("+newvars+"),Dp;"; 1051 execute(NewRing); 1052 // get params as variables 1053 // create a list of non-monomials 1054 ideal @L; 1055 ideal F; 1056 ideal NM = imap(save,NM); 1057 NM = simplify(NM,8); //delete multiples 1058 poly p,q; 1059 cl = 1; 1060 int j, cf; 1061 for(i=1; i<=size(NM);i++) 1062 { 1063 p = NM[i] - lead(NM[i]); 1064 if (p!=0) 1065 { 1066 // L[cl] = p; 1067 F = factorize(NM[i],1); //non-constant factors only 1068 cf = 1; 1069 // factorize every polynomial 1070 // throw away every monomial from factorization (also constants from above ring) 1071 for (j=1; j<=size(F);j++) 1072 { 1073 q = F[j]-lead(F[j]); 1074 if (q!=0) 1075 { 1076 @L[cl] = F[j]; 1077 cl++; 1078 } 1079 } 1080 } 1081 } 1082 // return the result [in string-format] 1083 @L = simplify(@L,2+4+8); // skip zeroes, doubled and entries, diff. by a constant 1084 list SL; 1085 for (j=1; j<=size(@L);j++) 1086 { 1087 SL[j] = string(@L[j]); 1088 } 1089 setring save; 1090 return(SL); 1091 } 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 } 1112 //--------------------------------------------------------------- 1051 1113 proc canonize(list L) 1052 1114 "USAGE: canonize(L), L a list … … 1089 1151 view(CC); 1090 1152 } 1091 1092 1153 //--------------------------------------------------------------- 1093 1154 static proc smdeg(matrix N) … … 1436 1497 print(Tr); // generators of the torsion submodule 1437 1498 } 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.