Changeset 649021 in git


Ignore:
Timestamp:
Dec 8, 2018, 9:57:54 AM (5 years ago)
Author:
Karim Abou Zeid <karim23697@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
a548d67bbd30d76652bb8a6596850125133a2374
Parents:
ac8f852ee98f3d2c31345586af75ef366f73758d5529319cbb0358eaef7fc55c04b6726e9cba7e09
Message:
Merge branch 'rightGB' into christmas-release
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/fpalgebras.lib

    r552931 r649021  
    44info="
    55LIBRARY: fpalgebras.lib    Definitions of some finitely presented algebras and groups (Letterplace)
    6 AUTHORS: Karim Abou Zeid,       karim.abou.zeid at rwth-aachen.de
    7          Viktor Levandovskyy,   viktor.levandovskyy at math.rwth-aachen.de
     6AUTHORS: Karim Abou Zeid,       karim.abou.zeid at rwth-aachen.de@*
     7         Viktor Levandovskyy,   viktor.levandovskyy at math.rwth-aachen.de@*
    88         Grischa Studzinski,    grischa.studzinski at rwth-aachen.de
    99
  • Singular/LIB/freegb.lib

    rac8f852 r649021  
    444444  ideal J = letplaceGBasis(I);
    445445  J;
     446}
     447
     448proc lpRightStd(ideal F, ideal Q)
     449{
     450  return (system("rightgb", F, Q));
    446451}
    447452
  • Singular/extra.cc

    r552931 r649021  
    12431243    else
    12441244  #endif
    1245   /*==================== rightgb for freeGB  ====================*/
     1245 /*==================== freeAlgebra for freeGB  ==================*/
    12461246  #ifdef HAVE_SHIFTBBA
    1247     if (strcmp(sys_cmd, "rightgb") == 0)
    1248     {
    1249       const short t[]={2,IDEAL_CMD,IDEAL_CMD};
     1247    if (strcmp(sys_cmd, "freeAlgebra") == 0)
     1248    {
     1249      // copied from freegb.cc
     1250      const short t[]={2,RING_CMD,INT_CMD};
    12501251      if (iiCheckTypes(h,t,1))
    12511252      {
    1252         ideal F=(ideal)h->CopyD();
    1253         ideal Q=(ideal)(h->next->CopyD());
    1254         res->rtyp = IDEAL_CMD;
    1255         res->data = rightgb(F, Q);
    1256         return FALSE;
     1253        ring r=(ring)h->Data();
     1254        int d=(int)((long)h->next->Data());
     1255        if (d<2)
     1256        {
     1257          WerrorS("degree must be >=2");
     1258          return TRUE;
     1259        }
     1260        int i=0;
     1261        while(r->order[i]!=0)
     1262        {
     1263          if ((r->order[i]==ringorder_c) ||(r->order[i]==ringorder_C)) i++;
     1264          else if ((r->block0[i]==1)&&(r->block1[i]==r->N)) i++;
     1265          else
     1266          {
     1267            WerrorS("only for rings with a global ordering of one block");
     1268            return TRUE;
     1269          }
     1270        }
     1271        if ((r->order[i]!=0)
     1272            || (rHasLocalOrMixedOrdering(r)))
     1273        {
     1274          //WerrorS("only for rings with a global ordering of one block");
     1275          Werror("only for rings with a global ordering of one block,i=%d, o=%d",i,r->order[i]);
     1276          return TRUE;
     1277        }
     1278        ring R=freeAlgebra(r,d);
     1279        res->rtyp=RING_CMD;
     1280        res->data=R;
     1281        return R==NULL;
    12571282      }
    12581283      else return TRUE;
  • kernel/GBEngine/kstd1.cc

    rac8f852 r649021  
    25682568#ifdef HAVE_SHIFTBBA
    25692569ideal kStdShift(ideal F, ideal Q, tHomog h,intvec ** w, intvec *hilb,int syzComp,
    2570                 int newIdeal, intvec *vw)
     2570                int newIdeal, intvec *vw, BOOLEAN rightGB)
    25712571{
    25722572  ideal r;
     
    25752575  kStrategy strat=new skStrategy;
    25762576  intvec* temp_w=NULL;
     2577
     2578  strat->rightGB = rightGB;
    25772579
    25782580  if(!TEST_OPT_RETURN_SB)
  • kernel/GBEngine/kstd1.h

    rac8f852 r649021  
    3939          int syzComp=0,int newIdeal=0, intvec *vw=NULL, s_poly_proc_t sp=NULL);
    4040
    41 ideal kStdShift(ideal F, ideal Q, tHomog h,intvec ** w, intvec *hilb,int syzComp,
    42                 int newIdeal, intvec *vw);
     41ideal kStdShift(ideal F, ideal Q, tHomog h,intvec ** mw, intvec *hilb=NULL,
     42    int syzComp=0, int newIdeal=0, intvec *vw=NULL, BOOLEAN rightGB=FALSE);
    4343
    4444/* the following global data are defined in kutil.cc */
  • kernel/GBEngine/kstd2.cc

    rac8f852 r649021  
    41784178  initBbaShift(strat); /* DONE */
    41794179  /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
    4180   /*Shdl=*/initBuchMoraShift(F, Q,strat); /* updateS with no toT, i.e. no init for T */
    4181   updateSShift(strat); /* initializes T */
     4180  /*Shdl=*/initBuchMora(F, Q,strat);
    41824181  if (strat->minim>0) strat->M=idInit(IDELEMS(F),F->rank);
    41834182  reduc = olddeg = 0;
     
    43524351        // posInS only depends on the leading term
    43534352        strat->enterS(strat->P, pos, strat, strat->tl);
    4354         enterTShift(strat->P, strat);
     4353        if (!strat->rightGB)
     4354          enterTShift(strat->P, strat);
    43554355      }
    43564356
     
    43694369          // and add pairs
    43704370          int pos=posInS(strat,strat->sl,strat->P.p,strat->P.ecart);
    4371           int atR=strat->tl+1; // enterTShift introduces P.p=T[tl+1], T[tl+2]...
    4372           enterTShift(strat->P,strat,-1);
    4373           enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, atR);
    4374           strat->enterS(strat->P, pos, strat, atR);
     4371          enterT(strat->P, strat);
     4372          enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
     4373          strat->enterS(strat->P, pos, strat, strat->tl);
     4374          if (!strat->rightGB)
     4375            enterTShift(strat->P,strat);
    43754376        }
    43764377      }
     
    43934394    for (int k = 0; k <= strat->sl; ++k)
    43944395    {
     4396      if ((strat->fromQ!=NULL) && (strat->fromQ[k])) continue; // do not reduce Q_k
    43954397      for (int j = 0; j<=strat->tl; ++j)
    43964398      {
     
    44574459
    44584460
    4459 ideal freegb(ideal I)
     4461ideal freegb(ideal F)
    44604462{
    44614463  assume(rIsLPRing(currRing));
    4462   assume(idIsInV(I));
    4463   ideal RS = kStdShift(I,NULL, testHomog, NULL,NULL,0,0,NULL);
     4464  assume(idIsInV(F));
     4465  ideal RS = kStdShift(F, NULL, testHomog, NULL);
     4466  idSkipZeroes(RS); // is this even necessary?
     4467  assume(idIsInV(RS));
     4468  return(RS);
     4469}
     4470
     4471ideal rightgb(ideal F, ideal Q)
     4472{
     4473  assume(rIsLPRing(currRing));
     4474  assume(idIsInV(F));
     4475  ideal RS = kStdShift(F, Q, testHomog, NULL, NULL, 0, 0, NULL, TRUE);
    44644476  idSkipZeroes(RS); // is this even necessary?
    44654477  assume(idIsInV(RS));
  • kernel/GBEngine/kutil.cc

    rac8f852 r649021  
    80358035      Print("\n  %d:",i);
    80368036      p_wrp(strat->S[i], currRing, strat->tailRing);
     8037      if (strat->fromQ!=NULL && strat->fromQ[i])
     8038        Print(" (from Q)");
    80378039    }
    80388040    strat->news = FALSE;
     
    91519153        enterT(h,strat);
    91529154        strat->S_2_R[i] = strat->tl;
     9155#ifdef HAVE_SHIFTBBA
     9156        if (currRing->isLPring)
     9157          enterTShift(h, strat);
     9158#endif
    91539159      }
    91549160    }
     
    92479253      enterT(h,strat);
    92489254      strat->S_2_R[i] = strat->tl;
     9255#ifdef HAVE_SHIFTBBA
     9256      if (currRing->isLPring)
     9257        enterTShift(h, strat);
     9258#endif
    92499259    }
    92509260    if (suc!= -1) updateS(toT,strat);
     
    93619371void enterSBbaShift (LObject &p,int atS,kStrategy strat, int atR)
    93629372{
    9363   int toInsert = itoInsert(p.p, strat->tailRing);
    9364   for (int i = toInsert; i > 0; i--)
     9373  int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
     9374  for (int i = maxPossibleShift; i > 0; i--)
    93659375  {
    93669376    LObject qq;
     
    1020410214  strat->cp = 0;
    1020510215  strat->c3 = 0;
     10216#ifdef HAVE_SHIFTBBA
     10217  strat->cv = 0;
     10218#endif
    1020610219  strat->tail = pInit();
    1020710220  /*- set s -*/
     
    1026710280    updateS(TRUE,strat);
    1026810281  }
    10269   if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
    10270   strat->fromQ=NULL;
     10282#ifdef HAVE_SHIFTBBA
     10283  if (!(rIsLPRing(currRing) && strat->rightGB)) // for right GB, we need to check later whether a poly is from Q
     10284#endif
     10285  {
     10286    if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
     10287    strat->fromQ=NULL;
     10288  }
    1027110289  assume(kTest_TS(strat));
    1027210290}
     
    1028810306  pLmFree(&strat->tail);
    1028910307  strat->syzComp=0;
     10308
     10309#ifdef HAVE_SHIFTBBA
     10310  if (rIsLPRing(currRing) && strat->rightGB)
     10311  {
     10312    if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
     10313    strat->fromQ=NULL;
     10314  }
     10315#endif
    1029010316}
    1029110317
     
    1218012206
    1218112207#ifdef HAVE_SHIFTBBA
    12182 /* including the self pairs */
    12183 void updateSShift(kStrategy strat)
    12184 {
    12185   /* to use after updateS(toT=FALSE,strat) */
    12186   /* fills T with shifted elt's of S */
    12187   int i;
    12188   LObject h;
    12189   int atT = -1; // or figure out smth better
    12190   strat->tl = -1; // init
    12191   for (i=0; i<=strat->sl; i++)
    12192   {
    12193     memset(&h,0,sizeof(h));
    12194     h.p =  strat->S[i];
    12195     strat->initEcart(&h);
    12196     h.sev = strat->sevS[i];
    12197     h.t_p = NULL;
    12198     h.GetTP(); // creates correct t_p
    12199     /*puts the elements of S with their shifts to T*/
    12200     //    int atT, int uptodeg, int lV)
    12201     strat->S_2_R[i] = strat->tl + 1; // the el't with shift 0 will be inserted first
    12202     // need a small check for above; we insert >=1 elements
    12203     // insert this check into kTest_TS ?
    12204     enterTShift(h,strat,atT);
    12205   }
    12206   /* what about setting strat->tl? */
     12208// creates if possible (q,p), (shifts(q),p)
     12209static void enterOnePairWithShifts (int q_inS /*also i*/, poly q, poly p, int ecartp, int p_isFromQ, kStrategy strat, int atR, int p_lastVblock, int q_lastVblock)
     12210{
     12211  // note: ecart and isFromQ is for p
     12212  assume(q_inS < 0 || strat->S[q_inS] == q); // if q is from S, q_inS should be the index of q in S
     12213  assume(pmFirstVblock(p) == 1);
     12214  assume(pmFirstVblock(q) == 1);
     12215  assume(p_lastVblock == pmLastVblock(p));
     12216  assume(q_lastVblock == pmLastVblock(q));
     12217
     12218  // TODO: is ecartq = 0 still ok?
     12219  int ecartq = 0; //Hans says it's ok; we're in the homog case, no ecart
     12220
     12221  int q_isFromQ = 0;
     12222  if (strat->fromQ != NULL && q_inS >= 0)
     12223    q_isFromQ = strat->fromQ[q_inS];
     12224
     12225  int degbound = currRing->N/currRing->isLPring;
     12226  int neededShift = p_lastVblock - 1;
     12227  int maxPossibleShift = degbound - q_lastVblock;
     12228  int maxShift = si_min(neededShift, maxPossibleShift);
     12229  int firstShift = (q == p ? 1 : 0); // do not add (q,p) if q=p
     12230  for (int j = firstShift; j <= maxShift; j++)
     12231  {
     12232    poly qq = pLPCopyAndShiftLM(q, j);
     12233    enterOnePairShift(qq, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, j, q_inS);
     12234  }
    1220712235}
    1220812236#endif
    1220912237
    1221012238#ifdef HAVE_SHIFTBBA
    12211 void initBuchMoraShift (ideal F,ideal Q,kStrategy strat)
    12212 {
    12213   strat->interpt = BTEST1(OPT_INTERRUPT);
    12214   strat->kHEdge=NULL;
    12215   if (rHasGlobalOrdering(currRing)) strat->kHEdgeFound=FALSE;
    12216   /*- creating temp data structures------------------- -*/
    12217   strat->cp = 0;
    12218   strat->c3 = 0;
    12219   strat->cv = 0;
    12220   strat->tail = pInit();
    12221   /*- set s -*/
    12222   strat->sl = -1;
    12223   /*- set L -*/
    12224   strat->Lmax = setmaxL;
    12225   strat->Ll = -1;
    12226   strat->L = initL();
    12227   /*- set B -*/
    12228   strat->Bmax = setmaxL;
    12229   strat->Bl = -1;
    12230   strat->B = initL();
    12231   /*- set T -*/
    12232   strat->tl = -1;
    12233   strat->tmax = setmaxT;
    12234   strat->T = initT();
    12235   strat->R = initR();
    12236   strat->sevT = initsevT();
    12237   /*- init local data struct.---------------------------------------- -*/
    12238   strat->P.ecart=0;
    12239   strat->P.length=0;
    12240   if (rHasLocalOrMixedOrdering(currRing))
    12241   {
    12242     if (strat->kHEdge!=NULL) pSetComp(strat->kHEdge, strat->ak);
    12243     if (strat->kNoether!=NULL) pSetComp(strat->kNoetherTail(), strat->ak);
    12244   }
    12245   if(rField_is_Ring(currRing))
    12246   {
    12247     /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
    12248   }
    12249   {
    12250     if(TEST_OPT_SB_1)
    12251     {
    12252       int i;
    12253       ideal P=idInit(IDELEMS(F)-strat->newIdeal,F->rank);
    12254       for (i=strat->newIdeal;i<IDELEMS(F);i++)
    12255       {
    12256         P->m[i-strat->newIdeal] = F->m[i];
    12257         F->m[i] = NULL;
    12258       }
    12259       initSSpecial(F,Q,P,strat);
    12260       for (i=strat->newIdeal;i<IDELEMS(F);i++)
    12261       {
    12262         F->m[i] = P->m[i-strat->newIdeal];
    12263         P->m[i-strat->newIdeal] = NULL;
    12264       }
    12265       idDelete(&P);
    12266     }
    12267     else
    12268     {
    12269       /*Shdl=*/initSL(F, Q,strat); /*sets also S, ecartS, fromQ */
    12270       // /*Shdl=*/initS(F, Q,strat); /*sets also S, ecartS, fromQ */
    12271     }
    12272   }
    12273   strat->fromT = FALSE;
    12274   if (!TEST_OPT_SB_1)
    12275   {
    12276     /* the only change: we do not fill the set T*/
    12277     if(!rField_is_Ring(currRing)) updateS(FALSE,strat);
    12278   }
    12279   if (strat->fromQ!=NULL) omFreeSize(strat->fromQ,IDELEMS(strat->Shdl)*sizeof(int));
    12280   strat->fromQ=NULL;
    12281   /* more changes: fill the set T with all the shifts of elts of S*/
    12282   /* is done by other procedure */
     12239// creates if possible (q,p), use it when q is already shifted
     12240static void enterOnePairWithoutShifts (int p_inS /*also i*/, poly q, poly p, int ecartq, int q_isFromQ, kStrategy strat, int atR, int p_lastVblock, int q_shift)
     12241{
     12242  // note: ecart and isFromQ is for p
     12243  assume(p_inS < 0 || strat->S[p_inS] == p); // if p is from S, p_inS should be the index of p in S
     12244  assume(pmFirstVblock(p) == 1);
     12245  assume(p_lastVblock == pmLastVblock(p));
     12246  assume(q_shift == pmFirstVblock(q) - 1);
     12247
     12248  // TODO: is ecartp = 0 still ok?
     12249  int ecartp = 0; //Hans says it's ok; we're in the homog e:, no ecart
     12250
     12251  int p_isFromQ = 0;
     12252  if (strat->fromQ != NULL && p_inS >= 0)
     12253    p_isFromQ = strat->fromQ[p_inS];
     12254
     12255  int maxNeededShift = p_lastVblock - 1;
     12256  if (q_shift <= maxNeededShift)
     12257    enterOnePairShift(q, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, q_shift, -1);
    1228312258}
    1228412259#endif
    1228512260
    1228612261#ifdef HAVE_SHIFTBBA
    12287 /*1
    12288 * put the pairs (sh \dot s[i],p)  into the set B, ecart=ecart(p)
    12289 */
    12290 static void enterOnePairManyShifts (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
    12291 {
    12292   poly s = strat->S[i];
    12293   assume(i<=strat->sl); // from OnePair
    12294 
    12295   /* cycles through all shifts of s[i] until uptodeg - lastVblock(s[i]) */
    12296   /* that is create the pairs (f, s \dot g)  */
    12297 
    12298   //  poly q = pCopy(pHead(strat->S[i])); // lm in currRing
    12299   //  pNext(q) = prCopyR(pNext(strat->S[i]),strat->tailRing,currRing); // zero shift
    12300 
    12301  /* determine how many elements we have to insert for a given s[i] */
    12302   /* x(0)y(1)z(2) : lastVblock-1=2, to add until lastVblock=uptodeg-1 */
    12303   /* hence, a total number of elt's to add is: */
    12304   /*  int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1);  */
    12305   int toInsert =  itoInsert(s, currRing);
    12306 
    12307 
    12308   /* these vars hold for all shifts of s[i] */
    12309   int ecartq = 0; //Hans says it's ok; we're in the homog case, no ecart
    12310 
    12311   int qfromQ;
    12312   if (strat->fromQ != NULL)
    12313   {
    12314     qfromQ = strat->fromQ[i];
    12315   }
    12316   else
    12317   {
    12318     qfromQ = -1;
    12319   }
    12320 
    12321   // for the 0th shift: insert the orig. pair
    12322   enterOnePairShift(s, p, ecart, isFromQ, strat, -1, ecartq, qfromQ, 0, i);
    12323 
    12324   for (int j = 1; j <= toInsert; j++)
    12325   {
    12326     poly q = pLPCopyAndShiftLM(s, j);
    12327     enterOnePairShift(q, p, ecart, isFromQ, strat, -1, ecartq, qfromQ, j, i);
    12328   }
    12329 }
    12330 #endif
    12331 
    12332 #ifdef HAVE_SHIFTBBA
    12333 /*1
    12334 * put the pairs (sh \dot qq,p)  into the set B, ecart=ecart(p)
    12335 * despite the name, not only self shifts
    12336 */
    12337 void enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int /*atR*/)
    12338 {
    12339   /* should cycle through all shifts of q until uptodeg - lastVblock(q) */
    12340   /* that is create the pairs (f, s \dot g)  */
    12341 
    12342   int toInsert =  itoInsert(qq, currRing);
    12343 
    12344   /* these vars hold for all shifts of s[i] */
    12345   int ecartq = 0; //Hans says it's ok; we're in the homog case, no ecart
    12346   int qfromQ = 0; // strat->fromQ[i];
    12347 
    12348   /* since this proc is applied twice for (h, s*g) and (g,s*h), init j with 1 */
    12349   for (int j = 1; j<= toInsert; j++)
    12350   {
    12351     poly q = pLPCopyAndShiftLM(qq, j);
    12352     enterOnePairShift(q, p, ecart, isFromQ, strat, -1, ecartq, qfromQ, j, -1);
    12353   }
    12354 }
    12355 #endif
    12356 
    12357 #ifdef HAVE_SHIFTBBA
     12262
     12263#ifdef KDEBUG
     12264// enable to print which pairs are considered or discarded and why
     12265/* #define CRITERION_DEBUG */
     12266#endif
    1235812267/*2
    1235912268* put the pair (q,p)  into the set B, ecart=ecart(p), q is the shift of some s[i]
     
    1236112270void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
    1236212271{
     12272#ifdef CRITERION_DEBUG
     12273  if (TEST_OPT_DEBUG)
     12274  {
     12275    PrintS("Consider pair ("); wrp(q); PrintS(", "); wrp(p); PrintS(")"); PrintLn();
     12276    // also write the LMs in separate lines:
     12277    poly lmq = pHead(q);
     12278    poly lmp = pHead(p);
     12279    pSetCoeff(lmq, n_Init(1, currRing->cf));
     12280    pSetCoeff(lmp, n_Init(1, currRing->cf));
     12281    Print("    %s\n", pString(lmq));
     12282    Print("    %s\n", pString(lmp));
     12283    pLmDelete(lmq);
     12284    pLmDelete(lmp);
     12285  }
     12286#endif
    1236312287
    1236412288  /* Format: q and p are like strat->P.p, so lm in CR, tail in TR */
     
    1237012294  assume(p_CheckIsFromRing(pNext(p),strat->tailRing));
    1237112295
    12372 #ifdef KDEBUG
    12373 //    if (TEST_OPT_DEBUG)
    12374 //    {
    12375 //       PrintS("enterOnePairShift(q,p) invoked with q = ");
    12376 //       wrp(q); //      wrp(pHead(q));
    12377 //       PrintS(", p = ");
    12378 //       wrp(p); //wrp(pHead(p));
    12379 //       PrintLn();
    12380 //    }
    12381 #endif
    12382 
    1238312296  /* poly q stays for s[i], ecartq = ecart(q), qisFromQ = applies to q */
    1238412297
     
    1239712310  Lp.lcm = p_Lcm(p,q, currRing); // q is what was strat->S[i], so a poly in LM/TR presentation
    1239812311
    12399   /* apply the V criterion */
    12400   if (!pIsInV(Lp.lcm))
    12401   {
    12402 #ifdef KDEBUG
    12403     if (TEST_OPT_DEBUG)
    12404     {
    12405       PrintS("V crit applied to q = ");
    12406       wrp(q); //      wrp(pHead(q));
    12407       PrintS(", p = ");
    12408       wrp(p); //wrp(pHead(p));
    12409       PrintLn();
    12410     }
    12411 #endif
     12312  /* the V criterion */
     12313  if (!pmIsInV(Lp.lcm))
     12314  {
     12315    strat->cv++; // counter for applying the V criterion
    1241212316    pLmFree(Lp.lcm);
    12413     /* + counter for applying the V criterion */
    12414     strat->cv++;
     12317#ifdef CRITERION_DEBUG
     12318    if (TEST_OPT_DEBUG) PrintS("--- V crit\n");
     12319#endif
    1241512320    return;
    1241612321  }
     
    1243712342      strat->cp++;
    1243812343      pLmFree(Lp.lcm);
     12344#ifdef CRITERION_DEBUG
     12345      if (TEST_OPT_DEBUG) PrintS("--- prod crit\n");
     12346#endif
    1243912347      return;
    1244012348    }
     
    1244412352    {
    1244512353      pLmFree(Lp.lcm);
     12354#ifdef CRITERION_DEBUG
     12355      if (TEST_OPT_DEBUG) PrintS("--- ecartq > ecart\n");
     12356#endif
    1244612357      return;
    1244712358      /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
     
    1246612377          {
    1246712378            pLmFree(Lp.lcm);
     12379#ifdef CRITERION_DEBUG
     12380            if (TEST_OPT_DEBUG) Print("--- divided by B[%d]\n", j);
     12381#endif
    1246812382            return;
    1246912383          }
     
    1247512389        {
    1247612390          deleteInL(strat->B,&strat->Bl,j,strat);
     12391#ifdef CRITERION_DEBUG
     12392          if (TEST_OPT_DEBUG) Print("divides B[%d] -> delete B[%d]\n", j, j);
     12393#endif
    1247712394          strat->c3++;
    1247812395        }
     
    1250412421          strat->cp++;
    1250512422          pLmFree(Lp.lcm);
     12423#ifdef CRITERION_DEBUG
     12424          if (TEST_OPT_DEBUG) PrintS("--- prod crit\n");
     12425#endif
    1250612426          return;
    1250712427      }
     
    1250912429      {
    1251012430        pLmFree(Lp.lcm);
     12431#ifdef CRITERION_DEBUG
     12432        if (TEST_OPT_DEBUG) PrintS("--- ecartq > ecart\n");
     12433#endif
    1251112434        return;
    1251212435        /*the pair is (s[i],t[.]), discard it if the ecart is too big*/
     
    1252712450          {
    1252812451            pLmFree(Lp.lcm);
     12452#ifdef CRITERION_DEBUG
     12453            if (TEST_OPT_DEBUG) Print("--- divided by B[%d]\n", j);
     12454#endif
    1252912455            return;
    1253012456          }
     
    1253512461        {
    1253612462          deleteInL(strat->B,&strat->Bl,j,strat);
     12463#ifdef CRITERION_DEBUG
     12464          if (TEST_OPT_DEBUG) Print("divides B[%d] -> delete B[%d]\n", j, j);
     12465#endif
    1253712466          strat->c3++;
    1253812467        }
     
    1254712476    pNorm(p);
    1254812477  if ((q==NULL) || (p==NULL))
     12478  {
     12479#ifdef CRITERION_DEBUG
     12480    if (TEST_OPT_DEBUG) PrintS("--- q == NULL || p == NULL\n");
     12481#endif
    1254912482    return;
     12483  }
    1255012484  if ((strat->fromQ!=NULL) && (isFromQ!=0) && (qfromQ!=0))
     12485  {
    1255112486    Lp.p=NULL;
     12487#ifdef CRITERION_DEBUG
     12488    if (TEST_OPT_DEBUG) PrintS("--- pair from Q\n");
     12489#endif
     12490  }
    1255212491  else
    1255312492  {
     
    1260712546    */
    1260812547    if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
     12548#ifdef CRITERION_DEBUG
     12549    if (TEST_OPT_DEBUG) PrintS("--- S-poly = 0\n");
     12550#endif
    1260912551  }
    1261012552  else
     
    1264312585    l = strat->posInL(strat->B,strat->Bl,&Lp,strat);
    1264412586    enterL(&strat->B,&strat->Bl,&strat->Bmax,Lp,l);
     12587#ifdef CRITERION_DEBUG
     12588    if (TEST_OPT_DEBUG) PrintS("+++ Entered pair\n");
     12589#endif
    1264512590  }
    1264612591}
     
    1265512600void initenterpairsShift (poly h,int k,int ecart,int isFromQ, kStrategy strat, int atR)
    1265612601{
     12602  int h_lastVblock = pmLastVblock(h);
     12603  assume(h_lastVblock != 0 || pLmIsConstantComp(h));
     12604  // TODO: is it allowed to skip pairs with constants? also with constants from other components?
     12605  if (h_lastVblock == 0) return;
     12606  assume(pmFirstVblock(h) == 1);
    1265712607  /* h comes from strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
    1265812608  //  atR = -1;
     
    1266012610  || (pGetComp(h)<=strat->syzComp))
    1266112611  {
    12662     int j;
     12612    int i,j;
    1266312613    BOOLEAN new_pair=FALSE;
    1266412614
     12615    int degbound = currRing->N/currRing->isLPring;
     12616    int maxShift = degbound - h_lastVblock;
     12617
    1266512618    if (pGetComp(h)==0)
    1266612619    {
     12620      if (strat->rightGB)
     12621      {
     12622        if (isFromQ)
     12623        {
     12624          // pairs (shifts(h),s[1..k]), (h, s[1..k])
     12625          for (i=0; i<=maxShift; i++)
     12626          {
     12627            poly hh = pLPCopyAndShiftLM(h, i);
     12628            for (j=0; j<=k; j++)
     12629            {
     12630              if (strat->fromQ == NULL || !strat->fromQ[j])
     12631              {
     12632                new_pair=TRUE;
     12633                poly s = strat->S[j];
     12634                enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i);
     12635              }
     12636            }
     12637          }
     12638        }
     12639        else
     12640        {
     12641          new_pair=TRUE;
     12642          for (j=0; j<=k; j++)
     12643          {
     12644            poly s = strat->S[j];
     12645            if (strat->fromQ != NULL && strat->fromQ[j])
     12646            {
     12647              // pairs (shifts(s[j]),h), (s[j],h)
     12648              enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
     12649            }
     12650            else
     12651            {
     12652              // pair (h, s[j])
     12653              enterOnePairWithoutShifts(j, h, s, ecart, isFromQ, strat, atR, pmLastVblock(s), 0);
     12654            }
     12655          }
     12656        }
     12657      }
    1266712658      /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
    12668       if ((isFromQ)&&(strat->fromQ!=NULL))
    12669       {
    12670         for (j=0; j<=k; j++)
    12671         {
     12659      else if ((isFromQ)&&(strat->fromQ!=NULL))
     12660      {
     12661        // pairs (shifts(s[1..k]),h), (s[1..k],h)
     12662        for (j=0; j<=k; j++) {
    1267212663          if (!strat->fromQ[j])
    1267312664          {
    1267412665            new_pair=TRUE;
    12675             enterOnePairManyShifts(j,h,ecart,isFromQ,strat, atR);
    12676             // other side pairs:
    12677             enterOnePairSelfShifts(h,strat->S[j],ecart,isFromQ,strat, atR);
    12678           //Print("j:%d, Ll:%d\n",j,strat->Ll);
     12666            poly s = strat->S[j];
     12667            enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
    1267912668          }
    1268012669        }
     12670        // pairs (shifts(h),s[1..k])
     12671        if (new_pair)
     12672        {
     12673          for (i=1; i<=maxShift; i++)
     12674          {
     12675            poly hh = pLPCopyAndShiftLM(h, i);
     12676            for (j=0; j<=k; j++)
     12677            {
     12678              if (!strat->fromQ[j])
     12679              {
     12680                poly s = strat->S[j];
     12681                enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i);
     12682              }
     12683            }
     12684          }
     12685        }
    1268112686      }
    1268212687      else
    1268312688      {
    1268412689        new_pair=TRUE;
     12690        // pairs (shifts(s[1..k]),h), (s[1..k],h)
     12691        for (j=0; j<=k; j++) {
     12692          poly s = strat->S[j];
     12693          // TODO: cache lastVblock of s[1..k] for later use
     12694          enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
     12695        }
     12696        // pairs (shifts(h),s[1..k]), (shifts(h), h)
     12697        for (i=1; i<=maxShift; i++)
     12698        {
     12699          poly hh = pLPCopyAndShiftLM(h, i);
     12700          for (j=0; j<=k; j++)
     12701          {
     12702            poly s = strat->S[j];
     12703            enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i);
     12704          }
     12705          enterOnePairWithoutShifts(-1, hh, h, ecart, isFromQ, strat, atR, h_lastVblock, i);
     12706        }
     12707      }
     12708    }
     12709    else
     12710    {
     12711      new_pair=TRUE;
     12712      if (strat->rightGB)
     12713      {
    1268512714        for (j=0; j<=k; j++)
    1268612715        {
    12687           enterOnePairManyShifts(j,h,ecart,isFromQ,strat, atR);
    12688           // other side pairs
    12689           enterOnePairSelfShifts(h,strat->S[j],ecart,isFromQ,strat, atR);
    12690         }
    12691         /* HERE we put (h, s*h) pairs */
    12692        /* enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV); */
    12693        enterOnePairSelfShifts (h, h, ecart, isFromQ, strat, atR);
    12694       }
    12695     }
    12696     else
    12697     {
    12698       for (j=0; j<=k; j++)
    12699       {
    12700         if ((pGetComp(h)==pGetComp(strat->S[j]))
    12701         || (pGetComp(strat->S[j])==0))
    12702         {
    12703           new_pair=TRUE;
    12704           enterOnePairManyShifts(j,h,ecart,isFromQ,strat, atR);
    12705           // other side pairs
    12706           enterOnePairSelfShifts(h,strat->S[j],ecart,isFromQ,strat, atR);
    12707         //Print("j:%d, Ll:%d\n",j,strat->Ll);
    12708         }
    12709       }
    12710       /* HERE we put (h, s*h) pairs */
    12711       enterOnePairSelfShifts (h, h, ecart, isFromQ, strat, atR);
     12716          if ((pGetComp(h)==pGetComp(strat->S[j]))
     12717              || (pGetComp(strat->S[j])==0))
     12718          {
     12719            assume(isFromQ == 0); // this case is not handeled here and should also never happen
     12720            poly s = strat->S[j];
     12721            if (strat->fromQ != NULL && strat->fromQ[j])
     12722            {
     12723              // pairs (shifts(s[j]),h), (s[j],h)
     12724              enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
     12725            }
     12726            else
     12727            {
     12728              // pair (h, s[j])
     12729              enterOnePairWithoutShifts(j, h, s, ecart, isFromQ, strat, atR, pmLastVblock(s), 0);
     12730            }
     12731          }
     12732        }
     12733      }
     12734      else
     12735      {
     12736        // pairs (shifts(s[1..k]),h), (s[1..k],h)
     12737        for (j=0; j<=k; j++) {
     12738          if ((pGetComp(h)==pGetComp(strat->S[j]))
     12739              || (pGetComp(strat->S[j])==0))
     12740          {
     12741            poly s = strat->S[j];
     12742            enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
     12743          }
     12744        }
     12745        // pairs (shifts(h),s[1..k]), (shifts(h), h)
     12746        for (i=1; i<=maxShift; i++)
     12747        {
     12748          poly hh = pLPCopyAndShiftLM(h, i);
     12749          for (j=0; j<=k; j++)
     12750          {
     12751            if ((pGetComp(h)==pGetComp(strat->S[j]))
     12752                || (pGetComp(strat->S[j])==0))
     12753            {
     12754              poly s = strat->S[j];
     12755              enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i);
     12756            }
     12757          }
     12758          enterOnePairWithoutShifts(-1, hh, h, ecart, isFromQ, strat, atR, h_lastVblock, i);
     12759        }
     12760      }
    1271212761    }
    1271312762
     
    1273812787    ||(pGetComp(h)<=strat->syzComp)))
    1273912788  {
    12740     //Print("start clearS k=%d, pos=%d, sl=%d\n",k,pos,strat->sl);
    1274112789    unsigned long h_sev = pGetShortExpVector(h);
    1274212790    loop
    1274312791    {
    1274412792      if (j > k) break;
    12745       clearS(h,h_sev, &j,&k,strat);
     12793      // TODO this currently doesn't clear all possible elements because of commutative division
     12794      if (!(strat->rightGB && strat->fromQ != NULL && strat->fromQ[j]))
     12795        clearS(h,h_sev, &j,&k,strat);
    1274612796      j++;
    1274712797    }
    12748     //Print("end clearS sl=%d\n",strat->sl);
    12749   }
    12750  // PrintS("end enterpairs\n");
     12798  }
    1275112799}
    1275212800#endif
     
    1276512813  pAssume(p.p != NULL);
    1276612814
    12767   int toInsert = itoInsert(p.p, strat->tailRing);
    12768 
    12769   for (int i = 1; i <= toInsert; i++)
     12815  int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
     12816
     12817  for (int i = 1; i <= maxPossibleShift; i++)
    1277012818  {
    1277112819    LObject qq;
  • kernel/GBEngine/kutil.h

    rac8f852 r649021  
    368368  #ifdef HAVE_SHIFTBBA
    369369  int cv; // in shift bases: counting V criterion
     370  /*BOOLEAN*/ char rightGB;
    370371  #endif
    371372  /*BOOLEAN*/ char interpt;
     
    852853void enterTShift(LObject p, kStrategy strat, int atT = -1);
    853854
    854 void initBuchMoraShift (ideal F,ideal Q,kStrategy strat);
    855 
    856 void enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int atR);
    857 
    858855void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS);
    859856
    860857void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR);
    861858
    862 void updateSShift(kStrategy strat);
    863 
    864859void initBbaShift(kStrategy strat);
    865860
     
    868863int redFirstShift (LObject* h,kStrategy strat); // ok
    869864
    870 ideal freegb(ideal I);
     865ideal freegb(ideal F);
     866ideal rightgb(ideal F, ideal Q);
    871867
    872868ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat);
  • kernel/GBEngine/shiftgb.cc

    rac8f852 r649021  
    4343}
    4444
    45 /* for poly in lmCR/tailTR presentation */
    46 int itoInsert(poly p, const ring r)
     45int p_mLPmaxPossibleShift(poly p, const ring r)
    4746{
    48   /* the below situation (commented out) might happen! */
    49 //   if (r == currRing)
    50 //   {
    51 //     "Current ring is not expected in toInsert";
    52 //     return(0);
    53 //   }
    54   /* compute the number of insertions */
    55   int i = p_mLastVblock(p, currRing);
    56   if (pNext(p) != NULL)
    57   {
    58     i = si_max(i, p_LastVblock(pNext(p), r) );
    59   }
    60   //  i = uptodeg  - i +1;
     47  int lastBlock = p_mLastVblock(p, r);
     48  if (lastBlock == 0) return 0;
    6149  int uptodeg = r->N/r->isLPring;
    62   //  p_wrp(p,currRing,r); Print("----i:%d",i); PrintLn();
    63   return uptodeg - i;
     50  return uptodeg - lastBlock;
    6451}
    6552
  • kernel/GBEngine/shiftgb.h

    rac8f852 r649021  
    1515#define pLPCopyAndShiftLM(p, sh) p_LPCopyAndShiftLM(p, sh, currRing)
    1616
    17 int itoInsert(poly p, const ring r);
     17int p_mLPmaxPossibleShift(poly p, const ring r);
     18#define pmLPmaxPossibleShift(p) p_mLPmaxPossibleShift(p, currRing)
    1819
    1920#endif
  • libpolys/polys/shiftop.cc

    r552931 r649021  
    823823        return NULL;
    824824      }
    825       int ** wvhdl=(int**)omAlloc0((r->N+2)*sizeof(int*));
    826       rRingOrder_t* ord=(rRingOrder_t*)omAlloc0((r->N+2)*sizeof(rRingOrder_t));
    827       int* blk0=(int*)omAlloc0((r->N+2)*sizeof(int));
    828       int* blk1=(int*)omAlloc0((r->N+2)*sizeof(int));
     825      int ** wvhdl=(int**)omAlloc0((r->N+3)*sizeof(int*));
     826      rRingOrder_t* ord=(rRingOrder_t*)omAlloc0((r->N+3)*sizeof(rRingOrder_t));
     827      int* blk0=(int*)omAlloc0((r->N+3)*sizeof(int));
     828      int* blk1=(int*)omAlloc0((r->N+3)*sizeof(int));
    829829      omFree(R->wvhdl);  R->wvhdl=wvhdl;
    830830      omFree(R->order);  R->order=ord;
     
    834834      {
    835835        ord[i+p]=ringorder_a;
     836        //Print("entry:%d->a\n",i+p);
    836837        blk0[i+p]=1;
    837838        blk1[i+p]=R->N;
     
    847848      }
    848849      ord[r->N+p]=r->order[p]; /* lp or rp */
     850      //Print("entry:%d->lp\n",r->N+p);
    849851      blk0[r->N+p]=1;
    850852      blk1[r->N+p]=R->N;
     
    857859        return NULL;
    858860      }
     861      //if (p==1) PrintS("entry:0 ->c/C\n");
     862      //else if (p==0) Print("entry:%d ->c/C\n",r->N+1);
    859863      break;
    860864    }
Note: See TracChangeset for help on using the changeset viewer.