Changeset 166ebd2 in git
- Timestamp:
- Mar 29, 2011, 5:59:25 PM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- a796fbdaa0242a20ef39e60d40c2d02dba2c9eb4
- Parents:
- e7c67af3ca54121581499413ed55f282b49e8ac6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/multigrading.lib
re7c67af r166ebd2 37 37 printGroup(G); print a group 38 38 39 areIsomorphicGroups(G,H); test wheter G an H are isomorphic groups (TODO Tuebingen)39 areIsomorphicGroups(G,H); test wheter G an H are isomorphic groups 40 40 isGroup(G); test whether G is a valid group 41 41 isGroupHomomorphism(L1,L2,A); test wheter A defines a group homomrphism from L1 to L2 … … 92 92 93 93 hilbertSeries(M); compute the multigraded Hilbert Series of M 94 evalHilbertSeries(h,v); evaluate hilberts series h by substituting v[i] for t_(i)95 94 96 95 lll(A); applies LLL(.) of lll.lib which only works for lists on a matrix A … … 101 100 "; 102 101 102 /// evalHilbertSeries(h,v); evaluate hilberts series h by substituting v[i] for t_(i) (too experimentall) 103 103 104 // finestMDeg(def r) 104 105 // newMap(map F, intmat Q, list #) 105 106 106 107 LIB "standard.lib"; // for groebner 107 LIB "lll.lib"; // for lll_matrix 108 // LIB "lll.lib"; // for lll_matrix // no need now, right? 108 109 LIB "matrix.lib"; // for multiDegTor 109 110 … … 159 160 "EXAMPLE:"; echo=2; 160 161 161 // TODO! 162 162 ring r = 0, (x, y, z), dp; 163 intmat S1[3][3] = 164 1, 0, 0, 165 0, 1, 0, 166 0, 0, 1; 167 intmat L1[3][1] = 168 0, 169 0, 170 0; 171 172 def G1 = createGroup(S1, L1); // (S1 + L1)/L1 173 printGroup(G1); 174 175 setBaseMultigrading(S1, L1); // to change... 176 177 ring R = 0, (a, b, c), dp; 178 intmat S2[2][3] = 179 1, 0, 180 0, 1; 181 intmat L2[2][1] = 182 0, 183 2; 184 185 def G2 = createGroup(S2, L2); 186 printGroup(G2); 187 188 setBaseMultigrading(S2, L2); // to change... 189 190 191 map F = r, a, b, c; 192 intmat A[nrows(L2)][nrows(L1)] = 193 1, 0, 0, 194 3, 2, -6; 195 196 // graded ring homomorphism is given by (compatible): 197 print(F); 198 print(A); 199 200 isGradedRingHomomorphism(r, ideal(F), A); 201 def h = createGradedRingHomomorphism(r, ideal(F), A); 202 203 print(h); 163 204 } 164 205 … … 255 296 256 297 proc createQuotientGroup(intmat L) 257 " 258 L - relations 259 TODO: bad name 298 "USAGE: createGroup(L); L is an integer matrix 299 PURPOSE: create the group of the form (I+L)/L, 300 where I is the square identity matrix of size nrows(L) x nrows(L) 301 NOTE: L specifies relations between free generators of Z^nrows(L) 302 RETURN: group 303 EXAMPLE: example createQuotientGroup; shows an example 260 304 " 261 305 { … … 265 309 return (createGroup(S,L)); 266 310 } 311 example 312 { 313 "EXAMPLE:"; echo=2; 314 315 intmat I[3][3] = 316 1, 0, 0, 317 0, 1, 0, 318 0, 0, 1; 319 320 intmat L[3][2] = 321 1, 1, 322 1, 3, 323 1, 5; 324 325 326 // The group Z^3 / L can be constructed as follows: 327 328 // shortcut: 329 def G = createQuotientGroup(L); 330 printGroup(G); 331 332 // the general way: 333 def GG = createGroup(I, L); // (I+L)/L 334 printGroup(GG); 335 } 267 336 268 337 proc createTorsionFreeGroup(intmat S) 269 " 270 S - generators 271 TODO: bad name 338 "USAGE: createTorsionFreeGroup(S); S is an integer matrix 339 PURPOSE: create the free subgroup generated by S within the 340 free Abelian group of rank nrows(S) 341 RETURN: group 342 EXAMPLE: example createTorsionFreeGroup; shows an example 272 343 " 273 344 { … … 275 346 intmat L[r][1] = 0; 276 347 return (createGroup(S,L)); 348 } 349 example 350 { 351 "EXAMPLE:"; echo=2; 352 353 // ----------- extreme case ------------ // 354 intmat S[1][3] = 355 1, -1, 10; 356 357 // Torsion: 358 intmat L[1][1] = 359 0; 360 361 362 // The free subgroup generated by elements of S within Z^1 363 // can be constructed as follows: 364 365 // shortcut: 366 def G = createTorsionFreeGroup(S); 367 printGroup(G); 368 369 // the general way: 370 def GG = createGroup(S, L); // (S+L)/L 371 printGroup(GG); 277 372 } 278 373 … … 409 504 "EXAMPLE:"; echo=2; 410 505 506 intmat S[3][3] = 507 1, 0, 0, 508 0, 1, 0, 509 0, 0, 1; 510 511 intmat L[3][2] = 512 1, 1, 513 1, 3, 514 1, 5; 515 516 def G = createGroup(S, L); // (S+L)/L 517 printGroup(G); 518 411 519 } 412 520 413 521 /******************************************************/ 414 proc areIsomorphicGroups(def G, def H)522 static proc areIsomorphicGroups(def G, def H) 415 523 "USAGE: areIsomorphicGroups(G, H); G and H are groups 416 524 PURPOSE: ? … … 426 534 "EXAMPLE:"; echo=2; 427 535 428 } 429 430 536 // TODO! 537 538 } 539 540 /******************************************************/ 431 541 proc isGroup(def G) 432 "test whether G is a valid group" 542 "USAGE: isGroup(G); G a list 543 PURPOSE: checks whether G is a valid group 544 NOTE: G should be created by createGroup 545 (or createQuotientGroup, createTorsionFreeGroup) 546 RETURN: int, 1 if G is a valid group and 0 otherwise 547 EXAMPLE: example isGroup; shows an example 548 " 433 549 { 434 550 string isGroup = "isGroup"; … … 452 568 453 569 return(1); 570 } 571 example 572 { 573 "EXAMPLE:"; echo=2; 574 575 intmat S[3][3] = 576 1, 0, 0, 577 0, 1, 0, 578 0, 0, 1; 579 580 intmat L[3][2] = 581 1, 1, 582 1, 3, 583 1, 5; 584 585 def G = createGroup(S, L); // (S+L)/L 586 587 isGroup(G); 588 589 printGroup(G); 590 454 591 } 455 592 … … 944 1081 945 1082 proc getGradedGenerator(def m, int i) 946 " 947 returns m[i], but with grading 1083 "USAGE: getGradedGenerator(M, i), 'M' module/ideal, 'i' int 1084 RETURN: returns the i-th generator of M, endowed with the module grading from M 1085 EXAMPLE: example getGradedGenerator; shows an example 948 1086 " 949 1087 { … … 962 1100 ERROR("m is expected to be an ideal or a module"); 963 1101 } 964 1102 example 1103 { 1104 "EXAMPLE:"; echo=2; 1105 1106 ring r = 0,(x,y,z,w),dp; 1107 intmat MM[2][4]= 1108 1,1,1,1, 1109 0,1,3,4; 1110 setBaseMultigrading(MM); 1111 1112 module M = ideal( xw-yz, x2z-y3, xz2-y2w, yw2-z3); 1113 1114 1115 intmat v[2][nrows(M)]= 1116 1, 1117 0; 1118 1119 M = setModuleGrading(M, v); 1120 1121 isHomogeneous(M); 1122 "Multidegrees: "; print(multiDeg(M)); 1123 1124 // Let's compute syzygies! 1125 def S = multiDegSyzygy(M); S; 1126 "Module Units Multigrading: "; print( getModuleGrading(S) ); 1127 "Multidegrees: "; print(multiDeg(S)); 1128 1129 isHomogeneous(S); 1130 1131 // same as S[1] together with the induced module weighting 1132 def v = getGradedGenerator(S, 1); 1133 print(v); 1134 print(setModuleGrading(v)); 1135 1136 isHomogeneous(v); 1137 1138 isHomogeneous(S[1]); 1139 } 965 1140 966 1141 /******************************************************/ … … 1472 1647 } 1473 1648 } 1474 1475 example 1476 { 1477 1478 "EXAMPLE:"; 1479 1480 ring R = 0,x,dp; 1481 intmat m[5][5]=13,25,37,83,294,12,-33,9,0,64,77,12,34,6,1,43,2,88,91,100,-46,32,37,42,15; 1482 lll(m); 1483 list l=intvec(13,25,37, 83, 294),intvec(12, -33, 9,0,64), intvec (77,12,34,6,1), intvec (43,2,88,91,100), intvec (-46,32,37,42,15); 1484 lll(l); 1649 example 1650 { 1651 "EXAMPLE:"; echo=2; 1652 1653 ring R = 0,x,dp; 1654 intmat m[5][5] = 1655 13,25,37,83,294, 1656 12,-33,9,0,64, 1657 77,12,34,6,1, 1658 43,2,88,91,100, 1659 -46,32,37,42,15; 1660 lll(m); 1661 1662 list l = 1663 intvec(13,25,37, 83, 294), 1664 intvec(12, -33, 9,0,64), 1665 intvec (77,12,34,6,1), 1666 intvec (43,2,88,91,100), 1667 intvec (-46,32,37,42,15); 1668 lll(l); 1485 1669 } 1486 1670 1487 1671 1488 1672 proc smithNormalForm(intmat A, list #) 1489 " 1490 This method returns 3 Matrices P, D and Q such that D = P*A*Q. 1491 WARNING: This might not be what you expect. 1673 "USAGE: smithNormalForm(A[,opt]); intmat A 1674 PURPOSE: Computes the Smith Normal Form of A 1675 RETURN: if no optional argument is given: intmat, the Smith Normal Form of A, 1676 otherwise: a list of 3 integer matrices P, D Q, such that D == P*A*Q. 1677 EXAMPLE: example smithNormalForm; shows an example 1492 1678 " 1493 1679 { … … 1556 1742 example 1557 1743 { 1558 "EXAMPLE: "; echo=2; 1559 1560 intmat A[5][7] = 1561 1,0,1,0,-2,9,-71, 1562 0,-24,248,-32,-96,448,-3496, 1563 0,4,-42,4,-8,30,-260, 1564 0,0,0,18,-90,408,-3168, 1565 0,0,0,-32,224,-1008,7872; 1566 1567 list l = smithNormalForm(A, 5); 1568 1569 l; 1570 l[1]*A*l[3]; 1571 det(l[1]); 1572 det(l[3]); 1744 "EXAMPLE:"; echo=2; 1745 1746 1747 intmat A[5][7] = 1748 1,0,1,0,-2,9,-71, 1749 0,-24,248,-32,-96,448,-3496, 1750 0,4,-42,4,-8,30,-260, 1751 0,0,0,18,-90,408,-3168, 1752 0,0,0,-32,224,-1008,7872; 1753 1754 print( smithNormalForm(A) ); 1755 1756 list l = smithNormalForm(A, 5); 1757 1758 l; 1759 1760 l[1]*A*l[3]; 1761 1762 det(l[1]); 1763 det(l[3]); 1573 1764 } 1574 1765 … … 1688 1879 1689 1880 proc areZeroElements(intmat m, list #) 1690 "same as isZeroElement but for an integer matrix considered as a collection of columns" 1881 "USAGE: areZeroElements(D, [T]); intmat D, group T 1882 PURPOSE: For a integer matrix D, considered column-wise as a set of 1883 integer vecors representing the multidegree of some polynomial 1884 or vector this method checks whether all these multidegrees 1885 are contained in the grading group 1886 group (either set globally or given as an optional argument), 1887 i.e. if they all are zero in the multigrading. 1888 EXAMPLE: example areZeroElements; shows an example 1889 " 1691 1890 { 1692 1891 int r = nrows(m); … … 1705 1904 return(1); 1706 1905 } 1707 1906 example 1907 { 1908 "EXAMPLE:"; echo=2; 1909 1910 ring r = 0,(x,y,z),dp; 1911 1912 intmat S[2][3]= 1913 1,0,1, 1914 0,1,1; 1915 1916 intmat L[2][1]= 1917 2, 1918 2; 1919 1920 setBaseMultigrading(S,L); 1921 1922 poly a = 1; 1923 poly b = xyz; 1924 1925 ideal I = a, b; 1926 print(multiDeg(I)); 1927 1928 intmat m[5][2]=multiDeg(a),multiDeg(b); m=transpose(m); 1929 1930 print(multiDeg(a)); 1931 print(multiDeg(b)); 1932 1933 print(m); 1934 1935 areZeroElements(m); 1936 1937 intmat LL[2][1]= 1938 1, 1939 -1; 1940 1941 areZeroElements(m,LL); 1942 } 1943 1944 1945 /******************************************************/ 1946 proc isZeroElement(intvec mdeg, list #) 1947 "USAGE: isZeroElement(d, [T]); intvec d, group T 1948 PURPOSE: For a integer vector 'd' representing the multidegree of some polynomial 1949 or vector this method computes if the multidegree is contained in the grading group 1950 group (either set globally or given as an optional argument), i.e. if it is zero in the multigrading. 1951 EXAMPLE: example isZeroElement; shows an example 1952 " 1953 { 1954 int i = 1; 1955 if( size(#) >= i ) 1956 { 1957 def a = #[1]; 1958 if( typeof(a) == "intmat" ) 1959 { 1960 intmat H = hermiteNormalForm(a); 1961 i++; 1962 } 1963 if( typeof(a) == "list" ) 1964 { 1965 list L = a; 1966 intmat H = attrib(L, "hermite"); // todo 1967 i++; 1968 } 1969 kill a; 1970 } 1971 1972 if( i == 1 ) 1973 { 1974 intmat H = getLattice("hermite"); 1975 } 1976 1977 int x, k, row; 1978 1979 int r = nrows(H); 1980 int c = ncols(H); 1981 1982 int rr = nrows(mdeg); 1983 row = 1; 1984 intvec v; 1985 for(i=1; (i<=r)&&(row<=r)&&(i<=c); i++) 1986 { 1987 while((H[row,i]==0)&&(row<=r)) 1988 { 1989 row++; 1990 if(row == (r+1)){ 1991 break; 1992 } 1993 } 1994 if(row<=r){ 1995 if(H[row,i]!=0) 1996 { 1997 v = H[1..r,i]; 1998 mdeg = mdeg-(mdeg[row]-mdeg[row]%v[row])/v[row]*v; 1999 } 2000 } 2001 } 2002 return( mdeg == 0 ); 2003 2004 } 1708 2005 example 1709 2006 { … … 1732 2029 poly f = z2; 1733 2030 1734 intmat m[5][2]=multiDeg(a)-multiDeg(b),multiDeg(b)-multiDeg(c),multiDeg(c)-multiDeg(d),multiDeg(d)-multiDeg(e),multiDeg(e)-multiDeg(f);1735 m=transpose(m);1736 areZeroElements(m);1737 areZeroElements(m,tt);1738 }1739 1740 1741 /******************************************************/1742 proc isZeroElement(intvec mdeg, list #)1743 "USAGE: isZeroElement(d, [T]); intvec d, group T1744 PURPOSE: For a integer vector mdeg representing the multidegree of some polynomial1745 or vector this method computes if the multidegree is contained in the grading group1746 group (either set globally or given as an optional argument), i.e. if it is zero in the multigrading.1747 EXAMPLE: example isZeroElement; shows an example1748 "1749 {1750 int i = 1;1751 if( size(#) >= i )1752 {1753 def a = #[1];1754 if( typeof(a) == "intmat" )1755 {1756 intmat H = hermiteNormalForm(a);1757 i++;1758 }1759 if( typeof(a) == "list" )1760 {1761 list L = a;1762 intmat H = attrib(L, "hermite"); // todo1763 i++;1764 }1765 kill a;1766 }1767 1768 if( i == 1 )1769 {1770 intmat H = getLattice("hermite");1771 }1772 1773 int x, k, row;1774 1775 int r = nrows(H);1776 int c = ncols(H);1777 1778 int rr = nrows(mdeg);1779 row = 1;1780 intvec v;1781 for(i=1; (i<=r)&&(row<=r)&&(i<=c); i++)1782 {1783 while((H[row,i]==0)&&(row<=r))1784 {1785 row++;1786 if(row == (r+1)){1787 break;1788 }1789 }1790 if(row<=r){1791 if(H[row,i]!=0)1792 {1793 v = H[1..r,i];1794 mdeg = mdeg-(mdeg[row]-mdeg[row]%v[row])/v[row]*v;1795 }1796 }1797 }1798 return( mdeg == 0 );1799 1800 }1801 example1802 {1803 "EXAMPLE:"; echo=2;1804 1805 ring r = 0,(x,y,z),dp;1806 1807 intmat g[2][3]=1808 1,0,1,1809 0,1,1;1810 intmat t[2][1]=1811 -2,1812 1;1813 1814 intmat tt[2][1]=1815 1,1816 -1;1817 1818 setBaseMultigrading(g,t);1819 1820 poly a = x10yz;1821 poly b = x8y2z;1822 poly c = x4z2;1823 poly d = y5;1824 poly e = x2y2;1825 poly f = z2;1826 1827 2031 intvec v1 = multiDeg(a) - multiDeg(b); 1828 2032 v1; … … 1910 2114 1911 2115 proc gradiator(def h) 1912 PURPOSE: coarsens the grading of the basering until the polynom or ideal h becomes homogeneous. 1913 2116 "PURPOSE: coarsens the grading of the basering until the polynom or ideal h becomes homogeneous." 1914 2117 { 1915 2118 if(typeof(h)=="poly"){ … … 1942 2145 example 1943 2146 { 1944 "EXAMPLE:"; echo=2; 2147 "EXAMPLE:"; echo=2; 2148 1945 2149 ring r = 0,(x,y,z),dp; 1946 2150 intmat g[2][3] = 1,0,1,0,1,1; … … 3067 3271 /******************************************************/ 3068 3272 proc multiDegBasis(intvec d) 3069 " 3070 USAGE: multidegree d 3273 "USAGE: multidegree d 3071 3274 ASSUME: current ring is multigraded, monomial ordering is global 3072 3275 PURPOSE: compute all monomials of multidegree d … … 3284 3487 { 3285 3488 "EXAMPLE:"; echo=2; 3286 3287 3489 3288 3490 ring r = 0,(x,y,z,w),dp; … … 3977 4179 } 3978 4180 3979 proc evalHilbertSeries(def h, intvec v) 3980 " 3981 evaluate hilbert series h by substibuting v[i] for t_(i) (1/v[i] for s_(i)) 3982 return: int (h(v)) 4181 static proc evalHilbertSeries(def h, intvec v) 4182 " 4183 TODO 4184 evaluate hilbert series h by substibuting v[i] for t_(i) (1/v[i] for s_(i)) 4185 return: int (h(v)) 3983 4186 " 3984 4187 { … … 4304 4507 /******************************************************/ 4305 4508 proc intRank(intmat A) 4306 " 4307 USAGE: intRank(A); intmat A 4509 "USAGE: intRank(A); intmat A 4308 4510 PURPOSE: compute the rank of the integral matrix A 4309 4511 by computing a hermite normalform. … … 4553 4755 4554 4756 proc kernelLattice(def P) 4555 " 4556 USAGE: kernelLattice(P); intmat P 4757 "USAGE: kernelLattice(P); intmat P 4557 4758 PURPOSE: compute a integral basis for the kernel of the 4558 4759 homomorphism of lattices defined by the intmat P.
Note: See TracChangeset
for help on using the changeset viewer.