Changeset 9cf556a in git


Ignore:
Timestamp:
Feb 23, 2015, 7:41:45 PM (9 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
Children:
d41983a767c9bf708fbafc7dab33313946211698
Parents:
8be7a45ea5f7a9d57fce858bc39c53bb88fbe2bf
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2015-02-23 19:41:45+01:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2015-02-23 19:55:29+01:00
Message:
Fix grdeg to handle zero columns (set attrib("degHomog") by grobj)

chg: cleanup
add: gtranspose?
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/gradedModules.lib

    r8be7a45 r9cf556a  
    11///////////////////////////////////////////////////////////////////////////
    22version="version gradedModules.lib 4.0.1.1 Jan_2015 "; // $Id$
    3 category="General purpose?";
     3category="Commutative Algebra";
    44info="
    55LIBRARY: gradedModules.lib     Operations with graded modules/matrices/resolutions
    66AUTHORS:  Oleksandr Motsak <U@D>, where U=motsak, D=mathematik.uni-kl.de
    7 @*         Hanieh Keneshlou <hkeneshlou@yahoo.com>
     7@*        Hanieh Keneshlou <hkeneshlou@yahoo.com>
    88KEYWORDS: graded modules, graded homomorphisms, syzygies
    99OVERVIEW:
    10     The library contains several procedures for operations with graded modules/matrices/resolutions
    11     TODO!
     10    The library contains several procedures for constructing and manipulating graded modules/matrices/resolutions.
     11NOTE:
     12    set assumeLevel to positive integer value in order to auto-check all assumptions.
    1213REFERENCES:
    1314[MO]   Motsak, O.: Non-commutative Computer Algebra with applications: Graded commutative algebra and related
    14        structures in Singular with applications, Ph.D. thesis, TU Kaiserslautern, 2010 TODO!?
     15       structures in Singular with applications, Ph.D. thesis, TU Kaiserslautern, 2010
    1516PROCEDURES:
    1617    grzero()        presentation of basering(0)^1
     
    3637static proc pad(int m, string s, string c){ string r = s; while( size(r) < m ){ r = c + r; } return(r); }
    3738static proc mstring( int m, string c){ if( m < 0 ) { return (c); }; return (string(m)); }
    38 static proc zstring( int m, int b, string c){ if(b) { return (c); }; return (string(m)); }
    3939// view helper
    40 static proc draw ( intmat D, intvec zc, int d )
     40static proc draw ( intmat D, int d )
    4141{
    4242//  print(D); return ();
     
    5050  {
    5151    head = head + pad(max, string(D[1 , c]), " ") + " ";
    52     foot = foot + pad(max, zstring(D[nr, c], zc[c - d], "?"), " ") + " ";
     52    foot = foot + pad(max, string(D[nr, c]), " ") + " ";
    5353  }
    5454  // last head/foot enties:
    5555  head = head + pad(max, string(D[1 , c]), " ");
    56   foot = foot + pad(max, zstring(D[nr, c], zc[c-d], "?"), " ");
     56  foot = foot + pad(max, string(D[nr, c]), " ");
    5757  // head/foot dash lines:
    5858  string dash  = repeat( (max + 1) * (nc - 2*d) , "-");
     
    7474}
    7575
    76 proc grview(def N)
    77 "
    78 PURPOSE: print the degree/grading data about the GRADED matrix/module/ideal N
     76proc grview(N)
     77"USAGE:  grview(M), graded object M
     78RETURN:  nothing
     79PURPOSE: print the degree/grading data about the GRADED matrix/module/ideal/mapping object M             
     80ASSUME:  M must be graded
     81EXAMPLE: example grsum; shows an example
    7982"
    8083{
     
    8992//  typeof( N ) ;  attrib( N );  attrib(N, "isHomog");
    9093
    91   ASSUME(0, /* input must be graded! */ typeof(attrib(N, "isHomog")) == "intvec" );
    92 
    9394  // input should be graded:
    94   intvec gr = attrib(N, "isHomog"); // grading weights?
    95   ASSUME(0, /* input must be correctly graded! */ nrows(N) == size(gr) );
    96 
    97 //  intvec gr = attrib( N, "isHomog" ); //  module(N); "grading: ", gr;
    98 
     95  ASSUME(1, grtest(N) );
     96 
     97  intvec G = grdeg(N);
    9998  matrix M = module(N);
     99 
    100100  int nc = ncols(M); int nr = nrows(M);
    101101  int r,c;
     
    103103  intmat D[nr+2*d][nc+2*d];
    104104
    105   module L = module(N); L = lead(L); vector v;
    106   int m = 1 + nvars(basering);
    107   intvec zc = 0:nc;
    108105  for( c = nc; c > 0; c-- )
    109106  {
    110107    D[1, c+d] = c; // top row indeces
    111     v = L[c];
    112     if( v != 0 )
    113     {
    114       D[nr+2*d, c+d] = deg(v) + gr[ leadexp(v)[m] ]; // bottom row with computed column induced degrees
    115     } else
    116     {
    117 //      D[nr+2*d, c+d] = 0; // TODO: 0/-1 is valid :(
    118       zc[c] = 1;
    119     }
    120   }
     108    D[nr+2*d, c+d] = G[c]; // deg(v) + gr[ leadexp(v)[m] ]; // bottom row with computed column induced degrees
     109  }
     110
     111  intvec gr = attrib(N, "isHomog"); // grading weights?
    121112
    122113  for( r = nr; r > 0; r-- )
     
    129120    D[r+d, nc+2*d] = r; // right-most block with indeces
    130121  }
    131   draw(D, zc, d); // print it nicely!
     122  draw(D, d); // print it nicely!
    132123}
    133124
     
    200191
    201192// Q@Wolfram: what should be done with zero gens!?
    202 proc grdeg( def M, list # )
    203 "graded degrees of gens(i.e. columns)"
    204 {
    205  // use initial grading if given
    206   if( size(#) == 1 )
    207   {
    208     def w = #[1];
    209     if( typeof(w) == "intvec" )
    210     {
    211       if( nrows(M) == size(w) )
    212       {
    213         attrib(M, "isHomog", w);
    214       }
    215     }
    216     kill w;
    217   }
    218 
     193proc grdeg(M)
     194"USAGE:  grdeg(M), graded object M
     195RETURN:  intvec of degrees
     196PURPOSE: graded degrees of columns (generators) of M
     197ASSUME:  M must be a graded object (matrix/module/ideal/mapping)
     198NOTE:    if M has zero cols it shoud have attrib(M,'degHomog') set.
     199EXAMPLE: example grsum; shows an example
     200"
     201{           
    219202  ASSUME(1, grtest(M) );
    220203
     204  if ( typeof(attrib(M, "degHomog")) == "intvec" )
     205  {   
     206    intvec t = attrib(M, "degHomog"); // graded degrees
     207    ASSUME(0, ncols(M) == size(t) );
     208
     209    return (t);
     210  }
     211 
     212  ASSUME(0, ncols(M) == size(M) );
     213 
    221214  def w = attrib(M, "isHomog"); // grading weights?
    222215
     
    230223  intvec c = leadexp(L[1..m])[n]; // their module-components
    231224
    232   w = intvec(-6665, w); // 0?????
    233   intvec gr = w[1+c]; // weights
     225//   w = intvec(-6665), w; // 0?????
     226  intvec gr = w[c]; //  + 1]; // weights?????
    234227
    235228  gr = gr + d; // finally we compute their graded degrees
    236229
    237   return (gr); // do we need g or w[c] ?
     230  return (gr);
    238231}
    239232
     
    257250  ASSUME(1, issorted(gr[pivot], s));
    258251
    259   module N = grobj(module(M[pivot]), w);  // reorder the starting ideal/module
     252  module N = grobj(module(M[pivot]), w, intvec(gr[pivot]));  // reorder the starting ideal/module
    260253
    261254//  "reorder: "; grview(N);
     
    264257}
    265258
     259static proc gtranspose(M)
     260"??????"
     261{   
     262  ASSUME(1, grtest(M) );
     263  return (  grobj(transpose(M), -grdeg(M), -attrib(M, "isHomog"))  );
     264}
     265
     266
    266267proc grtranspose(def M)
    267268"
    268 transpose graded module/map or a chain complex?...
     269transpose&reorder graded module/map or a chain complex?...
    269270"
    270271{
     
    311312  ASSUME(1, grtest(M) );
    312313
    313   // TODO: something is wrong here:
    314 
    315314 intvec d; module N;
    316315
    317316 (N,d) = reorder(M, -1);
    318317
    319  kill M; module M = grobj(transpose(N), -d);
     318 kill M; module M = grobj(transpose(N), -d, -attrib(N, "isHomog"));
    320319
    321320// "b";  grview(M);
     
    333332 return (N);
    334333}
    335 
    336 
    337334
    338335proc grorder(def M)
     
    382379  (N,d) = reorder(M, 1); kill M;
    383380
    384   module M = grobj(transpose(N), -d); kill N,d;
     381  module M = grobj(transpose(N), -d, -attrib(N, "isHomog")); kill N,d;
    385382
    386383// "b";  grview(M);
     
    390387  (N,d) = reorder(M, -1); kill M;
    391388
    392   module M = grobj(transpose(N), -d);
     389  module M = grobj(transpose(N), -d, -attrib(N, "isHomog"));
    393390
    394391// "c";  grview(M);
     
    471468"
    472469{
    473  return ( grobj(module([0]), intvec(0)) );
     470 return ( grobj(module([0]), intvec(0), intvec(0)) );
    474471}
    475472
     
    515512  module S = module(A), T;
    516513
    517   return(grobj(S, c));
     514  intvec da = grdeg(A);
     515  intvec db = grdeg(B);
     516  intvec dc = da, db;
     517
     518  return(grobj(S, c, dc));
    518519}
    519520example
     
    580581"
    581582{
     583  ASSUME(1, grtest(M) );
     584 
    582585  intvec a = attrib(M, "isHomog");
    583   return (grobj(M, intvec( a - intvec(d:size(a))) ));
    584 }
    585 
     586  a = a - intvec(d:size(a));
     587 
     588  intvec t = attrib(M, "degHomog");
     589  t = t - intvec(d:size(t));
     590 
     591  return (grobj(M, a, t));
     592}
     593
     594
     595proc grisequal (def A, def B)
     596"
     597   TODO
     598"
     599{
     600  ASSUME(1, grtest(A) );
     601  ASSUME(1, grtest(B) );
     602
     603  int ra = nrows(A);
     604  int rb = nrows(B);
     605
     606  intvec wa = attrib(A, "isHomog");
     607  intvec wb = attrib(B, "isHomog");
     608
     609  if( (ra != rb) || (ncols(A) != ncols(B)) ){ return (0); } // TODO: ???
     610
     611  intvec da = grdeg(A);
     612  intvec db = grdeg(B);
     613 
     614  return ( (da == db) && (wa == wb) &&
     615           (size(module(matrix(A) - matrix(B))) == 0)    ); // TODO: ???
     616}
     617
     618proc grtwist(int a, int d)
     619"
     620    matrix presentation for twisted polynomial ring S(d)^a
     621"
     622{
     623  ASSUME(0, a > 0);
     624 
     625  module Z; Z[a] = [0];
     626  intvec w = -intvec(d:a);
     627  Z = grobj(Z, w, w); // will set the rank as well
     628  ASSUME(2, grisequal(Z, grpower( grshift(grzero(), d), a ) )); // optional check
     629  return(Z);
     630}
     631
     632proc grobj(def A, intvec w, list #)
     633"
     634   TODO
     635"
     636{
     637  module M = module(A);
     638  ASSUME(0, size(w) >= nrows(M) );
     639 
     640  attrib(M, "rank", size(w));
     641  attrib(M, "isHomog", w);
     642
     643  if( size(#) > 0 )
     644  {
     645    ASSUME(0, typeof(#[1]) == "intvec" );
     646    ASSUME(0, size(#[1]) == ncols(M) );
     647    attrib(M, "degHomog", #[1]);
     648  }
     649  else
     650  {
     651    ASSUME(0, /* no zero cols please! */ size(M) == ncols(M) );
     652    attrib(M, "degHomog", grdeg(M));
     653  }   
     654
     655  ASSUME(0, grtest(M) );
     656  return (M);
     657}
    586658
    587659proc grtest(def N)
     
    595667
    596668  intvec gr = attrib(N, "isHomog"); // grading weights...
    597   if ( nrows(N) > size(gr) ) { return (0); };  // wrong number of rows?
     669  if ( nrows(N) != size(gr) ) { return (0); };  // wrong number of rows?
    598670
    599671//  if( attrib(N, "rank") != size(gr) ){ return (0); } // wrong rank :(
    600672
    601 
     673  if ( typeof(attrib(N, "degHomog")) == "intvec" )
     674  {
     675    intvec T = attrib(N, "degHomog"); // graded degrees
     676    if ( ncols(N) != size(T) ) { return (0); };  // wrong number of cols?
     677
     678    int k = nvars(basering) + 1; // index of mod. column in the leadexp
     679
     680    module L = lead(module(N)); vector v;
     681
     682    // checking T for non-zero N[i]
     683    int i = size(T);
     684   
     685    for (; i > 0; i-- )
     686    {
     687      v = L[i];
     688      if( v != 0 )
     689      {
     690        if( (deg(v) + gr[ leadexp(v)[k] ]) != T[i] ) { return (0); };  // wrong T[i]       
     691      }
     692    }
     693
     694    // TODO: check t on nonzero cols...
     695  } else
     696  {
     697    if( ncols(N) != size(N) ) { return (0); };
     698  }
     699 
    602700//  if( !homog(N) ) { return (0); };  // N should be homogenous
    603701
    604 
    605702  return (1);
    606703}
    607 
    608 proc grisequal (def A, def B)
    609 "TODO"
    610 {
    611   ASSUME(1, grtest(A) );
    612   ASSUME(1, grtest(B) );
    613 
    614   int ra = nrows(A);
    615   int rb = nrows(B);
    616 
    617   intvec wa = attrib(A, "isHomog");
    618   intvec wb = attrib(B, "isHomog");
    619 
    620   if( (ra != rb) || (ncols(A) != ncols(B)) ){ return (0); } // TODO: ???
    621   return ( (wa == wb) &&
    622            (size(module(matrix(A) - matrix(B))) == 0)    ); // TODO: ???
    623 }
    624 
    625 proc grtwist(int a, int d)
    626 "
    627 matrix presentation for twisted polynomial ring S(d)^a
    628 "
    629 {
    630   module Z; Z[a] = [0];
    631   Z = grobj(Z, -intvec(d:a)); // will set the rank as well
    632 
    633   ASSUME(2, grisequal(Z, grpower( grshift(grzero(), d), a ) )); // optional check
    634   return(Z);
    635 }
    636 
    637 proc grobj(def A, intvec w)
    638 ""
    639 {
    640   module M = module(A);
    641   ASSUME(0, size(w) >= nrows(M) );
    642   attrib(M, "rank", size(w));
    643   attrib(M, "isHomog", w);
    644   ASSUME(1, grtest(M) );
    645   return (M);
    646 }
    647 
     704   
    648705
    649706static proc align( def A, int d)
Note: See TracChangeset for help on using the changeset viewer.