Changeset 821b26 in git


Ignore:
Timestamp:
Apr 10, 2009, 9:28:58 PM (15 years ago)
Author:
Motsak Oleksandr <motsak@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38dfc5131670d387a89455159ed1e071997eec94')
Children:
71a293d2c41550db6c408d972d02ee810465fbfa
Parents:
88e5d02561990a0b8b126978b31a19f6dcb68b1c
Message:
*motsak: new experimental sheaf-cohomology-related stuff


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/sheafcoh.lib

    r88e5d0 r821b26  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: sheafcoh.lib,v 1.16 2009-04-07 16:18:06 seelisch Exp $";
     2version="$Id: sheafcoh.lib,v 1.17 2009-04-10 19:28:58 motsak Exp $";
    33category="Commutative Algebra";
    44info="
     
    1010PROCEDURES:
    1111 truncate(phi,d);        truncation of coker(phi) at d
     12 truncateFast(phi,d);    truncation of coker(phi) at d (fast+ experimental)
    1213 CM_regularity(M);       Castelnuovo-Mumford regularity of coker(M)
    1314 sheafCohBGG(M,l,h);     cohomology of sheaf associated to coker(M)
     
    1516 sheafCoh(M,l,h);        cohomology of sheaf associated to coker(M)
    1617 dimH(i,M,d);            compute h^i(F(d)), F sheaf associated to coker(M)
     18 dimGradedPart()
    1719
    1820AUXILIARY PROCEDURES:
     
    2628LIB "nctools.lib";
    2729LIB "homolog.lib";
     30
     31
     32///////////////////////////////////////////////////////////////////////////////
     33// testing for consistency of the library:
     34proc testSheafCohLibrary()
     35{
     36  printlevel = printlevel + 1;
     37  example truncate;
     38  example truncateFast;
     39  example CM_regularity;
     40  example sheafCoh;
     41  example sheafCohBGG;
     42  example dimH;
     43  example dimGradedPart;
     44  example sheafCohBGG2;
     45  example getStructureSheaf;
     46  printlevel = printlevel - 1;
     47}
     48
     49
    2850
    2951///////////////////////////////////////////////////////////////////////////////
     
    4062}
    4163
    42 // returns transposed Jacobian of a module M
    43 static proc tJacobian(module M)
    44 {
    45   M = transpose(M);
    46 
    47   int N = nvars(basering);
    48   int k = ncols(M);
    49   int r = nrows(M);
    50 
    51   module Result;
    52   Result[N*k] = 0;
    53 
    54   int i, j;
    55   int l = 1;
    56 
    57   for( j = 1; j <= N; j++ ) // for all variables
    58   {
    59     for( i = 1; i <= k; i++ ) // for every v \in transpose(M)
    60     {
    61       Result[l] = diff(M[i], var(j));
    62       l++;
    63     }
    64   }
    65 
    66   return(Result);
    67 }
    68 
    69 
     64
     65///////////////////////////////////////////////////////////////////////////////
    7066/**
    7167  let M = { w_1, ..., w_k }, k = size(M) == ncols(M), n = nvars(currRing).
     
    9187static proc TensorModuleMult(int m, module M)
    9288{
     89  return( system("tensorModuleMult", m, M) ); // trick!
     90
    9391  int n = nvars(basering);
    9492  int k = ncols(M);
     
    142140  return(j);
    143141}
     142
     143///////////////////////////////////////////////////////////////////////////////
     144static proc min(int i,int j)
     145{
     146  if(i>j){return(j);}
     147  return(i);
     148}
     149
    144150
    145151///////////////////////////////////////////////////////////////////////////////
     
    171177  int i,m,dummy;
    172178  int s = nrows(phi);
    173   module L;
     179  module L; // TOO BIG!!!
    174180  for (i=1; i<=s; i++) {
    175181    if (d>v[i]) {
     
    218224///////////////////////////////////////////////////////////////////////////////
    219225
     226proc truncateFast(module M, int d)
     227"USAGE:   truncateFast(M,d);  M module, d int
     228ASSUME:  @code{M} is graded, and it comes assigned with an admissible degree
     229         vector as an attribute 'isHomog'
     230RETURN:  module
     231NOTE:    Output is a presentation matrix for the truncation of coker(M)
     232         at d.
     233         Fast + experimental version. M shoud be a SB!
     234DISPLAY: If @code{printlevel}>=1, step-by step timings will be printed.
     235         If @code{printlevel}>=2 we add progress debug messages
     236         if @code{printlevel}>=3, even all intermediate results...
     237EXAMPLE: example truncateFast; shows an example
     238KEYWORDS: truncated module
     239"
     240{
     241//  int PL = printlevel + 1;
     242  int PL = printlevel - voice + 2;
     243
     244  dbprint(PL-1, "// truncateFast(M: "+ string(nrows(M)) + " x " + string(ncols(M)) +", " + string(d) + "):");
     245  dbprint(PL-2, M);
     246 
     247  intvec save = option(get);
     248  if( PL >= 2 )
     249  {
     250    option(prot);   
     251    option(mem);   
     252  }
     253
     254  int tTruncateBegin=timer;
     255
     256  if (attrib(M,"isSB")!=1)
     257  {
     258    ERROR("M must be a standard basis!");
     259  };
     260
     261  dbprint(PL-1, "// M is a SB! ");
     262
     263  if ( typeof(attrib(M,"isHomog"))=="string" ) {
     264    if (size(M)==0) {
     265      // assign weights 0 to generators of R^n (n=nrows(M))
     266      intvec v;
     267      v[nrows(M)]=0;
     268      attrib(M,"isHomog",v);
     269    }
     270    else {
     271      ERROR("No admissible degree vector assigned");
     272    }
     273  }
     274  else {
     275   intvec v=attrib(M,"isHomog");
     276  }
     277
     278  dbprint(PL-1, "// weighting(M): ["+ string(v) + "]");
     279
     280  int i,m,dummy;
     281  int s = nrows(M);
     282
     283   int tKBaseBegin = timer;
     284    module L = kbase(M, d); // TODO: check whether this is always correct!?!
     285
     286
     287    dbprint(PL-1, "// L = kbase(M,d): "+string(nrows(L)) + " x " + string(ncols(L)) +"");
     288    dbprint(PL-2, L);
     289    dbprint(PL-1, "// weighting(L): ["+ string(attrib(L, "isHomog")) + "]");
     290
     291   int tModuloBegin = timer;
     292    L = modulo(L,M);
     293
     294    dbprint(PL-1, "// L = modulo(L,M): "+string(nrows(L)) + " x " + string(ncols(L)) +"");
     295    dbprint(PL-2, L);
     296    dbprint(PL-1, "// weighting(L): ["+ string(attrib(L, "isHomog")) + "]");
     297
     298   int tPruneBegin = timer;
     299    L = prune(L);
     300
     301    dbprint(PL-1, "// L = prune(L): "+string(nrows(L)) + " x " + string(ncols(L)) +"");
     302    dbprint(PL-2, L);
     303    dbprint(PL-1, "// weighting(L): ["+ string(attrib(L, "isHomog")) + "]");
     304
     305   int tPruneEnd = timer;
     306    L = minbase(L);
     307   int tMinBaseEnd = timer;
     308
     309    dbprint(PL-1, "// L = minbase(L): "+string(nrows(L)) + " x " + string(ncols(L)) +"");
     310    dbprint(PL-2, L);
     311    dbprint(PL-1, "// weighting(L): ["+ string(attrib(L, "isHomog")) + "]");
     312
     313
     314
     315
     316  if (size(L)!=0)
     317  {
     318
     319    // it only remains to set the degrees for L:
     320    // ------------------------------------------
     321    m = v[1];
     322    for(i=2; i<=size(v); i++) {  if(v[i]<m) { m = v[i]; } }
     323    dummy = homog(L);
     324    intvec vv = attrib(L,"isHomog");
     325    if (d>m) { vv = vv+d; }
     326    else     { vv = vv+m; }
     327    attrib(L,"isHomog",vv);
     328  }
     329
     330  int tTruncateEnd=timer;
     331 
     332  dbprint(PL-1, "// corrected weighting(L): ["+ string(attrib(L, "isHomog")) + "]");
     333
     334
     335  if(PL > 0)
     336  {
     337  "
     338  -------------- TIMINGS --------------
     339  Trunc        Time: ", tTruncateEnd - tTruncateBegin, "
     340    :: Before .Time: ", tKBaseBegin - tTruncateBegin, "
     341    :: kBase   Time: ", tModuloBegin - tKBaseBegin, "
     342    :: Modulo  Time: ", tPruneBegin - tModuloBegin, "
     343    :: Prune   Time: ", tPruneEnd - tPruneBegin, "
     344    :: Minbase Time: ", tMinBaseEnd - tPruneEnd, "
     345    :: After  .Time: ", tTruncateEnd - tMinBaseEnd;
     346  }
     347 
     348  option(set, save);
     349
     350  return(L);
     351}
     352example
     353{"EXAMPLE:";
     354   echo = 2;
     355   ring R=0,(x,y,z,u,v),dp;
     356   module M=maxideal(3);
     357   homog(M);
     358   // compute presentation matrix for truncated module (R/<x,y,z,u>^3)_(>=2)
     359   int t=timer;
     360   module M2t=truncate(M,2);
     361   t = timer - t;
     362   "// Simple truncate: ", t;
     363   t=timer;
     364   module M2=truncateFast(std(M),2);
     365   t = timer - t;
     366   "// Fast truncate: ", t;
     367   print(M2);
     368   "// Check: M2t == M2?: ", size(NF(M2, std(M2t))) + size(NF(M2t, std(M2)));
     369
     370   dimGradedPart(M2,1);
     371   dimGradedPart(M2,2);
     372   // this should coincide with:
     373   dimGradedPart(M,2);
     374   // shift grading by 1:
     375   intvec v=1;
     376   attrib(M,"isHomog",v);
     377   t=timer;
     378   M2t=truncate(M,2);
     379   t = timer - t;
     380   "// Simple truncate: ", t;
     381   t=timer;
     382   M2=truncateFast(std(M),2);
     383   t = timer - t;
     384   "// Fast truncate: ", t;
     385   print(M2);
     386   "// Check: M2t == M2?: ", size(NF(M2, std(M2t))) + size(NF(M2t, std(M2))); //?
     387   dimGradedPart(M2,3);
     388}
     389
     390///////////////////////////////////////////////////////////////////////////////
     391
     392
     393
     394
     395
    220396proc dimGradedPart(module phi, int d)
    221397"USAGE:   dimGradedPart(M,d);  M module, d int
     
    304480    }
    305481  }
    306   def L = mres(M,0);
     482 
     483  if( attrib(CM_regularity,"Algorithm") != "mres" )
     484  {
     485    def L = minres( res(M,0) ); // let's try it out!
     486  } else
     487  {
     488    def L = mres(M,0);
     489  }
     490 
    307491  intmat BeL = betti(L);
    308492  int r = nrows(module(matrix(BeL)));  // last non-zero row
     
    445629}
    446630
     631
     632///////////////////////////////////////////////////////////////////////////////
     633static proc showResult( def R, int l, int h )
     634{
     635  int PL = printlevel - voice + 2;
     636// int PL = printlevel + 1;
     637
     638  intmat Betti;
     639  if(typeof(R)=="resolution")
     640  {
     641    Betti = betti(R);
     642  } else
     643  {
     644    if(typeof(R)!="intmat")
     645    {
     646      ERROR("Wrong input!!!");
     647    };
     648
     649    Betti = R; 
     650  } 
     651
     652  int n=nvars(basering)-1;
     653  int ell = l + n;
     654
     655  int k     = ncols(Betti);
     656  int row   = nrows(Betti);
     657  int shift = attrib(Betti,"rowShift") + (k + ell - 1);
     658
     659  intmat newBetti[ n + 1 ][ h - l + 1 ];
     660
     661  int i, j;
     662
     663  for (j=1; j<=row; j++) {
     664    for (i=l; i<=h; i++) {
     665      if( (n+2-shift-j)>0 ) {
     666
     667        if (  (k+1-j-i+ell-shift>0) and (j+i-ell+shift>=1)) {
     668          newBetti[n+2-shift-j,i-l+1]=Betti[j,k+1-j-i+ell-shift];
     669        }
     670        else { newBetti[n+2-shift-j,i-l+1]=-1; }
     671
     672      }
     673    }
     674  }
     675
     676  int iWTH = h-l+1;
     677  for (j=2; j<=n+1; j++) {
     678    for (i=1; i<min(j, iWTH); i++) {
     679      newBetti[j,i]=-1;
     680    }
     681  }
     682  int d = k - h + ell - 1;
     683  for (j=1; j<=n; j++) {
     684    for (i=iWTH; i>=k+j; i--) {
     685      newBetti[j,i]=-1;
     686    }
     687  }
     688
     689  if( PL > 0 )
     690  {
     691    "Cohomology table:";
     692    displayCohom(newBetti, l, h, n);
     693  }
     694
     695  return(newBetti);
     696}
     697///////////////////////////////////////////////////////////////////////////////
     698
     699
     700
    447701///////////////////////////////////////////////////////////////////////////////
    448702proc sheafCohBGG2(module M,int l,int h)
     
    468722         refers to a negative entry (= dimension not yet determined).
    469723         refers to a not computed dimension. @*
     724         If @code{printlevel}>=1, step-by step timings will be printed.
     725         If @code{printlevel}>=2 we add progress debug messages
     726         if @code{printlevel}>=3, even all intermediate results...
    470727NOTE:    This procedure is based on the Bernstein-Gel'fand-Gel'fand
    471728         correspondence and on Tate resolution ( see [Eisenbud, Floystad,
     
    480737"
    481738{
     739  int PL = printlevel - voice + 2;
     740//  int PL = printlevel;
     741
     742  dbprint(PL-1, "// sheafCohBGG2(M: "+ string(nrows(M)) + " x " + string(ncols(M)) +", " + string(l) + ", " + string(h) + "):");
     743  dbprint(PL-2, M);
     744
     745  intvec save = option(get);
     746 
     747  if( PL >= 2 )
     748  {
     749    option(prot);   
     750    option(mem);   
     751  }
     752
     753  def isCoker = attrib(M, "isCoker");
     754  if( typeof(isCoker) == "int" )   
     755  {
     756    if( isCoker > 0 )
     757    {
     758      dbprint(PL-1, "We are going to assume that M is given by coker matrix (that is, M is not a submodule presentation!)");
     759    }
     760  }
     761
     762           
    482763  int i,j,k,row,col;
     764 
    483765  if( typeof(attrib(M,"isHomog"))!="intvec" ) {
    484766     if (size(M)==0) { attrib(M,"isHomog",0); }
    485767     else { ERROR("No admissible degree vector assigned"); }
    486768  }
    487   intvec ivOptionsSave = option(get);
     769
     770  dbprint(PL-1, "// weighting(M): ["+ string(attrib(M, "isHomog")) + "]");
     771 
    488772  option(redSB); option(redTail);
    489773
    490   int n=nvars(basering)-1;
    491   int ell=l+n;
    492774  def R=basering;
    493   int reg = CM_regularity(M);
    494   int bound=max(reg+1,h-1);
    495   module MT=truncate(M,bound);
     775
     776  int n = nvars(R) - 1;
     777  int ell = l + n;
     778
     779 
     780/////////////////////////////////////////////////////////////////////////////
     781// computations
     782
     783  int tBegin=timer;
     784  int reg   = CM_regularity(M);
     785  int tCMEnd = timer;
     786
     787  dbprint(PL-1, "// CM_reg(M): "+ string(reg));
     788
     789  int bound = max(reg + 1, h - 1);
     790
     791  dbprint(PL-1, "// bound: "+ string(bound));
     792
     793  ///////////////////////////////////////////////////////////////
     794  int tSTDBegin=timer;
     795  M = std(M); // for kbase! // NOTE: this should be after CM_regularity, since otherwise CM_regularity computes JUST TOOOOOOO LONG sometimes (see Reg_Hard examples!)
     796  int tSTDEnd = timer;
     797
     798  dbprint(PL-1, "// M = std(M: "+string(nrows(M)) + " x " + string(ncols(M))  + ")");
     799  dbprint(PL-2, M);
     800  dbprint(PL-1, "// weighting(M): ["+ string(attrib(M, "isHomog")) + "]"); 
     801
     802
     803  printlevel = printlevel + 1;
     804  int tTruncateBegin=timer;
     805  module MT = truncateFast(M, bound);
     806  int tTruncateEnd=timer;
     807  printlevel = printlevel - 1;
     808
     809  dbprint(PL-1, "// MT = truncateFast(M: "+string(nrows(MT)) + " x " + string(ncols(MT)) +", " + string(bound) + ")");
     810  dbprint(PL-2, MT);
     811  dbprint(PL-1, "// weighting(MT): ["+ string(attrib(MT, "isHomog")) + "]"); 
     812 
    496813  int m=nrows(MT);
    497   MT = tJacobian(MT); // transpose(jacobM(MT));
    498   MT=syz(MT);
    499 
     814
     815  ///////////////////////////////////////////////////////////////
     816  int tTransposeJacobBegin=timer;
     817  MT = jacob(MT); // ! :(
     818  int tTransposeJacobEnd=timer;
     819
     820
     821  dbprint(PL-1, "// MT = jacob(MT: "+string(nrows(MT)) + " x " + string(ncols(MT))  + ")");
     822  dbprint(PL-2, MT);
     823  dbprint(PL-1, "// weighting(MT): ["+ string(attrib(MT, "isHomog")) + "]"); 
     824 
     825
     826  int tSyzBegin=timer;
     827  MT = syz(MT);
     828  int tSyzEnd=timer;
     829
     830
     831  dbprint(PL-1, "// MT = syz(MT: "+string(nrows(MT)) + " x " + string(ncols(MT))  + ")");
     832  dbprint(PL-2, MT);
     833  dbprint(PL-1, "// weighting(MT): ["+ string(attrib(MT, "isHomog")) + "]"); 
     834
     835 
     836  int tMatrixOppBegin=timer;
    500837  module SS = TensorModuleMult(m, MT);
    501 
     838  int tMatrixOppEnd=timer; 
     839
     840  dbprint(PL-1, "// SS = TensorModuleMult("+ string(m)+ ", MT: "+string(nrows(MT)) + " x " + string(ncols(MT))  + ")");
     841  dbprint(PL-2, SS);
     842  dbprint(PL-1, "// weighting(SS): ["+ string(attrib(SS, "isHomog")) + "]"); 
     843 
     844 
    502845  //--- to the exterior algebra
    503846  def AR = Exterior(); setring AR;
    504847
     848  dbprint(PL-1, "// Test: var(1) * var(1): "+ string(var(1) * var(1)));
     849
     850  int maxbound = max(1, bound - ell + 1);
     851//  int maxbound = max(1, bound - l + 1); // As In M2!!!
     852
     853  dbprint(PL-1, "// maxbound: "+ string(maxbound));
     854 
     855  //--- here we are with our matrix
    505856  module EM=imap(R,SS);
    506857  intvec w;
    507   //--- here we are with our matrix
    508   int bound1=max(1,bound-ell+1);
    509858  for (i=1; i<=nrows(EM); i++)
    510859  {
    511860     w[i]=-bound-1;
    512861  }
     862
    513863  attrib(EM,"isHomog",w);
    514   resolution RE = minres(nres(EM,bound1));
    515   intmat Betti=betti(RE);
    516   k=ncols(Betti);
    517   row=nrows(Betti);
    518   int shift=attrib(Betti,"rowShift")+(k+ell-1);
    519   intmat newBetti[n+1][h-l+1];
    520   for (j=1; j<=row; j++) {
    521     for (i=l; i<=h; i++) {
    522       if ((k+1-j-i+ell-shift>0) and (j+i-ell+shift>=1)) {
    523         newBetti[n+2-shift-j,i-l+1]=Betti[j,k+1-j-i+ell-shift];
    524       }
    525       else { newBetti[n+2-shift-j,i-l+1]=-1; }
    526     }
    527   }
    528   for (j=2; j<=n+1; j++) {
    529     for (i=1; i<j; i++) {
    530       newBetti[j,i]=-1;
    531     }
    532   }
    533   int d=k-h+ell-1;
    534   for (j=1; j<=n; j++) {
    535     for (i=h-l+1; i>=k+j; i--) {
    536       newBetti[j,i]=-1;
    537     }
    538   }
    539   displayCohom(newBetti,l,h,n);
    540 
     864
     865 
     866
     867  ///////////////////////////////////////////////////////////////
     868
     869  dbprint(PL-1, "// EM: "+string(nrows(EM)) + " x " + string(ncols(EM))  + ")");
     870  dbprint(PL-2, EM);
     871  dbprint(PL-1, "// weighting(EM): ["+ string(attrib(EM, "isHomog")) + "]"); 
     872 
     873
     874  int tResulutionBegin=timer;
     875  resolution RE = nres(EM, maxbound);
     876  int tMinResBegin=timer;
     877  RE = minres(RE);   
     878  int tBettiBegin=timer;
     879  intmat Betti = betti(RE); // betti(RE, 1);?
     880  int tResulutionEnd=timer;
     881 
     882  int tEnd = tResulutionEnd;
     883
     884  if( PL > 0 )
     885  {
     886    "
     887        ----      RESULTS  ---- 
     888        Tate Resolution (Length: ", size(RE), "):
     889    ";
     890    RE;
     891    "Betti numbers for Tate resolution (diagonal cohomology table):";
     892    print(Betti, "betti"); // Diagonal form!
     893  };
     894
     895 
     896  printlevel = printlevel + 1;
     897  Betti = showResult(Betti, l, h ); // Show usual form of cohomology table
     898  printlevel = printlevel - 1;
     899
     900 
     901  if(PL > 0)
     902  {
     903  "
     904      ----      TIMINGS     -------
     905      Trunc      Time: ", tTruncateEnd - tTruncateBegin, "
     906      Reg        Time: ", tCMEnd - tBegin, "
     907      kStd       Time: ", tSTDEnd - tSTDBegin, "
     908      Jacob      Time: ", tTransposeJacobEnd - tTransposeJacobBegin, "
     909      Syz        Time: ", tSyzEnd - tSyzBegin, "
     910      Mat        Time: ", tMatrixOppEnd - tMatrixOppBegin, "
     911      ------------------------------ 
     912      Res        Time: ", tResulutionEnd - tResulutionBegin, "
     913      :: NRes    Time: ", tMinResBegin - tResulutionBegin, "
     914      :: MinRes .Time: ", tBettiBegin - tMinResBegin, "
     915      :: Betti  .Time: ", tResulutionEnd - tBettiBegin, "
     916      ---------------------------------------------------------
     917      Total Time: ", tEnd - tBegin, "
     918      ---------------------------------------------------------
     919      ";
     920  };
     921 
    541922  setring R;
    542   option(set, ivOptionsSave);
    543 
    544   return(newBetti);
     923
     924  option(set, save);
     925
     926  return(Betti);
    545927}
    546928example
    547929{"EXAMPLE:";
    548930   echo = 2;
     931   int pl = printlevel;
    549932   // cohomology of structure sheaf on P^4:
    550933   //-------------------------------------------
    551    ring r=0,x(1..5),dp;
    552    module M=0;
    553    def A=sheafCohBGG2(0,-9,4);
     934   ring r=32001,x(1..5),dp;
     935   module M= getStructureSheaf();
     936
     937   int t = timer;
     938   def A=sheafCohBGG(0,-9,4);
     939   timer - t;
     940   
     941   printlevel = voice; A=sheafCohBGG2(0,-9,4); printlevel = pl;
     942   
    554943   // cohomology of cotangential bundle on P^3:
    555944   //-------------------------------------------
    556    ring R=0,(x,y,z,u),dp;
    557    resolution T1=mres(maxideal(1),0);
    558    module M=T1[3];
    559    intvec v=2,2,2,2,2,2;
    560    attrib(M,"isHomog",v);
    561    def B=sheafCohBGG2(M,-8,4);
     945   ring R=32001,(x,y,z,u),dp;
     946
     947   module M = getCotangentialBundle();
     948   
     949   int t = timer;
     950   def B=sheafCohBGG(M,-8,4);
     951   timer - t;
     952   
     953   printlevel = voice; B=sheafCohBGG2(M,-8,4); printlevel = pl;
    562954}
    563955
     
    7901182}
    7911183///////////////////////////////////////////////////////////////////////////////
     1184
     1185proc getStructureSheaf(list #)
     1186{
     1187
     1188  if( size(#) == 0 )
     1189  {
     1190
     1191    module M = 0;
     1192    intvec v = 0;
     1193    attrib(M,"isHomog",v);
     1194    homog(M);
     1195
     1196    attrib(M, "isCoker", 1);
     1197
     1198    attrib(M);   
     1199    return(M);
     1200  };
     1201
     1202 
     1203
     1204
     1205 
     1206  if( typeof(#[1]) == "ideal")
     1207  {
     1208
     1209
     1210    ideal I = #[1];
     1211
     1212    if( size(#) == 2 )
     1213    {
     1214      if( typeof(#[2]) == "int" )
     1215      {
     1216        if( #[2] != 0 )
     1217        {
     1218          qring @@@@QQ = std(I);
     1219
     1220          module M = getStructureSheaf();
     1221         
     1222          export M;
     1223
     1224//          keepring @@@@QQ; // This is a bad idea... :(
     1225          return (@@@@QQ);
     1226        }
     1227      }
     1228    }
     1229
     1230/*
     1231    // This seems to be wrong!!!
     1232    module M = I * gen(1);
     1233    homog(M);
     1234   
     1235    M = modulo(gen(1), module(I * gen(1))); // basering^1 / I
     1236
     1237    homog(M);
     1238   
     1239    attrib(M, "isCoker", 1);
     1240
     1241    attrib(M);
     1242    return(M);
     1243*/   
     1244  }   
     1245 
     1246  ERROR("Wrong argument");
     1247 
     1248}   
     1249example
     1250{"EXAMPLE:";
     1251   echo = 2; int pl = printlevel;
     1252   printlevel = voice;
     1253
     1254
     1255   ////////////////////////////////////////////////////////////////////////////////
     1256   ring r;
     1257   module M = getStructureSheaf();
     1258   "Basering: ";
     1259   basering;
     1260   "Module: ", string(M), ", grading is given by weights: ", attrib(M, "isHomog");
     1261
     1262   def A=sheafCohBGG2(M,-9,9);
     1263   print(A);
     1264   
     1265   ////////////////////////////////////////////////////////////////////////////////
     1266   setring r;
     1267   module M = getStructureSheaf(ideal(var(1)), 0);
     1268   
     1269   "Basering: ";
     1270   basering;
     1271   "Module: ", string(M), ", grading is given by weights: ", attrib(M, "isHomog");
     1272
     1273   def A=sheafCohBGG2(M,-9,9);
     1274   print(A);
     1275
     1276   ////////////////////////////////////////////////////////////////////////////////
     1277   setring r;
     1278   def Q = getStructureSheaf(ideal(var(1)), 1); // returns a new ring!
     1279   setring Q; // M was exported in the new ring!
     1280   
     1281   "Basering: ";
     1282   basering;
     1283   "Module: ", string(M), ", grading is given by weights: ", attrib(M, "isHomog");
     1284
     1285   def A=sheafCohBGG2(M,-9,9);
     1286   print(A);
     1287
     1288   printlevel = pl;
     1289}
     1290
     1291
     1292proc getCotangentialBundle()
     1293{
     1294  resolution T1=mres(maxideal(1),3);
     1295  module M=T1[3];
     1296  attrib(M,"isHomog");
     1297  homog(M);
     1298  attrib(M, "isCoker", 1);
     1299  attrib(M);
     1300  return (M);
     1301};
     1302
     1303proc getIdealSheafPullback(ideal I, ideal pi)
     1304{
     1305  def save = basering;
     1306  map P = save, pi;
     1307  return( P(I) );
     1308}
     1309
     1310// TODO: set attributes!
     1311
     1312
     1313proc getIdealSheaf(ideal I)
     1314{
     1315  resolution FI = mres(I,2); // Syz + grading...
     1316  module M = FI[2];
     1317  attrib(M, "isCoker", 1);
     1318  attrib(M);
     1319  return(M);
     1320};
     1321
     1322
     1323
    7921324
    7931325
Note: See TracChangeset for help on using the changeset viewer.