Changeset 030f16d in git
- Timestamp:
- Jul 28, 2000, 2:54:45 PM (23 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'ba3e3ef698fa0b7c5867199959cc83330073d3cb')
- Children:
- 827a49d7d340e1a3812ae8cf7d34fce5c4ea6d54
- Parents:
- da5475ad68b027eb46bd3128738511f1af10775c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/toric.lib
rda5475 r030f16d 1 // $Id: toric.lib,v 1.2 2000-05-16 08:25:01 Singular Exp $ 2 // 3 // author : Christine Theis 4 // 5 //version="$Id: toric.lib,v 1.2 2000-05-16 08:25:01 Singular Exp $"; 1 // version="$Id: toric.lib,v 1.3 2000-07-28 12:54:45 theis Exp $"; 6 2 7 3 /////////////////////////////////////////////////////////////////////////////// 8 4 9 5 info=" 10 LIBRARY: toric.lib Procedures for computing toric ideals 11 12 13 Let A an integral (mxn)-matrix. The toric ideal I_A of A is defined 14 as the ideal 15 16 I_A:=< x^u - x^v | u,v integral and nonnegative, u-v in the kernel of A > 17 18 in the ring of n variables x:=x1,...,xn. 19 Toric ideals play an important role in polyhedral geometry and may also be 20 used for integer programming. They are generated by binomials with 21 relatively prime monomials. Buchberger's algorithm can be specialized to 22 these structures in a way that considerably speeds up computation. 23 24 25 toric_ideal(intmat A, string alg); 26 toric_ideal(intmat A, string alg, intvec prsv); 27 28 procedures for computing the toric ideal of A 29 They return the standard basis of the toric ideal of A with respect 30 to the term ordering in the actual basering. 31 When calling this procedure, a ring with n variables should be active. 32 Not all term orderings are supported: The usual global term orderings 33 may be used, but no block orderings combining them. 34 One may call the procedure with several different algorithms: 35 36 - the algorithm of Conti/Traverso using elimination (ect), 37 - the algorithm of Pottier (pt), 38 - an algorithm of Bigatti/La Scala/Robbiano (blr), 39 - the algorithm of Hosten/Sturmfels (hs), 40 - the algorithm of DiBiase/Urbanke (du). 41 42 The last two seem to be the fastest in the actual implementation. 43 `alg' should be the abbreviation (in brackets) for an algorithm 44 as above. 45 If `alg' is chosen to be `blr' or `hs', the algorithm needs a 46 vector with positive coefficcients in the row space of A. If 47 no row of A contains only positive entries, one must use the 48 second version of toric_ideal which takes such a vector in the 49 third argument. 50 51 52 toric_std(ideal I); 53 54 computes the standard basis of I using the specialized Buchberger 55 algorithm. The generating system by which I is given has to consist 56 of binomials of the form x^u-x^v (although there are other generating 57 systems of toric ideals). There is no real check if I is toric. 58 If the generator list of I contains a binomial whose monomials are not 59 relatively prime, the procedure outputs a warning. If I is generated by 60 binomials of the above form, but not toric, toric_std computes an ideal 61 `between' I and its saturation with respect to all variables. 62 6 LIBRARY: toric.lib COMPUTING TORIC IDEALS 7 8 AUTHOR: Christine Theis, email: ctheis@math.uni-sb.de 9 10 PROCEDURES: 11 12 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 63 15 "; 64 16 65 17 /////////////////////////////////////////////////////////////////////////////// 66 18 19 20 67 21 static proc toric_ideal_1(intmat A, string alg) 68 { 22 { 69 23 ideal I; 70 24 // to be returned … … 73 27 if(nvars(basering)<ncols(A)) 74 28 { 75 "ERROR: number of matrix columns must be greater or equal number of ring variables";29 "ERROR: The number of matrix columns is smaller than the number of ring variables."; 76 30 return(I); 77 } 31 } 78 32 79 33 // check suitability of actual term ordering … … 95 49 if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c")) 96 50 { 97 "Warning: block orderings are not supported; lp used for computation";51 "Warning: Block orderings are not supported; lp used for computation."; 98 52 } 99 53 } … … 108 62 if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord)) 109 63 { 110 "Warning: block orderings are not supported; lp used for computation";64 "Warning: Block orderings are not supported; lp used for computation."; 111 65 } 112 66 } … … 122 76 if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c")) 123 77 { 124 "Warning: block orderings are not supported; dp used for computation";78 "Warning: Block orderings are not supported; dp used for computation."; 125 79 } 126 80 } … … 135 89 if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord)) 136 90 { 137 "Warning: block orderings are not supported; dp used for computation";91 "Warning: Block orderings are not supported; dp used for computation."; 138 92 } 139 93 } … … 149 103 if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c")) 150 104 { 151 "Warning: block orderings are not supported; Dp used for computation";105 "Warning: Block orderings are not supported; Dp used for computation."; 152 106 } 153 107 } … … 162 116 if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord)) 163 117 { 164 "Warning: block orderings are not supported; Dp used for computation";165 } 166 } 118 "Warning: Block orderings are not supported; Dp used for computation."; 119 } 120 } 167 121 168 122 int pos; … … 187 141 if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c")) 188 142 { 189 "Warning: block orderings are not supported; wp("+string(weightvec)+") used for computation";143 "Warning: Block orderings are not supported; wp("+string(weightvec)+") used for computation."; 190 144 } 191 145 } … … 208 162 if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord)) 209 163 { 210 "Warning: block orderings are not supported; wp("+string(weightvec)+") used for computation";164 "Warning: Block orderings are not supported; wp("+string(weightvec)+") used for computation."; 211 165 } 212 166 } … … 230 184 if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c")) 231 185 { 232 "Warning: block orderings are not supported; Wp("+string(weightvec)+") used for computation";186 "Warning: Block orderings are not supported; Wp("+string(weightvec)+") used for computation."; 233 187 } 234 188 } … … 251 205 if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord)) 252 206 { 253 "Warning: block orderings are not supported; Wp("+string(weightvec)+") used for computation";207 "Warning: Block orderings are not supported; Wp("+string(weightvec)+") used for computation."; 254 208 } 255 209 } … … 257 211 if(external_ord=="") 258 212 { 259 "ERROR: term ordering of actual basering not supported";213 "ERROR: The term ordering of the actual basering is not supported."; 260 214 return(I); 261 215 } 262 216 263 217 // check algorithm 264 218 if(alg=="ct" || alg=="pct") … … 267 221 // extended matrix 268 222 { 269 "ERROR: algorithm not suitable";223 "ERROR: The chosen algorithm is not suitable."; 270 224 return(I); 271 225 } 272 226 273 // create temporary file with that the external program is called227 // create temporary file with which the external program is called 274 228 275 229 int dummy; 276 230 int process=system("pid"); 277 string matrixfile=" temp_MATRIX"+string(process);231 string matrixfile="./temp_MATRIX"+string(process); 278 232 link MATRIX=":w "+matrixfile; 279 233 open(MATRIX); … … 292 246 } 293 247 } 294 248 295 249 // search for positive row space vector, if required by the 296 // algorithm 250 // algorithm 297 251 int found=0; 298 252 if((alg=="blr") || (alg=="hs")) 299 { 253 { 300 254 for(i=1;i<=nrows(A);i++) 301 255 { … … 315 269 if(found==0) 316 270 { 317 "ERROR: algorithm needs 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."; 318 272 close(MATRIX); 319 273 dummy=system("sh","rm -f "+matrixfile); 320 274 return(I); 321 } 275 } 322 276 write(MATRIX,"positive row space vector:"); 323 277 for(j=1;j<=ncols(A);j++) 324 { 278 { 325 279 write(MATRIX,A[found,j]); 326 280 } … … 334 288 // read toric ideal from created file 335 289 link TORIC_IDEAL=":r "+matrixfile+".GB."+alg; 336 string toric_id eal=read(TORIC_IDEAL);290 string toric_id=read(TORIC_IDEAL); 337 291 338 292 int generators; 339 pos=find(toric_id eal,"size");340 pos=find(toric_id eal,":",pos);293 pos=find(toric_id,"size"); 294 pos=find(toric_id,":",pos); 341 295 pos++; 342 343 while(toric_id eal[pos]==" " || toric_ideal[pos]==newline)296 297 while(toric_id[pos]==" " || toric_id[pos]==newline) 344 298 { 345 299 pos++; 346 300 } 347 301 number_string=""; 348 while(toric_id eal[pos]!=" " && toric_ideal[pos]!=newline)349 { 350 number_string=number_string+toric_id eal[pos];302 while(toric_id[pos]!=" " && toric_id[pos]!=newline) 303 { 304 number_string=number_string+toric_id[pos]; 351 305 pos++; 352 306 } 353 307 execute("generators="+number_string+";"); 354 308 355 309 intvec v; 356 310 poly head; 357 311 poly tail; 358 312 359 pos=find(toric_id eal,"basis");360 pos=find(toric_id eal,":",pos);313 pos=find(toric_id,"basis"); 314 pos=find(toric_id,":",pos); 361 315 pos++; 362 316 … … 368 322 for(j=1;j<=ncols(A);j++) 369 323 { 370 while(toric_id eal[pos]==" " || toric_ideal[pos]==newline)371 { 372 pos++; 373 } 374 number_string=""; 375 while(toric_id eal[pos]!=" " && toric_ideal[pos]!=newline)376 { 377 number_string=number_string+toric_id eal[pos];324 while(toric_id[pos]==" " || toric_id[pos]==newline) 325 { 326 pos++; 327 } 328 number_string=""; 329 while(toric_id[pos]!=" " && toric_id[pos]!=newline) 330 { 331 number_string=number_string+toric_id[pos]; 378 332 pos++; 379 333 } … … 385 339 if(v[j]>0) 386 340 { 387 head=head*var(j)^v[j]; 341 head=head*var(j)^v[j]; 388 342 } 389 343 } 390 344 I[i]=head-tail; 391 345 } 392 346 393 347 // delete all created files 394 348 dummy=system("sh","rm -f "+matrixfile); … … 398 352 } 399 353 354 355 400 356 static proc toric_ideal_2(intmat A, string alg, intvec prsv) 401 { 357 { 402 358 ideal I; 403 359 // to be returned … … 406 362 if(size(prsv)<ncols(A)) 407 363 { 408 "ERROR: number of matrix columns must equal size of positive row space vector";364 "ERROR: The number of matrix columns does not equal the size of the positive row space vector."; 409 365 return(I); 410 } 366 } 411 367 412 368 // check suitability of actual basering 413 369 if(nvars(basering)!=ncols(A)) 414 370 { 415 "ERROR: number of matrix columns must be greater or equal number of ring variables";371 "ERROR: The number of matrix columns is smaller than the number of ring variables."; 416 372 return(I); 417 } 373 } 418 374 419 375 // check suitability of actual term ordering … … 435 391 if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c")) 436 392 { 437 "Warning: block orderings are not supported; lp used for computation";393 "Warning: Block orderings are not supported; lp used for computation."; 438 394 } 439 395 } … … 448 404 if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord)) 449 405 { 450 "Warning: block orderings are not supported; lp used for computation";406 "Warning: Block orderings are not supported; lp used for computation."; 451 407 } 452 408 } … … 462 418 if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c")) 463 419 { 464 "Warning: block orderings are not supported; dp used for computation";420 "Warning: Block orderings are not supported; dp used for computation."; 465 421 } 466 422 } … … 475 431 if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord)) 476 432 { 477 "Warning: block orderings are not supported; dp used for computation";433 "Warning: Block orderings are not supported; dp used for computation."; 478 434 } 479 435 } … … 489 445 if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c")) 490 446 { 491 "Warning: block orderings are not supported; Dp used for computation";447 "Warning: Block orderings are not supported; Dp used for computation."; 492 448 } 493 449 } … … 502 458 if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord)) 503 459 { 504 "Warning: block orderings are not supported; Dp used for computation";505 } 506 } 460 "Warning: Block orderings are not supported; Dp used for computation."; 461 } 462 } 507 463 508 464 int pos; … … 527 483 if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c")) 528 484 { 529 "Warning: block orderings are not supported; wp("+string(weightvec)+") used for computation";485 "Warning: Block orderings are not supported; wp("+string(weightvec)+") used for computation."; 530 486 } 531 487 } … … 548 504 if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord)) 549 505 { 550 "Warning: block orderings are not supported; wp("+string(weightvec)+") used for computation";506 "Warning: Block orderings are not supported; wp("+string(weightvec)+") used for computation."; 551 507 } 552 508 } … … 570 526 if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c")) 571 527 { 572 "Warning: block orderings are not supported; Wp("+string(weightvec)+") used for computation";528 "Warning: Block orderings are not supported; Wp("+string(weightvec)+") used for computation."; 573 529 } 574 530 } … … 591 547 if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord)) 592 548 { 593 "Warning: block orderings are not supported; Wp("+string(weightvec)+") used for computation";549 "Warning: Block orderings are not supported; Wp("+string(weightvec)+") used for computation."; 594 550 } 595 551 } … … 597 553 if(external_ord=="") 598 554 { 599 "ERROR: term ordering of actual basering not supported";555 "ERROR: The term ordering of the actual basering is not supported."; 600 556 return(I); 601 557 } 602 558 603 559 // check algorithm 604 560 if(alg=="ct" || alg=="pct") … … 607 563 // extended matrix 608 564 { 609 "ERROR: algorithm not suitable";565 "ERROR: The chosen algorithm is not suitable."; 610 566 return(I); 611 567 } 612 568 613 // create temporary file with that the external program is called 569 // create temporary file with that the external program is called 614 570 615 571 int dummy; 616 572 int process=system("pid"); 617 string matrixfile=" temp_MATRIX"+string(process);573 string matrixfile="./temp_MATRIX"+string(process); 618 574 link MATRIX=":w "+matrixfile; 619 575 open(MATRIX); … … 635 591 // enter positive row space vector, if required by the algorithm 636 592 if((alg=="blr") || (alg=="hs")) 637 { 593 { 638 594 write(MATRIX,"positive row space vector:"); 639 595 for(j=1;j<=ncols(A);j++) 640 { 596 { 641 597 write(MATRIX,prsv[j]); 642 598 } … … 649 605 // read toric ideal from created file 650 606 link TORIC_IDEAL=":r "+matrixfile+".GB."+alg; 651 string toric_id eal=read(TORIC_IDEAL);607 string toric_id=read(TORIC_IDEAL); 652 608 653 609 int generators; 654 pos=find(toric_id eal,"size");655 pos=find(toric_id eal,":",pos);610 pos=find(toric_id,"size"); 611 pos=find(toric_id,":",pos); 656 612 pos++; 657 658 while(toric_id eal[pos]==" " || toric_ideal[pos]==newline)613 614 while(toric_id[pos]==" " || toric_id[pos]==newline) 659 615 { 660 616 pos++; 661 617 } 662 618 number_string=""; 663 while(toric_id eal[pos]!=" " && toric_ideal[pos]!=newline)664 { 665 number_string=number_string+toric_id eal[pos];619 while(toric_id[pos]!=" " && toric_id[pos]!=newline) 620 { 621 number_string=number_string+toric_id[pos]; 666 622 pos++; 667 623 } 668 624 execute("generators="+number_string+";"); 669 625 670 626 intvec v; 671 627 poly head; 672 628 poly tail; 673 629 674 pos=find(toric_id eal,"basis");675 pos=find(toric_id eal,":",pos);630 pos=find(toric_id,"basis"); 631 pos=find(toric_id,":",pos); 676 632 pos++; 677 633 … … 683 639 for(j=1;j<=ncols(A);j++) 684 640 { 685 while(toric_id eal[pos]==" " || toric_ideal[pos]==newline)686 { 687 pos++; 688 } 689 number_string=""; 690 while(toric_id eal[pos]!=" " && toric_ideal[pos]!=newline)691 { 692 number_string=number_string+toric_id eal[pos];641 while(toric_id[pos]==" " || toric_id[pos]==newline) 642 { 643 pos++; 644 } 645 number_string=""; 646 while(toric_id[pos]!=" " && toric_id[pos]!=newline) 647 { 648 number_string=number_string+toric_id[pos]; 693 649 pos++; 694 650 } … … 700 656 if(v[j]>0) 701 657 { 702 head=head*var(j)^v[j]; 658 head=head*var(j)^v[j]; 703 659 } 704 660 } 705 661 I[i]=head-tail; 706 662 } 707 663 708 664 // delete all created files 709 665 dummy=system("sh","rm -f "+matrixfile); … … 713 669 } 714 670 671 672 715 673 proc toric_ideal 716 "USAGE: 717 toric_ideal(A,alg); A intmat, alg string 718 toric_ideal(A,alg,prsv); A intmat, alg string, prsv intvec 719 RETURN: toric ideal of A as explained in toric.lib 720 return type = ideal 721 EXAMPLE: example toric_ideal; shows an example" 674 "USAGE: toric_ideal(A,alg); A intmat, alg string 675 toric_ideal(A,alg,prsv); A intmat, alg string, prsv intvec 676 RETURN: ideal: standard basis of the toric ideal of A 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 679 One may call the procedure with several different algorithms: 680 681 - the algorithm of Conti/Traverso using elimination (ect), 682 683 - the algorithm of Pottier (pt), 684 685 - an algorithm of Bigatti/La Scala/Robbiano (blr), 686 687 - the algorithm of Hosten/Sturmfels (hs), 688 689 - the algorithm of DiBiase/Urbanke (du). 690 691 The argument `alg' should be the abbreviation for an algorithm as above: ect, pt, blr, hs or du. 692 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 695 For the mathematical background, see 696 @texinfo 697 @ref{Toric ideals and integer programming}. 698 @end texinfo 699 EXAMPLE: example toric_ideal; shows an example 700 SEE ALSO: toric_std, toric_lib, IP_lib, toric ideals 701 " 722 702 { 723 703 if(size(#)==2) … … 730 710 } 731 711 } 712 713 714 732 715 example 733 716 { 734 735 736 ring r=0,(x,y,z),dp; 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 717 "EXAMPLE"; echo=2; 718 719 ring r=0,(x,y,z),dp; 720 721 // call with two arguments 722 intmat A[2][3]=1,1,0,0,1,1; 723 A; 724 725 // ideal I=toric_ideal(A,"du"); 726 // I; 727 728 // I=toric_ideal(A,"blr"); 729 // I; 730 731 // call with three arguments 732 intvec prsv=1,2,1; 733 // I=toric_ideal(A,"blr",prsv); 734 // I; 735 753 736 } 754 737 738 739 755 740 proc toric_std(ideal I) 756 "USAGE: toric_std(I); I ideal 757 RETURN: standard basis of I as explained in toric.lib 758 return type = ideal 759 EXAMPLE: example toric_std; shows an example" 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}. 747 @end texinfo 748 EXAMPLE: example toric_std; shows an example 749 SEE ALSO: toric_ideal, toric_lib, IP_lib, toric ideals 750 " 760 751 { 761 752 ideal J; … … 780 771 if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c")) 781 772 { 782 "Warning: block orderings are not supported; lp used for computation";773 "Warning: Block orderings are not supported; lp used for computation."; 783 774 } 784 775 } … … 793 784 if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord)) 794 785 { 795 "Warning: block orderings are not supported; lp used for computation";786 "Warning: Block orderings are not supported; lp used for computation."; 796 787 } 797 788 } … … 807 798 if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c")) 808 799 { 809 "Warning: block orderings are not supported; dp used for computation";800 "Warning: Block orderings are not supported; dp used for computation."; 810 801 } 811 802 } … … 820 811 if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord)) 821 812 { 822 "Warning: block orderings are not supported; dp used for computation";813 "Warning: Block orderings are not supported; dp used for computation."; 823 814 } 824 815 } … … 834 825 if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c")) 835 826 { 836 "Warning: block orderings are not supported; Dp used for computation";827 "Warning: Block orderings are not supported; Dp used for computation."; 837 828 } 838 829 } … … 847 838 if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord)) 848 839 { 849 "Warning: block orderings are not supported; Dp used for computation";850 } 851 } 840 "Warning: Block orderings are not supported; Dp used for computation."; 841 } 842 } 852 843 853 844 int pos; … … 872 863 if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c")) 873 864 { 874 "Warning: block orderings are not supported; wp("+string(weightvec)+") used for computation";875 } 876 } 877 865 "Warning: Block orderings are not supported; wp("+string(weightvec)+") used for computation."; 866 } 867 } 868 878 869 if(external_ord=="" && find(singular_ord,"wp")==3) 879 870 { … … 894 885 if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord)) 895 886 { 896 "Warning: block orderings are not supported; wp("+string(weightvec)+") used for computation";887 "Warning: Block orderings are not supported; wp("+string(weightvec)+") used for computation."; 897 888 } 898 889 } … … 916 907 if(singular_ord!=(test_ord+"C") && singular_ord!=(test_ord+"c")) 917 908 { 918 "Warning: block orderings are not supported; Wp("+string(weightvec)+") used for computation";909 "Warning: Block orderings are not supported; Wp("+string(weightvec)+") used for computation."; 919 910 } 920 911 } … … 937 928 if(singular_ord!=("C"+test_ord) && singular_ord!=("c"+test_ord)) 938 929 { 939 "Warning: block orderings are not supported; Wp("+string(weightvec)+") used for computation";930 "Warning: Block orderings are not supported; Wp("+string(weightvec)+") used for computation."; 940 931 } 941 932 } … … 943 934 if(external_ord=="") 944 935 { 945 "ERROR: term ordering of actual basering not supported";936 "ERROR: The term ordering of the actual basering is not supported."; 946 937 return(I); 947 938 } 948 939 949 940 // create first temporary file with which the external program is called 950 941 951 942 int dummy; 952 943 int process=system("pid"); 953 string groebnerfile=" temp_GROEBNER"+string(process);944 string groebnerfile="./temp_GROEBNER"+string(process); 954 945 link GROEBNER=":w "+groebnerfile; 955 946 open(GROEBNER); … … 957 948 write(GROEBNER,"GROEBNER","computed with algorithm:","pt","term ordering:","elimination block",0,"weighted block",nvars(basering),external_ord); 958 949 // algorithm is totally unimportant, only required by the external program 959 950 960 951 for(i=1;i<=nvars(basering);i++) 961 952 { 962 953 write(GROEBNER,weightvec[i]); 963 954 } 964 955 965 956 write(GROEBNER,"size:",size(I),"Groebner basis:"); 966 957 poly head; … … 971 962 for(j=1;j<=size(I);j++) 972 963 { 973 // test suitability of generator j 964 // test suitability of generator j 974 965 rest=I[j]; 975 966 head=lead(rest); … … 977 968 tail=lead(rest); 978 969 rest=rest-tail; 979 970 980 971 if(head==0 && tail==0 && rest!=0) 981 972 { 982 "ERROR: generator "+string(j)+" of input ideal is no binomial";973 "ERROR: Generator "+string(j)+" of the input ideal is no binomial."; 983 974 close(GROEBNER); 984 975 dummy=system("sh","rm -f "+groebnerfile); 985 976 return(J); 986 977 } 987 978 988 979 if(leadcoef(tail)!=-leadcoef(head)) 989 // generator no difference of monomials (or a constant multiple)990 { 991 "ERROR: generator "+string(j)+" of input ideal is no difference of monomials";980 // generator is no difference of monomials (or a constant multiple) 981 { 982 "ERROR: Generator "+string(j)+" of the input ideal is no difference of monomials."; 992 983 close(GROEBNER); 993 984 dummy=system("sh","rm -f "+groebnerfile); 994 985 return(J); 995 986 } 996 987 997 988 if(gcd(head,tail)!=1) 998 989 { 999 "Warning: monomials of generator "+string(j)+" of input ideal are not relatively prime";1000 } 1001 990 "Warning: The monomials of generator "+string(j)+" of the input ideal are not relatively prime."; 991 } 992 1002 993 // write vector representation of generator j into the file 1003 994 v=leadexp(head)-leadexp(tail); … … 1008 999 } 1009 1000 close(GROEBNER); 1010 1001 1011 1002 // create second temporary file 1012 1003 1013 string newcostfile=" temp_NEW_COST"+string(process);1004 string newcostfile="./temp_NEW_COST"+string(process); 1014 1005 link NEW_COST=":w "+newcostfile; 1015 1006 open(NEW_COST); 1016 1007 1017 write(NEW_COST,"NEW_COST","variables:",nvars(basering),"cost vector:"); 1008 write(NEW_COST,"NEW_COST","variables:",nvars(basering),"cost vector:"); 1018 1009 for(i=1;i<=nvars(basering);i++) 1019 1010 { 1020 1011 write(NEW_COST,weightvec[i]); 1021 1012 } 1022 1013 1023 1014 // call external program 1024 1015 dummy=system("sh","change_cost "+groebnerfile+" "+newcostfile); 1025 1016 1026 1017 // read toric standard basis from created file 1027 1018 link TORIC_IDEAL=":r "+newcostfile+".GB.pt"; 1028 string toric_id eal=read(TORIC_IDEAL);1019 string toric_id=read(TORIC_IDEAL); 1029 1020 1030 1021 int generators; 1031 pos=find(toric_id eal,"size");1032 pos=find(toric_id eal,":",pos);1022 pos=find(toric_id,"size"); 1023 pos=find(toric_id,":",pos); 1033 1024 pos++; 1034 1035 while(toric_id eal[pos]==" " || toric_ideal[pos]==newline)1025 1026 while(toric_id[pos]==" " || toric_id[pos]==newline) 1036 1027 { 1037 1028 pos++; 1038 1029 } 1039 1030 number_string=""; 1040 while(toric_id eal[pos]!=" " && toric_ideal[pos]!=newline)1041 { 1042 number_string=number_string+toric_id eal[pos];1031 while(toric_id[pos]!=" " && toric_id[pos]!=newline) 1032 { 1033 number_string=number_string+toric_id[pos]; 1043 1034 pos++; 1044 1035 } 1045 1036 execute("generators="+number_string+";"); 1046 1037 1047 pos=find(toric_id eal,"basis");1048 pos=find(toric_id eal,":",pos);1038 pos=find(toric_id,"basis"); 1039 pos=find(toric_id,":",pos); 1049 1040 pos++; 1050 1041 … … 1056 1047 for(i=1;i<=nvars(basering);i++) 1057 1048 { 1058 while(toric_id eal[pos]==" " || toric_ideal[pos]==newline)1059 { 1060 pos++; 1061 } 1062 number_string=""; 1063 while(toric_id eal[pos]!=" " && toric_ideal[pos]!=newline)1064 { 1065 number_string=number_string+toric_id eal[pos];1049 while(toric_id[pos]==" " || toric_id[pos]==newline) 1050 { 1051 pos++; 1052 } 1053 number_string=""; 1054 while(toric_id[pos]!=" " && toric_id[pos]!=newline) 1055 { 1056 number_string=number_string+toric_id[pos]; 1066 1057 pos++; 1067 1058 } … … 1073 1064 if(v[i]>0) 1074 1065 { 1075 head=head*var(i)^v[i]; 1066 head=head*var(i)^v[i]; 1076 1067 } 1077 1068 } 1078 1069 J[j]=head-tail; 1079 1070 } 1080 1071 1081 1072 // delete all created files 1082 1073 dummy=system("sh","rm -f "+groebnerfile); 1083 1074 dummy=system("sh","rm -f "+groebnerfile+".GB.pt"); 1084 dummy=system("sh","rm -f "+newcostfile); 1075 dummy=system("sh","rm -f "+newcostfile); 1085 1076 1086 1077 return(J); 1087 1078 } 1079 1080 1081 1088 1082 example 1089 1083 { 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 // not only binomials 1101 1102 1103 //binomials whose monomials are not relatively prime1104 1105 1106 1107 1108 1109 1110 1111 1112 // comparison with real standard basis and saturation 1113 1114 1115 1116 1084 "EXAMPLE"; echo=2; 1085 1086 ring r=0,(x,y,z),wp(3,2,1); 1087 1088 // call with toric ideal (of the matrix A=(1,1,1)) 1089 ideal I=x-y,x-z; 1090 //ideal J=toric_std(I); 1091 //J; 1092 1093 // call with the same ideal, but badly chosen generators: 1094 // 1) not only binomials 1095 I=x-y,2x-y-z; 1096 //J=toric_std(I); 1097 // 2) binomials whose monomials are not relatively prime 1098 I=x-y,xy-yz,y-z; 1099 //J=toric_std(I); 1100 //J; 1101 1102 // call with a non-toric ideal that seems to be toric 1103 I=x-yz,xy-z; 1104 //J=toric_std(I); 1105 //J; 1106 // comparison with real standard basis and saturation 1107 ideal H=std(I); 1108 H; 1109 LIB "elim.lib"; 1110 sat(H,xyz); 1117 1111 } 1118 1112 1119 ////////////////////////////////////////////////////////////////////////////// 1113
Note: See TracChangeset
for help on using the changeset viewer.