Changeset b6f755 in git
- Timestamp:
- Sep 14, 2000, 2:38:55 PM (23 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- b4e536263bb0aa911b1f252afe51fd37579eaaa1
- Parents:
- 88f41c23800323735502f1de13789462ad26d128
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/all.lib
r88f41c rb6f755 1 // $Id: all.lib,v 1.2 6 2000-08-18 11:58:31Singular Exp $1 // $Id: all.lib,v 1.27 2000-09-14 12:37:08 Singular Exp $ 2 2 /////////////////////////////////////////////////////////////////////////////// 3 3 4 version="$Id: all.lib,v 1.2 6 2000-08-18 11:58:31Singular Exp $";4 version="$Id: all.lib,v 1.27 2000-09-14 12:37:08 Singular Exp $"; 5 5 info=" 6 6 LIBRARY: all.lib Load all libraries … … 69 69 LIB "spcurve.lib"; 70 70 LIB "algebra.lib"; 71 LIB "i p.lib";71 LIB "intprog.lib"; 72 72 LIB "toric.lib"; 73 73 LIB "mregular.lib" -
Singular/LIB/toric.lib
r88f41c rb6f755 1 // version="$Id: toric.lib,v 1. 6 2000-08-14 12:56:58 obachmanExp $";1 // version="$Id: toric.lib,v 1.7 2000-09-14 12:37:10 Singular Exp $"; 2 2 3 3 /////////////////////////////////////////////////////////////////////////////// 4 4 5 5 info=" 6 LIBRARY: toric.lib COMPUTING TORIC IDEALS6 LIBRARY: toric.lib COMPUTING TORIC IDEALS 7 7 8 8 AUTHOR: Christine Theis, email: ctheis@math.uni-sb.de … … 10 10 PROCEDURES: 11 11 12 toric_ideal(intmat A, string alg [,intvec prsv]); 13 14 toric_std(ideal I); computes the standard basis of I using a specialized Buchberger algorithm12 toric_ideal(intmat A, string alg [,intvec prsv]); computes the toric ideal of A 13 14 toric_std(ideal I); computes the standard basis of I using a specialized Buchberger algorithm 15 15 "; 16 16 … … 20 20 21 21 static proc toric_ideal_1(intmat A, string alg) 22 { 22 { 23 23 ideal I; 24 24 // to be returned … … 29 29 "ERROR: The number of matrix columns is smaller than the number of ring variables."; 30 30 return(I); 31 } 31 } 32 32 33 33 // check suitability of actual term ordering … … 118 118 "Warning: Block orderings are not supported; Dp used for computation."; 119 119 } 120 } 120 } 121 121 122 122 int pos; … … 214 214 return(I); 215 215 } 216 216 217 217 // check algorithm 218 218 if(alg=="ct" || alg=="pct") … … 225 225 } 226 226 227 // create temporary file with which the external program is called 227 // create temporary file with which the external program is called 228 228 229 229 int dummy; 230 230 int process=system("pid"); 231 string matrixfile="temp_MATRIX"+string(process); 231 string matrixfile="temp_MATRIX"+string(process); 232 232 link MATRIX=":w "+matrixfile; 233 233 open(MATRIX); … … 246 246 } 247 247 } 248 248 249 249 // search for positive row space vector, if required by the 250 // algorithm 250 // algorithm 251 251 int found=0; 252 252 if((alg=="blr") || (alg=="hs")) 253 { 253 { 254 254 for(i=1;i<=nrows(A);i++) 255 255 { … … 269 269 if(found==0) 270 270 { 271 "ERROR: The chosen algorithm needs a positive vector in the row space of the matrix."; 271 "ERROR: The chosen algorithm needs a positive vector in the row space of the matrix."; 272 272 close(MATRIX); 273 273 dummy=system("sh","rm -f "+matrixfile); 274 274 return(I); 275 } 275 } 276 276 write(MATRIX,"positive row space vector:"); 277 277 for(j=1;j<=ncols(A);j++) 278 { 278 { 279 279 write(MATRIX,A[found,j]); 280 280 } … … 294 294 pos=find(toric_id,":",pos); 295 295 pos++; 296 296 297 297 while(toric_id[pos]==" " || toric_id[pos]==newline) 298 298 { … … 306 306 } 307 307 execute("generators="+number_string+";"); 308 308 309 309 intvec v; 310 310 poly head; … … 339 339 if(v[j]>0) 340 340 { 341 head=head*var(j)^v[j]; 341 head=head*var(j)^v[j]; 342 342 } 343 343 } 344 344 I[i]=head-tail; 345 345 } 346 346 347 347 // delete all created files 348 348 dummy=system("sh","rm -f "+matrixfile); … … 355 355 356 356 static proc toric_ideal_2(intmat A, string alg, intvec prsv) 357 { 357 { 358 358 ideal I; 359 359 // to be returned … … 364 364 "ERROR: The number of matrix columns does not equal the size of the positive row space vector."; 365 365 return(I); 366 } 366 } 367 367 368 368 // check suitability of actual basering … … 371 371 "ERROR: The number of matrix columns is smaller than the number of ring variables."; 372 372 return(I); 373 } 373 } 374 374 375 375 // check suitability of actual term ordering … … 460 460 "Warning: Block orderings are not supported; Dp used for computation."; 461 461 } 462 } 462 } 463 463 464 464 int pos; … … 556 556 return(I); 557 557 } 558 558 559 559 // check algorithm 560 560 if(alg=="ct" || alg=="pct") … … 567 567 } 568 568 569 // create temporary file with that the external program is called 569 // create temporary file with that the external program is called 570 570 571 571 int dummy; 572 572 int process=system("pid"); 573 string matrixfile="temp_MATRIX"+string(process); 573 string matrixfile="temp_MATRIX"+string(process); 574 574 link MATRIX=":w "+matrixfile; 575 575 open(MATRIX); … … 591 591 // enter positive row space vector, if required by the algorithm 592 592 if((alg=="blr") || (alg=="hs")) 593 { 593 { 594 594 write(MATRIX,"positive row space vector:"); 595 595 for(j=1;j<=ncols(A);j++) 596 { 596 { 597 597 write(MATRIX,prsv[j]); 598 598 } … … 611 611 pos=find(toric_id,":",pos); 612 612 pos++; 613 613 614 614 while(toric_id[pos]==" " || toric_id[pos]==newline) 615 615 { … … 623 623 } 624 624 execute("generators="+number_string+";"); 625 625 626 626 intvec v; 627 627 poly head; … … 656 656 if(v[j]>0) 657 657 { 658 head=head*var(j)^v[j]; 658 head=head*var(j)^v[j]; 659 659 } 660 660 } 661 661 I[i]=head-tail; 662 662 } 663 663 664 664 // delete all created files 665 665 dummy=system("sh","rm -f "+matrixfile); … … 674 674 "USAGE: toric_ideal(A,alg); A intmat, alg string 675 675 toric_ideal(A,alg,prsv); A intmat, alg string, prsv intvec 676 RETURN: ideal: standard basis of the toric ideal of A 676 RETURN: ideal: standard basis of the toric ideal of A 677 677 NOTE: These procedures return the standard basis of the toric ideal of A with respect to the term ordering in the actual basering. Not all term orderings are supported: The usual global term orderings may be used, but no block orderings combining them. 678 678 679 679 One may call the procedure with several different algorithms: 680 680 … … 689 689 - the algorithm of DiBiase/Urbanke (du). 690 690 691 The argument `alg' should be the abbreviation for an algorithm as above: ect, pt, blr, hs or du. 691 The argument `alg' should be the abbreviation for an algorithm as above: ect, pt, blr, hs or du. 692 692 693 693 If `alg' is chosen to be `blr' or `hs', the algorithm needs a vector with positive coefficcients in the row space of A. If no row of A contains only positive entries, one has to use the second version of toric_ideal which takes such a vector as its third argument. 694 694 695 For the mathematical background, see 696 @texinfo 697 @ref{Toric ideals and integer programming}. 695 For the mathematical background, see 696 @texinfo 697 @ref{Toric ideals and integer programming}. 698 698 @end texinfo 699 699 EXAMPLE: example toric_ideal; shows an example 700 SEE ALSO: toric_std, toric_lib, i p_lib, Toric ideals700 SEE ALSO: toric_std, toric_lib, intprog_lib, Toric ideals 701 701 " 702 702 { … … 717 717 "EXAMPLE"; echo=2; 718 718 719 ring r=0,(x,y,z),dp; 719 ring r=0,(x,y,z),dp; 720 720 721 721 // call with two arguments … … 725 725 ideal I=toric_ideal(A,"du"); 726 726 I; 727 727 728 728 I=toric_ideal(A,"blr"); 729 729 I; 730 730 731 731 // call with three arguments 732 732 intvec prsv=1,2,1; 733 733 I=toric_ideal(A,"blr",prsv); 734 734 I; 735 735 736 736 } 737 737 … … 740 740 proc toric_std(ideal I) 741 741 "USAGE: toric_std(I); I ideal 742 RETURN: ideal: standard basis of I 743 NOTE: This procedure computes the standard basis of I using a specialized Buchberger algorithm. The generating system by which I is given has to consist of binomials of the form x^u-x^v. There is no real check if I is toric. If I is generated by binomials of the above form, but not toric, toric_std computes an ideal `between' I and its saturation with respect to all variables. 744 For the mathematical background, see 745 @texinfo 746 @ref{Toric ideals and integer programming}. 742 RETURN: ideal: standard basis of I 743 NOTE: This procedure computes the standard basis of I using a specialized Buchberger algorithm. The generating system by which I is given has to consist of binomials of the form x^u-x^v. There is no real check if I is toric. If I is generated by binomials of the above form, but not toric, toric_std computes an ideal `between' I and its saturation with respect to all variables. 744 For the mathematical background, see 745 @texinfo 746 @ref{Toric ideals and integer programming}. 747 747 @end texinfo 748 748 EXAMPLE: example toric_std; shows an example 749 SEE ALSO: toric_ideal, toric_lib, i p_lib, Toric ideals749 SEE ALSO: toric_ideal, toric_lib, intprog_lib, Toric ideals 750 750 " 751 751 { … … 840 840 "Warning: Block orderings are not supported; Dp used for computation."; 841 841 } 842 } 842 } 843 843 844 844 int pos; … … 866 866 } 867 867 } 868 868 869 869 if(external_ord=="" && find(singular_ord,"wp")==3) 870 870 { … … 937 937 return(I); 938 938 } 939 939 940 940 // create first temporary file with which the external program is called 941 941 942 942 int dummy; 943 943 int process=system("pid"); 944 string groebnerfile="temp_GROEBNER"+string(process); 944 string groebnerfile="temp_GROEBNER"+string(process); 945 945 link GROEBNER=":w "+groebnerfile; 946 946 open(GROEBNER); … … 948 948 write(GROEBNER,"GROEBNER","computed with algorithm:","pt","term ordering:","elimination block",0,"weighted block",nvars(basering),external_ord); 949 949 // algorithm is totally unimportant, only required by the external program 950 950 951 951 for(i=1;i<=nvars(basering);i++) 952 952 { 953 953 write(GROEBNER,weightvec[i]); 954 954 } 955 955 956 956 write(GROEBNER,"size:",size(I),"Groebner basis:"); 957 957 poly head; … … 962 962 for(j=1;j<=size(I);j++) 963 963 { 964 // test suitability of generator j 964 // test suitability of generator j 965 965 rest=I[j]; 966 966 head=lead(rest); … … 968 968 tail=lead(rest); 969 969 rest=rest-tail; 970 970 971 971 if(head==0 && tail==0 && rest!=0) 972 972 { … … 976 976 return(J); 977 977 } 978 978 979 979 if(leadcoef(tail)!=-leadcoef(head)) 980 980 // generator is no difference of monomials (or a constant multiple) … … 985 985 return(J); 986 986 } 987 987 988 988 if(gcd(head,tail)!=1) 989 989 { 990 990 "Warning: The monomials of generator "+string(j)+" of the input ideal are not relatively prime."; 991 991 } 992 992 993 993 // write vector representation of generator j into the file 994 994 v=leadexp(head)-leadexp(tail); … … 999 999 } 1000 1000 close(GROEBNER); 1001 1001 1002 1002 // create second temporary file 1003 1003 1004 string newcostfile="temp_NEW_COST"+string(process); 1004 string newcostfile="temp_NEW_COST"+string(process); 1005 1005 link NEW_COST=":w "+newcostfile; 1006 1006 open(NEW_COST); 1007 1007 1008 write(NEW_COST,"NEW_COST","variables:",nvars(basering),"cost vector:"); 1008 write(NEW_COST,"NEW_COST","variables:",nvars(basering),"cost vector:"); 1009 1009 for(i=1;i<=nvars(basering);i++) 1010 1010 { 1011 1011 write(NEW_COST,weightvec[i]); 1012 1012 } 1013 1013 1014 1014 // call external program 1015 1015 dummy=system("sh","change_cost "+groebnerfile+" "+newcostfile); 1016 1016 1017 1017 // read toric standard basis from created file 1018 1018 link TORIC_IDEAL=":r "+newcostfile+".GB.pt"; … … 1023 1023 pos=find(toric_id,":",pos); 1024 1024 pos++; 1025 1025 1026 1026 while(toric_id[pos]==" " || toric_id[pos]==newline) 1027 1027 { … … 1064 1064 if(v[i]>0) 1065 1065 { 1066 head=head*var(i)^v[i]; 1066 head=head*var(i)^v[i]; 1067 1067 } 1068 1068 } 1069 1069 J[j]=head-tail; 1070 1070 } 1071 1071 1072 1072 // delete all created files 1073 1073 dummy=system("sh","rm -f "+groebnerfile); 1074 1074 dummy=system("sh","rm -f "+groebnerfile+".GB.pt"); 1075 dummy=system("sh","rm -f "+newcostfile); 1075 dummy=system("sh","rm -f "+newcostfile); 1076 1076 1077 1077 return(J); … … 1090 1090 ideal J=toric_std(I); 1091 1091 J; 1092 1092 1093 1093 // call with the same ideal, but badly chosen generators: 1094 // 1) not only binomials 1094 // 1) not only binomials 1095 1095 I=x-y,2x-y-z; 1096 1096 J=toric_std(I); … … 1099 1099 J=toric_std(I); 1100 1100 J; 1101 1101 1102 1102 // call with a non-toric ideal that seems to be toric 1103 1103 I=x-yz,xy-z; 1104 1104 J=toric_std(I); 1105 1105 J; 1106 // comparison with real standard basis and saturation 1106 // comparison with real standard basis and saturation 1107 1107 ideal H=std(I); 1108 1108 H; … … 1110 1110 sat(H,xyz); 1111 1111 } 1112 1113
Note: See TracChangeset
for help on using the changeset viewer.