Changeset 2815e8 in git
 Timestamp:
 Mar 17, 2011, 2:22:01 PM (13 years ago)
 Branches:
 (u'fiekerDuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '4188d308699580d975efd0f6cca8dcb41c396f70')
 Children:
 94312b5b33172e44faad48ff7a9912f1cd6aa31f
 Parents:
 fec3bde6a8e1670c13a5b3176f479ac2b3da7399
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

Singular/LIB/multigrading.lib
rfec3bde r2815e8 16 16 OVERVIEW: This library allows one to virtually add multigradings to Singular. 17 17 For more see http://code.google.com/p/convexsingular/wiki/Multigrading 18 For theoretical references see: 18 For theoretical references see: 19 19 E. Miller, B. Sturmfels: 'Combinatorial Commutative Algebra' and 20 20 M. Kreuzer, L. Robbiano: 'Computational Commutative Algebra'. … … 32 32 createGroup(S,L); create a group generated by S, with relations L 33 33 createQuotientGroup(L); create a group generated by the unit matrix whith relations L 34 createTorsionFreeGroup(S); create a group generated by S which is torsionfree 34 createTorsionFreeGroup(S); create a group generated by S which is torsionfree 35 35 printGroup(G); print a group 36 36 … … 54 54 intersectLattices(A,B); compute an integral basis for the intersection of the lattices A and B. 55 55 isIntegralSurjective(P); test whether the map P of lattices is surjective. 56 isPrimitiveSublattice(A); test whether A generates a primitive sublattice. 56 isPrimitiveSublattice(A); test whether A generates a primitive sublattice. 57 57 intInverse(A); compute the integral inverse matrix of the intmat A 58 58 intAdjoint(A,i,j); delete row i and column j of the intmat A. … … 70 70 isPositive(); test whether the current multigrading is positive 71 71 isZeroElement(p); test whether p has zero multidegree 72 areZeroElements(M); test whether an integer matrix M considered as a collection of columns has zero multidegree 72 areZeroElements(M); test whether an integer matrix M considered as a collection of columns has zero multidegree 73 73 isHomogeneous(a); test whether 'a' is multigradedhomogeneous 74 74 … … 79 79 mDegModulo(I,J); compute the multigraded 'modulo' module of I and J 80 80 mDegResolution(M,l[,m]); compute the multigraded resolution of M 81 mDegTensor(m,n); compute the tensor product of multigraded modules m,n 81 mDegTensor(m,n); compute the tensor product of multigraded modules m,n 82 82 mDegTor(i,m,n); compute the Tor_i(m,n) for multigraded modules m,n 83 83 … … 128 128 proc createGradedRingHomomorphism(def src, ideal Im, def A) 129 129 "USAGE: createGradedRingHomomorphism(R, f, A); ring R, ideal f, group homomorphism A 130 PURPOSE: create a multigraded group ring homomorphism defined by 130 PURPOSE: create a multigraded group ring homomorphism defined by 131 131 a ring map from R to the current ring, given by generators images f 132 132 and a group homomorphism A between grading groups … … 137 137 string isGRH = "isGRH"; 138 138 139 if( !isGradedRingHomomorphism( def src, ideal Im, def A) )139 if( !isGradedRingHomomorphism(src, Im, A) ) 140 140 { 141 141 ERROR("Input data is wrong"); 142 142 } 143 143 144 144 list h; 145 145 h[3] = A; 146 146 147 147 // map f = src, Im; 148 148 h[2] = Im; // f? 149 149 h[1] = src; 150 150 151 151 attrib(h, isGRH, (1==1)); // mark it "a graded ring homomorphism" 152 152 … … 165 165 proc isGradedRingHomomorphism(def src, ideal Im, def A) 166 166 "USAGE: isGradedRingHomomorphism(R, f, A); ring R, ideal f, group homomorphism A 167 PURPOSE: test a multigraded group ring homomorphism defined by 167 PURPOSE: test a multigraded group ring homomorphism defined by 168 168 a ring map from R to the current ring, given by generators images f 169 169 and a group homomorphism A between grading groups … … 176 176 intmat result_degs = mDeg(Im); 177 177 print(result_degs); 178 178 179 179 setring src; 180 180 181 181 intmat input_degs = mDeg(maxideal(1)); 182 182 print(input_degs); … … 184 184 def image_degs = A * input_degs; 185 185 print( image_degs ); 186 186 187 187 def df = image_degs  result_degs; 188 188 print(df); 189 189 190 190 setring dst; 191 191 192 192 return (areZeroElements( df )); 193 193 } … … 195 195 { 196 196 "EXAMPLE:"; echo=2; 197 197 198 198 ring r = 0, (x, y, z), dp; 199 199 intmat S1[3][3] = … … 203 203 intmat L1[3][1] = 204 204 0, 205 0, 205 0, 206 206 0; 207 207 208 208 def G1 = createGroup(S1, L1); // (S1 + L1)/L1 209 209 printGroup(G1); 210 210 211 211 setBaseMultigrading(S1, L1); // to change... 212 212 … … 221 221 def G2 = createGroup(S2, L2); 222 222 printGroup(G2); 223 223 224 224 setBaseMultigrading(S2, L2); // to change... 225 225 … … 229 229 1, 0, 0, 230 230 3, 2, 6; 231 231 232 232 // graded ring homomorphism is given by (compatible): 233 233 print(F); … … 238 238 239 239 print(h); 240 240 241 241 // not a homo.. 242 242 intmat B[nrows(L2)][nrows(L1)] = … … 247 247 isGradedRingHomomorphism(r, ideal(F), B); 248 248 def hh = createGradedRingHomomorphism(r, ideal(F), B); 249 249 250 250 if( defined(hh) ) { ERROR("That input was not valid"); } 251 251 } … … 254 254 proc createQuotientGroup(intmat L) 255 255 " 256 L  relations 257 TODO: bad name 256 L  relations 257 TODO: bad name 258 258 " 259 259 { … … 267 267 " 268 268 S  generators 269 TODO: bad name 269 TODO: bad name 270 270 " 271 271 { … … 279 279 proc createGroup(intmat S, intmat L) 280 280 "USAGE: createGroup(S, L); S, L are integer matrices 281 PURPOSE: create the group of the form (S+L)/L, i.e. 281 PURPOSE: create the group of the form (S+L)/L, i.e. 282 282 S specifies generators, L specifies relations. 283 283 RETURN: group … … 289 289 string attrGroupSNF = "smith"; 290 290 291 291 292 292 /* 293 293 if( size(#) > 0 ) … … 305 305 } else { ERROR("Wrong optional argument: 2"); } 306 306 } 307 } 308 if( !defined(S) ) 307 } 308 if( !defined(S) ) 309 309 {} 310 */ 310 */ 311 311 312 312 if( nrows(L) != nrows(S) ) … … 314 314 ERROR("Incompatible matrices!"); 315 315 } 316 316 317 317 def H = attrib(L, attrGroupHNF); 318 318 if( !defined(H)  typeof(H) != "intmat") … … 320 320 attrib(L, attrGroupHNF, hermiteNormalForm(L)); 321 321 } else { kill H; } 322 322 323 323 def HH = attrib(L, attrGroupSNF); 324 324 if( !defined(HH)  typeof(HH) != "intmat") … … 337 337 { 338 338 "EXAMPLE:"; echo=2; 339 339 340 340 intmat S[3][3] = 341 341 1, 0, 0, … … 345 345 intmat L[3][2] = 346 346 1, 1, 347 1, 3, 347 1, 3, 348 348 1, 5; 349 349 350 350 def G = createGroup(S, L); // (S+L)/L 351 351 352 352 printGroup(G); 353 353 354 354 kill S, L, G; 355 355 … … 366 366 367 367 printGroup(G); 368 368 369 369 kill S, L, G; 370 370 371 371 //  extreme case  // 372 372 intmat S[1][3] = … … 396 396 "Relations: "; 397 397 print(G[2]); 398 398 399 399 // attrib(G[2]); 400 400 } … … 402 402 { 403 403 "EXAMPLE:"; echo=2; 404 404 405 405 } 406 406 … … 418 418 { 419 419 "EXAMPLE:"; echo=2; 420 420 421 421 } 422 422 … … 426 426 { 427 427 string isGroup = "isGroup"; 428 428 429 429 // valid? 430 430 if( typeof(G) != "list" ){ return(0); } … … 435 435 436 436 // if( !defined(a) ) { return(0); } 437 // if( typeof(a) != "int" ) { return(0); } 437 // if( typeof(a) != "int" ) { return(0); } 438 438 // if( !a ){ return(0); } 439 439 440 440 441 441 if( size(G) != 2 ){ return(0); } 442 442 if( typeof(G[1]) != "intmat" ){ return(0); } 443 443 if( typeof(G[2]) != "intmat" ){ return(0); } 444 444 if( nrows(G[1]) != nrows(G[2]) ){ return(0); } 445 445 446 446 return(1==1); 447 447 } … … 460 460 string attrMgrad = "mgrad"; 461 461 string attrGradingGroup = "gradingGroup"; 462 462 463 463 if( size(#) > 0 ) 464 464 { … … 466 466 { 467 467 def L = createGroup(M, #[1]); 468 } 468 } 469 469 470 470 if( isGroup(#[1]) ) … … 477 477 } 478 478 } 479 } 479 } 480 480 else 481 481 { … … 484 484 485 485 if( !defined(L) ){ ERROR("Wrong arguments: no group given?"); } 486 487 488 489 attrib(basering, attrMgrad, M); 490 attrib(basering, attrGradingGroup, L); 486 487 488 489 attrib(basering, attrMgrad, M); 490 attrib(basering, attrGradingGroup, L); 491 491 492 492 ideal Q = ideal(basering); … … 495 495 "Warning: your quotient ideal is not homogenous (multigrading was set anyway)!"; 496 496 } 497 498 497 498 499 499 500 500 … … 503 503 { 504 504 "EXAMPLE:"; echo=2; 505 505 506 506 ring R = 0, (x, y, z), dp; 507 507 … … 515 515 intmat L[3][2] = 516 516 1, 1, 517 1, 3, 517 1, 3, 518 518 1, 5; 519 519 520 520 // attaches M & L to R (==basering): 521 521 setBaseMultigrading(M, L); // Grading: Z^3/L … … 523 523 // Weights are accessible via "getVariableWeights()": 524 524 getVariableWeights(); 525 526 // Test all possible usages: 525 526 // Test all possible usages: 527 527 (getVariableWeights() == M) && (getVariableWeights(R) == M) && (getVariableWeights(basering) == M); 528 528 529 529 // Grading group is accessible via "getLattice()": 530 530 getLattice(); 531 532 // Test all possible usages: 531 532 // Test all possible usages: 533 533 (getLattice() == L) && (getLattice(R) == L) && (getLattice(basering) == L); 534 534 … … 536 536 getLattice("hermite"); 537 537 538 // Test all possible usages: 538 // Test all possible usages: 539 539 intmat H = hermiteNormalForm(L); 540 540 (getLattice("hermite") == H) && (getLattice(R, "hermite") == H) && (getLattice(basering, "hermite") == H); … … 553 553 0, 554 554 2; 555 555 556 556 // attaches M & L to R (==basering): 557 557 setBaseMultigrading(M, L); // Grading: Z + (Z/2Z) … … 573 573 intmat L[1][1] = 574 574 0; 575 575 576 576 // attaches M & L to R (==basering): 577 577 setBaseMultigrading(M); // Grading: Z^3 … … 614 614 def M = attrib(R, attrMgrad); 615 615 if( typeof(M) == "intmat"){ return (M); } 616 ERROR( "Sorry no multigrading matrix!" ); 616 ERROR( "Sorry no multigrading matrix!" ); 617 617 } 618 618 example 619 619 { 620 620 "EXAMPLE:"; echo=2; 621 621 622 622 ring R = 0, (x, y, z), dp; 623 623 … … 631 631 intmat L[3][2] = 632 632 1, 1, 633 1, 3, 633 1, 3, 634 634 1, 5; 635 635 636 636 // attaches M & L to R (==basering): 637 637 setBaseMultigrading(M, L); // Grading: Z^3/L … … 653 653 0, 654 654 2; 655 655 656 656 // attaches M & L to R (==basering): 657 657 setBaseMultigrading(M, L); // Grading: Z + (Z/2Z) … … 671 671 intmat L[1][1] = 672 672 0; 673 673 674 674 // attaches M & L to R (==basering): 675 675 setBaseMultigrading(M); // Grading: Z^3 … … 697 697 def R = #[i]; 698 698 i++; 699 } 700 } 699 } 700 } 701 701 702 702 if( !defined(R) ) … … 706 706 707 707 def G = attrib(R, attrGradingGroup); 708 708 709 709 if( !isGroup(G) ) 710 710 { 711 711 ERROR("Sorry no grading group!"); 712 } 713 714 return(G); 712 } 713 714 return(G); 715 715 } 716 716 example 717 717 { 718 718 "EXAMPLE:"; echo=2; 719 719 720 720 ring R = 0, (x, y, z), dp; 721 721 … … 729 729 intmat L[3][2] = 730 730 1, 1, 731 1, 3, 731 1, 3, 732 732 1, 5; 733 733 734 734 // attaches M & L to R (==basering): 735 735 setBaseMultigrading(M, L); // Grading: Z^3/L … … 738 738 739 739 printGroup( G ); 740 740 741 741 G[1] == M; G[2] == L; 742 742 … … 754 754 0, 755 755 2; 756 756 757 757 // attaches M & L to R (==basering): 758 758 setBaseMultigrading(M, L); // Grading: Z + (Z/2Z) … … 761 761 762 762 printGroup( G ); 763 763 764 764 G[1] == M; G[2] == L; 765 765 … … 774 774 intmat L[1][1] = 775 775 0; 776 776 777 777 // attaches M & L to R (==basering): 778 778 setBaseMultigrading(M); // Grading: Z^3 … … 781 781 782 782 printGroup( G ); 783 783 784 784 G[1] == M; G[2] == L; 785 785 … … 792 792 "USAGE: getLattice([R[,opt]]) 793 793 PURPOSE: get associated grading group matrix, i.e. generators (cols) of the grading group 794 RETURN: intmat, the grading group matrix, or 794 RETURN: intmat, the grading group matrix, or 795 795 its hermite normal form if an optional argument (\"hermiteNormalForm\") is given or 796 796 smith normal form if an optional argument (\"smith\") is given … … 804 804 { 805 805 i++; 806 } 807 } 806 } 807 } 808 808 809 809 string attrGradingGroupHNF = "hermite"; … … 811 811 812 812 def G = getGradingGroup(#); 813 814 // printGroup(G); 813 814 // printGroup(G); 815 815 816 816 … … 824 824 def M = attrib(T, attrGradingGroupHNF); 825 825 if( (!defined(M)) or (typeof(M) != "intmat") ) 826 { 827 M = hermiteNormalForm(T); 826 { 827 M = hermiteNormalForm(T); 828 828 } 829 829 return (M); … … 834 834 def M = attrib(T, attrGradingGroupSNF); 835 835 if( (!defined(M)) or (typeof(M) != "intmat") ) 836 { 837 M = smithNormalForm(T); 836 { 837 M = smithNormalForm(T); 838 838 } 839 839 return (M); … … 841 841 } 842 842 843 return(T); 843 return(T); 844 844 } 845 845 example 846 846 { 847 847 "EXAMPLE:"; echo=2; 848 848 849 849 ring R = 0, (x, y, z), dp; 850 850 … … 858 858 intmat L[3][2] = 859 859 1, 1, 860 1, 3, 860 1, 3, 861 861 1, 5; 862 862 863 863 // attaches M & L to R (==basering): 864 864 setBaseMultigrading(M, L); // Grading: Z^3/L … … 883 883 0, 884 884 2; 885 885 886 886 // attaches M & L to R (==basering): 887 887 setBaseMultigrading(M, L); // Grading: Z + (Z/2Z) … … 904 904 intmat L[1][1] = 905 905 0; 906 906 907 907 // attaches M & L to R (==basering): 908 908 setBaseMultigrading(M); // Grading: Z^3 … … 920 920 " 921 921 { 922 if( typeof(m) == "ideal" ) 922 if( typeof(m) == "ideal" ) 923 923 { 924 924 return (m[i]); … … 928 928 { 929 929 def v = getModuleGrading(m); 930 930 931 931 return ( setModuleGrading(m[i],v) ); 932 932 } … … 948 948 949 949 def V = attrib(m, attrModuleGrading); 950 950 951 951 if( typeof(V) != "intmat" ) 952 952 { … … 957 957 return (VV); 958 958 } 959 959 960 960 ERROR("Sorry: vector or module need modulegradingmatrix! See 'getModuleGrading'."); 961 961 } … … 970 970 ERROR("Sorry wrong width of V: " + string(ncols(V))); 971 971 } 972 972 973 973 return (V); 974 974 } … … 976 976 { 977 977 "EXAMPLE:"; echo=2; 978 978 979 979 ring R = 0, (x,y), dp; 980 980 intmat M[2][2]= … … 984 984 1, 2, 3, 4, 0, 985 985 0, 10, 20, 30, 1; 986 986 987 987 setBaseMultigrading(M, T); 988 988 989 989 ideal I = x, y, xy^5; 990 990 isHomogeneous(I); 991 991 992 992 intmat V = mDeg(I); print(V); 993 993 994 994 module S = syz(I); print(S); 995 995 996 996 S = setModuleGrading(S, V); 997 997 998 998 getModuleGrading(S) == V; 999 999 1000 1000 vector v = getGradedGenerator(S, 1); 1001 1001 getModuleGrading(v) == V; 1002 1002 isHomogeneous(v); 1003 print( mDeg(v) ); 1004 1003 print( mDeg(v) ); 1004 1005 1005 isHomogeneous(S); 1006 1006 print( mDeg(S) ); … … 1022 1022 if(nrows(G) != nrows(R)){ ERROR("Incompatible gradings.");} 1023 1023 if(ncols(G) < nrows(m)){ ERROR("Multigrading does not fit to module.");} 1024 1024 1025 1025 attrib(m, attrModuleGrading, G); 1026 1026 return(m); … … 1029 1029 { 1030 1030 "EXAMPLE:"; echo=2; 1031 1031 1032 1032 ring R = 0, (x,y), dp; 1033 1033 intmat M[2][2]= … … 1037 1037 1, 2, 3, 4, 0, 1038 1038 0, 10, 20, 30, 1; 1039 1039 1040 1040 setBaseMultigrading(M, T); 1041 1041 1042 1042 ideal I = x, y, xy^5; 1043 1043 intmat V = mDeg(I); 1044 1044 1045 1045 // V == M; modulo T 1046 1046 print(V); 1047 1047 1048 1048 module S = syz(I); 1049 1049 1050 1050 S = setModuleGrading(S, V); 1051 1051 getModuleGrading(S) == V; 1052 1052 1053 1053 print(S); 1054 1054 1055 1055 vector v = getGradedGenerator(S, 1); 1056 1056 getModuleGrading(v) == V; 1057 1057 1058 print( mDeg(v) ); 1058 print( mDeg(v) ); 1059 1059 1060 1060 isHomogeneous(S); … … 1089 1089 for(i = 1; i<=mr; i++) 1090 1090 { 1091 result[((i1)*nr+1)..(i*nr),((i1)*nc+1)..(i*nc)] = N[1..nr,1..nc]; 1091 result[((i1)*nr+1)..(i*nr),((i1)*nc+1)..(i*nc)] = N[1..nr,1..nc]; 1092 1092 } 1093 1093 } … … 1157 1157 else 1158 1158 { 1159 1159 1160 1160 matrix fd[nrows(m)][0]; 1161 1161 matrix fd2[nrows(l[i+1])][0]; … … 1169 1169 freedim2 = setModuleGrading(freedim2,getModuleGrading(l[i+1])); 1170 1170 freedim3 = setModuleGrading(freedim3, getModuleGrading(l[i])); 1171 1171 1172 1172 module mimag = mDegTensor(freedim3, m); 1173 1173 //"mimag ok."; … … 1241 1241 "USAGE: gisGoupHomomorphism(L1,L2,A); L1 and L2 are groups, A is an integer matrix 1242 1242 PURPOSE: checks whether A defines a group homomorphism phi: L1 > L2 1243 RETURN: int, 1 if A defines the homomorphism and 0 otherwise 1243 RETURN: int, 1 if A defines the homomorphism and 0 otherwise 1244 1244 EXAMPLE: example isGroupHomomorphism; shows an example 1245 1245 " 1246 1246 { 1247 // TODO: L1, L2 1247 // TODO: L1, L2 1248 1248 if( (ncols(A) != nrows(L1)) or (nrows(A) != nrows(L2)) ) 1249 1249 { … … 1252 1252 1253 1253 intmat im = A * L1; 1254 1255 return (areZeroElements(im, L2)); 1254 1255 return (areZeroElements(im, L2)); 1256 1256 } 1257 1257 example … … 1264 1264 0, 1265 1265 2; 1266 1266 1267 1267 intmat L2[3][2]= 1268 1268 0, 0, … … 1270 1270 0, 3; 1271 1271 1272 intmat A[3][4] = 1272 intmat A[3][4] = 1273 1273 1, 2, 3, 0, 1274 1274 7, 0, 0, 0, … … 1278 1278 isGroupHomomorphism(L1, L2, A); 1279 1279 1280 intmat B[3][4] = 1280 intmat B[3][4] = 1281 1281 1, 2, 3, 0, 1282 1282 7, 0, 0, 0, 1283 1283 1, 2, 0, 2; 1284 print( B ); 1284 print( B ); 1285 1285 1286 1286 isGroupHomomorphism(L1, L2, B); // Not a homomorphism! … … 1308 1308 1309 1309 if(H[j, i]!=0) 1310 { 1310 { 1311 1311 d=d*H[j, i]; 1312 1312 } … … 1314 1314 1315 1315 if( (d*d)==1 ) 1316 { 1316 { 1317 1317 return(1==1); 1318 1318 } … … 1330 1330 1, 2, 3, 4, 0, 1331 1331 0,10,20,30, 1; 1332 1332 1333 1333 setBaseMultigrading(M,T); 1334 1334 1335 1335 // Is the resulting group free? 1336 1336 isTorsionFree(); … … 1340 1340 1341 1341 ring R=0,(x,y,z),dp; 1342 intmat A[3][3] = 1342 intmat A[3][3] = 1343 1343 1,0,0, 1344 1344 0,1,0, … … 1430 1430 } 1431 1431 result= result+ list (buf); 1432 1432 1433 1433 } 1434 1434 return(result); 1435 } 1435 } 1436 1436 else 1437 1437 { … … 1522 1522 } 1523 1523 } 1524 //"here is the size ",size(#); 1524 //"here is the size ",size(#); 1525 1525 if(size(#) == 0){ 1526 1526 return(D); … … 1533 1533 "EXAMPLE: "; echo=2; 1534 1534 1535 intmat A[5][7] = 1535 intmat A[5][7] = 1536 1536 1,0,1,0,2,9,71, 1537 1537 0,24,248,32,96,448,3496, … … 1550 1550 1551 1551 /******************************************************/ 1552 proc hermiteNormalForm(intmat A, list #) 1552 proc hermiteNormalForm(intmat A, list #) 1553 1553 "USAGE: hermiteNormalForm( A ); 1554 PURPOSE: Computes the (lower triangular) Hermite Normal Form 1554 PURPOSE: Computes the (lower triangular) Hermite Normal Form 1555 1555 of the matrix A by column operations. 1556 1556 RETURN: intmat, the Hermite Normal Form of A … … 1558 1558 " 1559 1559 { 1560 1560 1561 1561 int row, column, i, j; 1562 1562 int rr = nrows(A); … … 1574 1574 if(A[row, j]!=0) 1575 1575 { 1576 1577 1578 1579 1580 1581 1576 transform = unitMatrix(cc); 1577 transform[j,j] = 0; 1578 transform[column, column] = 0; 1579 transform[column,j] = 1; 1580 transform[j,column] = 1; 1581 q = q*transform; 1582 1582 A = A*transform; 1583 1583 break; … … 1606 1606 q = q*transform; 1607 1607 A = A*transform; 1608 1608 // A; 1609 1609 } 1610 1610 } … … 1612 1612 { 1613 1613 transform = unitMatrix(cc); 1614 1615 1614 transform[column,column] = 1; 1615 q = q*transform; 1616 1616 A = A*transform; 1617 1617 } … … 1623 1623 transform[column,j]=transform[column,j]+1;} 1624 1624 q = q*transform; 1625 A = A*transform; 1625 A = A*transform; 1626 1626 } 1627 1627 } … … 1637 1637 "EXAMPLE:"; echo=2; 1638 1638 1639 intmat M[2][5] = 1639 intmat M[2][5] = 1640 1640 1, 2, 3, 4, 0, 1641 1641 0,10,20,30, 1; … … 1644 1644 print(hermiteNormalForm(M)); 1645 1645 1646 intmat T[3][4] = 1646 intmat T[3][4] = 1647 1647 3,3,3,3, 1648 1648 2,1,3,0, … … 1652 1652 print(hermiteNormalForm(T)); 1653 1653 1654 intmat A[4][5] = 1654 intmat A[4][5] = 1655 1655 1,2,3,2,2, 1656 1656 1,2,3,4,0, … … 1669 1669 1670 1670 intvec v; 1671 1671 1672 1672 for( ; i > 0; i ) 1673 1673 { 1674 1674 v = m[1..r, i]; 1675 1675 if( !isZeroElement(v, #) ) 1676 { 1676 { 1677 1677 return (0); 1678 1678 } … … 1709 1709 intmat m[5][2]=mDeg(a)mDeg(b),mDeg(b)mDeg(c),mDeg(c)mDeg(d),mDeg(d)mDeg(e),mDeg(e)mDeg(f); 1710 1710 m=transpose(m); 1711 areZeroElement es(m);1712 areZeroElement es(m,tt);1711 areZeroElements(m); 1712 areZeroElements(m,tt); 1713 1713 } 1714 1714 … … 1736 1736 } 1737 1737 } 1738 1738 1739 1739 } 1740 1740 if( !defined(H) ) … … 1801 1801 isZeroElement(v1); 1802 1802 isZeroElement(v1, tt); 1803 1803 1804 1804 intvec v2 = mDeg(a)  mDeg(c); 1805 1805 v2; 1806 1806 isZeroElement(v2); 1807 1807 isZeroElement(v2, tt); 1808 1808 1809 1809 intvec v3 = mDeg(e)  mDeg(f); 1810 1810 v3; 1811 1811 isZeroElement(v3); 1812 1812 isZeroElement(v3, tt); 1813 1813 1814 1814 intvec v4 = mDeg(c)  mDeg(d); 1815 1815 v4; … … 1822 1822 proc defineHomogeneous(poly f, list #) 1823 1823 "USAGE: defineHomogeneous(f[, G]); polynomial f, integer matrix G 1824 PURPOSE: Yields a matrix which has to be appended to the grading group matrix to make the 1824 PURPOSE: Yields a matrix which has to be appended to the grading group matrix to make the 1825 1825 polynomial f homogeneous in the grading by grad. 1826 1826 EXAMPLE: example defineHomogeneous; shows an example 1827 1827 " 1828 1828 { 1829 if( size(#) > 0 ) 1830 { 1831 if( typeof(#[1]) == "intmat" ) 1829 if( size(#) > 0 ) 1830 { 1831 if( typeof(#[1]) == "intmat" ) 1832 1832 { 1833 1833 intmat grad = #[1]; … … 1859 1859 1860 1860 ring r =0,(x,y,z),dp; 1861 intmat grad[2][3] = 1861 intmat grad[2][3] = 1862 1862 1,0,1, 1863 1863 0,1,1; … … 1870 1870 M; 1871 1871 defineHomogeneous(f, grad) == M; 1872 1872 1873 1873 isHomogeneous(f); 1874 1874 setBaseMultigrading(grad, M); … … 1906 1906 return(s); 1907 1907 } 1908 return(1==0); 1908 return(1==0); 1909 1909 } 1910 1910 example … … 1944 1944 // listvar(); 1945 1945 def pre = preimage(f); 1946 1946 1947 1947 // "pre: "; pre; 1948 1948 … … 2035 2035 2036 2036 ring r = 0,(x,y,z),dp; 2037 2038 2037 2038 2039 2039 2040 2040 // Setting degrees for preimage ring.; 2041 intmat grad[3][3] = 2041 intmat grad[3][3] = 2042 2042 1,0,0, 2043 2043 0,1,0, … … 2045 2045 2046 2046 setBaseMultigrading(grad); 2047 2047 2048 2048 // grading on r: 2049 2049 getVariableWeights(); … … 2060 2060 2061 2061 listvar(); 2062 2062 2063 2063 map f = r,a2b6+b5+a3b+a2+ab,a2b73a2b5+b4+a,a6b6b3+a2; f; 2064 2064 2065 2065 2066 2066 // TODO: Unfortunately this is not a very spectacular example...: 2067 2067 // Pushing forward f: … … 2071 2071 getVariableWeights(); 2072 2072 getLattice(); 2073 2073 2074 2074 2075 2075 // only for the purpose of this example … … 2082 2082 proc equalMDeg(intvec exp1, intvec exp2, list #) 2083 2083 "USAGE: equalMDeg(exp1, exp2[, V]); intvec exp1, exp2, intmat V 2084 PURPOSE: Tests if the exponent vectors of two monomials (given by exp1 and exp2) 2084 PURPOSE: Tests if the exponent vectors of two monomials (given by exp1 and exp2) 2085 2085 represent the same multidegree. 2086 NOTE: the integer matrix V encodes multidegrees of module components, 2086 NOTE: the integer matrix V encodes multidegrees of module components, 2087 2087 if module component is present in exp1 and exp2 2088 2088 EXAMPLE: example equalMDeg; shows an example … … 2094 2094 } 2095 2095 2096 if( exp1 == exp2) 2096 if( exp1 == exp2) 2097 2097 { 2098 2098 return (1==1); … … 2228 2228 def g = groebner(a); // !!!! 2229 2229 2230 def b, aa; int j; 2230 def b, aa; int j; 2231 2231 for( int i = ncols(a); i > 0; i ) 2232 2232 { … … 2243 2243 } 2244 2244 return(1==1); 2245 } 2245 } 2246 2246 } 2247 2247 example … … 2252 2252 2253 2253 //Grading and Torsion matrices: 2254 intmat M[3][3] = 2254 intmat M[3][3] = 2255 2255 1,0,0, 2256 2256 0,1,0, … … 2278 2278 ///////////////////////////////////////////////////////// 2279 2279 // new Torsion matrix: 2280 intmat T[3][4] = 2280 intmat T[3][4] = 2281 2281 3,3,3,3, 2282 2282 2,1,3,0, 2283 2283 1,2,0,3; 2284 2284 2285 2285 setBaseMultigrading(M,T); 2286 2286 … … 2289 2289 mDegPartition(f); 2290 2290 2291 //  2291 //  2292 2292 g; 2293 2293 isHomogeneous(g); … … 2298 2298 ring R = 0, (x,y,z), dp; 2299 2299 2300 intmat A[2][3] = 2300 intmat A[2][3] = 2301 2301 0,0,1, 2302 2302 3,2,1; 2303 intmat T[2][1] = 2304 1, 2303 intmat T[2][1] = 2304 1, 2305 2305 4; 2306 2306 setBaseMultigrading(A, T); … … 2314 2314 mDegPartition(x3 y2z + x2 y3 + z + 1); 2315 2315 2316 2316 2317 2317 module N = gen(1) + (x+y) * gen(2), z*gen(3); 2318 2318 2319 2319 intmat V[2][3] = 0; // 1, 2, 3, 4, 5, 6; // columnwise weights of components!!?? 2320 2320 2321 2321 vector v1, v2; 2322 2322 2323 2323 v1 = setModuleGrading(N[1], V); v1; 2324 2324 mDegPartition(v1); … … 2333 2333 print( mDeg(N) ); 2334 2334 2335 /////////////////////////////////////// 2336 2337 V = 2338 1, 2, 3, 2335 /////////////////////////////////////// 2336 2337 V = 2338 1, 2, 3, 2339 2339 4, 5, 6; 2340 2340 … … 2351 2351 print( mDeg(N) ); 2352 2352 2353 /////////////////////////////////////// 2354 2355 V = 2356 0, 0, 0, 2353 /////////////////////////////////////// 2354 2355 V = 2356 0, 0, 0, 2357 2357 4, 1, 0; 2358 2358 … … 2394 2394 { 2395 2395 intmat V = getModuleGrading(A); 2396 2396 2397 2397 if( nrows(V) != r ) 2398 2398 { … … 2400 2400 } 2401 2401 } 2402 2402 2403 2403 if( A == 0 ) 2404 2404 { … … 2419 2419 A = A  lead(A); 2420 2420 while( size(A) > 0 ) 2421 { 2421 { 2422 2422 v = leadexp(A); // v; 2423 2423 m = max( m, M * v, r ); // ???? … … 2440 2440 A = A  lead(A); 2441 2441 while( size(A) > 0 ) 2442 { 2442 { 2443 2443 v = leadexp(A); // v; 2444 2444 … … 2465 2465 { 2466 2466 G[j, i] = d[j]; 2467 } 2467 } 2468 2468 } 2469 2469 return(G); … … 2477 2477 for( i = ncols(A); i > 0; i ) 2478 2478 { 2479 v = getGradedGenerator(A, i); 2480 2481 // G[1..r, i] 2479 v = getGradedGenerator(A, i); 2480 2481 // G[1..r, i] 2482 2482 d = mDeg(v); 2483 2483 … … 2485 2485 { 2486 2486 G[j, i] = d[j]; 2487 } 2487 } 2488 2488 2489 2489 } … … 2491 2491 return(G); 2492 2492 } 2493 2493 2494 2494 } 2495 2495 example … … 2515 2515 2516 2516 setBaseMultigrading(A, Ta); 2517 2517 2518 2518 mDeg( x*x*y ); 2519 2519 2520 2520 mDeg( y*y*y*x ); 2521 2521 2522 2522 mDeg( x*y + x + 1 ); 2523 2523 … … 2529 2529 2530 2530 // "ideal:"; 2531 2531 2532 2532 ideal I = y*x*x, x*y*y*y; 2533 2533 print( mDeg(I) ); … … 2537 2537 2538 2538 // "vectors:"; 2539 2539 2540 2540 intmat B[2][2] = 0, 1, 1, 0; 2541 2541 print(B); 2542 2542 2543 2543 mDeg( setModuleGrading(y*y*y*gen(2), B )); 2544 2544 mDeg( setModuleGrading(x*x*gen(1), B )); 2545 2545 2546 2546 2547 2547 vector V = x*gen(1) + y*gen(2); 2548 2548 V = setModuleGrading(V, B); … … 2551 2551 vector v1 = setModuleGrading([0, 0, 0], B); 2552 2552 print( mDeg( v1 ) ); 2553 2553 2554 2554 vector v2 = setModuleGrading([0], B); 2555 2555 print( mDeg( v2 ) ); 2556 2556 2557 2557 // "module:"; 2558 2558 2559 2559 module D = x*gen(1), y*gen(2); 2560 2560 D; 2561 2561 D = setModuleGrading(D, B); 2562 2562 print( mDeg( D ) ); 2563 2563 2564 2564 2565 2565 module DD = [0, 0],[0, 0, 0]; … … 2585 2585 { // TODO: What about an ideal or module??? 2586 2586 2587 if( typeof(p) == "poly" ) 2588 { 2589 ideal I; 2587 if( typeof(p) == "poly" ) 2588 { 2589 ideal I; 2590 2590 poly mp, t, tt; 2591 2591 } … … 2594 2594 if( typeof(p) == "vector" ) 2595 2595 { 2596 module I; 2596 module I; 2597 2597 vector mp, t, tt; 2598 2598 } … … 2605 2605 if( typeof(p) == "vector" ) 2606 2606 { 2607 intmat V = getModuleGrading(p); 2607 intmat V = getModuleGrading(p); 2608 2608 } 2609 2609 else … … 2612 2612 } 2613 2613 2614 if( size(p) > 1) 2614 if( size(p) > 1) 2615 2615 { 2616 2616 intvec m; … … 2619 2619 { 2620 2620 m = leadexp(p); 2621 mp = lead(p); 2621 mp = lead(p); 2622 2622 p = p  lead(p); 2623 2623 tt = p; t = 0; 2624 2624 2625 2625 while( size(tt) > 0 ) 2626 { 2626 { 2627 2627 // TODO: we do not cache matrices (M,T,H,V), which remain the same :( 2628 2628 // TODO: we need some lowlevel procedure with all these arguments...! 2629 if( equalMDeg( leadexp(tt), m, V ) ) 2629 if( equalMDeg( leadexp(tt), m, V ) ) 2630 2630 { 2631 2631 mp = mp + lead(tt); // "mp", mp; … … 2674 2674 2675 2675 mDegPartition(f); 2676 2676 2677 2677 vector v = xy*gen(1)x3y2*gen(2)+x4y*gen(3); 2678 2678 intmat B[2][3]=1,1,2,0,0,1; 2679 2679 v = setModuleGrading(v,B); 2680 2680 getModuleGrading(v); 2681 2681 2682 2682 mDegPartition(v, B); 2683 2683 } … … 2689 2689 { 2690 2690 intmat A[n][n]; 2691 2691 2692 2692 for( int i = n; i > 0; i ) 2693 2693 { … … 2704 2704 " 2705 2705 USAGE: finestMDeg(r); ring r 2706 RETURN: ring, r endowed with the finest multigrading 2706 RETURN: ring, r endowed with the finest multigrading 2707 2707 TODO: not yet... 2708 2708 " … … 2733 2733 2734 2734 2735 if( n > 0) 2736 { 2737 2738 intmat L[N][n]; 2735 if( n > 0) 2736 { 2737 2738 intmat L[N][n]; 2739 2739 // list L; 2740 2740 int j = n; … … 2744 2744 p = I[i]; 2745 2745 2746 if( size(p) > 1 ) 2746 if( size(p) > 1 ) 2747 2747 { 2748 2748 intvec m0 = leadexp(p); … … 2759 2759 2760 2760 print(L); 2761 setBaseMultigrading(A, L); 2762 } 2761 setBaseMultigrading(A, L); 2762 } 2763 2763 else 2764 2764 { … … 2797 2797 2798 2798 if( size(#) > 0 and typeof(#[1]) == "intmat" ) 2799 { 2799 { 2800 2800 attrib(F, "P", #[1]); 2801 2801 } … … 2883 2883 ERROR("Sorry: cannot find 'hilbert' command from 4ti2. Please install 4ti2!"); 2884 2884 } 2885 2885 2886 2886 // 2887 2887 // Initialization and Sanity Checks … … 2939 2939 j=system("sh","hilbert q n sing4ti2"); ////////// be quiet + no loggin!!! 2940 2940 2941 j=system("sh", "awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.hil " + 2942 " sed s/[\\\ \\\t\\\v\\\f]/,/g " + 2943 " sed s/,+/,/gsed s/,,/,/g " + 2944 " sed s/,,/,/g " + 2941 j=system("sh", "awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.hil " + 2942 " sed s/[\\\ \\\t\\\v\\\f]/,/g " + 2943 " sed s/,+/,/gsed s/,,/,/g " + 2944 " sed s/,,/,/g " + 2945 2945 "> sing4ti2.converted" ); 2946 2946 … … 2962 2962 string ergstr = "intvec erglist = " + s + "0;"; 2963 2963 execute(ergstr); 2964 2964 2965 2965 // print(erglist); 2966 2966 2967 2967 int Rnc = erglist[1]; 2968 2968 int Rnr = erglist[2]; 2969 2969 2970 2970 intmat R[Rnr][Rnc]; 2971 2971 … … 3035 3035 3036 3036 /******************************************************/ 3037 proc mDegBasis(intvec d) 3037 proc mDegBasis(intvec d) 3038 3038 " 3039 3039 USAGE: multidegree d … … 3079 3079 3080 3080 intmat AA[nr][nc + 2 * n]; 3081 AA[1..nr, 1.. nc] = A[1..nr, 1.. nc]; 3082 AA[1..nr, nc + (1.. n)] = T[1..nr, 1.. n]; 3083 AA[1..nr, nc + n + (1.. n)] = T[1..nr, 1.. n]; 3081 AA[1..nr, 1.. nc] = A[1..nr, 1.. nc]; 3082 AA[1..nr, nc + (1.. n)] = T[1..nr, 1.. n]; 3083 AA[1..nr, nc + n + (1.. n)] = T[1..nr, 1.. n]; 3084 3084 3085 3085 3086 3086 // print ( AA ); 3087 3087 3088 intmat K = leftKernelZ(( AA ) ); // 3088 intmat K = leftKernelZ(( AA ) ); // 3089 3089 3090 3090 // print(K); … … 3095 3095 // "!"; 3096 3096 3097 intmat B = hilbert4ti2intmat(transpose(KK), 1); 3097 intmat B = hilbert4ti2intmat(transpose(KK), 1); 3098 3098 3099 3099 // "!"; print(B); … … 3106 3106 3107 3107 3108 int i; 3108 int i; 3109 3109 int nnr = nrows(B); 3110 3110 int nnc = ncols(B); … … 3165 3165 intvec v1=4,0; 3166 3166 intvec v2=4,4; 3167 3167 3168 3168 intmat g3[1][2]=1,1; 3169 3169 setBaseMultigrading(g3); … … 3171 3171 v3; 3172 3172 mDegBasis(v3); 3173 3173 3174 3174 setBaseMultigrading(g1,l); 3175 3175 mDegBasis(v1); 3176 3176 setBaseMultigrading(g2); 3177 3177 mDegBasis(v2); 3178 3178 3179 3179 intmat M[2][2] = 1, 1, 1, 1; 3180 3180 intvec d = 2, 2; … … 3242 3242 " 3243 3243 { 3244 if( isHomogeneous(I, "checkGens") == 0) 3245 { 3246 ERROR ("Sorry: inhomogeneous input!"); 3247 } 3244 if( isHomogeneous(I, "checkGens") == 0) 3245 { 3246 ERROR ("Sorry: inhomogeneous input!"); 3247 } 3248 3248 module S = syz(I); 3249 3249 S = setModuleGrading(S, mDeg(I)); … … 3253 3253 { 3254 3254 "EXAMPLE:"; echo=2; 3255 3255 3256 3256 3257 3257 ring r = 0,(x,y,z,w),dp; … … 3261 3261 setBaseMultigrading(MM); 3262 3262 module M = ideal( xwyz, x2zy3, xz2y2w, yw2z3); 3263 3264 3263 3264 3265 3265 intmat v[2][nrows(M)]= 3266 3266 1, 3267 3267 0; 3268 3268 3269 3269 M = setModuleGrading(M, v); 3270 3270 … … 3285 3285 PURPOSE: computes the multigraded 'modulo' module of I and J 3286 3286 RETURNS: module, see 'modulo' command 3287 NOTE: I and J should have the same multigrading, and their 3287 NOTE: I and J should have the same multigrading, and their 3288 3288 generators must be multigraded homogeneous 3289 3289 EXAMPLE: example mDegModulo; shows an example … … 3291 3291 { 3292 3292 if( (isHomogeneous(I, "checkGens") == 0) or (isHomogeneous(J, "checkGens") == 0) ) 3293 { 3294 ERROR ("Sorry: inhomogeneous input!"); 3295 } 3293 { 3294 ERROR ("Sorry: inhomogeneous input!"); 3295 } 3296 3296 module K = modulo(I, J); 3297 3297 K = setModuleGrading(K, mDeg(I)); … … 3312 3312 3313 3313 "Multidegrees: "; print(mDeg(h1)); 3314 3314 3315 3315 // Let's compute modulo(h1, h2): 3316 3316 def K = mDegModulo(h1, h2); K; … … 3326 3326 "USAGE: mDegGroebner(I); I is a poly/vector/ideal/module 3327 3327 PURPOSE: computes the multigraded standard/groebner basis of I 3328 NOTE: I must be multigraded homogeneous 3328 NOTE: I must be multigraded homogeneous 3329 3329 RETURNS: ideal/module, the computed basis 3330 3330 EXAMPLE: example mDegGroebner; shows an example 3331 3331 " 3332 3332 { 3333 if( isHomogeneous(I) == 0) 3334 { 3335 ERROR ("Sorry: inhomogeneous input!"); 3336 } 3333 if( isHomogeneous(I) == 0) 3334 { 3335 ERROR ("Sorry: inhomogeneous input!"); 3336 } 3337 3337 3338 3338 def S = groebner(I); 3339 3339 3340 3340 if( typeof(I) == "module" or typeof(I) == "vector" ) 3341 3341 { 3342 S = setModuleGrading(S, getModuleGrading(I)); 3342 S = setModuleGrading(S, getModuleGrading(I)); 3343 3343 } 3344 3344 … … 3357 3357 setBaseMultigrading(MM); 3358 3358 3359 3359 3360 3360 module M = ideal( xwyz, x2zy3, xz2y2w, yw2z3); 3361 3362 3361 3362 3363 3363 intmat v[2][nrows(M)]= 3364 3364 1, 3365 3365 0; 3366 3366 3367 3367 M = setModuleGrading(M, v); 3368 3368 … … 3397 3397 proc mDegResolution(def I, int ll, list #) 3398 3398 "USAGE: mDegResolution(I,l,[f]); I is poly/vector/ideal/module; l,f are integers 3399 PURPOSE: computes the multigraded resolution of I of the length l, 3400 or the whole resolution if l is zero. Returns minimal resolution if an optional 3399 PURPOSE: computes the multigraded resolution of I of the length l, 3400 or the whole resolution if l is zero. Returns minimal resolution if an optional 3401 3401 argument 1 is supplied 3402 3402 NOTE: input must have multigradedhomogeneous generators. 3403 The returned list is truncated beginning with the first zero differential. 3403 The returned list is truncated beginning with the first zero differential. 3404 3404 RETURNS: list, the computed resolution 3405 3405 EXAMPLE: example mDegResolution; shows an example 3406 3406 " 3407 3407 { 3408 if( isHomogeneous(I, "checkGens") == 0) 3409 { 3410 ERROR ("Sorry: inhomogeneous input!"); 3411 } 3408 if( isHomogeneous(I, "checkGens") == 0) 3409 { 3410 ERROR ("Sorry: inhomogeneous input!"); 3411 } 3412 3412 3413 3413 def R = res(I, ll, #); list L = R; int l = size(L); … … 3418 3418 } 3419 3419 3420 int i; 3420 int i; 3421 3421 for( i = 2; i <= l; i++ ) 3422 3422 { … … 3429 3429 } 3430 3430 } 3431 3431 3432 3432 return (L); 3433 3433 3434 3434 3435 3435 } 3436 3436 example 3437 3437 { 3438 3438 "EXAMPLE:"; echo=2; 3439 3439 3440 3440 ring r = 0,(x,y,z,w),dp; 3441 3441 … … 3446 3446 setBaseMultigrading(M); 3447 3447 3448 3448 3449 3449 module m= ideal( xwyz, x2zy3, xz2y2w, yw2z3); 3450 3450 3451 3451 isHomogeneous(ideal( xwyz, x2zy3, xz2y2w, yw2z3), "checkGens"); 3452 3452 3453 3453 ideal A = xwyz, x2zy3, xz2y2w, yw2z3; 3454 3454 3455 3455 int j; 3456 3456 3457 3457 for(j=1; j<=ncols(A); j++) 3458 3458 { 3459 3459 mDegPartition(A[j]); 3460 3460 } 3461 3461 3462 3462 intmat v[2][1]= 3463 3463 1, 3464 3464 0; 3465 3465 3466 3466 m = setModuleGrading(m, v); 3467 3467 … … 3490 3490 3491 3491 ///////////////////////////////////////////////////////////////////////////// 3492 3492 3493 3493 L = mDegResolution(maxideal(1), 0, 1); 3494 3494 … … 3500 3500 "Multigrading: "; print(mDeg(L[j])); 3501 3501 } 3502 3502 3503 3503 kill v; 3504 3504 3505 3505 3506 3506 def h = hilbertSeries(m); … … 3509 3509 numerator1; 3510 3510 factorize(numerator1); 3511 3511 3512 3512 denominator1; 3513 3513 factorize(denominator1); … … 3523 3523 proc hilbertSeries(def I) 3524 3524 "USAGE: hilbertSeries(I); I is poly/vector/ideal/module 3525 PURPOSE: computes the multigraded Hilbert Series of M 3526 NOTE: input must have multigradedhomogeneous generators. 3525 PURPOSE: computes the multigraded Hilbert Series of M 3526 NOTE: input must have multigradedhomogeneous generators. 3527 3527 Multigrading should be positive. 3528 RETURNS: a ring in variables t_(i), s_(i), with polynomials 3529 numerator1 and denominator1 and muturally prime numerator2 3528 RETURNS: a ring in variables t_(i), s_(i), with polynomials 3529 numerator1 and denominator1 and muturally prime numerator2 3530 3530 and denominator2, quotients of which give the series. 3531 3531 EXAMPLE: example hilbertSeries; shows an example 3532 3532 " 3533 3533 { 3534 3534 3535 3535 if( !isFreeRepresented() ) 3536 3536 { … … 3538 3538 //ERROR("SORRY: ONLY TORSIONFREE CASE (POSITIVE GRADING)"); 3539 3539 } 3540 3540 3541 3541 int i, j, k, v; 3542 3542 3543 3543 intmat M = getVariableWeights(); 3544 3544 3545 3545 int cc = ncols(M); 3546 3546 int n = nrows(M); … … 3554 3554 3555 3555 int l = size(RES); 3556 3556 3557 3557 list L; L[l + 1] = 0; 3558 3558 … … 3561 3561 intmat zeros[n][1]; 3562 3562 L[1] = zeros; 3563 } 3563 } 3564 3564 else 3565 3565 { … … 3571 3571 L[j + 1] = mDeg(RES[j]); 3572 3572 } 3573 3573 3574 3574 l++; 3575 3575 3576 3576 ring R = 0,(t_(1..n),s_(1..n)),dp; 3577 3578 ideal units; 3577 3578 ideal units; 3579 3579 for( i=n; i>=1; i) 3580 3580 { 3581 3581 units[i] = (var(i) * var(n + i)  1); 3582 3582 } 3583 3583 3584 3584 qring Q = std(units); 3585 3585 3586 3586 // TODO: should not it be a quotient ring depending on Torsion??? 3587 3587 // I am not sure about what to do in the torsion case, but since … … 3592 3592 poly monom, summand, numerator; 3593 3593 poly denominator = 1; 3594 3594 3595 3595 for( i = 1; i <= cc; i++) 3596 3596 { … … 3603 3603 { 3604 3604 monom = monom * (var(k)^(v)); 3605 } 3605 } 3606 3606 else 3607 3607 { … … 3609 3609 } 3610 3610 } 3611 3611 3612 3612 if( monom == 1) 3613 3613 { … … 3617 3617 denominator = denominator * (1  monom); 3618 3618 } 3619 3620 for( j = 1; j<= l; j++) 3619 3620 for( j = 1; j<= l; j++) 3621 3621 { 3622 3622 summand = 0; … … 3632 3632 { 3633 3633 monom = monom * (var(k)^v); 3634 } 3634 } 3635 3635 else 3636 3636 { … … 3642 3642 numerator = numerator  (1)^j * summand; 3643 3643 } 3644 3644 3645 3645 if( denominator == 0 ) 3646 3646 { 3647 3647 ERROR("Multigrading not positive."); 3648 } 3649 3648 } 3649 3650 3650 poly denominator1 = denominator; 3651 3651 poly numerator1 = numerator; … … 3681 3681 "The s_(i)variables are defined to be the inverse of the t_(i)variables."; 3682 3682 "  "; 3683 3683 3684 3684 return(Q); 3685 3685 } … … 3687 3687 { 3688 3688 "EXAMPLE:"; echo=2; 3689 3689 3690 3690 ring r = 0,(x,y,z,w),dp; 3691 3691 intmat g[2][4]= … … 3693 3693 0,1,3,4; 3694 3694 setBaseMultigrading(g); 3695 3695 3696 3696 module M = ideal(xwyz, x2zy3, xz2y2w, yw2z3); 3697 3697 intmat V[2][1]= … … 3705 3705 factorize(numerator2); 3706 3706 factorize(denominator2); 3707 3707 3708 3708 kill g, h; setring r; 3709 3709 … … 3711 3711 1,2,3,4, 3712 3712 0,0,5,8; 3713 3713 3714 3714 setBaseMultigrading(g); 3715 3715 3716 3716 ideal I = x^2, y, z^3; 3717 3717 I = std(I); … … 3728 3728 mDeg(I); 3729 3729 def h = hilbertSeries(I); setring h; 3730 3730 3731 3731 factorize(numerator2); 3732 3732 factorize(denominator2); … … 3735 3735 //////////////////////////////////////////////// 3736 3736 ring R = 0,(x,y,z),dp; 3737 intmat W[2][3] = 3737 intmat W[2][3] = 3738 3738 1,1, 1, 3739 3739 0,0,1; 3740 3740 setBaseMultigrading(W); 3741 3741 ideal I = x3y,yz2,y2z,z4; 3742 3742 3743 3743 def h = hilbertSeries(I); setring h; 3744 3744 3745 3745 factorize(numerator2); 3746 3746 factorize(denominator2); … … 3749 3749 //////////////////////////////////////////////// 3750 3750 ring R = 0,(x,y,z,a,b,c),dp; 3751 intmat W[2][6] = 3751 intmat W[2][6] = 3752 3752 1,1, 1,1,1,1, 3753 3753 0,0,1,0,0,0; 3754 3754 setBaseMultigrading(W); 3755 3755 ideal I = x3y,yz2,y2z,z4; 3756 3756 3757 3757 def h = hilbertSeries(I); setring h; 3758 3758 3759 3759 factorize(numerator2); 3760 3760 factorize(denominator2); 3761 3761 3762 3762 kill R, W, h; 3763 3763 //////////////////////////////////////////////// 3764 3764 // This is example 5.3.9. from Robbianos book. 3765 3765 3766 3766 ring R = 0,(x,y,z,w),dp; 3767 intmat W[1][4] = 3767 intmat W[1][4] = 3768 3768 1,1, 1,1; 3769 3769 setBaseMultigrading(W); … … 3771 3771 3772 3772 hilb(std(I)); 3773 3773 3774 3774 def h = hilbertSeries(I); setring h; 3775 3775 3776 3776 numerator1; 3777 3777 denominator1; … … 3779 3779 factorize(numerator2); 3780 3780 factorize(denominator2); 3781 3781 3782 3782 3783 3783 kill h; … … 3788 3788 3789 3789 hilb(std(I2)); 3790 3790 3791 3791 def h = hilbertSeries(I2); setring h; 3792 3792 … … 3798 3798 //////////////////////////////////////////////// 3799 3799 setring R; 3800 3800 3801 3801 W = 2,2,2,2; 3802 3802 3803 3803 setBaseMultigrading(W); 3804 3804 … … 3810 3810 3811 3811 kill w; 3812 3812 3813 3813 3814 3814 def h = hilbertSeries(I2); setring h; 3815 3815 3816 3816 3817 3817 numerator1; denominator1; 3818 3818 kill h; 3819 3819 3820 3820 3821 3821 kill R, W; 3822 3822 … … 3832 3832 3833 3833 hilb(std(I)); 3834 3834 3835 3835 def h = hilbertSeries(I); setring h; 3836 3836 … … 3848 3848 3849 3849 numerator1; denominator1; 3850 3851 kill h;3852 ////////////////////////////////////////////////3853 setring R;3854 3855 I = x^5; I;3856 3857 hilb(std(I));3858 hilb(std(I), 1);3859 3860 def h = hilbertSeries(I); setring h;3861 3862 numerator1; denominator1;3863 3864 3865 kill h;3866 ////////////////////////////////////////////////3867 setring R;3868 3869 I = x^10; I;3870 3871 hilb(std(I));3872 3873 def h = hilbertSeries(I); setring h;3874 3875 numerator1; denominator1;3876 3850 3877 3851 kill h; … … 3879 3853 setring R; 3880 3854 3881 module M = 1; 3882 3883 M = setModuleGrading(M, W); 3884 3885 3886 hilb(std(M)); 3887 3888 def h = hilbertSeries(M); setring h; 3855 I = x^5; I; 3856 3857 hilb(std(I)); 3858 hilb(std(I), 1); 3859 3860 def h = hilbertSeries(I); setring h; 3889 3861 3890 3862 numerator1; denominator1; 3863 3891 3864 3892 3865 kill h; … … 3894 3867 setring R; 3895 3868 3896 kill M; module M = x^5*gen(1); 3897 // intmat V[1][3] = 0; // TODO: this would lead to a wrong result!!!? 3898 intmat V[1][1] = 0; // all gen(i) of degree 0! 3899 3900 M = setModuleGrading(M, V); 3901 3902 hilb(std(M)); 3903 3904 def h = hilbertSeries(M); setring h; 3869 I = x^10; I; 3870 3871 hilb(std(I)); 3872 3873 def h = hilbertSeries(I); setring h; 3905 3874 3906 3875 numerator1; denominator1; … … 3908 3877 kill h; 3909 3878 //////////////////////////////////////////////// 3910 setring R; 3911 3912 module N = x^5*gen(3); 3913 3914 kill V; 3915 3916 intmat V[1][3] = 0; // all gen(i) of degree 0! 3917 3918 N = setModuleGrading(N, V); 3919 3920 hilb(std(N)); 3921 3922 def h = hilbertSeries(N); setring h; 3879 setring R; 3880 3881 module M = 1; 3882 3883 M = setModuleGrading(M, W); 3884 3885 3886 hilb(std(M)); 3887 3888 def h = hilbertSeries(M); setring h; 3923 3889 3924 3890 numerator1; denominator1; … … 3926 3892 kill h; 3927 3893 //////////////////////////////////////////////// 3928 setring R; 3929 3930 3894 setring R; 3895 3896 kill M; module M = x^5*gen(1); 3897 // intmat V[1][3] = 0; // TODO: this would lead to a wrong result!!!? 3898 intmat V[1][1] = 0; // all gen(i) of degree 0! 3899 3900 M = setModuleGrading(M, V); 3901 3902 hilb(std(M)); 3903 3904 def h = hilbertSeries(M); setring h; 3905 3906 numerator1; denominator1; 3907 3908 kill h; 3909 //////////////////////////////////////////////// 3910 setring R; 3911 3912 module N = x^5*gen(3); 3913 3914 kill V; 3915 3916 intmat V[1][3] = 0; // all gen(i) of degree 0! 3917 3918 N = setModuleGrading(N, V); 3919 3920 hilb(std(N)); 3921 3922 def h = hilbertSeries(N); setring h; 3923 3924 numerator1; denominator1; 3925 3926 kill h; 3927 //////////////////////////////////////////////// 3928 setring R; 3929 3930 3931 3931 module S = M + N; 3932 3932 3933 3933 S = setModuleGrading(S, V); 3934 3934 … … 3952 3952 " 3953 3953 { 3954 if( 2*size(v) != nvars(h) ) 3954 if( 2*size(v) != nvars(h) ) 3955 3955 { 3956 3956 ERROR("Wrong input/size!"); … … 3976 3976 V[i] = var(i)  k; 3977 3977 } 3978 3978 3979 3979 V = groebner(V); 3980 3981 n = NF(n, V); 3982 d = NF(d, V); 3980 3981 n = NF(n, V); 3982 d = NF(d, V); 3983 3983 3984 3984 n; … … 3989 3989 ERROR("Sorry: denominator is zero!"); 3990 3990 } 3991 3991 3992 3992 if( n == 0 ) 3993 3993 { … … 3996 3996 3997 3997 poly g = gcd(n, d); 3998 3998 3999 3999 if( g != leadcoef(g) ) 4000 4000 { … … 4005 4005 n; 4006 4006 d; 4007 4008 4007 4008 4009 4009 for( i = N; i > 0; i  ) 4010 4010 { … … 4012 4012 n; 4013 4013 d; 4014 4014 4015 4015 k = v[i]; 4016 4016 k; 4017 4017 4018 4018 n = subst(n, var(i), k); 4019 4019 d = subst(d, var(i), k); 4020 4020 4021 4021 if( k != 0 ) 4022 4022 { … … 4034 4034 ERROR("Sorry: denominator is zero!"); 4035 4035 } 4036 4036 4037 4037 if( n == 0 ) 4038 4038 { … … 4041 4041 4042 4042 poly g = gcd(n, d); 4043 4043 4044 4044 if( g != leadcoef(g) ) 4045 4045 { … … 4050 4050 n; 4051 4051 d; 4052 4052 4053 4053 if( n != leadcoef(n)  d != leadcoef(d) ) 4054 4054 { … … 4080 4080 ideal I = mDegBasis(0); 4081 4081 ideal J = attrib(I,"ZeroPart"); 4082 /* 4082 /* 4083 4083 I am not quite sure what this ZeroPart is anymore. I thought it 4084 4084 should contain all monomials of degree 0, but then apparently 1 should … … 4094 4094 setBaseMultigrading(A); 4095 4095 isPositive(); 4096 4096 4097 4097 intmat A[1][2]=1,1; 4098 4098 setBaseMultigrading(A); … … 4127 4127 4128 4128 example mDegResolution; 4129 4130 "// ******************* example hilbertSeries ************************//"; 4129 4130 "// ******************* example hilbertSeries ************************//"; 4131 4131 example hilbertSeries; 4132 4132 … … 4142 4142 "d: "; 4143 4143 print(md); 4144 4144 4145 4145 "M: "; 4146 4146 module LL = M; // + L for d+1 … … 4149 4149 4150 4150 4151 intmat V = getModuleGrading(M); 4151 intmat V = getModuleGrading(M); 4152 4152 intvec vi; 4153 int s = nrows(M); 4153 int s = nrows(M); 4154 4154 int r = nrows(V); 4155 4155 int i; 4156 4156 module L; def B; 4157 for (i=s; i>0; i) 4157 for (i=s; i>0; i) 4158 4158 { 4159 4159 "comp: ", i; … … 4179 4179 print(L); 4180 4180 print(mDeg(L)); 4181 4181 4182 4182 V = getModuleGrading(L); 4183 4183 … … 4190 4190 } 4191 4191 } 4192 4192 4193 4193 L = simplify(L, 2); 4194 4194 L = setModuleGrading(L, V); 4195 4195 print(L); 4196 4196 print(mDeg(L)); 4197 4197 4198 4198 return(L); 4199 4199 } … … 4204 4204 // TODO! 4205 4205 ring r = 32003, (x,y), dp; 4206 4207 intmat M[2][2] = 4208 1, 0, 4206 4207 intmat M[2][2] = 4208 1, 0, 4209 4209 0, 1; 4210 4210 4211 4211 setBaseMultigrading(M); 4212 4212 4213 intmat V[2][1] = 4214 0, 4213 intmat V[2][1] = 4214 0, 4215 4215 0; 4216 4216 4217 4217 "X:"; 4218 4218 module h1 = x; … … 4231 4231 4232 4232 /******************************************************/ 4233 /* Some functions on lattices. 4234 TODO Tuebingen:  add functionality (see wiki) and 4233 /* Some functions on lattices. 4234 TODO Tuebingen:  add functionality (see wiki) and 4235 4235  adjust them to work for groups as well.*/ 4236 4236 /******************************************************/ … … 4241 4241 proc imageLattice(intmat Q, intmat L) 4242 4242 "USAGE: imageLattice(Q,L); Q and L are of type intmat 4243 PURPOSE: compute an integral basis for the image of the 4243 PURPOSE: compute an integral basis for the image of the 4244 4244 lattice L under the homomorphism of lattices Q. 4245 4245 RETURN: intmat … … 4255 4255 { 4256 4256 "EXAMPLE:"; echo=2; 4257 4257 4258 4258 intmat Q[2][3] = 4259 4259 1,2,3, … … 4275 4275 " 4276 4276 USAGE: intRank(A); intmat A 4277 PURPOSE: compute the rank of the integral matrix A 4277 PURPOSE: compute the rank of the integral matrix A 4278 4278 by computing a hermite normalform. 4279 4279 RETURNS: int … … 4291 4291 { 4292 4292 iszero = 1; 4293 4293 4294 4294 for ( i = 1; i <= nrows(B); i++ ) 4295 4295 { 4296 if ( B[i,j] != 0 ) 4296 if ( B[i,j] != 0 ) 4297 4297 { 4298 4298 iszero = 0; … … 4300 4300 } 4301 4301 } 4302 4302 4303 4303 if ( iszero == 1 ) 4304 4304 { … … 4313 4313 { 4314 4314 iszero = 1; 4315 4315 4316 4316 for ( j = 1; j <= ncols(B); j++ ) 4317 4317 { 4318 if ( B[i,j] != 0 ) 4318 if ( B[i,j] != 0 ) 4319 4319 { 4320 4320 iszero = 0; … … 4322 4322 } 4323 4323 } 4324 4324 4325 4325 if ( iszero == 1 ) 4326 4326 { … … 4331 4331 int r = nrows(B)  nzerorows; 4332 4332 4333 if ( ncols(B)  nzerocols < r ) 4333 if ( ncols(B)  nzerocols < r ) 4334 4334 { 4335 4335 r = ncols(B)  nzerocols; 4336 4336 } 4337 4337 4338 4338 return(r); 4339 4339 } … … 4359 4359 proc isSublattice(intmat L, intmat S) 4360 4360 "USAGE: isSublattice(L, S); L, S are of tpye intmat 4361 PURPOSE: checks whether the lattice created by L is a 4361 PURPOSE: checks whether the lattice created by L is a 4362 4362 sublattice of the lattice created by S. 4363 The procedure checks whether each generator of L is 4363 The procedure checks whether each generator of L is 4364 4364 contained in S. 4365 4365 RETURN: 0 if false, 1 if true … … 4369 4369 int a,b,g,i,j,k; 4370 4370 intmat Ker; 4371 4371 4372 4372 // check whether each column v of L is contained in 4373 4373 // the lattice generated by S 4374 4374 for ( i = 1; i <= ncols(L); i++ ) 4375 4375 { 4376 4376 4377 4377 // v is the ith column of L 4378 4378 intvec v; … … 4398 4398 } 4399 4399 4400 4400 4401 4401 // check gcd 4402 4402 Ker = kernelLattice(B); … … 4410 4410 4411 4411 g = R[1]; 4412 4412 4413 4413 for ( j = 2; j <= size(R); j++ ) 4414 4414 { … … 4416 4416 } 4417 4417 4418 if ( g != 1 ) 4418 if ( g != 1 ) 4419 4419 { 4420 4420 return(0); … … 4430 4430 { 4431 4431 "EXAMPLE:"; echo=2; 4432 4432 4433 4433 //ring R = 0,(x,y),dp; 4434 4434 intmat S2[3][2]= … … 4457 4457 proc latticeBasis(intmat B) 4458 4458 "USAGE: latticeBasis(B); intmat B 4459 PURPOSE: compute an integral basis for the lattice defined by 4459 PURPOSE: compute an integral basis for the lattice defined by 4460 4460 the columns of B. 4461 4461 RETURNS: intmat … … 4464 4464 { 4465 4465 int n = ncols(B); 4466 int r = intRank(B); 4467 4468 if ( r == 0 ) 4466 int r = intRank(B); 4467 4468 if ( r == 0 ) 4469 4469 { 4470 4470 intmat H[nrows(B)][1]; … … 4473 4473 for ( j = 1; j <= nrows(B); j++ ) 4474 4474 { 4475 H[j,1] = 0; 4475 H[j,1] = 0; 4476 4476 } 4477 4477 } … … 4480 4480 intmat H = hermiteNormalForm(B);; 4481 4481 4482 if (r < n) 4482 if (r < n) 4483 4483 { 4484 4484 // delete columns r+1 to n 4485 4485 // should be identical with the function 4486 // H = submat(H,1..nrows(H),1..r); 4486 // H = submat(H,1..nrows(H),1..r); 4487 4487 // for matrices 4488 4488 intmat Hdel[nrows(H)][r]; 4489 4489 int k; 4490 4490 int m; 4491 4491 4492 4492 for ( k = 1; k <= nrows(H); k++ ) 4493 4493 { … … 4498 4498 } 4499 4499 4500 H = Hdel; 4501 } 4502 } 4503 4504 return(H); 4505 } 4500 H = Hdel; 4501 } 4502 } 4503 4504 return(H); 4505 } 4506 4506 example 4507 4507 { 4508 4508 "EXAMPLE:"; echo=2; 4509 4509 4510 4510 intmat L[3][3] = 4511 4511 1,4,8, … … 4538 4538 else 4539 4539 { 4540 if ( r == n ) 4540 if ( r == n ) 4541 4541 { 4542 4542 intmat U[n][1]; // now all entries are zero. … … 4549 4549 // delete columns 1 to r 4550 4550 // should be identical with the function 4551 // U = submat(U,1..nrows(U),r+1..); 4551 // U = submat(U,1..nrows(U),r+1..); 4552 4552 // for matrices 4553 4553 intmat Udel[nrows(U)][ncols(U)  r]; 4554 4554 int k; 4555 4555 int m; 4556 4556 4557 4557 for ( k = 1; k <= nrows(U); k++ ) 4558 4558 { … … 4563 4563 } 4564 4564 4565 U = Udel; 4565 U = Udel; 4566 4566 4567 4567 } … … 4574 4574 "EXAMPLE"; echo = 2; 4575 4575 4576 intmat LL[3][4] = 4576 intmat LL[3][4] = 4577 4577 1,4,7,10, 4578 4578 2,5,8,11, … … 4634 4634 int k; 4635 4635 int m; 4636 4636 4637 4637 for ( k = 1; k <= nrows(Del); k++ ) 4638 4638 { … … 4642 4642 } 4643 4643 } 4644 4644 4645 4645 L = latticeBasis(Del); 4646 4646 4647 return(L); 4647 return(L); 4648 4648 4649 4649 } … … 4652 4652 "EXAMPLE"; echo = 2; 4653 4653 4654 intmat P[2][3] = 4654 intmat P[2][3] = 4655 4655 2,6,10, 4656 4656 4,8,12; … … 4671 4671 proc isPrimitiveSublattice(intmat A); 4672 4672 "USAGE: isPrimitiveSublattice(A); intmat A 4673 PURPOSE: check whether the given set of integral vectors in ZZ^m, 4674 i.e. the columns of A, generate a primitive sublattice in ZZ^m 4675 (a direct summand of ZZ^m). 4673 PURPOSE: check whether the given set of integral vectors in ZZ^m, 4674 i.e. the columns of A, generate a primitive sublattice in ZZ^m 4675 (a direct summand of ZZ^m). 4676 4676 RETURNS: int, where 0 is false and 1 is true. 4677 4677 EXAMPLE: example isPrimitiveSublattice; shows an example … … 4680 4680 intmat B = smithNormalForm(A); 4681 4681 int r = intRank(B); 4682 4683 if ( r == 0 ) 4682 4683 if ( r == 0 ) 4684 4684 { 4685 4685 return(1); … … 4696 4696 { 4697 4697 "EXAMPLE"; echo = 2; 4698 4698 4699 4699 intmat A[3][2] = 4700 4700 1,4, … … 4704 4704 // should be 0 4705 4705 int b = isPrimitiveSublattice(A); 4706 4706 4707 4707 kill A,b; 4708 4708 } … … 4711 4711 proc isIntegralSurjective(intmat P); 4712 4712 "USAGE: isIntegralSurjective(P); intmat P 4713 PURPOSE: test whether the given linear map P of lattices is 4713 PURPOSE: test whether the given linear map P of lattices is 4714 4714 surjective. 4715 4715 RETURNS: int, where 0 is false and 1 is true. … … 4718 4718 { 4719 4719 int r = intRank(P); 4720 4720 4721 4721 if ( r < nrows(P) ) 4722 4722 { … … 4734 4734 { 4735 4735 "EXAMPLE"; echo = 2; 4736 4736 4737 4737 intmat A[3][2] = 4738 4738 1,3,5, 4739 4739 2,4,6; 4740 4740 4741 4741 // should be 0 4742 4742 int b = isIntegralSurjective(A); 4743 4743 print(b); 4744 4744 4745 4745 kill A,b; 4746 4746 } … … 4749 4749 proc projectLattice(intmat B) 4750 4750 "USAGE: projectLattice(B); intmat B 4751 PURPOSE: A set of vectors in ZZ^m is given as the columns of B. 4752 Then this function provides a linear map ZZ^m > ZZ^n 4751 PURPOSE: A set of vectors in ZZ^m is given as the columns of B. 4752 Then this function provides a linear map ZZ^m > ZZ^n 4753 4753 having the primitive span of B its kernel. 4754 4754 RETURNS: intmat … … 4765 4765 else 4766 4766 { 4767 if ( r == n ) 4767 if ( r == n ) 4768 4768 { 4769 4769 intmat U[n][1]; // U now is the ndim zerovector … … 4772 4772 { 4773 4773 // we want a matrix with column operations so we transpose 4774 list L = hermiteNormalForm(B, "transform"); //hermite(transpose(B), "transform"); 4775 intmat U = transpose(L[2]); 4774 list L = hermiteNormalForm(B, "transform"); //hermite(transpose(B), "transform"); 4775 intmat U = transpose(L[2]); 4776 4776 4777 4777 // delete rows 1 to r … … 4779 4779 int k; 4780 4780 int m; 4781 4781 4782 4782 for ( k = 1; k <= nrows(U)  r ; k++ ) 4783 4783 { … … 4788 4788 } 4789 4789 4790 U = Udel; 4791 4792 } 4793 } 4794 4790 U = Udel; 4791 4792 } 4793 } 4794 4795 4795 return(U); 4796 4796 } … … 4798 4798 { 4799 4799 "EXAMPLE"; echo = 2; 4800 4801 intmat B[4][2] = 4800 4801 intmat B[4][2] = 4802 4802 1,5, 4803 4803 2,6, 4804 4804 3,7, 4805 4805 4,8; 4806 4806 4807 4807 // should result in a (2x4)matrix with columns 4808 4808 // [1, 2], [2, â3], [1, 0] and [0, 1]. 4809 4809 intmat U = projectLattice(B); 4810 4810 4811 4811 } 4812 4812 … … 4814 4814 proc intersectLattices(intmat A, intmat B) 4815 4815 "USAGE: intersectLattices(A, B); intmat A, intmat B 4816 PURPOSE: compute an integral basis for the intersection of the 4816 PURPOSE: compute an integral basis for the intersection of the 4817 4817 lattices A and B. 4818 4818 RETURNS: intmat … … 4845 4845 // delete all rows in K from ncols(A)+1 onwards 4846 4846 intmat Bas[ncols(A)][ncols(K)]; 4847 4847 4848 4848 for ( i = 1; i <= nrows(Bas); i++ ) 4849 4849 { 4850 for ( j = 1; j <= ncols(Bas); j++ ) 4850 for ( j = 1; j <= ncols(Bas); j++ ) 4851 4851 { 4852 4852 Bas[i,j] = K[i,j]; … … 4859 4859 int r = intRank(Cut); 4860 4860 4861 if ( r == 0 ) 4861 if ( r == 0 ) 4862 4862 { 4863 4863 intmat Cutdel[nrows(Cut)][1]; // is now the zerovector … … 4872 4872 for ( i = 1; i <= nrows(Cutdel); i++ ) 4873 4873 { 4874 for ( j = 1; j <= r; j++ ) 4874 for ( j = 1; j <= r; j++ ) 4875 4875 { 4876 4876 Cutdel[i,j] = Cut[i,j]; … … 4886 4886 { 4887 4887 "EXAMPLE"; echo = 2; 4888 4889 intmat A[3][2] = 4888 4889 intmat A[3][2] = 4890 4890 1,4, 4891 4891 2,5, 4892 4892 3,6; 4893 4893 4894 intmat B[3][2] = 4894 intmat B[3][2] = 4895 4895 6,9, 4896 4896 7,10, 4897 4897 8,11; 4898 4898 4899 4899 // should result in a (2x4)matrix with columns 4900 4900 // [3, 3, 3], [0, 3, 6] 4901 4901 intmat U = intersectLattices(A,B); 4902 4902 4903 4903 } 4904 4904 4905 4905 proc intInverse(intmat A); 4906 4906 "USAGE: intInverse(A); intmat A 4907 PURPOSE: compute the integral inverse of the intmat A. 4907 PURPOSE: compute the integral inverse of the intmat A. 4908 4908 If det(A) is neither 1 nor 1 an error is returned. 4909 4909 RETURNS: intmat … … 4912 4912 { 4913 4913 int d = det(A); 4914 4914 4915 4915 if ( d * d != 1 ) // is d = 1 or 1? Else: error 4916 4916 { 4917 4917 ERROR("determinant of the given intmat has to be 1 or 1."); 4918 4918 } 4919 4919 4920 4920 int c; 4921 4921 int i,j; … … 4930 4930 Ad = intAdjoint(A,i,j); 4931 4931 s = 1; 4932 4932 4933 4933 if ( ((i + j) % 2) > 0 ) 4934 4934 { … … 5005 5005 { 5006 5006 "EXAMPLE"; echo = 2; 5007 5007 5008 5008 intmat A[2][3] = 5009 5009 1,3,5, … … 5027 5027 int m = nrows(P); 5028 5028 int n = ncols(P); 5029 5029 5030 5030 if ( m == n ) 5031 5031 { 5032 intmat U = intInverse(P); 5032 intmat U = intInverse(P); 5033 5033 } 5034 5034 else 5035 5035 { 5036 5036 intmat U = (hermiteNormalForm(P, "transform"))[2]; 5037 5037 5038 5038 // delete columns m+1 to n 5039 5039 intmat Udel[nrows(U)][ncols(U)  (n  m)]; 5040 5040 int k; 5041 5041 int z; 5042 5042 5043 5043 for ( k = 1; k <= nrows(U); k++ ) 5044 5044 { … … 5048 5048 } 5049 5049 } 5050 5051 U = Udel; 5050 5051 U = Udel; 5052 5052 } 5053 5053 … … 5062 5062 2,4,5,7; 5063 5063 5064 // should be a matrix with two columns 5064 // should be a matrix with two columns 5065 5065 // for example: [â2, 1, 0, 0], [3, â3, 0, 1] 5066 5066 intmat U = integralSection(P); … … 5069 5069 print(P * U); 5070 5070 5071 kill U; 5071 kill U; 5072 5072 } 5073 5073 … … 5087 5087 intmat L2 = H[2]; 5088 5088 5089 // check whether G,H are subgroups of a common group, i.e. whether L1 and L2 span the same lattice 5089 // check whether G,H are subgroups of a common group, i.e. whether L1 and L2 span the same lattice 5090 5090 if ( !isSublattice(L1,L2)  !isSublattice(L2,L1)) 5091 5091 { … … 5109 5109 { 5110 5110 "EXAMPLE"; echo = 2; 5111 5111 5112 5112 intmat S1[2][2] = 5113 5113 1,0, … … 5117 5117 0; 5118 5118 5119 intmat S2[2][1] = 5119 intmat S2[2][1] = 5120 5120 1, 5121 5121 0; … … 5131 5131 5132 5132 kill G,H,N,S1,L1,S2,L2; 5133 5133 5134 5134 } 5135 5135 … … 5152 5152 5153 5153 // concatinate matrices to get S 5154 intmat A = concatintmat(S1,OS1); 5155 intmat B = concatintmat(OS2,S2); 5154 intmat A = concatintmat(S1,OS1); 5155 intmat B = concatintmat(OS2,S2); 5156 5156 intmat At = transpose(A); 5157 5157 intmat Bt = transpose(B); … … 5160 5160 5161 5161 // concatinate matrices to get L 5162 intmat C = concatintmat(L1,OL1); 5163 intmat D = concatintmat(OL2,L2); 5162 intmat C = concatintmat(L1,OL1); 5163 intmat D = concatintmat(OL2,L2); 5164 5164 intmat Ct = transpose(C); 5165 5165 intmat Dt = transpose(D); … … 5175 5175 { 5176 5176 "EXAMPLE"; echo = 2; 5177 5177 5178 5178 intmat S1[2][2] = 5179 5179 1,0, … … 5183 5183 0; 5184 5184 5185 intmat S2[2][2] = 5185 intmat S2[2][2] = 5186 5186 1,0, 5187 5187 0,2; … … 5197 5197 5198 5198 kill G,H,N,S1,L1,S2,L2; 5199 5199 5200 5200 } 5201 5201 … … 5213 5213 int r = intRank(V); 5214 5214 5215 5215 5216 5216 if ( r == 0 ) 5217 5217 { … … 5221 5221 { 5222 5222 list L = smithNormalForm(V, "transform"); // L = [A,S,B] where S is the smithNF and S = A*S*B 5223 intmat P = intInverse(L[1]); 5223 intmat P = intInverse(L[1]); 5224 5224 5225 5225 print(L); 5226 5227 if ( r < m ) 5226 5227 if ( r < m ) 5228 5228 { 5229 5229 // delete columns r+1 to m in P: … … 5248 5248 { 5249 5249 "EXAMPLE"; echo = 2; 5250 5250 5251 5251 intmat V[2][4] = 5252 5252 1,4,
Note: See TracChangeset
for help on using the changeset viewer.