Changeset d79a74 in git


Ignore:
Timestamp:
Dec 9, 2014, 6:59:51 PM (10 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '0bc2210f8055033868008a3836878db65ec6f89e')
Children:
70eecb25f735a5ffd8523ba1253e0d8a08f8c1a9
Parents:
56d8843ea10b1914d8654dce77191eb32927691a
Message:
Default s_res to work over basering and return the usual resolution object (if set RINGCHANGE=0 SSinit attribute) or return SRES as before

chg: minor cleanup
fix: bug (unable to load...)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/schreyer.lib

    r56d884 rd79a74  
    549549    ERROR("Sorry: need an ideal or a module for input");
    550550  }
    551 
    552   // TODO! DONE?
    553551  def @save = basering;
    554552 
     
    588586  }
    589587
    590  
     588  int @RINGCHANGE = 0;
     589
     590  if( typeof( attrib(SSinit, "RINGCHANGE") ) == "int" )
     591  {
     592    @RINGCHANGE = attrib(SSinit, "@RINGCHANGE");
     593  }
     594
     595
    591596  if( @DEBUG )
    592597  {
    593598    "SSinit::Input";
    594599    type(M);
    595 //    DetailedPrint(M);
    596600    attrib(M);
    597601  }
     
    606610    option(set, opts);
    607611    kill opts;
    608   }//  else
    609   // {
    610     M = simplify(M, 1 + 2 + 4 + 32); // interreduce?
    611   // }
     612  }
     613
     614  M = simplify(M, 1 + 2 + 4 + 32);
    612615
    613616  if( @IGNORETAILS )
     
    621624    }
    622625  }
    623 
    624  
    625 
     626 
    626627  def @N = MySort(M); // TODO: replace with inplace sorting!!!
    627628  def LEAD = lead(@N);
     
    672673 
    673674  // TODO: what about real modules? weighted ones?
    674  
    675   list @l = ringlist(@save);
    676 
    677   int @z = 0; ideal @m = maxideal(1); intvec @wdeg = deg(@m[1..ncols(@m)]);
    678 
    679   // NOTE: @wdeg will be ignored anyway :(
    680   @l[3] = list(list("C", @z), list("lp", @wdeg));
    681 
    682   kill @z, @wdeg; // since these vars are ring independent!
    683 
    684   def S = ring(@l); // --MakeInducedSchreyerOrdering(1);
    685 
    686   module F = freemodule(@RANK);
    687   intvec @V = deg(F[1..@RANK]);
    688  
    689   setring S; // ring with an easy divisibility test ("C, lex")
    690 
    691   if( @DEBUG )
    692   {
    693     "SSinit::NewRing(C, lex)";
    694     basering;
    695     DetailedPrint(basering);
    696   }
     675
     676  if( @RINGCHANGE )
     677  {
     678    list @l = ringlist(@save);
     679    int @z = 0; ideal @m = maxideal(1); intvec @wdeg = deg(@m[1..ncols(@m)]);
     680    // NOTE: @wdeg will be ignored anyway :(
     681    @l[3] = list(list("C", @z), list("lp", @wdeg));
     682    kill @z, @m, @wdeg; // since these vars are ring independent!
     683    def S = ring(@l); // --MakeInducedSchreyerOrdering(1);
     684    kill @l;
     685    setring S; // ring with an easy divisibility test ("C, lex") // or not!???
     686    if( @DEBUG )
     687    {
     688      "SSinit::NewRing(C,lex)?";
     689      basering;
     690      DetailedPrint(basering);
     691    }
     692  } else
     693  { def S = basering; }
    697694
    698695  // Setup the leading syzygy^{-1} module to zero:
    699696  module Z = 0; Z[@RANK] = 0; attrib(Z, "isHomog", intvec(0)); 
     697
     698  if( !@RINGCHANGE )
     699  {
     700    if( defined(RES) )  { if( @DEBUG ){ "WARN: killing existing object: RES!"; }; kill RES; }
     701    if( defined(MRES) ) { if( @DEBUG ){ "WARN: killing existing object: MRES!"; }; kill MRES; }
     702    if( defined(LRES) ) { if( @DEBUG ){ "WARN: killing existing object: LRES!"; }; kill LRES; }
     703    if( defined(TRES) ) { if( @DEBUG ){ "WARN: killing existing object: TRES!"; }; kill TRES; }
     704  }
    700705
    701706  module MRES = Z;
     
    704709  list LRES; LRES[1] = Z;
    705710  list TRES; TRES[1] = Z;
    706  
    707   def M = imap(@save, M);
    708 
     711 
     712  if( !defined(M) )
     713  {
     714    def M = imap(@save, M);
     715  }
     716
     717  module F = freemodule(@RANK); intvec @V = deg(F[1..@RANK]); kill F;
     718 
    709719  attrib(M, "isHomog", @V);
    710720  attrib(M, "isSB", 1);
    711721  attrib(M, "degrees", @DEGS); 
    712722 
    713   def LEAD = imap(@save, LEAD);
     723  if( !defined(LEAD) )
     724  {
     725    def LEAD = imap(@save, LEAD);
     726  } 
    714727 
    715728  attrib(LEAD, "isHomog", @V);
    716729  attrib(LEAD, "isSB", 1); 
    717730 
    718   def TAIL = imap(@save, TAIL);
     731  if( !defined(TAIL) )
     732  {
     733    def TAIL = imap(@save, TAIL);
     734  } 
    719735
    720736  if( @DEBUG )
     
    724740    attrib(M);
    725741    attrib(M, "isHomog");
    726 //    DetailedPrint(M);
    727742  }
    728743
     
    765780  }
    766781
    767 
    768782  if( typeof( attrib(SSinit, "HYBRIDNF") ) == "int" )
    769783  {
     
    773787    attrib(S, "HYBRIDNF", 0);
    774788  }
    775  
     789
     790  // maybe resetting existing ring attributes!
    776791  attrib(S, "DEBUG", @DEBUG);
    777792  attrib(S, "SYZCHECK", @SYZCHECK);
     
    21282143}
    21292144
     2145static proc SRES_minres(SRES SR)
     2146{
     2147  def save = basering;
     2148  SRES S;
     2149  def R = SR.r; S.r = R;
     2150  setring R;
     2151  S.rsltn = minres(SR.rsltn); // in target ring :(
     2152  return (S);
     2153}
     2154
     2155
    21302156// cannot be automatically used via overloading :(
    2131 proc SRES_list(SRES SR)
    2132 "TODO!"
    2133 {
     2157proc SRES_list(def SR)
     2158"USAGE:  SRES_list(resolution)
     2159RETURN:  list
     2160PURPOSE: convert given resolution to a list
     2161NOTE:    result is over basering
     2162SEE ALSO: s_res, resolution
     2163EXAMPLE: example s_res; shows an example
     2164"
     2165{
     2166  if( typeof(SR) != "SRES" )
     2167  {
     2168    list L = SR;
     2169    return (L);
     2170  }
     2171 
    21342172  def save = basering; 
    21352173  def R = SR.r;
    21362174
    2137   if( 0 )  // ( save == R ) // TODO: not implemented :(((
    2138   {
    2139     list L = SR.rsltn;
    2140     return (L);
    2141   }
     2175//    if( 0 )  // ( save == R ) // TODO: not implemented :(((
     2176//    {      list L = SR.rsltn;      return (L);    }
    21422177   
    21432178  setring R;
    21442179  list L = SR.rsltn;
    21452180  setring save; 
    2146   return (imap( R, L ));
    2147 }
    2148 
    2149 static proc SRES_minres(SRES SR)
    2150 {
    2151   def save = basering;
    2152   SRES S;
    2153   def R = SR.r; S.r = R;
    2154   setring R;
    2155   S.rsltn = minres(SR.rsltn);
    2156   return (S);
     2181  return (imap( R, L ));   
    21572182}
    21582183
    21592184static proc loadme()
    21602185{
    2161   int @DEBUG = 0; // !system("with", "ndebug");
    2162 
    2163   if( @DEBUG )
    2164   {
     2186  int @DEBUG = 0; // !system("with", "ndebug"); //    "om_ndebug?: ", system("with", "om_ndebug");
     2187
     2188  if( @DEBUG )  {    listvar(Syzextra);    listvar(Schreyer);    listvar(Top);  }
     2189
     2190  if( !defined(Schreyer::ComputeResolution) )
     2191  {
     2192    load("syzextra.so");
     2193     
     2194      if( @DEBUG ){        listvar(Syzextra);      }
     2195     
     2196//      exportto(Top, Syzextra::ClearContent); //      exportto(Top, Syzextra::ClearDenominators);     exportto(Schreyer, Syzextra::noop);
     2197//      exportto(Schreyer, Syzextra::leadrawexp); //      exportto(Schreyer, Syzextra::ISUpdateComponents);
     2198//      exportto(Schreyer, Syzextra::GetAMData);//      exportto(Schreyer, Syzextra::SetSyzComp);
     2199//      exportto(Schreyer, Syzextra::MakeSyzCompOrdering); //      exportto(Schreyer, Syzextra::reduce_syz);//      exportto(Schreyer, Syzextra::p_Content);
     2200    exportto(Schreyer, Syzextra::DetailedPrint);
     2201    exportto(Schreyer, Syzextra::m2_end);
     2202    exportto(Schreyer, Syzextra::leadmonomial);
     2203    exportto(Schreyer, Syzextra::leadcomp);
     2204    exportto(Schreyer, Syzextra::SetInducedReferrence);
     2205    exportto(Schreyer, Syzextra::GetInducedData);
     2206    exportto(Schreyer, Syzextra::MakeInducedSchreyerOrdering);
     2207    exportto(Schreyer, Syzextra::idPrepare);
    21652208   
    2166 //    "ndebug?: ", system("with", "ndebug");
    2167 //    "om_ndebug?: ", system("with", "om_ndebug");
    2168 
    2169     listvar(Syzextra);
    2170     listvar(Schreyer);
    2171     listvar(Top);
    2172   }
    2173 
    2174   if( !defined(Schreyer::DetailedPrint) )
    2175   {
    2176     if( 1 )
    2177     {
    2178 /*
    2179       if( system("with", "ndebug") )
    2180       {
    2181         "Loading the Debug version!";
    2182       } else
    2183       {
    2184         "Loading the Release version!";
    2185       }
    2186 */     
    2187       load("syzextra.so");
    2188 
    2189       if( @DEBUG )
    2190       {
    2191         listvar(Syzextra);
    2192       }
    2193      
    2194 //      exportto(Top, Syzextra::ClearContent);
    2195 //      exportto(Top, Syzextra::ClearDenominators);
    2196       exportto(Schreyer, Syzextra::m2_end);
    2197      
    2198 //      export Syzextra;
    2199 
    2200 //      exportto(Schreyer, Syzextra::noop);
    2201       exportto(Schreyer, Syzextra::DetailedPrint);
    2202       exportto(Schreyer, Syzextra::leadmonomial);
    2203       exportto(Schreyer, Syzextra::leadcomp);
    2204 //      exportto(Schreyer, Syzextra::leadrawexp);
    2205 //      exportto(Schreyer, Syzextra::ISUpdateComponents);
    2206       exportto(Schreyer, Syzextra::SetInducedReferrence);
    2207       exportto(Schreyer, Syzextra::GetInducedData);
    2208 //      exportto(Schreyer, Syzextra::GetAMData);
    2209 //      exportto(Schreyer, Syzextra::SetSyzComp);
    2210       exportto(Schreyer, Syzextra::MakeInducedSchreyerOrdering);
    2211 //      exportto(Schreyer, Syzextra::MakeSyzCompOrdering);
    2212       exportto(Schreyer, Syzextra::idPrepare);
    2213 //      exportto(Schreyer, Syzextra::reduce_syz);
    2214 //      exportto(Schreyer, Syzextra::p_Content);
    2215 
    2216       exportto(Schreyer, Syzextra::ProfilerStart); exportto(Schreyer, Syzextra::ProfilerStop);
    2217 
    2218       exportto(Schreyer, Syzextra::Tail);
    2219       exportto(Schreyer, Syzextra::ComputeLeadingSyzygyTerms);     
    2220       exportto(Schreyer, Syzextra::Compute2LeadingSyzygyTerms);
    2221       exportto(Schreyer, Syzextra::Sort_c_ds);
    2222 
    2223       exportto(Schreyer, Syzextra::FindReducer);
    2224 
    2225       exportto(Schreyer, Syzextra::ReduceTerm);
    2226       exportto(Schreyer, Syzextra::TraverseTail);
    2227 
    2228       exportto(Schreyer, Syzextra::SchreyerSyzygyNF);
    2229       exportto(Schreyer, Syzextra::ComputeSyzygy);
    2230 
    2231       exportto(Schreyer, Syzextra::ComputeResolution);
    2232 
    2233       exportto(Schreyer, Syzextra::NumberStatsInit);
    2234       exportto(Schreyer, Syzextra::NumberStatsPrint);
    2235 
    2236       newstruct("SRES","ring r,resolution rsltn"); // http://www.singular.uni-kl.de/Manual/latest/sing_179.htm#SEC218
    2237       // TODO: SSres - return SRESOLUTION?
    2238 
     2209    exportto(Schreyer, Syzextra::ProfilerStart);   exportto(Schreyer, Syzextra::ProfilerStop);
     2210    exportto(Schreyer, Syzextra::NumberStatsInit); exportto(Schreyer, Syzextra::NumberStatsPrint);
     2211   
     2212    exportto(Schreyer, Syzextra::Tail);
     2213    exportto(Schreyer, Syzextra::ComputeLeadingSyzygyTerms);
     2214    exportto(Schreyer, Syzextra::Compute2LeadingSyzygyTerms);
     2215    exportto(Schreyer, Syzextra::Sort_c_ds);
     2216   
     2217    exportto(Schreyer, Syzextra::FindReducer);
     2218
     2219    exportto(Schreyer, Syzextra::ReduceTerm);
     2220    exportto(Schreyer, Syzextra::TraverseTail);
     2221   
     2222    exportto(Schreyer, Syzextra::SchreyerSyzygyNF);
     2223    exportto(Schreyer, Syzextra::ComputeSyzygy);
     2224    exportto(Schreyer, Syzextra::ComputeResolution);
     2225   
     2226    // TODO: SSres - return SRESOLUTION?
     2227    newstruct("SRES","ring r,resolution rsltn"); // http://www.singular.uni-kl.de/Manual/latest/sing_179.htm#SEC218
    22392228//      system("install","SRES","string",SRES_string, 1);
    2240       system("install","SRES","print",SRES_print, 1);
    2241 
    2242       system("install","SRES","betti",SRES_betti1, 1); // http://www.singular.uni-kl.de/Manual/latest/sing_260.htm#SEC299
    2243       system("install","SRES","betti",SRES_betti2, 2); // http://www.singular.uni-kl.de/Manual/latest/sing_260.htm#SEC299
    2244       system("install","SRES","minres",SRES_minres, 1); // http://www.singular.uni-kl.de/Manual/latest/sing_344.htm#SEC383
    2245 
    2246 //      system("install","SRES","list", SRES_list, 1); // will never work :(((
    2247      
    2248       // TODO: SSsyz? SSYZYGY? // TODO: C/C++ computation for Syzygy?
    2249 //      newstruct("SSYZ","ring r,module szg"); // http://www.singular.uni-kl.de/Manual/latest/sing_179.htm#SEC218
    2250 //      system("install","SSYZYGY","string",SSYZYGY_string, 1);
    2251 //      system("install","SSYZYGY","print",SSYZYGY_print, 1);
    2252 //      system("install","SSYZYGY","module",SSYZYGY_module, 1);
    2253     }
     2229    system("install","SRES","print",SRES_print, 1);
     2230    system("install","SRES","betti",SRES_betti1, 1); // http://www.singular.uni-kl.de/Manual/latest/sing_260.htm#SEC299
     2231    system("install","SRES","betti",SRES_betti2, 2); // http://www.singular.uni-kl.de/Manual/latest/sing_260.htm#SEC299
     2232    system("install","SRES","minres",SRES_minres, 1); // http://www.singular.uni-kl.de/Manual/latest/sing_344.htm#SEC383
     2233    system("install","SRES","list", SRES_list, 1); // will never work :(((
    22542234
    22552235//    exportto(Top, DetailedPrint);
    2256 //    exportto(Top, GetInducedData);
    2257 
    2258     if( @DEBUG )
    2259     {
    2260       listvar(Top);
    2261       listvar(Schreyer);
    2262     }
     2236//    exportto(Top, s_res); // GetInducedData);
     2237
     2238    if( @DEBUG )    {      listvar(Top);      listvar(Schreyer);    }
    22632239  }
    22642240 
     
    22702246static proc mod_assure_load()
    22712247{
    2272   if( !defined(GetInducedData) )
    2273   {
    2274     "ERROR: Sorry but we are missing the dynamic module (syzextra.so)...";
    2275     $
     2248  if( !defined(Schreyer::ComputeResolution) )
     2249  {
     2250    "ERROR: Sorry but you seems to be missing the necessary dynamic module (syzextra.so)!";
     2251//    $
    22762252    // m2_end(666); // :(
    22772253  }
     
    25562532proc s_res(def I, int l)
    25572533"USAGE:  s_res(ideal/module M, int len)
    2558 RETURN:  SRES, a blackbox object containing a (part of) Schreyer resolution
     2534RETURN:  resolution object or SRES
    25592535PURPOSE: compute a Schreyer resolution of M of length at most len (see [BMSS])
    25602536NOTE:    If given len is zero then nvars(basering) + 1 is used instead.
    2561 @* SRES can be printed, treated by betti and minres or converted to list & mapped into the current ring with @code{SRES_list}
    25622537@* This functions is not related to other helpers from this library.
    25632538@* One can switch on computation protocol and statistic (depending on the build) by setting the @code{prot} option.
     
    25702545{
    25712546  int @prot = (find(option(),"prot") != 0) && (defined(NumberStatsInit)) && (defined(NumberStatsPrint));
    2572   def R=SSinit(I); setring R; int @l = size(RES);
    2573   SRES ret; ret.r = R;
     2547  def @save = basering;
     2548 
     2549  int @RINGCHANGE = 0;
     2550
     2551  if( typeof( attrib(SSinit, "RINGCHANGE") ) == "int" )
     2552  {
     2553    @RINGCHANGE = attrib(SSinit, "@RINGCHANGE");
     2554  }
     2555 
     2556  def R=SSinit(I);
     2557  if( @RINGCHANGE ){ setring R; }
     2558 
     2559  int @l = size(RES);
    25742560  if(@prot){ NumberStatsInit(); }
    2575   ret.rsltn = ComputeResolution(RES[@l], LRES[@l], TRES[@l], l);
     2561  def rsltn = ComputeResolution(RES[@l], LRES[@l], TRES[@l], l);
    25762562  if(@prot){ NumberStatsPrint("Number statistic for s_res with ComputeResolution"); }
     2563 
     2564  if( !@RINGCHANGE )
     2565  {
     2566    return (rsltn); // ret
     2567  }
     2568 
     2569  SRES ret; ret.r = R; ret.rsltn = rsltn; 
    25772570  return (ret);
    25782571}
     
    25812574  ring R;
    25822575  module M = maxideal(1); M;
    2583   SRES rs = s_res(M, 0);
     2576  def rs = s_res(M, 0);
    25842577  print(rs);
    25852578  print(betti(rs, 0)); // non-minimal betties
     
    26202613@m=rtimer;
    26212614  if(@PROFILE){ProfilerStop();}
    2622 RR=minres(RR);def S=betti(RR,1);@t=rtimer;
     2615RR=minres(RR); def S=betti(RR,1);@t=rtimer;
    26232616//  DetailedPrint(RR,0);  print(RR);  print(S, "betti");
    26242617  SCheck(R);
Note: See TracChangeset for help on using the changeset viewer.