Changeset a3337a in git


Ignore:
Timestamp:
Nov 29, 2012, 8:48:28 PM (11 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
d6283902d593a8accfa74862cafcd05348f70d1a
Parents:
91c7251b522fe5741414bc172467ac24df89485d
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-11-29 20:48:28+01:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2014-05-07 04:41:49+02:00
Message:
Added TestSSSres and ComputeResolution

chg/fix: better SCheck

TODO: use + update attributes (!?)
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/schreyer.lib

    r91c7251 ra3337a  
    21532153      exportto(Schreyer, Syzextra::SchreyerSyzygyNF);
    21542154      exportto(Schreyer, Syzextra::ComputeSyzygy);
     2155
     2156      exportto(Schreyer, Syzextra::ComputeResolution);     
    21552157    }
    21562158/*
     
    22052207      exportto(Schreyer, Syzextra_g::SchreyerSyzygyNF);
    22062208      exportto(Schreyer, Syzextra_g::ComputeSyzygy);
     2209
     2210      exportto(Schreyer, Syzextra_g::ComputeResolution);     
    22072211    }
    22082212*/
     
    22742278  int i, j;
    22752279  int f = 0;
    2276   def m;
     2280  def m, mm;
    22772281 
    22782282  for (i = size(@save_res_list); i > 0; i--)
     
    22872291    for (j = i-1; j > 0; j--)
    22882292    {
    2289       if( m != @save_res_list[j][4] )
     2293      mm = @save_res_list[j][4];
     2294      if( (nrows(m) != nrows(mm)) || (ncols(m) != ncols(mm)) )
    22902295      {
    2291         "ERROR: Betti[j: ", j, "] != Betti[i: ", i, "]:";
    2292         "j: ", j;
    2293         print( @save_res_list[j][4], "betti");
    2294         print(@save_res_list[j]);
     2296        "ERROR: SIZE(Betti[j: ", j, "]) != SIZE(Betti[i: ", i, "]):";
     2297        "j: ", j;
     2298        print( @save_res_list[j][4], "betti");
     2299        print(@save_res_list[j]);
    22952300       
    2296         "i: ", i;
    2297         print( @save_res_list[i][4], "betti");
    2298         print(@save_res_list[i]);
     2301        "i: ", i;
     2302        print( @save_res_list[i][4], "betti");
     2303        print(@save_res_list[i]);
    22992304
    23002305        f = 1;
     2306
     2307      } else
     2308      {
     2309        if( m != mm )
     2310        {
     2311          "ERROR: Betti[j: ", j, "] != Betti[i: ", i, "]:";
     2312          "j: ", j;
     2313          print( @save_res_list[j][4], "betti");
     2314          print(@save_res_list[j]);
     2315
     2316          "i: ", i;
     2317          print( @save_res_list[i][4], "betti");
     2318          print(@save_res_list[i]);
     2319
     2320          f = 1;
     2321        };
    23012322      };
    23022323 
     
    24332454  if(@PROFILE){ProfilerStop();}
    24342455  setring R;module M;list @l=list();@l[size(RES)-1]=list();r=nrows(RES[1]);for(i=2;i<=size(RES);i++){M=RES[i];rr=nrows(M);if((r>0)&&(size(M)>0)&&(r<rr)){M=transpose(M);M=M[(r+1)..ncols(M)];M=transpose(M);RES[i]=M;};r=rr;@l[i-1] = M;};resolution RR=@l;RR=minres(RR);def S=betti(RR,1);@t=rtimer;
     2456  DetailedPrint(RR,0);
     2457  SCheck(R);
     2458  StopAddResTest(RR, S, @t,@m);
     2459  kill S, RR; setring save; kill R;
     2460}
     2461
     2462proc TestSSSres(def I)
     2463{
     2464  def save = basering;
     2465  int @t,@m,r,rr,i;
     2466  string name =
     2467    "LEAD2SYZ:"  +string(attrib(SSinit,"LEAD2SYZ")) +
     2468    ",TAILREDSYZ:"+string(attrib(SSinit,"TAILREDSYZ")) +
     2469    ",HYBRIDNF:"  +string(attrib(SSinit,"HYBRIDNF"));
     2470
     2471  int @PROFILE = attrib(SSinit, "PROFILE");
     2472  if(@PROFILE){ string @prof = "SSSres_" + @save_res_desc + "_" + name + ".prof"; }
     2473
     2474  StartAddResTest(
     2475   "SSSres",
     2476   "minres + betti(,1) + mods: {" + name + "}"
     2477  );
     2478 
     2479  option(redSB); option(redTail);
     2480  if(@PROFILE){ProfilerStart(@prof);}
     2481  timer=0;rtimer=0;def R=SSinit(I);setring R;def RR=ComputeResolution(RES[2], LRES[2], TRES[2], 0);
     2482@m=rtimer;
     2483  if(@PROFILE){ProfilerStop();}
     2484RR=minres(RR);def S=betti(RR,1);@t=rtimer;
     2485//  DetailedPrint(RR,0);  print(RR);  print(S, "betti");
    24352486  SCheck(R);
    24362487  StopAddResTest(RR, S, @t,@m);
     
    25092560//  attrib(SSinit, "LEAD2SYZ", 1); attrib(SSinit, "TAILREDSYZ", 0); attrib(SSinit, "HYBRIDNF", 1); TestSSres(M);
    25102561
    2511   attrib(SSinit, "LEAD2SYZ", 1); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 2); TestSSres(M);
    2512   attrib(SSinit, "LEAD2SYZ", 1); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 1); TestSSres(M);
     2562  attrib(SSinit, "LEAD2SYZ", 1); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 2); TestSSSres(M);
     2563  attrib(SSinit, "LEAD2SYZ", 1); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 1); TestSSSres(M);
     2564
     2565
    25132566//  attrib(SSinit, "LEAD2SYZ", 1); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 0); TestSSres(M);
    25142567 
     
    25272580  StartResTesting(#);
    25282581 
    2529   attrib(SSinit, "LEAD2SYZ", 0); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 0); TestSSres(M);
    2530   attrib(SSinit, "LEAD2SYZ", 0); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 1); TestSSres(M);
    2531 //  attrib(SSinit, "LEAD2SYZ", 0); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 2); TestSSres(M);
    2532 
    2533   attrib(SSinit, "LEAD2SYZ", 1); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 0); TestSSres(M);
    2534   attrib(SSinit, "LEAD2SYZ", 1); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 1); TestSSres(M);
    2535 //  attrib(SSinit, "LEAD2SYZ", 1); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 2); TestSSres(M);
     2582  attrib(SSinit, "LEAD2SYZ", 0); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 0); TestSSSres(M);
     2583  attrib(SSinit, "LEAD2SYZ", 0); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 1); TestSSSres(M);
     2584//  attrib(SSinit, "LEAD2SYZ", 0); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 2); TestSSSres(M);
     2585
     2586  attrib(SSinit, "LEAD2SYZ", 1); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 0); TestSSSres(M);
     2587  attrib(SSinit, "LEAD2SYZ", 1); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 1); TestSSSres(M);
     2588//  attrib(SSinit, "LEAD2SYZ", 1); attrib(SSinit, "TAILREDSYZ", 1); attrib(SSinit, "HYBRIDNF", 2); TestSSSres(M);
    25362589
    25372590 
  • dyn_modules/syzextra/mod_main.cc

    r91c7251 ra3337a  
    1616#include <polys/monomials/p_polys.h>
    1717#include <polys/monomials/ring.h>
     18#include <polys/simpleideals.h>
     19
    1820// #include <kernel/longrat.h>
    1921#include <kernel/GBEngine/kstd1.h>
     
    389391    PRINT_RESOLUTION(syzstr, fullres);
    390392
    391     assume (id_RankFreeModule (syzstr->res[1], rr) == syzstr->res[1]->rank);
     393//    assume (id_RankFreeModule (syzstr->res[1], rr) == syzstr->res[1]->rank);
    392394
    393395    PRINT_RESOLUTION(syzstr, res);
     
    11131115
    11141116
     1117static BOOLEAN _ComputeResolution(leftv res, leftv h)
     1118{
     1119  const SchreyerSyzygyComputationFlags attributes(currRingHdl);
     1120
     1121  const BOOLEAN __DEBUG__      = attributes.__DEBUG__;
     1122   
     1123  const char* usage = "`ComputeResolution(<ideal/module>[,int])` expected";
     1124  const ring r = attributes.m_rBaseRing;
     1125
     1126  NoReturn(res);
     1127
     1128  // input
     1129  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
     1130  {
     1131    WerrorS(usage);
     1132    return TRUE;   
     1133  }
     1134
     1135  ideal M = (ideal)(h->CopyD()); // copy for resolution...!???
     1136  int size = IDELEMS(M);
     1137
     1138  assume( size >= 0 );
     1139
     1140  h = h->Next();
     1141
     1142  // lead
     1143  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
     1144  {
     1145    WerrorS(usage);
     1146    return TRUE;   
     1147  }
     1148 
     1149  ideal L = (ideal)(h->CopyD()); // no copy!
     1150  assume( IDELEMS(L) == size );
     1151 
     1152  h = h->Next();
     1153
     1154  // tail
     1155  if ((h==NULL) || (h->Typ()!=IDEAL_CMD && h->Typ() !=MODUL_CMD) || (h->Data() == NULL))
     1156  {
     1157    WerrorS(usage);
     1158    return TRUE;   
     1159  }
     1160
     1161  ideal T = (ideal)(h->CopyD()); // no copy!
     1162  assume( IDELEMS(T) == size );
     1163 
     1164  h = h->Next();
     1165
     1166  // length..?
     1167  long length = 0;
     1168 
     1169  if ((h!=NULL) && (h->Typ()==INT_CMD))
     1170  {
     1171    length = (long)(h->Data());
     1172    h = h->Next();
     1173  }
     1174 
     1175  assume( h == NULL );
     1176
     1177  if( length <= 0 )
     1178    length = 1 + rVar(r); 
     1179
     1180  if( __DEBUG__ )
     1181  {
     1182    PrintS("ComputeResolution(M, length)::Input: \n");
     1183    Print( "starting length: %ld\n", length);
     1184    PrintS("M: \n"); dPrint(M, r, r, 0);
     1185    PrintS("L=LEAD(M): \n"); dPrint(L, r, r, 1);
     1186    PrintS("T=TAIL(M): \n"); dPrint(T, r, r, 0);
     1187  }
     1188
     1189
     1190  syStrategy _res=(syStrategy)omAlloc0(sizeof(ssyStrategy));
     1191 
     1192//  class ssyStrategy; typedef ssyStrategy * syStrategy;
     1193//  typedef ideal *            resolvente;
     1194
     1195  _res->length = length + 1; // index + 1;
     1196  _res->fullres = (resolvente)omAlloc0((_res->length)*sizeof(ideal));
     1197  int index = 0;
     1198  _res->fullres[index++] = M;
     1199
     1200  while( (!idIs0(L)) && (index < length))
     1201  {
     1202    ideal LL, TT; 
     1203    ComputeSyzygy(L, T, LL, TT, attributes);
     1204
     1205    if( __DEBUG__ )
     1206    {
     1207      Print("ComputeResolution()::Separated Syzygy[%d]: \n", index);
     1208      PrintS("LL: \n"); dPrint(LL, r, r, 1);
     1209      PrintS("TT: \n"); dPrint(TT, r, r, 2);
     1210    }
     1211    size = IDELEMS(LL);
     1212
     1213    assume( size == IDELEMS(TT) );
     1214   
     1215    id_Delete(&L, r); id_Delete(&T, r);
     1216
     1217    L = LL; T = TT;
     1218   
     1219    // id_Add(T, L, r);
     1220    M = idInit(size, 0);
     1221    for( int i = size-1; i >= 0; i-- )
     1222    {
     1223      M->m[i] = p_Add_q(p_Copy(T->m[i], r), p_Copy(L->m[i], r), r); // TODO: :(((
     1224    }
     1225    M->rank = id_RankFreeModule(M, r);
     1226   
     1227    if( __DEBUG__ )
     1228    {
     1229      Print("ComputeResolution()::Restored Syzygy[%d]: \n", index);
     1230      PrintS("M = LL + TT: \n"); dPrint(M, r, r, 0);
     1231    }
     1232 
     1233    _res->fullres[index++] = M; // ???
     1234  }
     1235
     1236  id_Delete(&L, r); id_Delete(&T, r);
     1237 
     1238  res->data = _res;
     1239  res->rtyp = RESOLUTION_CMD;
     1240
     1241  if( __DEBUG__ )
     1242  {
     1243    Print("ComputeResolution::Output (index: %d): ", index);
     1244//    class sleftv; typedef sleftv * leftv;
     1245    sleftv _h;
     1246    DetailedPrint(&_h, res);
     1247  }
     1248
     1249//  omFreeSize(_res, sizeof(ssyStrategy));
     1250 
     1251  return FALSE;
     1252
     1253}
     1254
     1255
    11151256/// module (LL, TT) = SSComputeSyzygy(L, T);
    11161257/// Compute Syz(L ++ T) = N = LL ++ TT
     
    11261267//   const BOOLEAN __TAILREDSYZ__ = attributes.__TAILREDSYZ__;
    11271268
    1128   const char* usage = "`ComputeSyzygy(<ideal/module>, <ideal/module>])` expected";
     1269  const char* usage = "`ComputeSyzygy(<ideal/module>, <ideal/module>)` expected";
    11291270  const ring r = attributes.m_rBaseRing;
    11301271
     
    18261967  ADD(psModulFunctions, currPack->libname, "SchreyerSyzygyNF", FALSE, _SchreyerSyzygyNF);
    18271968  ADD(psModulFunctions, currPack->libname, "ComputeSyzygy", FALSE, _ComputeSyzygy);
    1828  
    1829   //  ADD(psModulFunctions, currPack->libname, "GetAMData", FALSE, GetAMData);
     1969
     1970  ADD(psModulFunctions, currPack->libname, "ComputeResolution", FALSE, _ComputeResolution);
     1971//  ADD(psModulFunctions, currPack->libname, "GetAMData", FALSE, GetAMData);
    18301972
    18311973  //  ADD(psModulFunctions, currPack->libname, "", FALSE, );
Note: See TracChangeset for help on using the changeset viewer.