Changeset a0bf79 in git
 Timestamp:
 Sep 23, 2010, 5:11:56 PM (13 years ago)
 Branches:
 (u'spielwiese', 'd1ba061a762c62d3a25159d8da8b6e17332291fa')
 Children:
 7c596bed4549a47d03834ba741671dbe1923e784
 Parents:
 efa2bca0582609e7d15dda825eb555ede060c868
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Singular/LIB/multigrading.lib
refa2bca ra0bf79 12 12 OVERVIEW: using this library allows one can virtually add multigrading 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); 87 attrib(basering, attrTorsion, T); 88 88 def H; 89 attrib(basering, attrTorsionHNF, H); 89 attrib(basering, attrTorsionHNF, H); 90 90 } 91 91 else … … 97 97 { 98 98 "EXAMPLE:"; echo=2; 99 99 100 100 ring R = 0, (x, y, z), dp; 101 101 … … 109 109 intmat L[3][2] = 110 110 1, 1, 111 1, 3, 111 1, 3, 112 112 1, 5; 113 113 114 114 // attaches M & L to R (==basering): 115 115 setBaseMultigrading(M, L); // Grading: Z^3/L … … 131 131 getTorsion(basering, "hermite") == H; 132 132 133 133 134 134 135 135 kill L, M; … … 146 146 0, 147 147 2; 148 148 149 149 // attaches M & L to R (==basering): 150 150 setBaseMultigrading(M, L); // Grading: Z + (Z/2Z) … … 166 166 intmat L[1][1] = 167 167 0; 168 168 169 169 // attaches M & L to R (==basering): 170 170 setBaseMultigrading(M); // Grading: Z^3 … … 207 207 def M = attrib(R, attrMgrad); 208 208 if( typeof(M) == "intmat"){ return (M); } 209 ERROR( "Sorry no multigrading matrix!" ); 209 ERROR( "Sorry no multigrading matrix!" ); 210 210 } 211 211 example 212 212 { 213 213 "EXAMPLE:"; echo=2; 214 214 215 215 ring R = 0, (x, y, z), dp; 216 216 … … 224 224 intmat L[3][2] = 225 225 1, 1, 226 1, 3, 226 1, 3, 227 227 1, 5; 228 228 229 229 // attaches M & L to R (==basering): 230 230 setBaseMultigrading(M, L); // Grading: Z^3/L … … 246 246 0, 247 247 2; 248 248 249 249 // attaches M & L to R (==basering): 250 250 setBaseMultigrading(M, L); // Grading: Z + (Z/2Z) … … 264 264 intmat L[1][1] = 265 265 0; 266 266 267 267 // attaches M & L to R (==basering): 268 268 setBaseMultigrading(M); // Grading: Z^3 … … 291 291 def R = #[i]; 292 292 i++; 293 } 294 } 293 } 294 } 295 295 296 296 if( !defined(R) ) … … 303 303 if( #[i] == "hermite" ) 304 304 { 305 if( typeof(attrib(R, attrTorsionHNF)) != "intmat" ) 305 if( typeof(attrib(R, attrTorsionHNF)) != "intmat" ) 306 306 { 307 307 def M = getTorsion(R); 308 308 if( typeof(M) != "intmat") 309 { 310 ERROR( "Sorry no torsion matrix!" ); 309 { 310 ERROR( "Sorry no torsion matrix!" ); 311 311 } 312 312 attrib(R, attrTorsionHNF, hermite(M)); // this might not work with R != basering... 313 } 313 } 314 314 return (attrib(R, attrTorsionHNF)); 315 315 } … … 318 318 def M = attrib(R, attrTorsion); 319 319 if( typeof(M) != "intmat") 320 { 321 ERROR( "Sorry no torsion matrix!" ); 320 { 321 ERROR( "Sorry no torsion matrix!" ); 322 322 } 323 323 return (M); … … 326 326 { 327 327 "EXAMPLE:"; echo=2; 328 328 329 329 ring R = 0, (x, y, z), dp; 330 330 … … 338 338 intmat L[3][2] = 339 339 1, 1, 340 1, 3, 340 1, 3, 341 341 1, 5; 342 342 343 343 // attaches M & L to R (==basering): 344 344 setBaseMultigrading(M, L); // Grading: Z^3/L … … 363 363 0, 364 364 2; 365 365 366 366 // attaches M & L to R (==basering): 367 367 setBaseMultigrading(M, L); // Grading: Z + (Z/2Z) … … 384 384 intmat L[1][1] = 385 385 0; 386 386 387 387 // attaches M & L to R (==basering): 388 388 setBaseMultigrading(M); // Grading: Z^3 … … 415 415 return (VV); 416 416 } 417 417 418 418 ERROR("Sorry: vector or module need modulegradingmatrix! See 'getModuleGrading'."); 419 419 } … … 428 428 ERROR("Sorry wrong width of V: " + string(ncols(V))); 429 429 } 430 430 431 431 return (V); 432 432 } … … 434 434 { 435 435 "EXAMPLE:"; echo=2; 436 436 437 437 ring R = 0, (x,y), dp; 438 438 intmat M[2][2]= … … 442 442 1, 2, 3, 4, 0, 443 443 0, 10, 20, 30, 1; 444 444 445 445 setBaseMultigrading(M, T); 446 446 447 447 ideal I = x, y, xy^5; 448 448 isHomogenous(I); 449 449 450 450 intmat V = mDeg(I); print(V); 451 451 452 452 module S = syz(I); print(S); 453 453 454 454 S = setModuleGrading(S, V); 455 455 456 456 getModuleGrading(S) == V; 457 457 458 458 vector v = setModuleGrading(S[1], V); 459 459 getModuleGrading(v) == V; 460 460 isHomogenous(v); 461 print( mDeg(v) ); 462 461 print( mDeg(v) ); 462 463 463 isHomogenous(S); 464 464 print( mDeg(S) ); … … 469 469 "USAGE: setModuleGrading(m, G), m module/vector, G intmat 470 470 PURPOSE: attaches the multiweights of free module generators to 'm' 471 WARNING: The method does not verify that the multigrading makes the 471 WARNING: The method does not verify that the multigrading makes the 472 472 module/vector homogenous. One can do that using isHomogenous(m). 473 473 " … … 486 486 { 487 487 "EXAMPLE:"; echo=2; 488 488 489 489 ring R = 0, (x,y), dp; 490 490 intmat M[2][2]= … … 494 494 1, 2, 3, 4, 0, 495 495 0, 10, 20, 30, 1; 496 496 497 497 setBaseMultigrading(M, T); 498 498 499 499 ideal I = x, y, xy^5; 500 500 intmat V = mDeg(I); 501 501 502 502 // V == M; modulo T 503 503 print(V); 504 504 505 505 module S = syz(I); 506 506 507 507 S = setModuleGrading(S, V); 508 508 getModuleGrading(S) == V; 509 509 510 510 print(S); 511 511 512 512 vector v = S[1]; v = setModuleGrading(v, V); 513 513 getModuleGrading(v) == V; 514 514 515 print( mDeg(v) ); 515 print( mDeg(v) ); 516 516 517 517 isHomogenous(S); … … 544 544 545 545 if(H[j, i]!=0) 546 { 546 { 547 547 d=d*H[j, i]; 548 548 } … … 550 550 551 551 if( (d*d)==1 ) 552 { 552 { 553 553 return(1==1); 554 554 } … … 566 566 1, 2, 3, 4, 0, 567 567 0,10,20,30, 1; 568 568 569 569 setBaseMultigrading(M,T); 570 570 571 571 // Is the resulting group torsion free? 572 572 isTorsionFree(); … … 576 576 577 577 ring R=0,(x,y,z),dp; 578 intmat A[3][3] = 578 intmat A[3][3] = 579 579 1,0,0, 580 580 0,1,0, … … 626 626 627 627 if((i+l)>nrows(A)){ break; } 628 628 629 629 if(A[i+l, i]<0) 630 630 { … … 658 658 659 659 for(k=1;k<=nrows(A);k++) 660 { 660 { 661 661 save=A[k, i]; 662 662 A[k, i]=A[k, j]; … … 668 668 d=a2/A[i+l, i]; 669 669 for(k=1;k<=nrows(A);k++) 670 { 670 { 671 671 A[k, j]=A[k, j] d*A[k, i]; 672 672 } … … 689 689 "EXAMPLE:"; echo=2; 690 690 691 intmat M[2][5] = 691 intmat M[2][5] = 692 692 1, 2, 3, 4, 0, 693 693 0,10,20,30, 1; … … 696 696 print(hermite(M)); 697 697 698 intmat T[3][4] = 698 intmat T[3][4] = 699 699 3,3,3,3, 700 700 2,1,3,0, … … 704 704 print(hermite(T)); 705 705 706 intmat A[4][5] = 706 intmat A[4][5] = 707 707 1,2,3,2,2, 708 708 1,2,3,4,0, … … 738 738 739 739 if(x!=0) 740 { 740 { 741 741 return(1==0); 742 742 } … … 745 745 746 746 for( k=1; k <= rr; k++) 747 { 747 { 748 748 mdeg[k] = mdeg[k]  x*H[k,i]; 749 749 } … … 779 779 v1; 780 780 isTorsionElement(v1); 781 781 782 782 intvec v2 = mDeg(a)  mDeg(c); 783 783 v2; 784 784 isTorsionElement(v2); 785 785 786 786 intvec v3 = mDeg(e)  mDeg(f); 787 787 v3; 788 788 isTorsionElement(v3); 789 789 790 790 intvec v4 = mDeg(c)  mDeg(d); 791 791 v4; … … 797 797 proc defineHomogenous(poly f, list #) 798 798 "USAGE: defineHomogenous(f[, G]); polynomial f, integer matrix G 799 PURPOSE: Yields a matrix which has to be appended to the torsion matrix to make the 799 PURPOSE: Yields a matrix which has to be appended to the torsion matrix to make the 800 800 polynomial f homogenous in the grading by grad. 801 801 " 802 802 { 803 if( size(#) > 0 ) 804 { 805 if( typeof(#[1]) == "intmat" ) 803 if( size(#) > 0 ) 804 { 805 if( typeof(#[1]) == "intmat" ) 806 806 { 807 807 intmat grad = #[1]; … … 833 833 834 834 ring r =0,(x,y,z),dp; 835 intmat grad[2][3] = 835 intmat grad[2][3] = 836 836 1,0,1, 837 837 0,1,1; … … 844 844 M; 845 845 defineHomogenous(f, grad) == M; 846 846 847 847 isHomogenous(f); 848 848 setBaseMultigrading(grad, M); … … 952 952 953 953 // Setting degrees for preimage ring.; 954 intmat grad[3][3] = 954 intmat grad[3][3] = 955 955 1,0,0, 956 956 0,1,0, … … 979 979 getVariableWeights(); 980 980 getTorsion(); 981 981 982 982 // TODO: Unfortunately this is not a very spectacular example.; 983 983 … … 988 988 proc equalMDeg(intvec exp1, intvec exp2, list #) 989 989 "USAGE: equalMDeg(exp1, exp2[, V]); intvec exp1, exp2, intmat V 990 PURPOSE: Tests if the exponent vectors of two monomials (given by exp1 and exp2) 990 PURPOSE: Tests if the exponent vectors of two monomials (given by exp1 and exp2) 991 991 represent the same multidegree. 992 NOTE: the integer matrix V encodes multidegrees of module components, 992 NOTE: the integer matrix V encodes multidegrees of module components, 993 993 if module component is present in exp1 and exp2 994 994 " … … 999 999 } 1000 1000 1001 if( exp1 == exp2) 1001 if( exp1 == exp2) 1002 1002 { 1003 1003 return (1==1); … … 1142 1142 def g = groebner(a); // !!!! 1143 1143 1144 def b, aa; int j; 1144 def b, aa; int j; 1145 1145 for( int i = ncols(a); i > 0; i ) 1146 1146 { … … 1162 1162 } 1163 1163 return(1==1); 1164 } 1164 } 1165 1165 } 1166 1166 example … … 1171 1171 1172 1172 //Grading and Torsion matrices: 1173 intmat M[3][3] = 1173 intmat M[3][3] = 1174 1174 1,0,0, 1175 1175 0,1,0, … … 1197 1197 ///////////////////////////////////////////////////////// 1198 1198 // new Torsion matrix: 1199 intmat T[3][4] = 1199 intmat T[3][4] = 1200 1200 3,3,3,3, 1201 1201 2,1,3,0, 1202 1202 1,2,0,3; 1203 1203 1204 1204 setBaseMultigrading(M,T); 1205 1205 … … 1208 1208 mDegPartition(f); 1209 1209 1210 //  1210 //  1211 1211 g; 1212 1212 isHomogenous(g); … … 1217 1217 ring R = 0, (x,y,z), dp; 1218 1218 1219 intmat A[2][3] = 1219 intmat A[2][3] = 1220 1220 0,0,1, 1221 1221 3,2,1; 1222 intmat T[2][1] = 1223 1, 1222 intmat T[2][1] = 1223 1, 1224 1224 4; 1225 1225 setBaseMultigrading(A, T); … … 1233 1233 mDegPartition(x3 y2z + x2 y3 + z + 1); 1234 1234 1235 1235 1236 1236 module N = gen(1) + (x+y) * gen(2), z*gen(3); 1237 1237 1238 1238 intmat V[2][3] = 0; // 1, 2, 3, 4, 5, 6; // columnwise weights of components!!?? 1239 1239 1240 1240 vector v1, v2; 1241 1241 1242 1242 v1 = setModuleGrading(N[1], V); v1; 1243 1243 mDegPartition(v1); … … 1252 1252 print( mDeg(N) ); 1253 1253 1254 /////////////////////////////////////// 1255 1256 V = 1257 1, 2, 3, 1254 /////////////////////////////////////// 1255 1256 V = 1257 1, 2, 3, 1258 1258 4, 5, 6; 1259 1259 … … 1270 1270 print( mDeg(N) ); 1271 1271 1272 /////////////////////////////////////// 1273 1274 V = 1275 0, 0, 0, 1272 /////////////////////////////////////// 1273 1274 V = 1275 0, 0, 0, 1276 1276 4, 1, 0; 1277 1277 … … 1340 1340 A = A  lead(A); 1341 1341 while( size(A) > 0 ) 1342 { 1342 { 1343 1343 v = leadexp(A); // v; 1344 1344 m = max( m, M * v, r ); // ???? … … 1361 1361 A = A  lead(A); 1362 1362 while( size(A) > 0 ) 1363 { 1363 { 1364 1364 v = leadexp(A); // v; 1365 1365 … … 1386 1386 { 1387 1387 G[j, i] = d[j]; 1388 } 1388 } 1389 1389 } 1390 1390 return(G); … … 1400 1400 v = setModuleGrading(A[i], V); 1401 1401 1402 // G[1..r, i] 1402 // G[1..r, i] 1403 1403 d = mDeg(v); 1404 1404 … … 1406 1406 { 1407 1407 G[j, i] = d[j]; 1408 } 1408 } 1409 1409 1410 1410 } … … 1412 1412 return(G); 1413 1413 } 1414 1414 1415 1415 } 1416 1416 example … … 1436 1436 1437 1437 setBaseMultigrading(A, Ta); 1438 1438 1439 1439 mDeg( x*x*y ); 1440 1440 1441 1441 mDeg( y*y*y*x ); 1442 1442 1443 1443 mDeg( x*y + x + 1 ); 1444 1444 … … 1450 1450 1451 1451 // "ideal:"; 1452 1452 1453 1453 ideal I = y*x*x, x*y*y*y; 1454 1454 print( mDeg(I) ); … … 1458 1458 1459 1459 // "vectors:"; 1460 1460 1461 1461 intmat B[2][2] = 0, 1, 1, 0; 1462 1462 print(B); 1463 1463 1464 1464 mDeg( setModuleGrading(y*y*y*gen(2), B )); 1465 1465 mDeg( setModuleGrading(x*x*gen(1), B )); 1466 1466 1467 1467 1468 1468 vector V = x*gen(1) + y*gen(2); 1469 1469 V = setModuleGrading(V, B); … … 1472 1472 vector v1 = setModuleGrading([0, 0, 0], B); 1473 1473 print( mDeg( v1 ) ); 1474 1474 1475 1475 vector v2 = setModuleGrading([0], B); 1476 1476 print( mDeg( v2 ) ); 1477 1477 1478 1478 // "module:"; 1479 1479 1480 1480 module D = x*gen(1), y*gen(2); 1481 1481 D; 1482 1482 D = setModuleGrading(D, B); 1483 1483 print( mDeg( D ) ); 1484 1484 1485 1485 1486 1486 module DD = [0, 0],[0, 0, 0]; … … 1504 1504 " 1505 1505 { 1506 if( typeof(p) == "poly" ) 1507 { 1508 ideal I; 1506 if( typeof(p) == "poly" ) 1507 { 1508 ideal I; 1509 1509 poly mp, t, tt; 1510 1510 } … … 1513 1513 if( typeof(p) == "vector" ) 1514 1514 { 1515 module I; 1515 module I; 1516 1516 vector mp, t, tt; 1517 1517 } … … 1524 1524 if( typeof(p) == "vector" ) 1525 1525 { 1526 intmat V = getModuleGrading(p); 1526 intmat V = getModuleGrading(p); 1527 1527 } 1528 1528 else … … 1531 1531 } 1532 1532 1533 if( size(p) > 1) 1533 if( size(p) > 1) 1534 1534 { 1535 1535 intvec m; … … 1538 1538 { 1539 1539 m = leadexp(p); 1540 mp = lead(p); 1540 mp = lead(p); 1541 1541 p = p  lead(p); 1542 1542 tt = p; t = 0; 1543 1543 1544 1544 while( size(tt) > 0 ) 1545 { 1545 { 1546 1546 // TODO: we make no caching of matrices (M,T,H,V), which remain the same! 1547 if( equalMDeg( leadexp(tt), m, V ) ) 1547 if( equalMDeg( leadexp(tt), m, V ) ) 1548 1548 { 1549 1549 mp = mp + lead(tt); // "mp", mp; … … 1592 1592 1593 1593 mDegPartition(f); 1594 1594 1595 1595 vector v = xy*gen(1)x3y2*gen(2)+x4y*gen(3); 1596 1596 intmat B[2][3]=1,1,2,0,0,1; 1597 1597 v = setModuleGrading(v,B); 1598 1598 getModuleGrading(v); 1599 1599 1600 1600 mDegPartition(v, B); 1601 1601 } … … 1607 1607 { 1608 1608 intmat A[n][n]; 1609 1609 1610 1610 for( int i = n; i > 0; i ) 1611 1611 { … … 1650 1650 1651 1651 1652 if( n > 0) 1653 { 1654 1655 intmat L[N][n]; 1652 if( n > 0) 1653 { 1654 1655 intmat L[N][n]; 1656 1656 // list L; 1657 1657 int j = n; … … 1661 1661 p = I[i]; 1662 1662 1663 if( size(p) > 1 ) 1663 if( size(p) > 1 ) 1664 1664 { 1665 1665 intvec m0 = leadexp(p); … … 1676 1676 1677 1677 print(L); 1678 setBaseMultigrading(A, L); 1679 } 1678 setBaseMultigrading(A, L); 1679 } 1680 1680 else 1681 1681 { … … 1714 1714 1715 1715 if( size(#) > 0 and typeof(#[1]) == "intmat" ) 1716 { 1716 { 1717 1717 attrib(F, "P", #[1]); 1718 1718 } … … 1850 1850 j=system("sh","hilbert q n sing4ti2"); ////////// be quiet + no loggin!!! 1851 1851 1852 j=system("sh", "awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.hil " + 1853 " sed s/[\\\ \\\t\\\v\\\f]/,/g " + 1854 " sed s/,+/,/gsed s/,,/,/g " + 1855 " sed s/,,/,/g " + 1852 j=system("sh", "awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.hil " + 1853 " sed s/[\\\ \\\t\\\v\\\f]/,/g " + 1854 " sed s/,+/,/gsed s/,,/,/g " + 1855 " sed s/,,/,/g " + 1856 1856 "> sing4ti2.converted" ); 1857 1857 if( defined(keepfiles) <= 0) … … 1869 1869 string ergstr = "intvec erglist = " + s + "0;"; 1870 1870 execute(ergstr); 1871 1871 1872 1872 // print(erglist); 1873 1873 1874 1874 int Rnc = erglist[1]; 1875 1875 int Rnr = erglist[2]; 1876 1876 1877 1877 intmat R[Rnr][Rnc]; 1878 1878 … … 1940 1940 1941 1941 /******************************************************/ 1942 proc mDegBasis(intvec d) 1942 proc mDegBasis(intvec d) 1943 1943 " 1944 1944 USAGE: multidegree d … … 1983 1983 1984 1984 intmat AA[nr][nc + 2 * n]; 1985 AA[1..nr, 1.. nc] = A[1..nr, 1.. nc]; 1986 AA[1..nr, nc + (1.. n)] = T[1..nr, 1.. n]; 1987 AA[1..nr, nc + n + (1.. n)] = T[1..nr, 1.. n]; 1985 AA[1..nr, 1.. nc] = A[1..nr, 1.. nc]; 1986 AA[1..nr, nc + (1.. n)] = T[1..nr, 1.. n]; 1987 AA[1..nr, nc + n + (1.. n)] = T[1..nr, 1.. n]; 1988 1988 1989 1989 1990 1990 // print ( AA ); 1991 1991 1992 intmat K = leftKernelZ(( AA ) ); // 1992 intmat K = leftKernelZ(( AA ) ); // 1993 1993 1994 1994 // print(K); … … 1999 1999 // "!"; 2000 2000 2001 intmat B = hilbert4ti2intmat(transpose(KK), 1); 2001 intmat B = hilbert4ti2intmat(transpose(KK), 1); 2002 2002 2003 2003 // "!"; print(B); … … 2010 2010 2011 2011 2012 int i; 2012 int i; 2013 2013 int nnr = nrows(B); 2014 2014 int nnc = ncols(B); … … 2069 2069 intvec v1=4,0; 2070 2070 intvec v2=4,4; 2071 2071 2072 2072 intmat g3[1][2]=1,1; 2073 2073 setBaseMultigrading(g3); … … 2075 2075 v3; 2076 2076 mDegBasis(v3); 2077 2077 2078 2078 setBaseMultigrading(g1,t); 2079 2079 mDegBasis(v1); 2080 2080 setBaseMultigrading(g2); 2081 2081 mDegBasis(v2); 2082 2082 2083 2083 intmat M[2][2] = 1, 1, 1, 1; 2084 2084 intvec d = 2, 2; … … 2142 2142 PURPOSE: computes the multigraded syzygy of I 2143 2143 RETURNS: module, the syzygy of I 2144 NOTE: generators of I must be multigraded homogeneous 2144 NOTE: generators of I must be multigraded homogeneous 2145 2145 " 2146 2146 { 2147 if( isHomogenous(I, "checkGens") == 0) 2148 { 2149 ERROR ("Sorry: inhomogenous input!"); 2150 } 2147 if( isHomogenous(I, "checkGens") == 0) 2148 { 2149 ERROR ("Sorry: inhomogenous input!"); 2150 } 2151 2151 module S = syz(I); 2152 2152 S = setModuleGrading(S, mDeg(I)); … … 2156 2156 { 2157 2157 "EXAMPLE:"; echo=2; 2158 2158 2159 2159 2160 2160 ring r = 0,(x,y,z,w),dp; … … 2166 2166 setBaseMultigrading(M); 2167 2167 2168 2168 2169 2169 module M = ideal( xwyz, x2zy3, xz2y2w, yw2z3); 2170 2171 2170 2171 2172 2172 intmat v[2][nrows(M)]= 2173 2173 1, 2174 2174 0; 2175 2175 2176 2176 M = setModuleGrading(M, v); 2177 2177 … … 2191 2191 "USAGE: mDegGroebner(I); I is a poly/vector/ideal/module 2192 2192 PURPOSE: computes the multigraded standard/groebner basis of I 2193 NOTE: I must be multigraded homogeneous 2193 NOTE: I must be multigraded homogeneous 2194 2194 RETURNS: ideal/module, the computed basis 2195 2195 " 2196 2196 { 2197 if( isHomogenous(I) == 0) 2198 { 2199 ERROR ("Sorry: inhomogenous input!"); 2200 } 2197 if( isHomogenous(I) == 0) 2198 { 2199 ERROR ("Sorry: inhomogenous input!"); 2200 } 2201 2201 2202 2202 def S = groebner(I); 2203 2203 2204 2204 if( typeof(I) == "module" or typeof(I) == "vector" ) 2205 2205 { 2206 S = setModuleGrading(S, getModuleGrading(I)); 2206 S = setModuleGrading(S, getModuleGrading(I)); 2207 2207 } 2208 2208 … … 2221 2221 setBaseMultigrading(M); 2222 2222 2223 2223 2224 2224 module M = ideal( xwyz, x2zy3, xz2y2w, yw2z3); 2225 2226 2225 2226 2227 2227 intmat v[2][nrows(M)]= 2228 2228 1, 2229 2229 0; 2230 2230 2231 2231 M = setModuleGrading(M, v); 2232 2232 … … 2261 2261 proc mDegResolution(def I, int ll, list #) 2262 2262 "USAGE: mDegResolution(I,l,[f]); I is poly/vector/ideal/module; l,f are integers 2263 PURPOSE: computes the multigraded resolution of I of the length l, 2264 or the whole resolution if l is zero. Returns minimal resolution if an optional 2263 PURPOSE: computes the multigraded resolution of I of the length l, 2264 or the whole resolution if l is zero. Returns minimal resolution if an optional 2265 2265 argument 1 is supplied 2266 2266 NOTE: input must have multigradedhomogeneous generators. … … 2269 2269 " 2270 2270 { 2271 if( isHomogenous(I, "checkGens") == 0) 2272 { 2273 ERROR ("Sorry: inhomogenous input!"); 2274 } 2271 if( isHomogenous(I, "checkGens") == 0) 2272 { 2273 ERROR ("Sorry: inhomogenous input!"); 2274 } 2275 2275 2276 2276 def R = res(I, ll, #); list L = R; int l = size(L); … … 2278 2278 if( (typeof(I) == "module") or (typeof(I) == "vector") ) 2279 2279 { 2280 L[1] = setModuleGrading(L[1], getModuleGrading(I)); 2281 } 2282 2283 int i; 2280 L[1] = setModuleGrading(L[1], getModuleGrading(I)); 2281 } 2282 2283 int i; 2284 2284 for( i = 2; i <= l; i++ ) 2285 2285 { … … 2292 2292 } 2293 2293 } 2294 2294 2295 2295 return (L); 2296 2296 2297 2297 2298 2298 } 2299 2299 example 2300 2300 { 2301 2301 "EXAMPLE:"; echo=2; 2302 2302 2303 2303 ring r = 0,(x,y,z,w),dp; 2304 2304 … … 2309 2309 setBaseMultigrading(M); 2310 2310 2311 2311 2312 2312 module m= ideal( xwyz, x2zy3, xz2y2w, yw2z3); 2313 2313 2314 2314 isHomogenous(ideal( xwyz, x2zy3, xz2y2w, yw2z3), "checkGens"); 2315 2315 2316 2316 ideal A = xwyz, x2zy3, xz2y2w, yw2z3; 2317 2317 2318 2318 int j; 2319 2319 2320 2320 for(j=1; j<=ncols(A); j++) 2321 2321 { 2322 2322 mDegPartition(A[j]); 2323 2323 } 2324 2324 2325 2325 intmat v[2][1]= 2326 2326 1, 2327 2327 0; 2328 2328 2329 2329 m = setModuleGrading(m, v); 2330 2330 … … 2353 2353 2354 2354 ///////////////////////////////////////////////////////////////////////////// 2355 2355 2356 2356 L = mDegResolution(maxideal(1), 0, 1); 2357 2357 … … 2363 2363 "Multigrading: "; print(mDeg(L[j])); 2364 2364 } 2365 2365 2366 2366 kill v; 2367 2367 2368 2368 2369 2369 def h = hilbertSeries(m); … … 2372 2372 numerator1; 2373 2373 factorize(numerator1); 2374 2374 2375 2375 denominator1; 2376 2376 factorize(denominator1); … … 2386 2386 proc hilbertSeries(def I) 2387 2387 "USAGE: hilbertSeries(I); I is poly/vector/ideal/module 2388 PURPOSE: computes the multigraded Hilbert Series of M 2389 NOTE: input must have multigradedhomogeneous generators. 2388 PURPOSE: computes the multigraded Hilbert Series of M 2389 NOTE: input must have multigradedhomogeneous generators. 2390 2390 Multigrading should be positive. 2391 RETURNS: a ring in variables t_(i), s_(i), with polynomials 2392 numerator1 and denominator1 and muturally prime numerator2 2391 RETURNS: a ring in variables t_(i), s_(i), with polynomials 2392 numerator1 and denominator1 and muturally prime numerator2 2393 2393 and denominator2, quotients of which give the series. 2394 2394 " 2395 2395 { 2396 2396 2397 2397 if( !isFreeRepresented() ) 2398 2398 { 2399 2399 ERROR("SORRY: ONLY TORSIONFREE CASE (POSITIVE GRADING)"); 2400 2400 } 2401 2401 2402 2402 int i, j, k, v; 2403 2403 2404 2404 intmat M = getVariableWeights(); 2405 2405 2406 2406 int cc = ncols(M); 2407 2407 int n = nrows(M); … … 2415 2415 2416 2416 int l = size(RES); 2417 2417 2418 2418 list L; L[l + 1] = 0; 2419 2419 … … 2422 2422 intmat zeros[n][1]; 2423 2423 L[1] = zeros; 2424 } 2424 } 2425 2425 else 2426 2426 { … … 2432 2432 L[j + 1] = mDeg(RES[j]); 2433 2433 } 2434 2434 2435 2435 l++; 2436 2436 2437 2437 ring R = 0,(t_(1..n),s_(1..n)),dp; 2438 2439 ideal units; 2438 2439 ideal units; 2440 2440 for( i=n; i>=1; i) 2441 2441 { 2442 2442 units[i] = (var(i) * var(n + i)  1); 2443 2443 } 2444 2444 2445 2445 qring Q = std(units); 2446 2446 2447 2447 // TODO: should not it be a quotient ring depending on Torsion??? 2448 2448 // I am not sure about what to do in the torsion case, but since … … 2453 2453 poly monom, summand, numerator; 2454 2454 poly denominator = 1; 2455 2455 2456 2456 for( i = 1; i <= cc; i++) 2457 2457 { … … 2465 2465 { 2466 2466 monom = monom * (var(k)^(v)); 2467 } 2467 } 2468 2468 else 2469 2469 { … … 2471 2471 } 2472 2472 } 2473 2473 2474 2474 if( monom == 1) 2475 2475 { … … 2479 2479 denominator = denominator * (1  monom); 2480 2480 } 2481 2482 for( j = 1; j<= l; j++) 2481 2482 for( j = 1; j<= l; j++) 2483 2483 { 2484 2484 summand = 0; … … 2494 2494 { 2495 2495 monom = monom * (var(k)^v); 2496 } 2496 } 2497 2497 else 2498 2498 { … … 2504 2504 numerator = numerator  (1)^j * summand; 2505 2505 } 2506 2506 2507 2507 if( denominator == 0 ) 2508 2508 { 2509 2509 ERROR("Multigrading not positive."); 2510 } 2511 2510 } 2511 2512 2512 poly denominator1 = denominator; 2513 2513 poly numerator1 = numerator; … … 2543 2543 "The s_(i)variables are defined to be the inverse of the t_(i)variables."; 2544 2544 "  "; 2545 2545 2546 2546 return(Q); 2547 2547 } … … 2549 2549 { 2550 2550 "EXAMPLE:"; echo=2; 2551 2551 2552 2552 ring r = 0,(x,y,z,w),dp; 2553 2553 intmat g[2][4]= … … 2555 2555 0,1,3,4; 2556 2556 setBaseMultigrading(g); 2557 2557 2558 2558 module M = ideal(xwyz, x2zy3, xz2y2w, yw2z3); 2559 2559 intmat V[2][1]= … … 2567 2567 factorize(numerator2); 2568 2568 factorize(denominator2); 2569 2569 2570 2570 kill g, h; setring r; 2571 2571 … … 2573 2573 1,2,3,4, 2574 2574 0,0,5,8; 2575 2575 2576 2576 setBaseMultigrading(g); 2577 2577 2578 2578 ideal I = x^2, y, z^3; 2579 2579 I = std(I); … … 2590 2590 mDeg(I); 2591 2591 def h = hilbertSeries(I); setring h; 2592 2592 2593 2593 factorize(numerator2); 2594 2594 factorize(denominator2); … … 2597 2597 //////////////////////////////////////////////// 2598 2598 //////////////////////////////////////////////// 2599 2599 2600 2600 ring R = 0,(x,y,z),dp; 2601 intmat W[2][3] = 2601 intmat W[2][3] = 2602 2602 1,1, 1, 2603 2603 0,0,1; 2604 2604 setBaseMultigrading(W); 2605 2605 ideal I = x3y,yz2,y2z,z4; 2606 2606 2607 2607 def h = hilbertSeries(I); setring h; 2608 2608 2609 2609 factorize(numerator2); 2610 2610 factorize(denominator2); … … 2615 2615 2616 2616 ring R = 0,(x,y,z,a,b,c),dp; 2617 intmat W[2][6] = 2617 intmat W[2][6] = 2618 2618 1,1, 1,1,1,1, 2619 2619 0,0,1,0,0,0; 2620 2620 setBaseMultigrading(W); 2621 2621 ideal I = x3y,yz2,y2z,z4; 2622 2622 2623 2623 def h = hilbertSeries(I); setring h; 2624 2624 2625 2625 factorize(numerator2); 2626 2626 factorize(denominator2); 2627 2627 2628 2628 kill R, W, h; 2629 2629 … … 2632 2632 //////////////////////////////////////////////// 2633 2633 // This is example 5.3.9. from Robbianos book. 2634 2634 2635 2635 ring R = 0,(x,y,z,w),dp; 2636 intmat W[1][4] = 2636 intmat W[1][4] = 2637 2637 1,1, 1,1; 2638 2638 setBaseMultigrading(W); … … 2640 2640 2641 2641 hilb(std(I)); 2642 2642 2643 2643 def h = hilbertSeries(I); setring h; 2644 2644 2645 2645 numerator1; 2646 2646 denominator1; … … 2648 2648 factorize(numerator2); 2649 2649 factorize(denominator2); 2650 2650 2651 2651 2652 2652 kill h; … … 2657 2657 2658 2658 hilb(std(I2)); 2659 2659 2660 2660 def h = hilbertSeries(I2); setring h; 2661 2661 … … 2667 2667 //////////////////////////////////////////////// 2668 2668 setring R; 2669 2669 2670 2670 W = 2,2,2,2; 2671 2671 2672 2672 setBaseMultigrading(W); 2673 2673 … … 2679 2679 2680 2680 kill w; 2681 2681 2682 2682 2683 2683 def h = hilbertSeries(I2); setring h; 2684 2684 2685 2685 2686 2686 numerator1; denominator1; 2687 2687 kill h; 2688 2688 2689 2689 2690 2690 kill R, W; 2691 2691 … … 2704 2704 2705 2705 hilb(std(I)); 2706 2706 2707 2707 def h = hilbertSeries(I); setring h; 2708 2708 … … 2720 2720 2721 2721 numerator1; denominator1; 2722 2723 kill h;2724 ////////////////////////////////////////////////2725 setring R;2726 2727 I = x^5; I;2728 2729 hilb(std(I));2730 hilb(std(I), 1);2731 2732 def h = hilbertSeries(I); setring h;2733 2734 numerator1; denominator1;2735 2736 2737 kill h;2738 ////////////////////////////////////////////////2739 setring R;2740 2741 I = x^10; I;2742 2743 hilb(std(I));2744 2745 def h = hilbertSeries(I); setring h;2746 2747 numerator1; denominator1;2748 2722 2749 2723 kill h; … … 2751 2725 setring R; 2752 2726 2753 module M = 1; 2754 2755 M = setModuleGrading(M, W); 2756 2757 2758 hilb(std(M)); 2759 2760 def h = hilbertSeries(M); setring h; 2727 I = x^5; I; 2728 2729 hilb(std(I)); 2730 hilb(std(I), 1); 2731 2732 def h = hilbertSeries(I); setring h; 2761 2733 2762 2734 numerator1; denominator1; 2735 2763 2736 2764 2737 kill h; … … 2766 2739 setring R; 2767 2740 2768 kill M; module M = x^5*gen(1); 2769 2770 // intmat V[1][3] = 0; // TODO: this would lead to a wrong result!!!? 2771 2772 intmat V[1][1] = 0; // all gen(i) of degree 0! 2773 2774 M = setModuleGrading(M, V); 2775 2776 hilb(std(M)); 2777 2778 def h = hilbertSeries(M); setring h; 2741 I = x^10; I; 2742 2743 hilb(std(I)); 2744 2745 def h = hilbertSeries(I); setring h; 2779 2746 2780 2747 numerator1; denominator1; … … 2782 2749 kill h; 2783 2750 //////////////////////////////////////////////// 2784 setring R; 2785 2786 module N = x^5*gen(3); 2787 2788 kill V; 2789 2790 intmat V[1][3] = 0; // all gen(i) of degree 0! 2791 2792 N = setModuleGrading(N, V); 2793 2794 hilb(std(N)); 2795 2796 def h = hilbertSeries(N); setring h; 2751 setring R; 2752 2753 module M = 1; 2754 2755 M = setModuleGrading(M, W); 2756 2757 2758 hilb(std(M)); 2759 2760 def h = hilbertSeries(M); setring h; 2797 2761 2798 2762 numerator1; denominator1; … … 2800 2764 kill h; 2801 2765 //////////////////////////////////////////////// 2802 setring R; 2803 2804 2766 setring R; 2767 2768 kill M; module M = x^5*gen(1); 2769 2770 // intmat V[1][3] = 0; // TODO: this would lead to a wrong result!!!? 2771 2772 intmat V[1][1] = 0; // all gen(i) of degree 0! 2773 2774 M = setModuleGrading(M, V); 2775 2776 hilb(std(M)); 2777 2778 def h = hilbertSeries(M); setring h; 2779 2780 numerator1; denominator1; 2781 2782 kill h; 2783 //////////////////////////////////////////////// 2784 setring R; 2785 2786 module N = x^5*gen(3); 2787 2788 kill V; 2789 2790 intmat V[1][3] = 0; // all gen(i) of degree 0! 2791 2792 N = setModuleGrading(N, V); 2793 2794 hilb(std(N)); 2795 2796 def h = hilbertSeries(N); setring h; 2797 2798 numerator1; denominator1; 2799 2800 kill h; 2801 //////////////////////////////////////////////// 2802 setring R; 2803 2804 2805 2805 module S = M + N; 2806 2806 2807 2807 S = setModuleGrading(S, V); 2808 2808
Note: See TracChangeset
for help on using the changeset viewer.