Changeset 343966 in git
 Timestamp:
 Sep 28, 2010, 6:27:37 PM (13 years ago)
 Branches:
 (u'jengelhdatetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
 Children:
 04e210843feb1167f9c6282699922f1756e760c5
 Parents:
 35b6ca571f5260579f60e2918659a4db705b4b5c
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Singular/LIB/multigrading.lib
r35b6ca r343966 10 10 11 11 12 OVERVIEW: using this library allows one can virtually add multigradingto Singular.12 OVERVIEW: This library allows one to virtually add multigradings to Singular. 13 13 For more see http://code.google.com/p/convexsingular/wiki/Multigrading 14 For theoretical references see: 14 For theoretical references see: 15 15 E. Miller, B. Sturmfels: 'Combinatorial Commutative Algebra' and 16 16 M. Kreuzer, L. Robbiano: 'Computational Commutative Algebra'. … … 62 62 PURPOSE: attaches weights of variables and torsion to the basering. 63 63 NOTE: M encodes the weights of variables columnwise. 64 The torsion is given by the lattice spanned by the columns of the integer 64 The torsion is given by the lattice spanned by the columns of the integer 65 65 matrix T in Z^nrows(M) over Z. 66 66 RETURN: nothing … … 74 74 75 75 attrib(basering, attrMgrad, M); 76 76 77 77 if( size(#) > 0 and typeof(#[1]) == "intmat" ) 78 78 { … … 85 85 if( nrows(T) == nrows(M) ) 86 86 { 87 attrib(basering, attrTorsion, T); 88 def H;89 attrib(basering, attrTorsionHNF, H); 87 attrib(basering, attrTorsion, T); 88 // def H; 89 // attrib(basering, attrTorsionHNF, H); 90 90 } 91 91 else … … 97 97 { 98 98 "EXAMPLE:"; echo=2; 99 99 100 ring R = 0, (x, y, z), dp; 101 100 102 // Weights of variables 101 103 intmat M[3][3] = … … 103 105 0, 1, 0, 104 106 0, 0, 1; 107 105 108 // Torsion: 106 109 intmat L[3][2] = 107 110 1, 1, 108 1, 3, 111 1, 3, 109 112 1, 5; 113 110 114 // attaches M & L to R (==basering): 111 115 setBaseMultigrading(M, L); // Grading: Z^3/L 116 112 117 // Weights are accessible via "getVariableWeights()": 113 getVariableWeights() == M; 114 getVariableWeights(R) == M; 115 getVariableWeights(basering) == M; 118 getVariableWeights(); 119 120 // Test all possible usages: 121 (getVariableWeights() == M) && (getVariableWeights(R) == M) && (getVariableWeights(basering) == M); 122 116 123 // Torsion is accessible via "getTorsion()": 117 getTorsion() == L; 118 getTorsion(R) == L; 119 getTorsion(basering) == L; 124 getTorsion(); 125 126 // Test all possible usages: 127 (getTorsion() == L) && (getTorsion(R) == L) && (getTorsion(basering) == L); 128 120 129 // And its hermite NF via getTorsion("hermite"): 130 getTorsion("hermite"); 131 132 // Test all possible usages: 121 133 intmat H = hermite(L); 122 getTorsion("hermite") == H; 123 getTorsion(R, "hermite") == H; 124 getTorsion(basering, "hermite") == H; 134 (getTorsion("hermite") == H) && (getTorsion(R, "hermite") == H) && (getTorsion(basering, "hermite") == H); 135 125 136 kill L, M; 137 126 138 //  isomorphic multigrading  // 139 127 140 // Weights of variables 128 141 intmat M[2][3] = 129 142 1, 2, 1, 130 143 1, 1, 0; 144 131 145 // Torsion: 132 146 intmat L[2][1] = 133 147 0, 134 148 2; 149 135 150 // attaches M & L to R (==basering): 136 151 setBaseMultigrading(M, L); // Grading: Z + (Z/2Z) 152 137 153 // Weights are accessible via "getVariableWeights()": 138 154 getVariableWeights() == M; 155 139 156 // Torsion is accessible via "getTorsion()": 140 157 getTorsion() == L; 158 141 159 kill L, M; 142 160 //  extreme case  // 161 143 162 // Weights of variables 144 163 intmat M[1][3] = 145 164 1, 1, 10; 165 146 166 // Torsion: 147 167 intmat L[1][1] = 148 168 0; 169 149 170 // attaches M & L to R (==basering): 150 171 setBaseMultigrading(M); // Grading: Z^3 172 151 173 // Weights are accessible via "getVariableWeights()": 152 174 getVariableWeights() == M; 175 153 176 // Torsion is accessible via "getTorsion()": 154 177 getTorsion() == L; … … 185 208 def M = attrib(R, attrMgrad); 186 209 if( typeof(M) == "intmat"){ return (M); } 187 ERROR( "Sorry no multigrading matrix!" ); 210 ERROR( "Sorry no multigrading matrix!" ); 188 211 } 189 212 example 190 213 { 191 214 "EXAMPLE:"; echo=2; 215 192 216 ring R = 0, (x, y, z), dp; 217 193 218 // Weights of variables 194 219 intmat M[3][3] = … … 196 221 0, 1, 0, 197 222 0, 0, 1; 223 198 224 // Torsion: 199 225 intmat L[3][2] = 200 226 1, 1, 201 1, 3, 227 1, 3, 202 228 1, 5; 229 203 230 // attaches M & L to R (==basering): 204 231 setBaseMultigrading(M, L); // Grading: Z^3/L 232 205 233 // Weights are accessible via "getVariableWeights()": 206 234 getVariableWeights() == M; 235 207 236 kill L, M; 237 208 238 //  isomorphic multigrading  // 239 209 240 // Weights of variables 210 241 intmat M[2][3] = 211 242 1, 2, 1, 212 243 1, 1, 0; 244 213 245 // Torsion: 214 246 intmat L[2][1] = 215 247 0, 216 248 2; 249 217 250 // attaches M & L to R (==basering): 218 251 setBaseMultigrading(M, L); // Grading: Z + (Z/2Z) 252 219 253 // Weights are accessible via "getVariableWeights()": 220 254 getVariableWeights() == M; 255 221 256 kill L, M; 257 222 258 //  extreme case  // 259 223 260 // Weights of variables 224 261 intmat M[1][3] = 225 262 1, 1, 10; 263 226 264 // Torsion: 227 265 intmat L[1][1] = 228 266 0; 267 229 268 // attaches M & L to R (==basering): 230 269 setBaseMultigrading(M); // Grading: Z^3 270 231 271 // Weights are accessible via "getVariableWeights()": 232 272 getVariableWeights() == M; … … 239 279 RETURN: intmat, the torsion matrix, or its hermite normal form 240 280 if an optional argument (\"hermite\") is given 281 EXAMPLE: example getTorsion; shows an example 241 282 " 242 283 { … … 252 293 def R = #[i]; 253 294 i++; 254 } 255 } 295 } 296 } 256 297 257 298 if( !defined(R) ) … … 264 305 if( #[i] == "hermite" ) 265 306 { 266 if( typeof(attrib(R, attrTorsionHNF)) != "intmat" ) 307 if( typeof(attrib(R, attrTorsionHNF)) != "intmat" ) 267 308 { 268 309 def M = getTorsion(R); 269 310 if( typeof(M) != "intmat") 270 { 271 ERROR( "Sorry no torsion matrix!" ); 311 { 312 ERROR( "Sorry no torsion matrix!" ); 272 313 } 273 attrib(R, attrTorsionHNF, hermite(M)); // this might not work with R != basering... 274 } 314 M = hermite(M); 315 attrib(R, attrTorsionHNF, M); // this might not work with R != basering... 316 } 275 317 return (attrib(R, attrTorsionHNF)); 276 318 } … … 279 321 def M = attrib(R, attrTorsion); 280 322 if( typeof(M) != "intmat") 281 { 282 ERROR( "Sorry no torsion matrix!" ); 323 { 324 ERROR( "Sorry no torsion matrix!" ); 283 325 } 284 326 return (M); … … 287 329 { 288 330 "EXAMPLE:"; echo=2; 331 289 332 ring R = 0, (x, y, z), dp; 333 290 334 // Weights of variables 291 335 intmat M[3][3] = … … 293 337 0, 1, 0, 294 338 0, 0, 1; 339 295 340 // Torsion: 296 341 intmat L[3][2] = 297 342 1, 1, 298 1, 3, 343 1, 3, 299 344 1, 5; 345 300 346 // attaches M & L to R (==basering): 301 347 setBaseMultigrading(M, L); // Grading: Z^3/L 348 302 349 // Torsion is accessible via "getTorsion()": 303 350 getTorsion() == L; 351 304 352 // its hermite NF: 305 353 print(getTorsion("hermite")); 354 306 355 kill L, M; 356 307 357 //  isomorphic multigrading  // 358 308 359 // Weights of variables 309 360 intmat M[2][3] = 310 361 1, 2, 1, 311 362 1, 1, 0; 363 312 364 // Torsion: 313 365 intmat L[2][1] = 314 366 0, 315 367 2; 368 316 369 // attaches M & L to R (==basering): 317 370 setBaseMultigrading(M, L); // Grading: Z + (Z/2Z) 371 318 372 // Torsion is accessible via "getTorsion()": 319 373 getTorsion() == L; 374 320 375 // its hermite NF: 321 376 print(getTorsion("hermite")); 377 322 378 kill L, M; 379 323 380 //  extreme case  // 381 324 382 // Weights of variables 325 383 intmat M[1][3] = 326 384 1, 1, 10; 385 327 386 // Torsion: 328 387 intmat L[1][1] = 329 388 0; 389 330 390 // attaches M & L to R (==basering): 331 391 setBaseMultigrading(M); // Grading: Z^3 392 332 393 // Torsion is accessible via "getTorsion()": 333 394 getTorsion() == L; 395 334 396 // its hermite NF: 335 397 print(getTorsion("hermite")); … … 340 402 "USAGE: getModuleGrading(m), 'm' module/vector 341 403 RETURN: integer matrix of the multiweights of free module generators attached to 'm' 404 EXAMPLE: example getModuleGrading; shows an example 342 405 " 343 406 { … … 356 419 return (VV); 357 420 } 358 421 359 422 ERROR("Sorry: vector or module need modulegradingmatrix! See 'getModuleGrading'."); 360 423 } … … 369 432 ERROR("Sorry wrong width of V: " + string(ncols(V))); 370 433 } 371 434 372 435 return (V); 373 436 } … … 375 438 { 376 439 "EXAMPLE:"; echo=2; 440 377 441 ring R = 0, (x,y), dp; 378 442 intmat M[2][2]= … … 382 446 1, 2, 3, 4, 0, 383 447 0, 10, 20, 30, 1; 448 384 449 setBaseMultigrading(M, T); 450 385 451 ideal I = x, y, xy^5; 386 452 isHomogenous(I); 453 387 454 intmat V = mDeg(I); print(V); 455 388 456 module S = syz(I); print(S); 457 389 458 S = setModuleGrading(S, V); 459 390 460 getModuleGrading(S) == V; 461 391 462 vector v = setModuleGrading(S[1], V); 392 463 getModuleGrading(v) == V; 393 464 isHomogenous(v); 394 print( mDeg(v) ); 465 print( mDeg(v) ); 466 395 467 isHomogenous(S); 396 468 print( mDeg(S) ); … … 401 473 "USAGE: setModuleGrading(m, G), m module/vector, G intmat 402 474 PURPOSE: attaches the multiweights of free module generators to 'm' 403 WARNING: The method does not verify thatthe multigrading makes the475 WARNING: The method does not verify whether the multigrading makes the 404 476 module/vector homogenous. One can do that using isHomogenous(m). 477 EXAMPLE: example setModuleGrading; shows an example 405 478 " 406 479 { … … 418 491 { 419 492 "EXAMPLE:"; echo=2; 493 420 494 ring R = 0, (x,y), dp; 421 495 intmat M[2][2]= … … 425 499 1, 2, 3, 4, 0, 426 500 0, 10, 20, 30, 1; 501 427 502 setBaseMultigrading(M, T); 503 428 504 ideal I = x, y, xy^5; 429 505 intmat V = mDeg(I); 506 430 507 // V == M; modulo T 431 508 print(V); 509 432 510 module S = syz(I); 511 433 512 S = setModuleGrading(S, V); 434 513 getModuleGrading(S) == V; 514 435 515 print(S); 516 436 517 vector v = S[1]; v = setModuleGrading(v, V); 437 518 getModuleGrading(v) == V; 438 print( mDeg(v) ); 519 520 print( mDeg(v) ); 521 439 522 isHomogenous(S); 523 440 524 print( mDeg(S) ); 441 525 } … … 449 533 PURPOSE: Determines whether the multigrading attached to the current ring is torsionfree. 450 534 RETURN: boolean, the result of the test 535 EXAMPLE: example isTorsionFree; shows an example 451 536 " 452 537 { 453 538 454 intmat H = hermite(transpose(getTorsion("hermite"))); // TODO: ?cache it? 539 intmat H = hermite(transpose(getTorsion("hermite"))); // TODO: ?cache it? //****** 455 540 456 541 int i, j; … … 465 550 466 551 if(H[j, i]!=0) 467 { 552 { 468 553 d=d*H[j, i]; 469 554 } … … 471 556 472 557 if( (d*d)==1 ) 473 { 558 { 474 559 return(1==1); 475 560 } … … 479 564 { 480 565 "EXAMPLE:"; echo=2; 566 481 567 ring R = 0,(x,y),dp; 482 568 intmat M[2][2]= … … 486 572 1, 2, 3, 4, 0, 487 573 0,10,20,30, 1; 574 488 575 setBaseMultigrading(M,T); 576 489 577 // Is the resulting group torsion free? 490 578 isTorsionFree(); 579 491 580 kill R, M, T; 492 581 /////////////////////////////////////////// 582 493 583 ring R=0,(x,y,z),dp; 494 intmat A[3][3] = 584 intmat A[3][3] = 495 585 1,0,0, 496 586 0,1,0, … … 503 593 // Is the resulting group torsion free? 504 594 isTorsionFree(); 595 505 596 kill R, A, B; 506 597 } … … 511 602 proc hermite(intmat A) 512 603 "USAGE: hermite( A ); 513 PROCEDURE: Computes the Hermite Normal Form of the matrix A by column operations. 604 PURPOSE: Computes the (lower triangular) Hermite Normal Form 605 of the matrix A by column operations. 514 606 RETURN: intmat, the Hermite Normal Form of A 607 EXAMPLE: example hermite; shows an example 515 608 " 516 609 { … … 541 634 542 635 if((i+l)>nrows(A)){ break; } 543 636 544 637 if(A[i+l, i]<0) 545 638 { … … 573 666 574 667 for(k=1;k<=nrows(A);k++) 575 { 668 { 576 669 save=A[k, i]; 577 670 A[k, i]=A[k, j]; … … 583 676 d=a2/A[i+l, i]; 584 677 for(k=1;k<=nrows(A);k++) 585 { 678 { 586 679 A[k, j]=A[k, j] d*A[k, i]; 587 680 } … … 603 696 { 604 697 "EXAMPLE:"; echo=2; 605 intmat M[2][5] = 698 699 intmat M[2][5] = 606 700 1, 2, 3, 4, 0, 607 701 0,10,20,30, 1; 702 608 703 // Hermite Normal Form of M: 609 704 print(hermite(M)); 610 intmat T[3][4] = 705 706 intmat T[3][4] = 611 707 3,3,3,3, 612 708 2,1,3,0, 613 709 1,2,0,3; 710 614 711 // Hermite Normal Form of T: 615 712 print(hermite(T)); 616 intmat A[4][5] = 713 714 intmat A[4][5] = 617 715 1,2,3,2,2, 618 716 1,2,3,4,0, 619 717 0,5,4,2,1, 620 718 3,2,4,0,2; 719 621 720 // Hermite Normal Form of A: 622 721 print(hermite(A)); … … 627 726 proc isTorsionElement(intvec mdeg) 628 727 "USAGE: isTorsionElement(intvec mdeg); 629 P ROCEDURE: For a integer vector mdeg representing the multidegree of some polynomial728 PURPOSE: For a integer vector mdeg representing the multidegree of some polynomial 630 729 or vector this method computes if the multidegree is contained in the torsion 631 730 group, i.e. if it is zero in the multigrading. 731 EXAMPLE: example isTorsionElement; shows an example 632 732 " 633 733 { … … 647 747 648 748 if(x!=0) 649 { 749 { 650 750 return(1==0); 651 751 } … … 654 754 655 755 for( k=1; k <= rr; k++) 656 { 756 { 657 757 mdeg[k] = mdeg[k]  x*H[k,i]; 658 758 } … … 666 766 { 667 767 "EXAMPLE:"; echo=2; 768 668 769 ring r = 0,(x,y,z),dp; 770 669 771 intmat g[2][3]= 670 772 1,0,1, … … 673 775 2, 674 776 1; 777 675 778 setBaseMultigrading(g,t); 779 676 780 poly a = x10yz; 677 781 poly b = x8y2z; … … 680 784 poly e = x2y2; 681 785 poly f = z2; 786 682 787 intvec v1 = mDeg(a)  mDeg(b); 683 788 v1; 684 789 isTorsionElement(v1); 790 685 791 intvec v2 = mDeg(a)  mDeg(c); 686 792 v2; 687 793 isTorsionElement(v2); 794 688 795 intvec v3 = mDeg(e)  mDeg(f); 689 796 v3; 690 797 isTorsionElement(v3); 798 691 799 intvec v4 = mDeg(c)  mDeg(d); 692 800 v4; … … 698 806 proc defineHomogenous(poly f, list #) 699 807 "USAGE: defineHomogenous(f[, G]); polynomial f, integer matrix G 700 PURPOSE: Yields a matrix which has to be appended to the torsion matrix to make the 808 PURPOSE: Yields a matrix which has to be appended to the torsion matrix to make the 701 809 polynomial f homogenous in the grading by grad. 810 EXAMPLE: example defineHomogenous; shows an example 702 811 " 703 812 { 704 if( size(#) > 0 ) 705 { 706 if( typeof(#[1]) == "intmat" ) 813 if( size(#) > 0 ) 814 { 815 if( typeof(#[1]) == "intmat" ) 707 816 { 708 817 intmat grad = #[1]; … … 732 841 { 733 842 "EXAMPLE:"; echo=2; 843 734 844 ring r =0,(x,y,z),dp; 735 intmat grad[2][3] = 845 intmat grad[2][3] = 736 846 1,0,1, 737 847 0,1,1; 848 738 849 setBaseMultigrading(grad); 850 739 851 poly f = x2y3z5+x3zx; 852 740 853 intmat M = defineHomogenous(f); 741 854 M; 742 855 defineHomogenous(f, grad) == M; 856 743 857 isHomogenous(f); 744 858 setBaseMultigrading(grad, M); … … 754 868 the torsion matrix may not be a subgroup of the grading group. Still all columns 755 869 are needed to find the correct image of the preimage gradings. 870 EXAMPLE: example pushForward; shows an example 756 871 " 757 872 { 758 873 759 874 int k,i,j; 760 f; 761 762 intmat oldgrad=getVariableWeights(preimage(f)); 763 intmat oldtor=getTorsion(preimage(f)); 764 765 int n=nvars(preimage(f)); 875 // f; 876 877 listvar(); 878 879 def pre = preimage(f); 880 881 "pre: "; 882 pre; 883 884 intmat oldgrad=getVariableWeights(pre); 885 intmat oldtor=getTorsion(pre); 886 887 int n=nvars(pre); 766 888 int np=nvars(basering); 767 889 int p=nrows(oldgrad); … … 846 968 { 847 969 "EXAMPLE:"; echo=2; 970 971 ring r = 0,(x,y,z),dp; 972 973 974 848 975 // Setting degrees for preimage ring.; 849 intmat grad[3][3] = 976 intmat grad[3][3] = 850 977 1,0,0, 851 978 0,1,0, 852 979 0,0,1; 853 ring r = 0,(x,y,z),dp; 854 if (voice>1) {keepring(r);} 980 855 981 setBaseMultigrading(grad); 982 856 983 // grading on r: 857 984 getVariableWeights(); 858 985 getTorsion(); 986 987 // only for the purpose of this example 988 if( voice > 1 ){ keepring(r); export(r); } 989 859 990 ring R = 0,(a,b),dp; 860 ideal i=a2b2+a6b5+ab3,a7b+b15ab6+a6b6; 991 ideal i = a2b2+a6b5+ab3,a7b+b15ab6+a6b6; 992 861 993 // The quotient ring by this ideal will become our image ring.; 862 994 qring Q = std(i); 863 map f = r,a2b6+b5+a3b+a2+ab,a2b73a2b5+b4+a,a6b6b3+a2; 864 f; 995 996 listvar(); 997 998 map f = r,a2b6+b5+a3b+a2+ab,a2b73a2b5+b4+a,a6b6b3+a2; f; 999 1000 1001 // TODO: Unfortunately this is not a very spectacular example...: 865 1002 // Pushing forward f: 866 1003 pushForward(f); 1004 867 1005 // due to pushForward we have got new grading on Q 868 1006 getVariableWeights(); 869 1007 getTorsion(); 870 // TODO: Unfortunately this is not a very spectacular example.; 1008 1009 1010 // only for the purpose of this example 1011 if( voice > 1 ){ kill r; } 1012 871 1013 } 872 1014 … … 875 1017 proc equalMDeg(intvec exp1, intvec exp2, list #) 876 1018 "USAGE: equalMDeg(exp1, exp2[, V]); intvec exp1, exp2, intmat V 877 PURPOSE: Tests if the exponent vectors of two monomials (given by exp1 and exp2) 1019 PURPOSE: Tests if the exponent vectors of two monomials (given by exp1 and exp2) 878 1020 represent the same multidegree. 879 NOTE: the integer matrix V encodes multidegrees of module components, 1021 NOTE: the integer matrix V encodes multidegrees of module components, 880 1022 if module component is present in exp1 and exp2 1023 EXAMPLE: example equalMDeg; shows an example 881 1024 " 882 1025 { … … 886 1029 } 887 1030 888 if( exp1 == exp2) 1031 if( exp1 == exp2) 889 1032 { 890 1033 return (1==1); … … 928 1071 { 929 1072 "EXAMPLE:"; echo=2; 1073 930 1074 ring r = 0,(x,y,z),dp; 1075 931 1076 intmat g[2][3]= 932 1077 1,0,1, 933 1078 0,1,1; 1079 934 1080 intmat t[2][1]= 935 1081 2, 936 1082 1; 1083 937 1084 setBaseMultigrading(g,t); 1085 938 1086 poly a = x10yz; 939 1087 poly b = x8y2z; … … 942 1090 poly e = x2y2; 943 1091 poly f = z2; 1092 1093 944 1094 equalMDeg(leadexp(a), leadexp(b)); 945 1095 equalMDeg(leadexp(a), leadexp(c)); … … 947 1097 equalMDeg(leadexp(a), leadexp(e)); 948 1098 equalMDeg(leadexp(a), leadexp(f)); 1099 949 1100 equalMDeg(leadexp(b), leadexp(c)); 950 1101 equalMDeg(leadexp(b), leadexp(d)); 951 1102 equalMDeg(leadexp(b), leadexp(e)); 952 1103 equalMDeg(leadexp(b), leadexp(f)); 1104 953 1105 equalMDeg(leadexp(c), leadexp(d)); 954 1106 equalMDeg(leadexp(c), leadexp(e)); 955 1107 equalMDeg(leadexp(c), leadexp(f)); 1108 956 1109 equalMDeg(leadexp(d), leadexp(e)); 957 1110 equalMDeg(leadexp(d), leadexp(f)); 1111 958 1112 equalMDeg(leadexp(e), leadexp(f)); 1113 959 1114 } 960 1115 … … 978 1133 "USAGE: isHomogenous(a[, f]); a polynomial/vector/ideal/module 979 1134 RETURN: boolean, TRUE if a is (multi)homogenous, and FALSE otherwise 1135 EXAMPLE: example isHomogenous; shows an example 980 1136 " 981 1137 { … … 1017 1173 def g = groebner(a); // !!!! 1018 1174 1019 def b, aa; int j; 1175 def b, aa; int j; 1020 1176 for( int i = ncols(a); i > 0; i ) 1021 1177 { … … 1037 1193 } 1038 1194 return(1==1); 1039 } 1195 } 1040 1196 } 1041 1197 example 1042 1198 { 1043 1199 "EXAMPLE:"; echo=2; 1200 1044 1201 ring r = 0,(x,y,z),dp; 1202 1045 1203 //Grading and Torsion matrices: 1046 intmat M[3][3] = 1204 intmat M[3][3] = 1047 1205 1,0,0, 1048 1206 0,1,0, 1049 1207 0,0,1; 1208 1050 1209 intmat T[3][1] = 1051 1210 1,2,3; 1211 1052 1212 setBaseMultigrading(M,T); 1213 1053 1214 attrib(r); 1215 1054 1216 poly f = xyz; 1217 1055 1218 mDegPartition(f); 1056 1219 print(mDeg(_)); 1220 1057 1221 isHomogenous(f); // f: is not homogenous 1222 1058 1223 poly g = 1xy2z3; 1059 1224 isHomogenous(g); // g: is homogenous 1060 1225 mDegPartition(g); 1226 1061 1227 kill T; 1062 1228 ///////////////////////////////////////////////////////// 1063 1229 // new Torsion matrix: 1064 intmat T[3][4] = 1230 intmat T[3][4] = 1065 1231 3,3,3,3, 1066 1232 2,1,3,0, 1067 1233 1,2,0,3; 1234 1068 1235 setBaseMultigrading(M,T); 1236 1069 1237 f; 1070 1238 isHomogenous(f); 1071 1239 mDegPartition(f); 1072 //  1240 1241 //  1073 1242 g; 1074 1243 isHomogenous(g); 1075 1244 mDegPartition(g); 1245 1076 1246 kill r, T, M; 1247 1077 1248 ring R = 0, (x,y,z), dp; 1078 intmat A[2][3] = 1249 1250 intmat A[2][3] = 1079 1251 0,0,1, 1080 1252 3,2,1; 1081 intmat T[2][1] = 1082 1, 1253 intmat T[2][1] = 1254 1, 1083 1255 4; 1084 1256 setBaseMultigrading(A, T); 1257 1085 1258 isHomogenous(ideal(x2  y3 xy +z, x*yz, x^3  y^2*z + x^2 y^3)); // 1 1086 1259 isHomogenous(ideal(x2  y3 xy +z, x*yz, x^3  y^2*z + x^2 y^3), "checkGens"); 1087 1260 isHomogenous(ideal(x+y, x2  y2)); // 0 1261 1088 1262 // Degree partition: 1089 1263 mDegPartition(x2  y3 xy +z); 1090 1264 mDegPartition(x3 y2z + x2 y3 + z + 1); 1265 1266 1091 1267 module N = gen(1) + (x+y) * gen(2), z*gen(3); 1268 1092 1269 intmat V[2][3] = 0; // 1, 2, 3, 4, 5, 6; // columnwise weights of components!!?? 1270 1093 1271 vector v1, v2; 1272 1094 1273 v1 = setModuleGrading(N[1], V); v1; 1095 1274 mDegPartition(v1); 1096 1275 print( mDeg(_) ); 1276 1097 1277 v2 = setModuleGrading(N[2], V); v2; 1098 1278 mDegPartition(v2); 1099 1279 print( mDeg(_) ); 1280 1100 1281 N = setModuleGrading(N, V); 1101 1282 isHomogenous(N); 1102 1283 print( mDeg(N) ); 1103 /////////////////////////////////////// 1104 V = 1105 1, 2, 3, 1284 1285 /////////////////////////////////////// 1286 1287 V = 1288 1, 2, 3, 1106 1289 4, 5, 6; 1290 1107 1291 v1 = setModuleGrading(N[1], V); v1; 1108 1292 mDegPartition(v1); 1109 1293 print( mDeg(_) ); 1294 1110 1295 v2 = setModuleGrading(N[2], V); v2; 1111 1296 mDegPartition(v2); 1112 1297 print( mDeg(_) ); 1298 1113 1299 N = setModuleGrading(N, V); 1114 1300 isHomogenous(N); 1115 1301 print( mDeg(N) ); 1116 /////////////////////////////////////// 1117 V = 1118 0, 0, 0, 1302 1303 /////////////////////////////////////// 1304 1305 V = 1306 0, 0, 0, 1119 1307 4, 1, 0; 1308 1120 1309 N = gen(1) + x * gen(2), z*gen(3); 1121 N = setModuleGrading(N, V); N;1310 N = setModuleGrading(N, V); print(N); 1122 1311 isHomogenous(N); 1123 1312 print( mDeg(N) ); 1124 v1 = setModuleGrading(N[1], V); v1;1313 v1 = setModuleGrading(N[1], V); print(v1); 1125 1314 mDegPartition(v1); 1126 1315 print( mDeg(_) ); 1127 N = setModuleGrading(N, V); N;1316 N = setModuleGrading(N, V); print(N); 1128 1317 isHomogenous(N); 1129 1318 print( mDeg(N) ); … … 1132 1321 /******************************************************/ 1133 1322 proc mDeg(def A) 1134 "USAGE: mDeg(A); anyA1323 "USAGE: mDeg(A); polynomial/vector/ideal/module A 1135 1324 PURPOSE: compute multidegree 1325 EXAMPLE: example mDeg; shows an example 1136 1326 " 1137 1327 { … … 1179 1369 A = A  lead(A); 1180 1370 while( size(A) > 0 ) 1181 { 1371 { 1182 1372 v = leadexp(A); // v; 1183 1373 m = max( m, M * v, r ); // ???? … … 1200 1390 A = A  lead(A); 1201 1391 while( size(A) > 0 ) 1202 { 1392 { 1203 1393 v = leadexp(A); // v; 1204 1394 … … 1225 1415 { 1226 1416 G[j, i] = d[j]; 1227 } 1417 } 1228 1418 } 1229 1419 return(G); … … 1239 1429 v = setModuleGrading(A[i], V); 1240 1430 1241 // G[1..r, i] 1431 // G[1..r, i] 1242 1432 d = mDeg(v); 1243 1433 … … 1245 1435 { 1246 1436 G[j, i] = d[j]; 1247 } 1437 } 1248 1438 1249 1439 } … … 1251 1441 return(G); 1252 1442 } 1253 1443 1254 1444 } 1255 1445 example 1256 1446 { 1257 1447 "EXAMPLE:"; echo=2; 1448 1258 1449 ring r = 0,(x, y), dp; 1450 1259 1451 intmat A[2][2] = 1, 0, 0, 1; 1260 1452 print(A); 1453 1261 1454 intmat Ta[2][1] = 0, 3; 1262 1455 print(Ta); 1456 1263 1457 // attrib(A, "torsion", Ta); // to think about 1458 1264 1459 // "poly:"; 1265 1460 setBaseMultigrading(A); 1461 1462 1266 1463 mDeg( x*x, A ); 1267 1464 mDeg( y*y*y, A ); 1465 1268 1466 setBaseMultigrading(A, Ta); 1467 1269 1468 mDeg( x*x*y ); 1469 1270 1470 mDeg( y*y*y*x ); 1471 1271 1472 mDeg( x*y + x + 1 ); 1473 1272 1474 mDegPartition(x*y + x + 1); 1475 1273 1476 print ( mDeg(0) ); 1274 1477 poly zero = 0; 1275 1478 print ( mDeg(zero) ); 1479 1276 1480 // "ideal:"; 1481 1277 1482 ideal I = y*x*x, x*y*y*y; 1278 1483 print( mDeg(I) ); 1484 1279 1485 print ( mDeg(ideal(0)) ); 1280 1486 print ( mDeg(ideal(0,0,0)) ); 1487 1281 1488 // "vectors:"; 1489 1282 1490 intmat B[2][2] = 0, 1, 1, 0; 1283 1491 print(B); 1492 1284 1493 mDeg( setModuleGrading(y*y*y*gen(2), B )); 1285 1494 mDeg( setModuleGrading(x*x*gen(1), B )); 1495 1496 1286 1497 vector V = x*gen(1) + y*gen(2); 1287 1498 V = setModuleGrading(V, B); 1288 1499 mDeg( V ); 1500 1289 1501 vector v1 = setModuleGrading([0, 0, 0], B); 1290 1502 print( mDeg( v1 ) ); 1503 1291 1504 vector v2 = setModuleGrading([0], B); 1292 1505 print( mDeg( v2 ) ); 1506 1293 1507 // "module:"; 1508 1294 1509 module D = x*gen(1), y*gen(2); 1295 1510 D; 1296 1511 D = setModuleGrading(D, B); 1297 1512 print( mDeg( D ) ); 1513 1514 1298 1515 module DD = [0, 0],[0, 0, 0]; 1299 1516 DD = setModuleGrading(DD, B); 1300 1517 print( mDeg( DD ) ); 1518 1301 1519 module DDD = [0, 0]; 1302 1520 DDD = setModuleGrading(DDD, B); 1303 1521 print( mDeg( DDD ) ); 1522 1304 1523 }; 1305 1524 … … 1312 1531 "USAGE: mDegPartition(def p), p polynomial/vector 1313 1532 RETURNS: an ideal/module consisting of multigradedhomogeneous parts of p 1533 EXAMPLE: example mDegPartition; shows an example 1314 1534 " 1315 1535 { 1316 if( typeof(p) == "poly" ) 1317 { 1318 ideal I; 1536 if( typeof(p) == "poly" ) 1537 { 1538 ideal I; 1319 1539 poly mp, t, tt; 1320 1540 } … … 1323 1543 if( typeof(p) == "vector" ) 1324 1544 { 1325 module I; 1545 module I; 1326 1546 vector mp, t, tt; 1327 1547 } … … 1334 1554 if( typeof(p) == "vector" ) 1335 1555 { 1336 intmat V = getModuleGrading(p); 1556 intmat V = getModuleGrading(p); 1337 1557 } 1338 1558 else … … 1341 1561 } 1342 1562 1343 if( size(p) > 1) 1563 if( size(p) > 1) 1344 1564 { 1345 1565 intvec m; … … 1348 1568 { 1349 1569 m = leadexp(p); 1350 mp = lead(p); 1570 mp = lead(p); 1351 1571 p = p  lead(p); 1352 1572 tt = p; t = 0; 1353 1573 1354 1574 while( size(tt) > 0 ) 1355 { 1356 // TODO: we make no caching of matrices (M,T,H,V), which remain the same! 1357 if( equalMDeg( leadexp(tt), m, V ) ) 1575 { 1576 // TODO: we do not cache matrices (M,T,H,V), which remain the same :( 1577 // TODO: we need some lowlevel procedure with all these arguments...! 1578 if( equalMDeg( leadexp(tt), m, V ) ) 1358 1579 { 1359 1580 mp = mp + lead(tt); // "mp", mp; … … 1387 1608 { 1388 1609 "EXAMPLE:"; echo=2; 1610 1389 1611 ring r = 0,(x,y,z),dp; 1612 1390 1613 intmat g[2][3]= 1391 1614 1,0,1, … … 1394 1617 2, 1395 1618 1; 1619 1396 1620 setBaseMultigrading(g,t); 1621 1397 1622 poly f = x10yz+x8y2zx4z2+y5+x2y2z2+x17z3y6; 1623 1398 1624 mDegPartition(f); 1625 1399 1626 vector v = xy*gen(1)x3y2*gen(2)+x4y*gen(3); 1400 1627 intmat B[2][3]=1,1,2,0,0,1; 1401 1628 v = setModuleGrading(v,B); 1402 1629 getModuleGrading(v); 1630 1403 1631 mDegPartition(v, B); 1404 1632 } … … 1410 1638 { 1411 1639 intmat A[n][n]; 1412 1640 1413 1641 for( int i = n; i > 0; i ) 1414 1642 { … … 1424 1652 static proc finestMDeg(def r) 1425 1653 " 1426 USAGE: 1427 PURPOSE: finest multigrading 1654 USAGE: finestMDeg(r); ring r 1655 RETURN: ring, r endowed with the finest multigrading 1656 TODO: not yet... 1428 1657 " 1429 1658 { … … 1453 1682 1454 1683 1455 if( n > 0) 1456 { 1457 1458 intmat L[N][n]; 1684 if( n > 0) 1685 { 1686 1687 intmat L[N][n]; 1459 1688 // list L; 1460 1689 int j = n; … … 1464 1693 p = I[i]; 1465 1694 1466 if( size(p) > 1 ) 1695 if( size(p) > 1 ) 1467 1696 { 1468 1697 intvec m0 = leadexp(p); … … 1479 1708 1480 1709 print(L); 1481 setBaseMultigrading(A, L); 1482 } 1710 setBaseMultigrading(A, L); 1711 } 1483 1712 else 1484 1713 { … … 1496 1725 { 1497 1726 "EXAMPLE:"; echo=2; 1727 1498 1728 ring r = 0,(x, y), dp; 1499 1729 qring q = std(x^2  y); 1730 1500 1731 finestMDeg(q); 1732 1501 1733 } 1502 1734 … … 1507 1739 static proc newMap(map F, intmat Q, list #) 1508 1740 " 1509 USAGE: ?? no use now...1510 PURPOSE: ??1741 USAGE: newMap(F, Q[, P]); map F, intmat Q[, intmat P] 1742 PURPOSE: endowe the map F with the integer matrices P [and Q] 1511 1743 " 1512 1744 { … … 1514 1746 1515 1747 if( size(#) > 0 and typeof(#[1]) == "intmat" ) 1516 { 1748 { 1517 1749 attrib(F, "P", #[1]); 1518 1750 } 1519 1751 return (F); 1520 1752 } 1521 1522 1753 1523 1754 /******************************************************/ … … 1565 1796 { 1566 1797 "EXAMPLE:"; echo=2; 1798 1567 1799 ring r= 0,(x,y,z),dp; 1568 1800 matrix M[3][1] = x,y,z; … … 1584 1816 @* i=int 1585 1817 ASSUME:  A is a matrix with integer entries which describes the lattice 1586 @* as ker(A), if second argument is not present, 1818 @* as ker(A), if second argument is not present, and 1587 1819 @* as the left image Im(A) = {zA : z \in ZZ^k}, if second argument is a positive integer 1588 1820 @*  number of variables of basering equals number of columns of A … … 1649 1881 j=system("sh","hilbert q n sing4ti2"); ////////// be quiet + no loggin!!! 1650 1882 1651 j=system("sh", "awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.hil " + 1652 " sed s/[\\\ \\\t\\\v\\\f]/,/g " + 1653 " sed s/,+/,/gsed s/,,/,/g " + 1654 " sed s/,,/,/g " + 1883 j=system("sh", "awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.hil " + 1884 " sed s/[\\\ \\\t\\\v\\\f]/,/g " + 1885 " sed s/,+/,/gsed s/,,/,/g " + 1886 " sed s/,,/,/g " + 1655 1887 "> sing4ti2.converted" ); 1656 1888 if( defined(keepfiles) <= 0) … … 1668 1900 string ergstr = "intvec erglist = " + s + "0;"; 1669 1901 execute(ergstr); 1670 1902 1671 1903 // print(erglist); 1672 1904 1673 1905 int Rnc = erglist[1]; 1674 1906 int Rnr = erglist[2]; 1675 1907 1676 1908 intmat R[Rnr][Rnc]; 1677 1909 … … 1697 1929 { 1698 1930 "EXAMPLE:"; echo=2; 1931 1699 1932 ring r=0,(x1,x2,x3,x4,x5,x6,x7,x8,x9),dp; 1700 1933 intmat M[7][9]= … … 1738 1971 1739 1972 /******************************************************/ 1740 proc mDegBasis(intvec d) 1973 proc mDegBasis(intvec d) 1741 1974 " 1742 1975 USAGE: multidegree d 1743 1976 ASSUME: current ring is multigraded, monomial ordering is global 1744 1977 PURPOSE: compute all monomials of multidegree d 1978 EXAMPLE: example mDegBasis; shows an example 1745 1979 " 1746 1980 { … … 1781 2015 1782 2016 intmat AA[nr][nc + 2 * n]; 1783 AA[1..nr, 1.. nc] = A[1..nr, 1.. nc]; 1784 AA[1..nr, nc + (1.. n)] = T[1..nr, 1.. n]; 1785 AA[1..nr, nc + n + (1.. n)] = T[1..nr, 1.. n]; 2017 AA[1..nr, 1.. nc] = A[1..nr, 1.. nc]; 2018 AA[1..nr, nc + (1.. n)] = T[1..nr, 1.. n]; 2019 AA[1..nr, nc + n + (1.. n)] = T[1..nr, 1.. n]; 1786 2020 1787 2021 1788 2022 // print ( AA ); 1789 2023 1790 intmat K = leftKernelZ(( AA ) ); // 2024 intmat K = leftKernelZ(( AA ) ); // 1791 2025 1792 2026 // print(K); … … 1797 2031 // "!"; 1798 2032 1799 intmat B = hilbert4ti2intmat(transpose(KK), 1); 2033 intmat B = hilbert4ti2intmat(transpose(KK), 1); 1800 2034 1801 2035 // "!"; print(B); … … 1808 2042 1809 2043 1810 int i; 2044 int i; 1811 2045 int nnr = nrows(B); 1812 2046 int nnc = ncols(B); … … 1859 2093 { 1860 2094 "EXAMPLE:"; echo=2; 2095 1861 2096 ring R = 0, (x, y), dp; 2097 1862 2098 intmat g1[2][2]=1,0,0,1; 1863 2099 intmat t[2][1]=2,0; … … 1865 2101 intvec v1=4,0; 1866 2102 intvec v2=4,4; 2103 1867 2104 intmat g3[1][2]=1,1; 1868 2105 setBaseMultigrading(g3); … … 1870 2107 v3; 1871 2108 mDegBasis(v3); 2109 1872 2110 setBaseMultigrading(g1,t); 1873 2111 mDegBasis(v1); 1874 2112 setBaseMultigrading(g2); 1875 2113 mDegBasis(v2); 2114 1876 2115 intmat M[2][2] = 1, 1, 1, 1; 1877 2116 intvec d = 2, 2; 2117 1878 2118 setBaseMultigrading(M); 2119 1879 2120 mDegBasis(d); 1880 2121 attrib(_, "ZeroPart"); 2122 1881 2123 kill R; 1882 2124 ring R = 0, (x, y, z), dp; 2125 1883 2126 intmat M[2][3] = 1, 2, 1, 1, 1, 0; 2127 1884 2128 intmat T[2][1] = 0, 2; 2129 1885 2130 intvec d = 4, 1; 2131 1886 2132 setBaseMultigrading(M, T); 2133 1887 2134 mDegBasis(d); 1888 2135 attrib(_, "ZeroPart"); 2136 2137 1889 2138 kill R; 2139 1890 2140 ring R = 0, (x, y, z), dp; 1891 2141 qring Q = std(ideal( y^6+ x*y^3*zx^2*z^2 )); 2142 2143 1892 2144 intmat M[2][3] = 1, 1, 2, 2, 1, 1; 1893 2145 // intmat T[2][1] = 0, 2; 2146 1894 2147 setBaseMultigrading(M); 2148 1895 2149 intvec d = 6, 6; 1896 2150 mDegBasis(d); 1897 2151 attrib(_, "ZeroPart"); 2152 2153 2154 1898 2155 kill R; 1899 2156 ring R = 0, (x, y, z), dp; 1900 2157 qring Q = std(ideal( x*z^3  y *z^6, x*y*z  x^4*y^2 )); 2158 2159 1901 2160 intmat M[2][3] = 1, 2, 1, 1, 1, 0; 1902 2161 intmat T[2][1] = 0, 2; 2162 1903 2163 intvec d = 4, 1; 2164 1904 2165 setBaseMultigrading(M, T); 2166 1905 2167 mDegBasis(d); 1906 2168 attrib(_, "ZeroPart"); … … 1910 2172 proc mDegSyzygy(def I) 1911 2173 "USAGE: mDegSyzygy(I); I is a poly/vector/ideal/module 1912 PURPOSE: computes the multigraded syzygy of I 1913 RETURNS: module, the syzygy of I 1914 NOTE: generators of I must be multigraded homogeneous 2174 PURPOSE: computes the multigraded syzygy module of I 2175 RETURNS: module, the syzygy module of I 2176 NOTE: generators of I must be multigraded homogeneous 2177 EXAMPLE: example mDegSyzygy; shows an example 1915 2178 " 1916 2179 { 1917 if( isHomogenous(I, "checkGens") == 0) 1918 { 1919 ERROR ("Sorry: inhomogenous input!"); 1920 } 2180 if( isHomogenous(I, "checkGens") == 0) 2181 { 2182 ERROR ("Sorry: inhomogenous input!"); 2183 } 1921 2184 module S = syz(I); 1922 2185 S = setModuleGrading(S, mDeg(I)); … … 1926 2189 { 1927 2190 "EXAMPLE:"; echo=2; 2191 2192 1928 2193 ring r = 0,(x,y,z,w),dp; 1929 2194 intmat MM[2][4]= … … 1932 2197 setBaseMultigrading(MM); 1933 2198 module M = ideal( xwyz, x2zy3, xz2y2w, yw2z3); 2199 2200 1934 2201 intmat v[2][nrows(M)]= 1935 2202 1, 1936 2203 0; 2204 1937 2205 M = setModuleGrading(M, v); 2206 1938 2207 isHomogenous(M); 1939 2208 "Multidegrees: "; print(mDeg(M)); 1940 // Let's compute Syzygy!2209 // Let's compute syzygies! 1941 2210 def S = mDegSyzygy(M); S; 1942 2211 "Module Units Multigrading: "; print( getModuleGrading(S) ); 1943 2212 "Multidegrees: "; print(mDeg(S)); 2213 1944 2214 isHomogenous(S); 1945 2215 } … … 1949 2219 "USAGE: mDegGroebner(I); I is a poly/vector/ideal/module 1950 2220 PURPOSE: computes the multigraded standard/groebner basis of I 1951 NOTE: I must be multigraded homogeneous 2221 NOTE: I must be multigraded homogeneous 1952 2222 RETURNS: ideal/module, the computed basis 2223 EXAMPLE: example mDegGroebner; shows an example 1953 2224 " 1954 2225 { 1955 if( isHomogenous(I) == 0) 1956 { 1957 ERROR ("Sorry: inhomogenous input!"); 1958 } 2226 if( isHomogenous(I) == 0) 2227 { 2228 ERROR ("Sorry: inhomogenous input!"); 2229 } 1959 2230 1960 2231 def S = groebner(I); 1961 2232 1962 2233 if( typeof(I) == "module" or typeof(I) == "vector" ) 1963 2234 { 1964 S = setModuleGrading(S, getModuleGrading(I)); 2235 S = setModuleGrading(S, getModuleGrading(I)); 1965 2236 } 1966 2237 … … 1979 2250 setBaseMultigrading(MM); 1980 2251 1981 2252 1982 2253 module M = ideal( xwyz, x2zy3, xz2y2w, yw2z3); 1983 1984 2254 2255 1985 2256 intmat v[2][nrows(M)]= 1986 2257 1, 1987 2258 0; 1988 2259 1989 2260 M = setModuleGrading(M, v); 1990 2261 … … 2019 2290 proc mDegResolution(def I, int ll, list #) 2020 2291 "USAGE: mDegResolution(I,l,[f]); I is poly/vector/ideal/module; l,f are integers 2021 PURPOSE: computes the multigraded resolution of I of the length l, 2022 or the whole resolution if l is zero. Returns minimal resolution if an optional 2292 PURPOSE: computes the multigraded resolution of I of the length l, 2293 or the whole resolution if l is zero. Returns minimal resolution if an optional 2023 2294 argument 1 is supplied 2024 2295 NOTE: input must have multigradedhomogeneous generators. 2025 The returned list is trun kated at the first zero entry.2296 The returned list is truncated beginning with the first zero differential. 2026 2297 RETURNS: list, the computed resolution 2298 EXAMPLE: example mDegResolution; shows an example 2027 2299 " 2028 2300 { 2029 if( isHomogenous(I, "checkGens") == 0) 2030 { 2031 ERROR ("Sorry: inhomogenous input!"); 2032 } 2301 if( isHomogenous(I, "checkGens") == 0) 2302 { 2303 ERROR ("Sorry: inhomogenous input!"); 2304 } 2033 2305 2034 2306 def R = res(I, ll, #); list L = R; int l = size(L); … … 2036 2308 if( (typeof(I) == "module") or (typeof(I) == "vector") ) 2037 2309 { 2038 L[1] = setModuleGrading(L[1], getModuleGrading(I)); 2039 } 2040 2041 int i; 2310 L[1] = setModuleGrading(L[1], getModuleGrading(I)); 2311 } 2312 2313 int i; 2042 2314 for( i = 2; i <= l; i++ ) 2043 2315 { … … 2050 2322 } 2051 2323 } 2052 2324 2053 2325 return (L); 2054 2326 2055 2327 2056 2328 } 2057 2329 example 2058 2330 { 2059 2331 "EXAMPLE:"; echo=2; 2332 2060 2333 ring r = 0,(x,y,z,w),dp; 2334 2061 2335 intmat M[2][4]= 2062 2336 1,1,1,1, 2063 2337 0,1,3,4; 2338 2064 2339 setBaseMultigrading(M); 2340 2341 2065 2342 module m= ideal( xwyz, x2zy3, xz2y2w, yw2z3); 2343 2066 2344 isHomogenous(ideal( xwyz, x2zy3, xz2y2w, yw2z3), "checkGens"); 2345 2067 2346 ideal A = xwyz, x2zy3, xz2y2w, yw2z3; 2347 2068 2348 int j; 2349 2069 2350 for(j=1; j<=ncols(A); j++) 2070 2351 { 2071 2352 mDegPartition(A[j]); 2072 2353 } 2354 2073 2355 intmat v[2][1]= 2074 2356 1, 2075 2357 0; 2358 2076 2359 m = setModuleGrading(m, v); 2360 2077 2361 // Let's compute Syzygy! 2078 2362 def S = mDegSyzygy(m); S; 2079 2363 "Module Units Multigrading: "; print( getModuleGrading(S) ); 2080 2364 "Multidegrees: "; print(mDeg(S)); 2365 2081 2366 ///////////////////////////////////////////////////////////////////////////// 2367 2082 2368 S = mDegGroebner(S); S; 2083 2369 "Module Units Multigrading: "; print( getModuleGrading(S) ); 2084 2370 "Multidegrees: "; print(mDeg(S)); 2371 2085 2372 ///////////////////////////////////////////////////////////////////////////// 2373 2086 2374 def L = mDegResolution(m, 0, 1); 2375 2087 2376 for( j =1; j<=size(L); j++) 2088 2377 { … … 2092 2381 "Multigrading: "; print(mDeg(L[j])); 2093 2382 } 2383 2094 2384 ///////////////////////////////////////////////////////////////////////////// 2385 2095 2386 L = mDegResolution(maxideal(1), 0, 1); 2387 2096 2388 for( j =1; j<=size(L); j++) 2097 2389 { … … 2101 2393 "Multigrading: "; print(mDeg(L[j])); 2102 2394 } 2395 2103 2396 kill v; 2397 2398 2104 2399 def h = hilbertSeries(m); 2105 2400 setring h; 2401 2106 2402 numerator1; 2107 2403 factorize(numerator1); 2404 2108 2405 denominator1; 2109 2406 factorize(denominator1); 2407 2110 2408 numerator2; 2111 2409 factorize(numerator2); 2410 2112 2411 denominator2; 2113 2412 factorize(denominator2); … … 2117 2416 proc hilbertSeries(def I) 2118 2417 "USAGE: hilbertSeries(I); I is poly/vector/ideal/module 2119 PURPOSE: computes the multigraded Hilbert Series of M 2120 NOTE: input must have multigradedhomogeneous generators. 2418 PURPOSE: computes the multigraded Hilbert Series of M 2419 NOTE: input must have multigradedhomogeneous generators. 2121 2420 Multigrading should be positive. 2122 RETURNS: a ring in variables t_(i), s_(i), with polynomials 2123 numerator1 and denominator1 and muturally prime numerator2 2421 RETURNS: a ring in variables t_(i), s_(i), with polynomials 2422 numerator1 and denominator1 and muturally prime numerator2 2124 2423 and denominator2, quotients of which give the series. 2424 EXAMPLE: example hilbertSeries; shows an example 2125 2425 " 2126 2426 { 2127 2427 2128 2428 if( !isFreeRepresented() ) 2129 2429 { 2130 2430 ERROR("SORRY: ONLY TORSIONFREE CASE (POSITIVE GRADING)"); 2131 2431 } 2132 2432 2133 2433 int i, j, k, v; 2134 2434 2135 2435 intmat M = getVariableWeights(); 2136 2436 2137 2437 int cc = ncols(M); 2138 2438 int n = nrows(M); … … 2146 2446 2147 2447 int l = size(RES); 2148 2448 2149 2449 list L; L[l + 1] = 0; 2150 2450 … … 2153 2453 intmat zeros[n][1]; 2154 2454 L[1] = zeros; 2155 } 2455 } 2156 2456 else 2157 2457 { … … 2163 2463 L[j + 1] = mDeg(RES[j]); 2164 2464 } 2165 2465 2166 2466 l++; 2167 2467 2168 2468 ring R = 0,(t_(1..n),s_(1..n)),dp; 2169 2170 ideal units; 2469 2470 ideal units; 2171 2471 for( i=n; i>=1; i) 2172 2472 { 2173 2473 units[i] = (var(i) * var(n + i)  1); 2174 2474 } 2175 2475 2176 2476 qring Q = std(units); 2177 2477 2178 2478 // TODO: should not it be a quotient ring depending on Torsion??? 2179 2479 // I am not sure about what to do in the torsion case, but since … … 2184 2484 poly monom, summand, numerator; 2185 2485 poly denominator = 1; 2186 2486 2187 2487 for( i = 1; i <= cc; i++) 2188 2488 { … … 2196 2496 { 2197 2497 monom = monom * (var(k)^(v)); 2198 } 2498 } 2199 2499 else 2200 2500 { … … 2202 2502 } 2203 2503 } 2204 2504 2205 2505 if( monom == 1) 2206 2506 { … … 2210 2510 denominator = denominator * (1  monom); 2211 2511 } 2212 2213 for( j = 1; j<= l; j++) 2512 2513 for( j = 1; j<= l; j++) 2214 2514 { 2215 2515 summand = 0; … … 2225 2525 { 2226 2526 monom = monom * (var(k)^v); 2227 } 2527 } 2228 2528 else 2229 2529 { … … 2235 2535 numerator = numerator  (1)^j * summand; 2236 2536 } 2237 2537 2238 2538 if( denominator == 0 ) 2239 2539 { 2240 2540 ERROR("Multigrading not positive."); 2241 } 2242 2541 } 2542 2243 2543 poly denominator1 = denominator; 2244 2544 poly numerator1 = numerator; … … 2274 2574 "The s_(i)variables are defined to be the inverse of the t_(i)variables."; 2275 2575 "  "; 2276 2576 2277 2577 return(Q); 2278 2578 } … … 2280 2580 { 2281 2581 "EXAMPLE:"; echo=2; 2582 2282 2583 ring r = 0,(x,y,z,w),dp; 2283 2584 intmat g[2][4]= … … 2285 2586 0,1,3,4; 2286 2587 setBaseMultigrading(g); 2588 2287 2589 module M = ideal(xwyz, x2zy3, xz2y2w, yw2z3); 2288 2590 intmat V[2][1]= 2289 2591 1, 2290 2592 0; 2593 2291 2594 M = setModuleGrading(M, V); 2595 2292 2596 def h = hilbertSeries(M); setring h; 2597 2293 2598 factorize(numerator2); 2294 2599 factorize(denominator2); 2600 2295 2601 kill g, h; setring r; 2602 2296 2603 intmat g[2][4]= 2297 2604 1,2,3,4, 2298 2605 0,0,5,8; 2606 2299 2607 setBaseMultigrading(g); 2608 2300 2609 ideal I = x^2, y, z^3; 2301 2610 I = std(I); 2302 2611 def L = mDegResolution(I, 0, 1); 2612 2303 2613 for( int j = 1; j<=size(L); j++) 2304 2614 { … … 2308 2618 "Multigrading: "; print(mDeg(L[j])); 2309 2619 } 2620 2310 2621 mDeg(I); 2311 2622 def h = hilbertSeries(I); setring h; 2623 2312 2624 factorize(numerator2); 2313 2625 factorize(denominator2); 2626 2314 2627 kill r, h, g, V; 2315 2628 //////////////////////////////////////////////// 2316 2629 ring R = 0,(x,y,z),dp; 2317 intmat W[2][3] = 2630 intmat W[2][3] = 2318 2631 1,1, 1, 2319 2632 0,0,1; 2320 2633 setBaseMultigrading(W); 2321 2634 ideal I = x3y,yz2,y2z,z4; 2635 2322 2636 def h = hilbertSeries(I); setring h; 2637 2323 2638 factorize(numerator2); 2324 2639 factorize(denominator2); 2640 2325 2641 kill R, W, h; 2326 2642 //////////////////////////////////////////////// 2327 2643 ring R = 0,(x,y,z,a,b,c),dp; 2328 intmat W[2][6] = 2644 intmat W[2][6] = 2329 2645 1,1, 1,1,1,1, 2330 2646 0,0,1,0,0,0; 2331 2647 setBaseMultigrading(W); 2332 2648 ideal I = x3y,yz2,y2z,z4; 2649 2333 2650 def h = hilbertSeries(I); setring h; 2651 2334 2652 factorize(numerator2); 2335 2653 factorize(denominator2); 2654 2336 2655 kill R, W, h; 2337 2656 //////////////////////////////////////////////// 2338 2657 // This is example 5.3.9. from Robbianos book. 2658 2339 2659 ring R = 0,(x,y,z,w),dp; 2340 intmat W[1][4] = 2660 intmat W[1][4] = 2341 2661 1,1, 1,1; 2342 2662 setBaseMultigrading(W); 2343 2663 ideal I = z3,y3zw2,x2y4w2xyz2; 2664 2344 2665 hilb(std(I)); 2666 2345 2667 def h = hilbertSeries(I); setring h; 2668 2346 2669 numerator1; 2347 2670 denominator1; 2671 2348 2672 factorize(numerator2); 2349 2673 factorize(denominator2); 2674 2675 2350 2676 kill h; 2351 2677 //////////////////////////////////////////////// 2352 2678 setring R; 2679 2353 2680 ideal I2 = x2,y2,z2; I2; 2681 2354 2682 hilb(std(I2)); 2683 2355 2684 def h = hilbertSeries(I2); setring h; 2685 2356 2686 numerator1; 2357 2687 denominator1; 2688 2689 2358 2690 kill h; 2359 2691 //////////////////////////////////////////////// 2360 2692 setring R; 2693 2361 2694 W = 2,2,2,2; 2695 2362 2696 setBaseMultigrading(W); 2697 2363 2698 getVariableWeights(); 2699 2364 2700 intvec w = 2,2,2,2; 2701 2365 2702 hilb(std(I2), 1, w); 2703 2366 2704 kill w; 2705 2706 2367 2707 def h = hilbertSeries(I2); setring h; 2708 2709 2368 2710 numerator1; denominator1; 2369 2711 kill h; 2712 2713 2370 2714 kill R, W; 2715 2371 2716 //////////////////////////////////////////////// 2372 2717 ring R = 0,(x),dp; … … 2374 2719 1; 2375 2720 setBaseMultigrading(W); 2721 2376 2722 ideal I; 2723 2377 2724 I = 1; I; 2725 2378 2726 hilb(std(I)); 2727 2379 2728 def h = hilbertSeries(I); setring h; 2729 2380 2730 numerator1; denominator1; 2731 2381 2732 kill h; 2382 2733 //////////////////////////////////////////////// 2383 2734 setring R; 2735 2384 2736 I = x; I; 2737 2385 2738 hilb(std(I)); 2739 2386 2740 def h = hilbertSeries(I); setring h; 2741 2387 2742 numerator1; denominator1; 2743 2744 kill h; 2745 //////////////////////////////////////////////// 2746 setring R; 2747 2748 I = x^5; I; 2749 2750 hilb(std(I)); 2751 hilb(std(I), 1); 2752 2753 def h = hilbertSeries(I); setring h; 2754 2755 numerator1; denominator1; 2756 2757 2758 kill h; 2759 //////////////////////////////////////////////// 2760 setring R; 2761 2762 I = x^10; I; 2763 2764 hilb(std(I)); 2765 2766 def h = hilbertSeries(I); setring h; 2767 2768 numerator1; denominator1; 2769 2388 2770 kill h; 2389 2771 //////////////////////////////////////////////// 2390 2772 setring R; 2391 I = x^5; I; 2392 hilb(std(I)); 2393 hilb(std(I), 1); 2394 def h = hilbertSeries(I); setring h; 2773 2774 module M = 1; 2775 2776 M = setModuleGrading(M, W); 2777 2778 2779 hilb(std(M)); 2780 2781 def h = hilbertSeries(M); setring h; 2782 2395 2783 numerator1; denominator1; 2784 2396 2785 kill h; 2397 2786 //////////////////////////////////////////////// 2398 2787 setring R; 2399 I = x^10; I; 2400 hilb(std(I)); 2401 def h = hilbertSeries(I); setring h; 2788 2789 kill M; module M = x^5*gen(1); 2790 // intmat V[1][3] = 0; // TODO: this would lead to a wrong result!!!? 2791 intmat V[1][1] = 0; // all gen(i) of degree 0! 2792 2793 M = setModuleGrading(M, V); 2794 2795 hilb(std(M)); 2796 2797 def h = hilbertSeries(M); setring h; 2798 2402 2799 numerator1; denominator1; 2800 2403 2801 kill h; 2404 2802 //////////////////////////////////////////////// 2405 setring R; 2406 module M = 1; 2407 M = setModuleGrading(M, W); 2408 hilb(std(M)); 2409 def h = hilbertSeries(M); setring h; 2803 setring R; 2804 2805 module N = x^5*gen(3); 2806 2807 kill V; 2808 2809 intmat V[1][3] = 0; // all gen(i) of degree 0! 2810 2811 N = setModuleGrading(N, V); 2812 2813 hilb(std(N)); 2814 2815 def h = hilbertSeries(N); setring h; 2816 2410 2817 numerator1; denominator1; 2818 2411 2819 kill h; 2412 2820 //////////////////////////////////////////////// 2413 setring R; 2414 kill M; module M = x^5*gen(1); 2415 // intmat V[1][3] = 0; // TODO: this would lead to a wrong result!!!? 2416 intmat V[1][1] = 0; // all gen(i) of degree 0! 2417 M = setModuleGrading(M, V); 2418 hilb(std(M)); 2419 def h = hilbertSeries(M); setring h; 2821 setring R; 2822 2823 2824 module S = M + N; 2825 2826 S = setModuleGrading(S, V); 2827 2828 hilb(std(S)); 2829 2830 def h = hilbertSeries(S); setring h; 2831 2420 2832 numerator1; denominator1; 2833 2421 2834 kill h; 2422 //////////////////////////////////////////////// 2423 setring R; 2424 module N = x^5*gen(3); 2425 kill V; 2426 intmat V[1][3] = 0; // all gen(i) of degree 0! 2427 N = setModuleGrading(N, V); 2428 hilb(std(N)); 2429 def h = hilbertSeries(N); setring h; 2430 numerator1; denominator1; 2431 kill h; 2432 //////////////////////////////////////////////// 2433 setring R; 2434 module S = M + N; 2435 S = setModuleGrading(S, V); 2436 hilb(std(S)); 2437 def h = hilbertSeries(S); setring h; 2438 numerator1; denominator1; 2439 kill h; 2835 2440 2836 kill V; 2441 2837 kill R, W; 2838 2442 2839 } 2443 2840 … … 2448 2845 proc testMultigradingLib () 2449 2846 { 2847 echo = 2; printlevel = 3; 2450 2848 example setBaseMultigrading; 2451 2849 example setModuleGrading; … … 2470 2868 2471 2869 example mDegResolution; 2870 2871 "// ******************* example hilbertSeries ************************//"; 2472 2872 example hilbertSeries; 2473 2873 2474 2874 2475 2875 // example mDegBasis; // needs 4ti2! 2476 } 2876 2877 "The End!"; 2878 2879 }
Note: See TracChangeset
for help on using the changeset viewer.