Changeset 166ebd2 in git


Ignore:
Timestamp:
Mar 29, 2011, 5:59:25 PM (12 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
a796fbdaa0242a20ef39e60d40c2d02dba2c9eb4
Parents:
e7c67af3ca54121581499413ed55f282b49e8ac6
Message:
ADD: some more examples and descriptions: 'createQuotientGroup','createTorsionFreeGroup', 'isGroup', 'getGradedGenerator','createGradedRingHomomorphism' etc.
FIX: evalHilbertSeries -> static (too experimentall)

From: Oleksandr Motsak <motsak@mathematik.uni-kl.de>

git-svn-id: file:///usr/local/Singular/svn/trunk@14084 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/multigrading.lib

    re7c67af r166ebd2  
    3737printGroup(G);             print a group
    3838
    39 areIsomorphicGroups(G,H);     test wheter G an H are isomorphic groups (TODO Tuebingen)
     39areIsomorphicGroups(G,H);     test wheter G an H are isomorphic groups
    4040isGroup(G);                   test whether G is a valid group
    4141isGroupHomomorphism(L1,L2,A); test wheter A defines a group homomrphism from L1 to L2
     
    9292
    9393hilbertSeries(M);         compute the multigraded Hilbert Series of M
    94 evalHilbertSeries(h,v);   evaluate hilberts series h by substituting v[i] for t_(i)
    9594
    9695lll(A);                   applies LLL(.) of lll.lib which only works for lists on a matrix A
     
    101100";
    102101
     102/// evalHilbertSeries(h,v);   evaluate hilberts series h by substituting v[i] for t_(i) (too experimentall)
     103
    103104// finestMDeg(def r)
    104105// newMap(map F, intmat Q, list #)
    105106
    106107LIB "standard.lib"; // for groebner
    107 LIB "lll.lib"; // for lll_matrix
     108// LIB "lll.lib"; // for lll_matrix // no need now, right?
    108109LIB "matrix.lib"; // for multiDegTor
    109110
     
    159160  "EXAMPLE:"; echo=2;
    160161
    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);
    163204}
    164205
     
    255296
    256297proc createQuotientGroup(intmat L)
    257 "
    258 L - relations
    259 TODO: bad name
     298"USAGE: createGroup(L); L is an integer matrix
     299PURPOSE: create the group of the form (I+L)/L,
     300where I is the square identity matrix of size nrows(L) x nrows(L)
     301NOTE: L specifies relations between free generators of Z^nrows(L)
     302RETURN: group
     303EXAMPLE: example createQuotientGroup; shows an example
    260304"
    261305{
     
    265309  return (createGroup(S,L));
    266310}
     311example
     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}
    267336
    268337proc createTorsionFreeGroup(intmat S)
    269 "
    270 S - generators
    271 TODO: bad name
     338"USAGE: createTorsionFreeGroup(S); S is an integer matrix
     339PURPOSE: create the free subgroup generated by S within the
     340free Abelian group of rank nrows(S)
     341RETURN: group
     342EXAMPLE: example createTorsionFreeGroup; shows an example
    272343"
    273344{
     
    275346  intmat L[r][1] = 0;
    276347  return (createGroup(S,L));
     348}
     349example
     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);
    277372}
    278373
     
    409504  "EXAMPLE:"; echo=2;
    410505
     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
    411519}
    412520
    413521/******************************************************/
    414 proc areIsomorphicGroups(def G, def H)
     522static proc areIsomorphicGroups(def G, def H)
    415523"USAGE: areIsomorphicGroups(G, H); G and H are groups
    416524PURPOSE: ?
     
    426534  "EXAMPLE:"; echo=2;
    427535
    428 }
    429 
    430 
     536  // TODO!
     537
     538}
     539
     540/******************************************************/
    431541proc isGroup(def G)
    432 "test whether G is a valid group"
     542"USAGE: isGroup(G); G a list
     543PURPOSE: checks whether G is a valid group
     544NOTE: G should be created by createGroup
     545(or createQuotientGroup, createTorsionFreeGroup)
     546RETURN: int, 1 if G is a valid group and 0 otherwise
     547EXAMPLE: example isGroup; shows an example
     548"
    433549{
    434550  string isGroup = "isGroup";
     
    452568
    453569  return(1);
     570}
     571example
     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
    454591}
    455592
     
    9441081
    9451082proc getGradedGenerator(def m, int i)
    946 "
    947 returns m[i], but with grading
     1083"USAGE: getGradedGenerator(M, i), 'M' module/ideal, 'i' int
     1084RETURN: returns the i-th generator of M, endowed with the module grading from M
     1085EXAMPLE: example getGradedGenerator; shows an example
    9481086"
    9491087{
     
    9621100  ERROR("m is expected to be an ideal or a module");
    9631101}
    964 
     1102example
     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}
    9651140
    9661141/******************************************************/
     
    14721647  }
    14731648}
    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);
     1649example
     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);
    14851669}
    14861670
    14871671
    14881672proc 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
     1674PURPOSE: Computes the Smith Normal Form of A
     1675RETURN: if no optional argument is given: intmat, the Smith Normal Form of A,
     1676otherwise: a list of 3 integer matrices P, D Q, such that D == P*A*Q.
     1677EXAMPLE: example smithNormalForm; shows an example
    14921678"
    14931679{
     
    15561742example
    15571743{
    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]);
    15731764}
    15741765
     
    16881879
    16891880proc 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
     1882PURPOSE: 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),
     1887i.e. if they all are zero in the multigrading.
     1888EXAMPLE: example areZeroElements; shows an example
     1889"
    16911890{
    16921891  int r = nrows(m);
     
    17051904  return(1);
    17061905}
    1707 
     1906example
     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/******************************************************/
     1946proc isZeroElement(intvec mdeg, list #)
     1947"USAGE: isZeroElement(d, [T]); intvec d, group T
     1948PURPOSE: For a integer vector 'd' representing the multidegree of some polynomial
     1949or vector this method computes if the multidegree is contained in the grading group
     1950group (either set globally or given as an optional argument), i.e. if it is zero in the multigrading.
     1951EXAMPLE: 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}
    17082005example
    17092006{
     
    17322029  poly f = z2;
    17332030
    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 T
    1744 PURPOSE: For a integer vector mdeg representing the multidegree of some polynomial
    1745 or vector this method computes if the multidegree is contained in the grading group
    1746 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 example
    1748 "
    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"); // todo
    1763       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 example
    1802 {
    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 
    18272031  intvec v1 = multiDeg(a) - multiDeg(b);
    18282032  v1;
     
    19102114
    19112115proc 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."
    19142117{
    19152118  if(typeof(h)=="poly"){
     
    19422145example
    19432146{
    1944 "EXAMPLE:"; echo=2;
     2147  "EXAMPLE:"; echo=2;
     2148
    19452149ring r = 0,(x,y,z),dp;
    19462150intmat g[2][3] = 1,0,1,0,1,1;
     
    30673271/******************************************************/
    30683272proc multiDegBasis(intvec d)
    3069 "
    3070 USAGE: multidegree d
     3273"USAGE: multidegree d
    30713274ASSUME: current ring is multigraded, monomial ordering is global
    30723275PURPOSE: compute all monomials of multidegree d
     
    32843487{
    32853488  "EXAMPLE:"; echo=2;
    3286 
    32873489
    32883490  ring r = 0,(x,y,z,w),dp;
     
    39774179}
    39784180
    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))
     4181static 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))
    39834186"
    39844187{
     
    43044507/******************************************************/
    43054508proc intRank(intmat A)
    4306 "
    4307 USAGE: intRank(A); intmat A
     4509"USAGE: intRank(A); intmat A
    43084510PURPOSE: compute the rank of the integral matrix A
    43094511by computing a hermite normalform.
     
    45534755
    45544756proc kernelLattice(def P)
    4555 "
    4556 USAGE: kernelLattice(P); intmat P
     4757"USAGE: kernelLattice(P); intmat P
    45574758PURPOSE: compute a integral basis for the kernel of the
    45584759homomorphism of lattices defined by the intmat P.
Note: See TracChangeset for help on using the changeset viewer.