Changeset a0bf79 in git


Ignore:
Timestamp:
Sep 23, 2010, 5:11:56 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'd1ba061a762c62d3a25159d8da8b6e17332291fa')
Children:
7c596bed4549a47d03834ba741671dbe1923e784
Parents:
efa2bca0582609e7d15dda825eb555ede060c868
Message:
format

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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/multigrading.lib

    refa2bca ra0bf79  
    1212OVERVIEW: using this library allows one can virtually add multigrading to Singular.
    1313For more see http://code.google.com/p/convex-singular/wiki/Multigrading
    14 For theoretical references see: 
     14For theoretical references see:
    1515E. Miller, B. Sturmfels: 'Combinatorial Commutative Algebra' and
    1616M. Kreuzer, L. Robbiano: 'Computational Commutative Algebra'.
     
    6262PURPOSE: attaches weights of variables and torsion to the basering.
    6363NOTE: M encodes the weights of variables column-wise.
    64 The torsion is given by the lattice spanned by the columns of the integer 
     64The torsion is given by the lattice spanned by the columns of the integer
    6565matrix T in Z^nrows(M) over Z.
    6666RETURN: nothing
     
    7474
    7575  attrib(basering, attrMgrad, M);
    76  
     76
    7777  if( size(#) > 0 and typeof(#[1]) == "intmat" )
    7878  {
     
    8585  if( nrows(T) == nrows(M) )
    8686  {
    87     attrib(basering, attrTorsion, T); 
     87    attrib(basering, attrTorsion, T);
    8888    def H;
    89     attrib(basering, attrTorsionHNF, H);       
     89    attrib(basering, attrTorsionHNF, H);
    9090  }
    9191  else
     
    9797{
    9898  "EXAMPLE:"; echo=2;
    99    
     99
    100100  ring R = 0, (x, y, z), dp;
    101101
     
    109109  intmat L[3][2] =
    110110    1, 1,
    111     1, 3, 
     111    1, 3,
    112112    1, 5;
    113    
     113
    114114  // attaches M & L to R (==basering):
    115115  setBaseMultigrading(M, L); // Grading: Z^3/L
     
    131131  getTorsion(basering, "hermite") == H;
    132132
    133  
     133
    134134
    135135  kill L, M;
     
    146146    0,
    147147    2;
    148    
     148
    149149  // attaches M & L to R (==basering):
    150150  setBaseMultigrading(M, L); // Grading: Z + (Z/2Z)
     
    166166  intmat L[1][1] =
    167167    0;
    168    
     168
    169169  // attaches M & L to R (==basering):
    170170  setBaseMultigrading(M); // Grading: Z^3
     
    207207  def M = attrib(R, attrMgrad);
    208208  if( typeof(M) == "intmat"){ return (M); }
    209   ERROR( "Sorry no multigrading matrix!" ); 
     209  ERROR( "Sorry no multigrading matrix!" );
    210210}
    211211example
    212212{
    213213  "EXAMPLE:"; echo=2;
    214    
     214
    215215  ring R = 0, (x, y, z), dp;
    216216
     
    224224  intmat L[3][2] =
    225225    1, 1,
    226     1, 3, 
     226    1, 3,
    227227    1, 5;
    228    
     228
    229229  // attaches M & L to R (==basering):
    230230  setBaseMultigrading(M, L); // Grading: Z^3/L
     
    246246    0,
    247247    2;
    248    
     248
    249249  // attaches M & L to R (==basering):
    250250  setBaseMultigrading(M, L); // Grading: Z + (Z/2Z)
     
    264264  intmat L[1][1] =
    265265    0;
    266    
     266
    267267  // attaches M & L to R (==basering):
    268268  setBaseMultigrading(M); // Grading: Z^3
     
    291291      def R = #[i];
    292292      i++;
    293     } 
    294   } 
     293    }
     294  }
    295295
    296296  if( !defined(R) )
     
    303303    if( #[i] == "hermite" )
    304304    {
    305       if( typeof(attrib(R, attrTorsionHNF)) != "intmat" ) 
     305      if( typeof(attrib(R, attrTorsionHNF)) != "intmat" )
    306306      {
    307307        def M = getTorsion(R);
    308308        if( typeof(M) != "intmat")
    309         { 
    310           ERROR( "Sorry no torsion matrix!" ); 
     309        {
     310          ERROR( "Sorry no torsion matrix!" );
    311311        }
    312312        attrib(R, attrTorsionHNF, hermite(M)); // this might not work with R != basering...
    313       } 
     313      }
    314314      return (attrib(R, attrTorsionHNF));
    315315    }
     
    318318  def M = attrib(R, attrTorsion);
    319319  if( typeof(M) != "intmat")
    320   { 
    321     ERROR( "Sorry no torsion matrix!" ); 
     320  {
     321    ERROR( "Sorry no torsion matrix!" );
    322322  }
    323323  return (M);
     
    326326{
    327327  "EXAMPLE:"; echo=2;
    328    
     328
    329329  ring R = 0, (x, y, z), dp;
    330330
     
    338338  intmat L[3][2] =
    339339    1, 1,
    340     1, 3, 
     340    1, 3,
    341341    1, 5;
    342    
     342
    343343  // attaches M & L to R (==basering):
    344344  setBaseMultigrading(M, L); // Grading: Z^3/L
     
    363363    0,
    364364    2;
    365    
     365
    366366  // attaches M & L to R (==basering):
    367367  setBaseMultigrading(M, L); // Grading: Z + (Z/2Z)
     
    384384  intmat L[1][1] =
    385385    0;
    386    
     386
    387387  // attaches M & L to R (==basering):
    388388  setBaseMultigrading(M); // Grading: Z^3
     
    415415      return (VV);
    416416    }
    417      
     417
    418418    ERROR("Sorry: vector or module need module-grading-matrix! See 'getModuleGrading'.");
    419419  }
     
    428428    ERROR("Sorry wrong width of V: " + string(ncols(V)));
    429429  }
    430    
     430
    431431  return (V);
    432432}
     
    434434{
    435435  "EXAMPLE:"; echo=2;
    436    
     436
    437437   ring R = 0, (x,y), dp;
    438438   intmat M[2][2]=
     
    442442     1,  2,  3,  4, 0,
    443443     0, 10, 20, 30, 1;
    444    
     444
    445445   setBaseMultigrading(M, T);
    446    
     446
    447447   ideal I = x, y, xy^5;
    448448   isHomogenous(I);
    449  
     449
    450450   intmat V = mDeg(I); print(V);
    451451
    452452   module S = syz(I); print(S);
    453    
     453
    454454   S = setModuleGrading(S, V);
    455455
    456456   getModuleGrading(S) == V;
    457    
     457
    458458   vector v = setModuleGrading(S[1], V);
    459459   getModuleGrading(v) == V;
    460460   isHomogenous(v);
    461    print( mDeg(v) );   
    462    
     461   print( mDeg(v) );
     462
    463463   isHomogenous(S);
    464464   print( mDeg(S) );
     
    469469"USAGE: setModuleGrading(m, G), m module/vector, G intmat
    470470PURPOSE: attaches the multiweights of free module generators to 'm'
    471 WARNING: The method does not verify that the multigrading makes the 
     471WARNING: The method does not verify that the multigrading makes the
    472472         module/vector homogenous. One can do that using isHomogenous(m).
    473473"
     
    486486{
    487487  "EXAMPLE:"; echo=2;
    488    
     488
    489489   ring R = 0, (x,y), dp;
    490490   intmat M[2][2]=
     
    494494     1,  2,  3,  4, 0,
    495495     0, 10, 20, 30, 1;
    496    
     496
    497497   setBaseMultigrading(M, T);
    498    
     498
    499499   ideal I = x, y, xy^5;
    500500   intmat V = mDeg(I);
    501    
     501
    502502   // V == M; modulo T
    503503   print(V);
    504504
    505505   module S = syz(I);
    506    
     506
    507507   S = setModuleGrading(S, V);
    508508   getModuleGrading(S) == V;
    509509
    510510   print(S);
    511    
     511
    512512   vector v = S[1]; v = setModuleGrading(v, V);
    513513   getModuleGrading(v) == V;
    514514
    515    print( mDeg(v) );   
     515   print( mDeg(v) );
    516516
    517517   isHomogenous(S);
     
    544544
    545545    if(H[j, i]!=0)
    546     { 
     546    {
    547547      d=d*H[j, i];
    548548    }
     
    550550
    551551  if( (d*d)==1 )
    552   { 
     552  {
    553553    return(1==1);
    554554  }
     
    566566     1, 2, 3, 4, 0,
    567567     0,10,20,30, 1;
    568    
     568
    569569   setBaseMultigrading(M,T);
    570    
     570
    571571   // Is the resulting group torsion free?
    572572   isTorsionFree();
     
    576576
    577577   ring R=0,(x,y,z),dp;
    578    intmat A[3][3] = 
     578   intmat A[3][3] =
    579579     1,0,0,
    580580     0,1,0,
     
    626626
    627627    if((i+l)>nrows(A)){ break; }
    628    
     628
    629629    if(A[i+l, i]<0)
    630630    {
     
    658658
    659659              for(k=1;k<=nrows(A);k++)
    660               { 
     660              {
    661661                save=A[k, i];
    662662                A[k, i]=A[k, j];
     
    668668            d=a2/A[i+l, i];
    669669            for(k=1;k<=nrows(A);k++)
    670             { 
     670            {
    671671              A[k, j]=A[k, j]- d*A[k, i];
    672672            }
     
    689689  "EXAMPLE:"; echo=2;
    690690
    691    intmat M[2][5] = 
     691   intmat M[2][5] =
    692692     1, 2, 3, 4, 0,
    693693     0,10,20,30, 1;
     
    696696   print(hermite(M));
    697697
    698    intmat T[3][4] = 
     698   intmat T[3][4] =
    699699     3,3,3,3,
    700700     2,1,3,0,
     
    704704   print(hermite(T));
    705705
    706    intmat A[4][5] = 
     706   intmat A[4][5] =
    707707     1,2,3,2,2,
    708708     1,2,3,4,0,
     
    738738
    739739      if(x!=0)
    740       { 
     740      {
    741741        return(1==0);
    742742      }
     
    745745
    746746      for( k=1; k <= rr; k++)
    747       { 
     747      {
    748748        mdeg[k] = mdeg[k] - x*H[k,i];
    749749      }
     
    779779  v1;
    780780  isTorsionElement(v1);
    781  
     781
    782782  intvec v2 = mDeg(a) - mDeg(c);
    783783  v2;
    784784  isTorsionElement(v2);
    785  
     785
    786786  intvec v3 = mDeg(e) - mDeg(f);
    787787  v3;
    788788  isTorsionElement(v3);
    789  
     789
    790790  intvec v4 = mDeg(c) - mDeg(d);
    791791  v4;
     
    797797proc defineHomogenous(poly f, list #)
    798798"USAGE: defineHomogenous(f[, G]); polynomial f, integer matrix G
    799 PURPOSE: Yields a matrix which has to be appended to the torsion matrix to make the 
     799PURPOSE: Yields a matrix which has to be appended to the torsion matrix to make the
    800800polynomial f homogenous in the grading by grad.
    801801"
    802802{
    803   if( size(#) > 0 ) 
    804   {
    805     if( typeof(#[1]) == "intmat" ) 
     803  if( size(#) > 0 )
     804  {
     805    if( typeof(#[1]) == "intmat" )
    806806    {
    807807      intmat grad = #[1];
     
    833833
    834834  ring r =0,(x,y,z),dp;
    835   intmat grad[2][3] = 
     835  intmat grad[2][3] =
    836836    1,0,1,
    837837    0,1,1;
     
    844844  M;
    845845  defineHomogenous(f, grad) == M;
    846  
     846
    847847  isHomogenous(f);
    848848  setBaseMultigrading(grad, M);
     
    952952
    953953  // Setting degrees for preimage ring.;
    954   intmat grad[3][3] = 
     954  intmat grad[3][3] =
    955955    1,0,0,
    956956    0,1,0,
     
    979979  getVariableWeights();
    980980  getTorsion();
    981  
     981
    982982  // TODO: Unfortunately this is not a very spectacular example.;
    983983
     
    988988proc equalMDeg(intvec exp1, intvec exp2, list #)
    989989"USAGE: equalMDeg(exp1, exp2[, V]); intvec exp1, exp2, intmat V
    990 PURPOSE: Tests if the exponent vectors of two monomials (given by exp1 and exp2) 
     990PURPOSE: Tests if the exponent vectors of two monomials (given by exp1 and exp2)
    991991represent the same multidegree.
    992 NOTE: the integer matrix V encodes multidegrees of module components, 
     992NOTE: the integer matrix V encodes multidegrees of module components,
    993993if module component is present in exp1 and exp2
    994994"
     
    999999  }
    10001000
    1001   if( exp1 == exp2) 
     1001  if( exp1 == exp2)
    10021002  {
    10031003    return (1==1);
     
    11421142    def g = groebner(a); // !!!!
    11431143
    1144     def b, aa; int j; 
     1144    def b, aa; int j;
    11451145    for( int i = ncols(a); i > 0; i-- )
    11461146    {
     
    11621162    }
    11631163    return(1==1);
    1164   } 
     1164  }
    11651165}
    11661166example
     
    11711171
    11721172  //Grading and Torsion matrices:
    1173   intmat M[3][3] = 
     1173  intmat M[3][3] =
    11741174    1,0,0,
    11751175    0,1,0,
     
    11971197  /////////////////////////////////////////////////////////
    11981198  // new Torsion matrix:
    1199   intmat T[3][4] = 
     1199  intmat T[3][4] =
    12001200    3,3,3,3,
    12011201    2,1,3,0,
    12021202    1,2,0,3;
    1203  
     1203
    12041204  setBaseMultigrading(M,T);
    12051205
     
    12081208  mDegPartition(f);
    12091209
    1210   // --------------------- 
     1210  // ---------------------
    12111211  g;
    12121212  isHomogenous(g);
     
    12171217  ring R = 0, (x,y,z), dp;
    12181218
    1219   intmat A[2][3] = 
     1219  intmat A[2][3] =
    12201220    0,0,1,
    12211221    3,2,1;
    1222   intmat T[2][1] = 
    1223     -1, 
     1222  intmat T[2][1] =
     1223    -1,
    12241224     4;
    12251225  setBaseMultigrading(A, T);
     
    12331233  mDegPartition(x3 -y2z + x2 -y3 + z + 1);
    12341234
    1235  
     1235
    12361236  module N = gen(1) + (x+y) * gen(2), z*gen(3);
    12371237
    12381238  intmat V[2][3] = 0; // 1, 2, 3,  4, 5, 6; //  column-wise weights of components!!??
    1239  
     1239
    12401240  vector v1, v2;
    1241  
     1241
    12421242  v1 = setModuleGrading(N[1], V); v1;
    12431243  mDegPartition(v1);
     
    12521252  print( mDeg(N) );
    12531253
    1254   /////////////////////////////////////// 
    1255 
    1256   V = 
    1257     1, 2, 3, 
     1254  ///////////////////////////////////////
     1255
     1256  V =
     1257    1, 2, 3,
    12581258    4, 5, 6;
    12591259
     
    12701270  print( mDeg(N) );
    12711271
    1272   /////////////////////////////////////// 
    1273 
    1274   V = 
    1275     0, 0, 0, 
     1272  ///////////////////////////////////////
     1273
     1274  V =
     1275    0, 0, 0,
    12761276    4, 1, 0;
    12771277
     
    13401340    A = A - lead(A);
    13411341    while( size(A) > 0 )
    1342     { 
     1342    {
    13431343      v = leadexp(A); //  v;
    13441344      m = max( m, M * v, r ); // ????
     
    13611361    A = A - lead(A);
    13621362    while( size(A) > 0 )
    1363     { 
     1363    {
    13641364      v = leadexp(A); //  v;
    13651365
     
    13861386      {
    13871387        G[j, i] = d[j];
    1388       }     
     1388      }
    13891389    }
    13901390    return(G);
     
    14001400      v = setModuleGrading(A[i], V);
    14011401
    1402       // G[1..r, i] 
     1402      // G[1..r, i]
    14031403      d = mDeg(v);
    14041404
     
    14061406      {
    14071407        G[j, i] = d[j];
    1408       }     
     1408      }
    14091409
    14101410    }
     
    14121412    return(G);
    14131413  }
    1414  
     1414
    14151415}
    14161416example
     
    14361436
    14371437  setBaseMultigrading(A, Ta);
    1438  
     1438
    14391439  mDeg( x*x*y );
    1440  
     1440
    14411441  mDeg( y*y*y*x );
    1442  
     1442
    14431443  mDeg( x*y + x + 1 );
    14441444
     
    14501450
    14511451//  "ideal:";
    1452  
     1452
    14531453  ideal I = y*x*x, x*y*y*y;
    14541454  print( mDeg(I) );
     
    14581458
    14591459//  "vectors:";
    1460  
     1460
    14611461  intmat B[2][2] = 0, 1, 1, 0;
    14621462  print(B);
    1463  
     1463
    14641464  mDeg( setModuleGrading(y*y*y*gen(2), B ));
    14651465  mDeg( setModuleGrading(x*x*gen(1), B ));
    14661466
    1467  
     1467
    14681468  vector V = x*gen(1) + y*gen(2);
    14691469  V = setModuleGrading(V, B);
     
    14721472  vector v1 = setModuleGrading([0, 0, 0], B);
    14731473  print( mDeg( v1 ) );
    1474  
     1474
    14751475  vector v2 = setModuleGrading([0], B);
    14761476  print( mDeg( v2 ) );
    14771477
    14781478//  "module:";
    1479  
     1479
    14801480  module D = x*gen(1), y*gen(2);
    14811481  D;
    14821482  D = setModuleGrading(D, B);
    14831483  print( mDeg( D ) );
    1484  
     1484
    14851485
    14861486  module DD = [0, 0],[0, 0, 0];
     
    15041504"
    15051505{
    1506   if( typeof(p) == "poly" ) 
    1507   {
    1508     ideal I;     
     1506  if( typeof(p) == "poly" )
     1507  {
     1508    ideal I;
    15091509    poly mp, t, tt;
    15101510  }
     
    15131513    if(  typeof(p) == "vector" )
    15141514    {
    1515       module I;     
     1515      module I;
    15161516      vector mp, t, tt;
    15171517    }
     
    15241524  if( typeof(p) == "vector" )
    15251525  {
    1526     intmat V = getModuleGrading(p); 
     1526    intmat V = getModuleGrading(p);
    15271527  }
    15281528  else
     
    15311531  }
    15321532
    1533   if( size(p) > 1) 
     1533  if( size(p) > 1)
    15341534  {
    15351535    intvec m;
     
    15381538    {
    15391539      m = leadexp(p);
    1540       mp = lead(p); 
     1540      mp = lead(p);
    15411541      p = p - lead(p);
    15421542      tt = p; t = 0;
    15431543
    15441544      while( size(tt) > 0 )
    1545       { 
     1545      {
    15461546        // TODO: we make no caching of matrices (M,T,H,V), which remain the same!
    1547         if( equalMDeg( leadexp(tt), m, V  ) ) 
     1547        if( equalMDeg( leadexp(tt), m, V  ) )
    15481548        {
    15491549          mp = mp + lead(tt); // "mp", mp;
     
    15921592
    15931593  mDegPartition(f);
    1594  
     1594
    15951595  vector v = xy*gen(1)-x3y2*gen(2)+x4y*gen(3);
    15961596  intmat B[2][3]=1,-1,-2,0,0,1;
    15971597  v = setModuleGrading(v,B);
    15981598  getModuleGrading(v);
    1599  
     1599
    16001600  mDegPartition(v, B);
    16011601}
     
    16071607{
    16081608  intmat A[n][n];
    1609  
     1609
    16101610  for( int i = n; i > 0; i-- )
    16111611  {
     
    16501650
    16511651
    1652   if( n > 0) 
    1653   {
    1654 
    1655     intmat L[N][n]; 
     1652  if( n > 0)
     1653  {
     1654
     1655    intmat L[N][n];
    16561656    //  list L;
    16571657    int j = n;
     
    16611661      p = I[i];
    16621662
    1663       if( size(p) > 1 ) 
     1663      if( size(p) > 1 )
    16641664      {
    16651665        intvec m0 = leadexp(p);
     
    16761676
    16771677    print(L);
    1678     setBaseMultigrading(A, L);     
    1679   } 
     1678    setBaseMultigrading(A, L);
     1679  }
    16801680  else
    16811681  {
     
    17141714
    17151715  if( size(#) > 0 and typeof(#[1]) == "intmat" )
    1716   { 
     1716  {
    17171717    attrib(F, "P", #[1]);
    17181718  }
     
    18501850   j=system("sh","hilbert -q -n sing4ti2"); ////////// be quiet + no loggin!!!
    18511851
    1852    j=system("sh", "awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.hil " + 
    1853                 "| sed s/[\\\ \\\t\\\v\\\f]/,/g " + 
    1854                 "| sed s/,+/,/g|sed s/,,/,/g " + 
    1855                 "| sed s/,,/,/g " + 
     1852   j=system("sh", "awk \'BEGIN{ORS=\",\";}{print $0;}\' sing4ti2.hil " +
     1853                "| sed s/[\\\ \\\t\\\v\\\f]/,/g " +
     1854                "| sed s/,+/,/g|sed s/,,/,/g " +
     1855                "| sed s/,,/,/g " +
    18561856                "> sing4ti2.converted" );
    18571857   if( defined(keepfiles) <= 0)
     
    18691869   string ergstr = "intvec erglist = " + s + "0;";
    18701870   execute(ergstr);
    1871  
     1871
    18721872   //   print(erglist);
    1873  
     1873
    18741874   int Rnc = erglist[1];
    18751875   int Rnr = erglist[2];
    1876    
     1876
    18771877   intmat R[Rnr][Rnc];
    18781878
     
    19401940
    19411941/******************************************************/
    1942 proc mDegBasis(intvec d) 
     1942proc mDegBasis(intvec d)
    19431943"
    19441944USAGE: multidegree d
     
    19831983
    19841984    intmat AA[nr][nc + 2 * n];
    1985     AA[1..nr, 1.. nc] = A[1..nr, 1.. nc]; 
    1986     AA[1..nr, nc + (1.. n)] = T[1..nr, 1.. n]; 
    1987     AA[1..nr, nc + n + (1.. n)] = -T[1..nr, 1.. n]; 
     1985    AA[1..nr, 1.. nc] = A[1..nr, 1.. nc];
     1986    AA[1..nr, nc + (1.. n)] = T[1..nr, 1.. n];
     1987    AA[1..nr, nc + n + (1.. n)] = -T[1..nr, 1.. n];
    19881988
    19891989
    19901990    //      print ( AA );
    19911991
    1992     intmat K = leftKernelZ(( AA ) ); // 
     1992    intmat K = leftKernelZ(( AA ) ); //
    19931993
    19941994    //      print(K);
     
    19991999    //      "!";
    20002000
    2001     intmat B = hilbert4ti2intmat(transpose(KK), 1); 
     2001    intmat B = hilbert4ti2intmat(transpose(KK), 1);
    20022002
    20032003    //      "!";      print(B);
     
    20102010
    20112011
    2012   int i; 
     2012  int i;
    20132013  int nnr = nrows(B);
    20142014  int nnc = ncols(B);
     
    20692069  intvec v1=4,0;
    20702070  intvec v2=4,4;
    2071  
     2071
    20722072  intmat g3[1][2]=1,1;
    20732073  setBaseMultigrading(g3);
     
    20752075  v3;
    20762076  mDegBasis(v3);
    2077  
     2077
    20782078  setBaseMultigrading(g1,t);
    20792079  mDegBasis(v1);
    20802080  setBaseMultigrading(g2);
    20812081  mDegBasis(v2);
    2082  
     2082
    20832083  intmat M[2][2] = 1, -1, -1, 1;
    20842084  intvec d = -2, 2;
     
    21422142PURPOSE: computes the multigraded syzygy of I
    21432143RETURNS: module, the syzygy of I
    2144 NOTE: generators of I must be multigraded homogeneous 
     2144NOTE: generators of I must be multigraded homogeneous
    21452145"
    21462146{
    2147   if( isHomogenous(I, "checkGens") == 0) 
    2148   { 
    2149     ERROR ("Sorry: inhomogenous input!"); 
    2150   } 
     2147  if( isHomogenous(I, "checkGens") == 0)
     2148  {
     2149    ERROR ("Sorry: inhomogenous input!");
     2150  }
    21512151  module S = syz(I);
    21522152  S = setModuleGrading(S, mDeg(I));
     
    21562156{
    21572157  "EXAMPLE:"; echo=2;
    2158  
     2158
    21592159
    21602160  ring r = 0,(x,y,z,w),dp;
     
    21662166  setBaseMultigrading(M);
    21672167
    2168  
     2168
    21692169  module M = ideal(  xw-yz, x2z-y3, xz2-y2w, yw2-z3);
    2170  
    2171  
     2170
     2171
    21722172  intmat v[2][nrows(M)]=
    21732173    1,
    21742174    0;
    2175  
     2175
    21762176  M = setModuleGrading(M, v);
    21772177
     
    21912191"USAGE: mDegGroebner(I); I is a poly/vector/ideal/module
    21922192PURPOSE: computes the multigraded standard/groebner basis of I
    2193 NOTE: I must be multigraded homogeneous 
     2193NOTE: I must be multigraded homogeneous
    21942194RETURNS: ideal/module, the computed basis
    21952195"
    21962196{
    2197   if( isHomogenous(I) == 0) 
    2198   { 
    2199     ERROR ("Sorry: inhomogenous input!"); 
    2200   } 
     2197  if( isHomogenous(I) == 0)
     2198  {
     2199    ERROR ("Sorry: inhomogenous input!");
     2200  }
    22012201
    22022202  def S = groebner(I);
    2203  
     2203
    22042204  if( typeof(I) == "module" or typeof(I) == "vector" )
    22052205  {
    2206     S = setModuleGrading(S, getModuleGrading(I));     
     2206    S = setModuleGrading(S, getModuleGrading(I));
    22072207  }
    22082208
     
    22212221  setBaseMultigrading(M);
    22222222
    2223  
     2223
    22242224  module M = ideal(  xw-yz, x2z-y3, xz2-y2w, yw2-z3);
    2225  
    2226  
     2225
     2226
    22272227  intmat v[2][nrows(M)]=
    22282228    1,
    22292229    0;
    2230  
     2230
    22312231  M = setModuleGrading(M, v);
    22322232
     
    22612261proc mDegResolution(def I, int ll, list #)
    22622262"USAGE: mDegResolution(I,l,[f]); I is poly/vector/ideal/module; l,f are integers
    2263 PURPOSE: computes the multigraded resolution of I of the length l, 
    2264 or the whole resolution if l is zero. Returns minimal resolution if an optional 
     2263PURPOSE: computes the multigraded resolution of I of the length l,
     2264or the whole resolution if l is zero. Returns minimal resolution if an optional
    22652265argument 1 is supplied
    22662266NOTE: input must have multigraded-homogeneous generators.
     
    22692269"
    22702270{
    2271   if( isHomogenous(I, "checkGens") == 0) 
    2272   { 
    2273     ERROR ("Sorry: inhomogenous input!"); 
    2274   } 
     2271  if( isHomogenous(I, "checkGens") == 0)
     2272  {
     2273    ERROR ("Sorry: inhomogenous input!");
     2274  }
    22752275
    22762276  def R = res(I, ll, #); list L = R; int l = size(L);
     
    22782278  if( (typeof(I) == "module") or (typeof(I) == "vector") )
    22792279  {
    2280     L[1] = setModuleGrading(L[1], getModuleGrading(I));     
    2281   }
    2282 
    2283   int i; 
     2280    L[1] = setModuleGrading(L[1], getModuleGrading(I));
     2281  }
     2282
     2283  int i;
    22842284  for( i = 2; i <= l; i++ )
    22852285  {
     
    22922292    }
    22932293  }
    2294  
     2294
    22952295  return (L);
    22962296
    2297  
     2297
    22982298}
    22992299example
    23002300{
    23012301  "EXAMPLE:"; echo=2;
    2302  
     2302
    23032303  ring r = 0,(x,y,z,w),dp;
    23042304
     
    23092309  setBaseMultigrading(M);
    23102310
    2311  
     2311
    23122312  module m= ideal(  xw-yz, x2z-y3, xz2-y2w, yw2-z3);
    2313  
     2313
    23142314  isHomogenous(ideal(  xw-yz, x2z-y3, xz2-y2w, yw2-z3), "checkGens");
    2315  
     2315
    23162316  ideal A = xw-yz, x2z-y3, xz2-y2w, yw2-z3;
    23172317
    23182318  int j;
    2319  
     2319
    23202320  for(j=1; j<=ncols(A); j++)
    23212321  {
    23222322    mDegPartition(A[j]);
    23232323  }
    2324  
     2324
    23252325  intmat v[2][1]=
    23262326    1,
    23272327    0;
    2328  
     2328
    23292329  m = setModuleGrading(m, v);
    23302330
     
    23532353
    23542354  /////////////////////////////////////////////////////////////////////////////
    2355  
     2355
    23562356  L = mDegResolution(maxideal(1), 0, 1);
    23572357
     
    23632363    "Multigrading: "; print(mDeg(L[j]));
    23642364  }
    2365  
     2365
    23662366  kill v;
    2367  
     2367
    23682368
    23692369  def h = hilbertSeries(m);
     
    23722372  numerator1;
    23732373  factorize(numerator1);
    2374  
     2374
    23752375  denominator1;
    23762376  factorize(denominator1);
     
    23862386proc hilbertSeries(def I)
    23872387"USAGE: hilbertSeries(I); I is poly/vector/ideal/module
    2388 PURPOSE: computes the multigraded Hilbert Series of M 
    2389 NOTE: input must have multigraded-homogeneous generators. 
     2388PURPOSE: computes the multigraded Hilbert Series of M
     2389NOTE: input must have multigraded-homogeneous generators.
    23902390Multigrading should be positive.
    2391 RETURNS: a ring in variables t_(i), s_(i), with polynomials 
    2392 numerator1 and denominator1 and muturally prime numerator2 
     2391RETURNS: a ring in variables t_(i), s_(i), with polynomials
     2392numerator1 and denominator1 and muturally prime numerator2
    23932393and denominator2, quotients of which give the series.
    23942394"
    23952395{
    2396    
     2396
    23972397  if( !isFreeRepresented() )
    23982398  {
    23992399    ERROR("SORRY: ONLY TORSION-FREE CASE (POSITIVE GRADING)");
    24002400  }
    2401    
     2401
    24022402  int i, j, k, v;
    24032403
    24042404  intmat M = getVariableWeights();
    2405  
     2405
    24062406  int cc = ncols(M);
    24072407  int n = nrows(M);
     
    24152415
    24162416  int l = size(RES);
    2417  
     2417
    24182418  list L; L[l + 1] = 0;
    24192419
     
    24222422    intmat zeros[n][1];
    24232423    L[1] = zeros;
    2424   } 
     2424  }
    24252425  else
    24262426  {
     
    24322432    L[j + 1] = mDeg(RES[j]);
    24332433  }
    2434  
     2434
    24352435  l++;
    24362436
    24372437  ring R = 0,(t_(1..n),s_(1..n)),dp;
    2438  
    2439   ideal units; 
     2438
     2439  ideal units;
    24402440  for( i=n; i>=1; i--)
    24412441  {
    24422442    units[i] = (var(i) * var(n + i) - 1);
    24432443  }
    2444  
     2444
    24452445  qring Q = std(units);
    2446  
     2446
    24472447  // TODO: should not it be a quotient ring depending on Torsion???
    24482448  // I am not sure about what to do in the torsion case, but since
     
    24532453  poly monom, summand, numerator;
    24542454  poly denominator = 1;
    2455  
     2455
    24562456  for( i = 1; i <= cc; i++)
    24572457  {
     
    24652465      {
    24662466        monom = monom * (var(k)^(v));
    2467       } 
     2467      }
    24682468      else
    24692469      {
     
    24712471      }
    24722472    }
    2473    
     2473
    24742474    if( monom == 1)
    24752475    {
     
    24792479    denominator = denominator * (1 - monom);
    24802480  }
    2481  
    2482   for( j = 1; j<= l; j++) 
     2481
     2482  for( j = 1; j<= l; j++)
    24832483  {
    24842484    summand = 0;
     
    24942494        {
    24952495          monom = monom * (var(k)^v);
    2496         } 
     2496        }
    24972497        else
    24982498        {
     
    25042504    numerator = numerator - (-1)^j * summand;
    25052505  }
    2506  
     2506
    25072507  if( denominator == 0 )
    25082508  {
    25092509    ERROR("Multigrading not positive.");
    2510   } 
    2511  
     2510  }
     2511
    25122512  poly denominator1 = denominator;
    25132513  poly numerator1 = numerator;
     
    25432543  "The s_(i)-variables are defined to be the inverse of the t_(i)-variables.";
    25442544  " ------------ ";
    2545  
     2545
    25462546  return(Q);
    25472547}
     
    25492549{
    25502550  "EXAMPLE:"; echo=2;
    2551  
     2551
    25522552  ring r = 0,(x,y,z,w),dp;
    25532553  intmat g[2][4]=
     
    25552555    0,1,3,4;
    25562556  setBaseMultigrading(g);
    2557  
     2557
    25582558  module M = ideal(xw-yz, x2z-y3, xz2-y2w, yw2-z3);
    25592559  intmat V[2][1]=
     
    25672567  factorize(numerator2);
    25682568  factorize(denominator2);
    2569  
     2569
    25702570  kill g, h; setring r;
    25712571
     
    25732573    1,2,3,4,
    25742574    0,0,5,8;
    2575  
     2575
    25762576  setBaseMultigrading(g);
    2577  
     2577
    25782578  ideal I = x^2, y, z^3;
    25792579  I = std(I);
     
    25902590  mDeg(I);
    25912591  def h = hilbertSeries(I); setring h;
    2592  
     2592
    25932593  factorize(numerator2);
    25942594  factorize(denominator2);
     
    25972597  ////////////////////////////////////////////////
    25982598  ////////////////////////////////////////////////
    2599  
     2599
    26002600  ring R = 0,(x,y,z),dp;
    2601   intmat W[2][3] = 
     2601  intmat W[2][3] =
    26022602     1,1, 1,
    26032603     0,0,-1;
    26042604  setBaseMultigrading(W);
    26052605  ideal I = x3y,yz2,y2z,z4;
    2606  
     2606
    26072607  def h = hilbertSeries(I); setring h;
    2608  
     2608
    26092609  factorize(numerator2);
    26102610  factorize(denominator2);
     
    26152615
    26162616  ring R = 0,(x,y,z,a,b,c),dp;
    2617   intmat W[2][6] = 
     2617  intmat W[2][6] =
    26182618     1,1, 1,1,1,1,
    26192619     0,0,-1,0,0,0;
    26202620  setBaseMultigrading(W);
    26212621  ideal I = x3y,yz2,y2z,z4;
    2622  
     2622
    26232623  def h = hilbertSeries(I); setring h;
    2624  
     2624
    26252625  factorize(numerator2);
    26262626  factorize(denominator2);
    2627  
     2627
    26282628  kill R, W, h;
    26292629
     
    26322632  ////////////////////////////////////////////////
    26332633  // This is example 5.3.9. from Robbianos book.
    2634  
     2634
    26352635  ring R = 0,(x,y,z,w),dp;
    2636   intmat W[1][4] = 
     2636  intmat W[1][4] =
    26372637     1,1, 1,1;
    26382638  setBaseMultigrading(W);
     
    26402640
    26412641  hilb(std(I));
    2642  
     2642
    26432643  def h = hilbertSeries(I); setring h;
    2644  
     2644
    26452645  numerator1;
    26462646  denominator1;
     
    26482648  factorize(numerator2);
    26492649  factorize(denominator2);
    2650  
     2650
    26512651
    26522652  kill h;
     
    26572657
    26582658  hilb(std(I2));
    2659  
     2659
    26602660  def h = hilbertSeries(I2); setring h;
    26612661
     
    26672667  ////////////////////////////////////////////////
    26682668  setring R;
    2669  
     2669
    26702670  W = 2,2,2,2;
    2671  
     2671
    26722672  setBaseMultigrading(W);
    26732673
     
    26792679
    26802680  kill w;
    2681  
     2681
    26822682
    26832683  def h = hilbertSeries(I2); setring h;
    26842684
    2685  
     2685
    26862686  numerator1; denominator1;
    26872687  kill h;
    26882688
    2689  
     2689
    26902690  kill R, W;
    26912691
     
    27042704
    27052705  hilb(std(I));
    2706  
     2706
    27072707  def h = hilbertSeries(I); setring h;
    27082708
     
    27202720
    27212721  numerator1; denominator1;
    2722  
    2723   kill h; 
    2724   ////////////////////////////////////////////////
    2725   setring R;
    2726 
    2727   I = x^5; I;
    2728 
    2729   hilb(std(I));
    2730   hilb(std(I), 1);
    2731 
    2732   def h = hilbertSeries(I); setring h;
    2733 
    2734   numerator1; denominator1;
    2735  
    2736  
    2737   kill h; 
    2738   ////////////////////////////////////////////////
    2739   setring R;
    2740 
    2741   I = x^10; I;
    2742 
    2743   hilb(std(I));
    2744 
    2745   def h = hilbertSeries(I); setring h;
    2746 
    2747   numerator1; denominator1;
    27482722
    27492723  kill h;
     
    27512725  setring R;
    27522726
    2753   module M = 1;
    2754 
    2755   M = setModuleGrading(M, W);
    2756 
    2757  
    2758   hilb(std(M));
    2759 
    2760   def h = hilbertSeries(M); setring h;
     2727  I = x^5; I;
     2728
     2729  hilb(std(I));
     2730  hilb(std(I), 1);
     2731
     2732  def h = hilbertSeries(I); setring h;
    27612733
    27622734  numerator1; denominator1;
     2735
    27632736
    27642737  kill h;
     
    27662739  setring R;
    27672740
    2768   kill M; module M = x^5*gen(1);
    2769 
    2770 //  intmat V[1][3] = 0; // TODO: this would lead to a wrong result!!!?
    2771 
    2772   intmat V[1][1] = 0; // all gen(i) of degree 0!
    2773 
    2774   M = setModuleGrading(M, V);
    2775 
    2776   hilb(std(M));
    2777 
    2778   def h = hilbertSeries(M); setring h;
     2741  I = x^10; I;
     2742
     2743  hilb(std(I));
     2744
     2745  def h = hilbertSeries(I); setring h;
    27792746
    27802747  numerator1; denominator1;
     
    27822749  kill h;
    27832750  ////////////////////////////////////////////////
    2784   setring R;
    2785 
    2786   module N = x^5*gen(3);
    2787 
    2788   kill V;
    2789  
    2790   intmat V[1][3] = 0; // all gen(i) of degree 0!
    2791 
    2792   N = setModuleGrading(N, V);
    2793      
    2794   hilb(std(N));
    2795 
    2796   def h = hilbertSeries(N); setring h;
     2751  setring R;
     2752
     2753  module M = 1;
     2754
     2755  M = setModuleGrading(M, W);
     2756
     2757
     2758  hilb(std(M));
     2759
     2760  def h = hilbertSeries(M); setring h;
    27972761
    27982762  numerator1; denominator1;
     
    28002764  kill h;
    28012765  ////////////////////////////////////////////////
    2802   setring R;
    2803 
    2804  
     2766  setring R;
     2767
     2768  kill M; module M = x^5*gen(1);
     2769
     2770//  intmat V[1][3] = 0; // TODO: this would lead to a wrong result!!!?
     2771
     2772  intmat V[1][1] = 0; // all gen(i) of degree 0!
     2773
     2774  M = setModuleGrading(M, V);
     2775
     2776  hilb(std(M));
     2777
     2778  def h = hilbertSeries(M); setring h;
     2779
     2780  numerator1; denominator1;
     2781
     2782  kill h;
     2783  ////////////////////////////////////////////////
     2784  setring R;
     2785
     2786  module N = x^5*gen(3);
     2787
     2788  kill V;
     2789
     2790  intmat V[1][3] = 0; // all gen(i) of degree 0!
     2791
     2792  N = setModuleGrading(N, V);
     2793
     2794  hilb(std(N));
     2795
     2796  def h = hilbertSeries(N); setring h;
     2797
     2798  numerator1; denominator1;
     2799
     2800  kill h;
     2801  ////////////////////////////////////////////////
     2802  setring R;
     2803
     2804
    28052805  module S = M + N;
    2806  
     2806
    28072807  S = setModuleGrading(S, V);
    28082808
Note: See TracChangeset for help on using the changeset viewer.