Changeset 94b41d in git


Ignore:
Timestamp:
Nov 17, 2019, 1:56:50 PM (4 years ago)
Author:
Karim Abou Zeid <karim23697@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
d98572591d1fca3f746f3511db83ac38423d00a4
Parents:
7e4d6070d91c9efd029e8337428f08708947a129
Message:
LP Z V1
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • Singular/table.h

    r7e4d60 r94b41d  
    285285#endif
    286286#if defined(HAVE_PLURAL) || defined(HAVE_SHIFTBBA)
    287 ,{D(jjTWOSTD),     TWOSTD_CMD,      IDEAL_CMD,      IDEAL_CMD     , ALLOW_NC |NO_RING}
     287,{D(jjTWOSTD),     TWOSTD_CMD,      IDEAL_CMD,      IDEAL_CMD     , ALLOW_NC |ALLOW_RING}
    288288#endif
    289289#ifdef HAVE_SHIFTBBA
    290 ,{D(jjTWOSTD),     TWOSTD_CMD,      MODUL_CMD,      MODUL_CMD     , ALLOW_LP |NO_RING}
     290,{D(jjTWOSTD),     TWOSTD_CMD,      MODUL_CMD,      MODUL_CMD     , ALLOW_LP |ALLOW_RING}
    291291#endif
    292292//,{  jjWRONG ,      TRACE_CMD,       0,              INTVEC_CMD    , ALLOW_NC |ALLOW_RING}
  • kernel/GBEngine/kspoly.cc

    r7e4d60 r94b41d  
    383383  }
    384384
     385#ifdef HAVE_SHIFTBBA
     386  poly lmRight;
     387  if (tailRing->isLPring)
     388  {
     389    assume(PR->shift == 0);
     390    assume(PW->shift == si_max(p_mFirstVblock(PW->p, tailRing) - 1, 0));
     391    k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing);
     392  }
     393#endif
     394
    385395  number ct, an, bn;
    386396  // take care of coef buisness
     
    400410
    401411  // and finally,
    402   PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
     412#ifdef HAVE_SHIFTBBA
     413  if (tailRing->isLPring)
     414  {
     415    PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(t2, lmRight, tailRing), pLength(t2), spNoether);
     416  }
     417  else
     418#endif
     419  {
     420    PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether);
     421  }
    403422  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
    404423  pSetCoeff(PR->p, ct);
    405 
    406   // the following is commented out: shrinking
    407 #ifdef HAVE_SHIFTBBA_NONEXISTENT
    408   if ( (currRing->isLPring) && (!strat->homog) )
    409   {
    410     // assume? h->p in currRing
    411     PR->GetP();
    412     poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
    413     PR->Clear(); // does the right things
    414     PR->p = qq;
    415     PR->t_p = NULL;
    416     PR->SetShortExpVector();
    417   }
    418 #endif
    419424
    420425  return ret;
     
    503508  }
    504509
     510#ifdef HAVE_SHIFTBBA
     511  poly lmRight;
     512  if (tailRing->isLPring)
     513  {
     514    assume(PR->shift == 0);
     515    assume(PW->shift == si_max(p_mFirstVblock(PW->p, tailRing) - 1, 0));
     516    k_SplitFrame(lm, lmRight, PW->shift + 1, tailRing);
     517  }
     518#endif
     519
    505520  // and finally,
    506   PR->Tail_Minus_mm_Mult_qq(lm, p2, pLength(p2) /*PW->GetpLength() - 1*/, spNoether);
     521#ifdef HAVE_SHIFTBBA
     522  if (tailRing->isLPring)
     523  {
     524    PR->Tail_Minus_mm_Mult_qq(lm, tailRing->p_Procs->pp_Mult_mm(p2, lmRight, tailRing), pLength(p2), spNoether);
     525  }
     526  else
     527#endif
     528  {
     529    PR->Tail_Minus_mm_Mult_qq(lm, p2, pLength(p2) /*PW->GetpLength() - 1*/, spNoether);
     530  }
    507531  assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p));
    508532
    509533  PR->LmDeleteAndIter();
    510534  p_SetCoeff(PR->p, *coef, currRing);
    511 
    512 
    513   // the following is commented out: shrinking
    514 #ifdef HAVE_SHIFTBBA_NONEXISTENT
    515   if ( (currRing->isLPring) && (!strat->homog) )
    516   {
    517     // assume? h->p in currRing
    518     PR->GetP();
    519     poly qq = p_Shrink(PR->p, currRing->isLPring, currRing);
    520     PR->Clear(); // does the right things
    521     PR->p = qq;
    522     PR->t_p = NULL;
    523     PR->SetShortExpVector();
    524   }
    525 #endif
    526535
    527536#if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)
     
    11881197  if (tailRing->isLPring)
    11891198  {
    1190     assume(si_max(p_mFirstVblock(p2, tailRing) - 1, 0) == 0);
    1191     // note: because of how the pairs are created, p2 should never be shifted
    1192     int split = p_mFirstVblock(p1, tailRing);
    1193     k_SplitFrame(m1, m12, split, tailRing);
    1194     k_SplitFrame(m2, m22, split, tailRing);
     1199    assume(p_mFirstVblock(p1, tailRing) <= 1 || p_mFirstVblock(p2, tailRing) <= 1);
     1200    k_SplitFrame(m1, m12, p_mFirstVblock(p1, tailRing), tailRing);
     1201    k_SplitFrame(m2, m22, p_mFirstVblock(p2, tailRing), tailRing);
    11951202    // manually free the coeffs, because pSetCoeff0 is used in the next step
    11961203    n_Delete(&(m1->coef), tailRing->cf);
  • kernel/GBEngine/kstd2.cc

    r7e4d60 r94b41d  
    989989      if (at <= strat->Ll)
    990990      {
    991         int dummy=strat->sl;
    992         if (kFindDivisibleByInS(strat, &dummy, h) < 0)
    993           return 1;
     991#ifdef HAVE_SHIFTBBA
     992        if (rIsLPRing(currRing))
     993        {
     994          if (kFindDivisibleByInT(strat, h) < 0)
     995            return 1;
     996        }
     997        else
     998#endif
     999        {
     1000          int dummy=strat->sl;
     1001          if (kFindDivisibleByInS(strat, &dummy, h) < 0)
     1002            return 1;
     1003        }
    9941004        enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
    9951005#ifdef KDEBUG
     
    16841694      {
    16851695#if 1
    1686         int dummy=strat->sl;
    1687         if (kFindDivisibleByInS(strat, &dummy, h) < 0)
    1688           return 1;
     1696#ifdef HAVE_SHIFTBBA
     1697        if (rIsLPRing(currRing))
     1698        {
     1699          if (kFindDivisibleByInT(strat, h) < 0)
     1700            return 1;
     1701        }
     1702        else
     1703#endif
     1704        {
     1705          int dummy=strat->sl;
     1706          if (kFindDivisibleByInS(strat, &dummy, h) < 0)
     1707            return 1;
     1708        }
    16891709#endif
    16901710#ifdef KDEBUG
     
    18851905      if (at <= strat->Ll)
    18861906      {
    1887         int dummy=strat->sl;
    1888         if (kFindDivisibleByInS(strat, &dummy, h) < 0)
    1889           return 1;
     1907#ifdef HAVE_SHIFTBBA
     1908        if (rIsLPRing(currRing))
     1909        {
     1910          if (kFindDivisibleByInT(strat, h) < 0)
     1911            return 1;
     1912        }
     1913        else
     1914#endif
     1915        {
     1916          int dummy=strat->sl;
     1917          if (kFindDivisibleByInS(strat, &dummy, h) < 0)
     1918            return 1;
     1919        }
    18901920        enterL(&strat->L,&strat->Ll,&strat->Lmax,*h,at);
    18911921#ifdef KDEBUG
     
    23672397      /* reduction of the element chosen from L */
    23682398      red_result = strat->red(&strat->P,strat);
    2369       if (errorreported)  break;
     2399      if (errorreported) break;
    23702400    }
    23712401
     
    42324262  SI_SAVE_OPT1(save);
    42334263
    4234   initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit, NO CHANGES */
     4264  initBuchMoraCrit(strat); /*set Gebauer, honey, sugarCrit*/
    42354265  if(rField_is_Ring(currRing))
    42364266    initBuchMoraPosRing(strat);
    42374267  else
    4238     initBuchMoraPos(strat); /*NO CHANGES YET: perhaps later*/
    4239   initHilbCrit(F,Q,&hilb,strat); /*NO CHANGES*/
    4240   initBbaShift(strat); /* DONE */
     4268    initBuchMoraPos(strat);
     4269  initHilbCrit(F,Q,&hilb,strat);
     4270  initBba(strat);
    42414271  /*set enterS, spSpolyShort, reduce, red, initEcart, initEcartPair*/
    42424272  /*Shdl=*/initBuchMora(F, Q,strat);
     
    42564286
    42574287#ifdef HAVE_TAIL_RING
    4258 //  kStratInitChangeTailRing(strat);
    4259    strat->tailRing=currRing;
    4260 #endif
    4261 
     4288  // if(!idIs0(F) &&(!rField_is_Ring(currRing)))  // create strong gcd poly computes with tailring and S[i] ->to be fixed
     4289  //   kStratInitChangeTailRing(strat);
     4290  strat->tailRing=currRing;
     4291#endif
     4292  if (BVERBOSE(23))
     4293  {
     4294    if (test_PosInT!=NULL) strat->posInT=test_PosInT;
     4295    if (test_PosInL!=NULL) strat->posInL=test_PosInL;
     4296    kDebugPrint(strat);
     4297  }
    42624298
    42634299#ifdef KDEBUG
     
    42674303  while (strat->Ll >= 0)
    42684304  {
    4269 #ifdef KDEBUG
    4270     if (TEST_OPT_DEBUG) messageSets(strat);
    4271 #endif
    4272     if (strat->Ll== 0) strat->interpt=TRUE;
     4305    #ifdef KDEBUG
     4306      if (TEST_OPT_DEBUG) messageSets(strat);
     4307    #endif
     4308    if (siCntrlc)
     4309    {
     4310      while (strat->Ll >= 0)
     4311        deleteInL(strat->L,&strat->Ll,strat->Ll,strat);
     4312      strat->noClearS=TRUE;
     4313    }
    42734314    if (TEST_OPT_DEGBOUND
    42744315        && ((strat->honey && (strat->L[strat->Ll].ecart+currRing->pFDeg(strat->L[strat->Ll].p,currRing)>Kstd1_deg))
     
    42894330      else strat->noClearS=TRUE;
    42904331    }
     4332    if (strat->Ll== 0) strat->interpt=TRUE;
    42914333    /* picks the last element from the lazyset L */
    42924334    strat->P = strat->L[strat->Ll];
     
    42964338    {
    42974339      // deletes the short spoly
    4298       pLmFree(strat->P.p);
     4340      if (rField_is_Ring(currRing))
     4341        pLmDelete(strat->P.p);
     4342      else
     4343        pLmFree(strat->P.p);
    42994344      strat->P.p = NULL;
    43004345      poly m1 = NULL, m2 = NULL;
     
    43074352        // if not, change to a ring where exponents are at least
    43084353        // large enough
    4309         kStratChangeTailRing(strat);
     4354        if (!kStratChangeTailRing(strat))
     4355        {
     4356          WerrorS("OVERFLOW...");
     4357          break;
     4358        }
    43104359      }
    43114360      // create the real one
     
    43214370    }
    43224371
    4323     if (strat->P.p == NULL && strat->P.t_p == NULL)
     4372    if ((strat->P.p == NULL) && (strat->P.t_p == NULL))
    43244373    {
    43254374      red_result = 0;
     
    43344383      red_result = strat->red(&strat->P,strat);
    43354384      if (errorreported) break;
     4385    }
     4386
     4387    if (strat->overflow)
     4388    {
     4389      if (!kStratChangeTailRing(strat)) { WerrorS("OVERFLOW.."); break;}
    43364390    }
    43374391
     
    43554409      // therefore we call pCleardenom instead of pNorm
    43564410      strat->redTailChange=FALSE;
    4357       if (TEST_OPT_INTSTRATEGY)
     4411     
     4412      /* if we are computing over Z we always want to try and cut down
     4413       * the coefficients in the tail terms */
     4414      if (rField_is_Z(currRing) && !rHasLocalOrMixedOrdering(currRing)) {
     4415        redtailBbaAlsoLC_Z(&(strat->P), strat->tl, strat);
     4416        strat->P.pCleardenom();
     4417      }
     4418
     4419      if ((TEST_OPT_INTSTRATEGY) || (rField_is_Ring(currRing)))
    43584420      {
    43594421        strat->P.pCleardenom();
    43604422        if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL))
    43614423        {
     4424          strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT,!TEST_OPT_CONTENTSB);
     4425          strat->P.pCleardenom();
     4426          if (strat->redTailChange)
     4427          {
     4428            strat->P.t_p=NULL;
     4429            strat->initEcart(&(strat->P)); // somehow we need this here with letterplace
     4430          }
     4431        }
     4432      }
     4433      else
     4434      {
     4435        strat->P.pNorm();
     4436        if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL))
     4437        {
    43624438          strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
    4363           strat->P.pCleardenom();
    4364           if (strat->redTailChange) {
     4439          if (strat->redTailChange)
     4440          {
    43654441            strat->P.t_p=NULL;
    4366             strat->initEcart(&(strat->P));
    4367           }
    4368         }
    4369       }
    4370       else
    4371       {
    4372         strat->P.pNorm();
    4373         if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) {
    4374           strat->P.p = redtailBba(&(strat->P),pos-1,strat, withT);
    4375           if (strat->redTailChange) {
    4376             strat->P.t_p=NULL;
    4377             strat->initEcart(&(strat->P));
     4442            strat->initEcart(&(strat->P)); // somehow we need this here with letterplace
    43784443          }
    43794444        }
     
    43824447#ifdef KDEBUG
    43834448      if (TEST_OPT_DEBUG){PrintS("new s:");strat->P.wrp();PrintLn();}
    4384 #endif
     4449#endif /* KDEBUG */
    43854450
    43864451      // min_std stuff
     
    44454510#ifdef KDEBUG
    44464511    memset(&(strat->P), 0, sizeof(strat->P));
    4447 #endif
     4512#endif /* KDEBUG */
    44484513    kTest_TS(strat);
    44494514  }
    44504515#ifdef KDEBUG
    44514516  if (TEST_OPT_DEBUG) messageSets(strat);
    4452 #endif
     4517#endif /* KDEBUG */
    44534518  /*  shift case: look for elt's in S such that they are divisible by elt in T */
    44544519  if ((TEST_OPT_SB_1 || TEST_OPT_REDSB) && !strat->noClearS) // when is OPT_SB_1 set?
    44554520  {
    4456     for (int k = 0; k <= strat->sl; ++k)
    4457     {
    4458       if ((strat->fromQ!=NULL) && (strat->fromQ[k])) continue; // do not reduce Q_k
    4459       for (int j = 0; j<=strat->tl; ++j)
    4460       {
    4461         // this is like clearS in bba, but we reduce with elements from T, because it contains the shifts too
    4462         assume(strat->sevT[j] == pGetShortExpVector(strat->T[j].p));
    4463         assume(strat->sevS[k] == pGetShortExpVector(strat->S[k]));
    4464         if (pLmShortDivisibleBy(strat->T[j].p, strat->sevT[j], strat->S[k], ~strat->sevS[k]))
    4465         {
    4466           if (pLmCmp(strat->T[j].p, strat->S[k]) != 0) { // check whether LM is different
    4467             deleteInS(k, strat);
    4468             --k;
    4469             break;
     4521    if(!rField_is_Ring(currRing))
     4522    {
     4523      for (int k = 0; k <= strat->sl; ++k)
     4524      {
     4525        if ((strat->fromQ!=NULL) && (strat->fromQ[k])) continue; // do not reduce Q_k
     4526        for (int j = 0; j<=strat->tl; ++j)
     4527        {
     4528          // this is like clearS in bba, but we reduce with elements from T, because it contains the shifts too
     4529          assume(strat->sevT[j] == pGetShortExpVector(strat->T[j].p));
     4530          assume(strat->sevS[k] == pGetShortExpVector(strat->S[k]));
     4531          if (pLmShortDivisibleBy(strat->T[j].p, strat->sevT[j], strat->S[k], ~strat->sevS[k]))
     4532          {
     4533            if (pLmCmp(strat->T[j].p, strat->S[k]) != 0) { // check whether LM is different
     4534              deleteInS(k, strat);
     4535              --k;
     4536              break;
     4537            }
    44704538          }
    44714539        }
     
    45014569  /* release temp data-------------------------------- */
    45024570  exitBuchMora(strat);
     4571  /* postprocessing for GB over ZZ --------------------*/
     4572  if (!errorreported)
     4573  {
     4574    if(rField_is_Z(currRing))
     4575    {
     4576      for(int i = 0;i<=strat->sl;i++)
     4577      {
     4578        if(!nGreaterZero(pGetCoeff(strat->S[i])))
     4579        {
     4580          strat->S[i] = pNeg(strat->S[i]);
     4581        }
     4582      }
     4583      finalReduceByMon(strat);
     4584      for(int i = 0;i<IDELEMS(strat->Shdl);i++)
     4585      {
     4586        if(!nGreaterZero(pGetCoeff(strat->Shdl->m[i])))
     4587        {
     4588          strat->S[i] = pNeg(strat->Shdl->m[i]);
     4589        }
     4590      }
     4591    }
     4592    //else if (rField_is_Ring(currRing))
     4593    //  finalReduceByMon(strat);
     4594  }
    45034595//  if (TEST_OPT_WEIGHTM)
    45044596//  {
     
    45134605  SI_RESTORE_OPT1(save);
    45144606  /* postprocessing for GB over Q-rings ------------------*/
    4515   if (Q!=NULL) updateResult(strat->Shdl,Q,strat);
     4607  if ((Q!=NULL)&&(!errorreported)) updateResult(strat->Shdl,Q,strat);
    45164608
    45174609  idTest(strat->Shdl);
     
    46554747  }
    46564748}
    4657 
    4658 void initBbaShift(kStrategy strat)
    4659 {
    4660  /* setting global variables ------------------- */
    4661   strat->enterS = enterSBba; /* remains as is, we change enterT! */
    4662 
    4663   strat->red = redFirstShift; /* no redHomog ! */
    4664 
    4665   if (currRing->pLexOrder && strat->honey)
    4666     strat->initEcart = initEcartNormal;
    4667   else
    4668     strat->initEcart = initEcartBBA;
    4669   if (strat->honey)
    4670     strat->initEcartPair = initEcartPairMora;
    4671   else
    4672     strat->initEcartPair = initEcartPairBba;
    4673 //  if ((TEST_OPT_WEIGHTM)&&(F!=NULL))
    4674 //  {
    4675 //    //interred  machen   Aenderung
    4676 //    pFDegOld=currRing->pFDeg;
    4677 //    pLDegOld=pLDeg;
    4678 //    //h=ggetid("ecart");
    4679 //    //if ((h!=NULL) /*&& (IDTYP(h)==INTVEC_CMD)*/)
    4680 //    //{
    4681 //    //  ecartWeights=iv2array(IDINTVEC(h));
    4682 //    //}
    4683 //    //else
    4684 //    {
    4685 //      ecartWeights=(short *)omAlloc(((currRing->N)+1)*sizeof(short));
    4686 //      /*uses automatic computation of the ecartWeights to set them*/
    4687 //      kEcartWeights(F->m,IDELEMS(F)-1,ecartWeights,currRing);
    4688 //    }
    4689 //    pRestoreDegProcs(currRing,totaldegreeWecart, maxdegreeWecart);
    4690 //    if (TEST_OPT_PROT)
    4691 //    {
    4692 //      for(int i=1; i<=rVar(currRing); i++)
    4693 //        Print(" %d",ecartWeights[i]);
    4694 //      PrintLn();
    4695 //      mflush();
    4696 //    }
    4697 //  }
    4698 }
    4699 #endif
     4749#endif
  • kernel/GBEngine/kutil.cc

    r7e4d60 r94b41d  
    733733}
    734734
     735#ifdef HAVE_SHIFTBBA
     736int kFindInTShift(poly p, TSet T, int tlength)
     737{
     738  int i;
     739
     740  for (i=0; i<=tlength; i++)
     741  {
     742    // in the Letterplace ring the LMs in T and L are copies thus we have to use pEqualPolys() instead of ==
     743    if (pEqualPolys(T[i].p, p)) return i;
     744  }
     745  return -1;
     746}
     747
     748int kFindInTShift(poly p, kStrategy strat)
     749{
     750  int i;
     751  do
     752  {
     753    i = kFindInTShift(p, strat->T, strat->tl);
     754    if (i >= 0) return i;
     755    strat = strat->next;
     756  }
     757  while (strat != NULL);
     758  return -1;
     759}
     760#endif
     761
    735762#ifdef KDEBUG
    736763
     
    924951      }
    925952    }
    926     if (testp!=2) kFalseReturn(kTest_T(L, strat_tailRing, lpos, 'L'));
     953    kFalseReturn(kTest_T(L, strat_tailRing, lpos, 'L'));
    927954    if (pn != NULL)
    928955      pNext(L->p) = pn;
     
    942969    pFalseReturn(pp_Test(L->p2, currRing, L->tailRing));
    943970  }
    944   else if (tlength > 0 && T != NULL && (lpos >=0) && (testp!=2))
     971  else if (tlength > 0 && T != NULL && (lpos >=0))
    945972  {
    946973    // now p1 and p2 must be != NULL and must be contained in T
    947     // unless for SHIFTGB: here each p_i must be in T or
    948     // be shifted from an element in T -> to difficult to test
    949974    int i;
    950     i = kFindInT(L->p1, T, tlength);
     975#ifdef HAVE_SHIFTBBA
     976    if (rIsLPRing(currRing))
     977      i = kFindInTShift(L->p1, T, tlength);
     978    else
     979#endif
     980      i = kFindInT(L->p1, T, tlength);
    951981    if (i < 0)
    952982      return dReportError("L[%d].p1 not in T",lpos);
    953     i = kFindInT(L->p2, T, tlength);
     983#ifdef HAVE_SHIFTBBA
     984    if (rIsLPRing(currRing))
     985    {
     986      if (rField_is_Ring(currRing)) return TRUE; // m*shift(q) is not in T
     987      i = kFindInTShift(L->p2, T, tlength);
     988    }
     989    else
     990#endif
     991      i = kFindInT(L->p2, T, tlength);
    954992    if (i < 0)
    955993      return dReportError("L[%d].p2 not in T",lpos);
     
    9801018  if (strat->L != NULL)
    9811019  {
    982   #ifdef HAVE_SHIFTBBA
    983     if (strat->red==redFirstShift) // is this in bbaShift ?
    984     {
    985       for (i=0; i<=strat->Ll; i++)
    986       {
    987         kFalseReturn(kTest_L(&(strat->L[i]), strat->tailRing,
    988                            2, i,
    989                            strat->T, strat->tl));
    990       }
    991     }
    992     else
    993   #endif
    9941020    for (i=0; i<=strat->Ll; i++)
    9951021    {
     
    10611087  // test strat->L[i].i_r1
    10621088  #ifdef HAVE_SHIFTBBA
    1063   if (strat->red!=redFirstShift) // not from bbaShift
     1089  if (!rIsLPRing(currRing)) // in the Letterplace ring we currently don't set/use i_r1 and i_r2
    10641090  #endif
    10651091  if (strat->L!=NULL)
     
    95349560    p.pCleardenom();
    95359561    if ((TEST_OPT_REDSB)||(TEST_OPT_REDTAIL)) {
    9536       p.p = redtailBba(&p,strat->sl,strat, FALSE,!TEST_OPT_CONTENTSB);
     9562#ifdef HAVE_SHIFTBBA
     9563      if (rIsLPRing(currRing))
     9564        p.p = redtailBba(&p,strat->tl,strat, TRUE,!TEST_OPT_CONTENTSB);
     9565      else
     9566#endif
     9567      {
     9568        p.p = redtailBba(&p,strat->sl,strat, FALSE,!TEST_OPT_CONTENTSB);
     9569      }
    95379570      p.pCleardenom();
    95389571      if (strat->redTailChange)
     
    95499582  /* enter p to T set */
    95509583  enterT(p, strat);
     9584#ifdef HAVE_SHIFTBBA
     9585  if (rIsLPRing(currRing) && !strat->rightGB)
     9586    enterTShift(p,strat);
     9587#endif
    95519588
    95529589  for (j = 0; j <= strat->sl; ++j) {
     
    95789615    }
    95799616  }
    9580   /* generate new pairs with p, probably removing older, now useless pairs */
    9581   superenterpairs(p.p, strat->sl, p.ecart, pos, strat, strat->tl);
     9617#ifdef HAVE_SHIFTBBA
     9618  if (rIsLPRing(currRing))
     9619    enterpairsShift(p.p, strat->sl, p.ecart, pos, strat, strat->tl); // TODO LP
     9620  else
     9621#endif
     9622  {
     9623    /* generate new pairs with p, probably removing older, now useless pairs */
     9624    superenterpairs(p.p, strat->sl, p.ecart, pos, strat, strat->tl);
     9625  }
    95829626  /* enter p to S set */
    95839627  strat->enterS(p, pos, strat, strat->tl);
     
    1117911223      while(ok == FALSE && p != NULL)
    1118011224      {
    11181         if(pLmDivisibleBy(strat->S[i], p))
     11225        if(pLmDivisibleBy(strat->S[i], p)
     11226#ifdef HAVE_SHIFTBBA
     11227            || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], p))
     11228#endif
     11229          )
    1118211230        {
    1118311231          number dummy = n_IntMod(p->coef, strat->S[i]->coef, currRing->cf);
     
    1120011248        while(pp != NULL)
    1120111249        {
    11202           if(pLmDivisibleBy(strat->S[i], pp))
     11250          if(pLmDivisibleBy(strat->S[i], pp)
     11251#ifdef HAVE_SHIFTBBA
     11252            || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->S[i], pp))
     11253#endif
     11254            )
    1120311255          {
    1120411256            number dummy = n_IntMod(pp->coef, strat->S[i]->coef, currRing->cf);
     
    1133611388        {
    1133711389          p = strat->Shdl->m[i];
    11338           while((p!=NULL) && pLmDivisibleBy(strat->Shdl->m[j], p))
     11390          while((p!=NULL) && (pLmDivisibleBy(strat->Shdl->m[j], p)
     11391#if HAVE_SHIFTBBA
     11392                || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], p))
     11393#endif
     11394                ))
    1133911395          {
    1134011396            number dummy = n_IntMod(p->coef, strat->Shdl->m[j]->coef, currRing->cf);
     
    1136411420            while(pp != NULL)
    1136511421            {
    11366               if(pLmDivisibleBy(strat->Shdl->m[j], pp))
     11422              if(pLmDivisibleBy(strat->Shdl->m[j], pp)
     11423#if HAVE_SHIFTBBA
     11424                  || (rIsLPRing(currRing) && pLPLmDivisibleBy(strat->Shdl->m[j], pp))
     11425#endif
     11426                )
    1136711427              {
    1136811428                number dummy = n_IntMod(pp->coef, strat->Shdl->m[j]->coef, currRing->cf);
     
    1220912269
    1221012270#ifdef HAVE_SHIFTBBA
     12271/*2
     12272* put the  lcm(q,p)  into the set B, q is the shift of some s[i]
     12273*/
     12274static BOOLEAN enterOneStrongPolyShift (poly q, poly p, int /*ecart*/, int /*isFromQ*/, kStrategy strat, int atR, int /*ecartq*/, int qisFromQ, int shiftcount, int ifromS)
     12275{
     12276  number d, s, t;
     12277  /* assume(atR >= 0); */
     12278  assume(ifromS <= strat->sl);
     12279  assume(rField_is_Ring(currRing));
     12280  poly m1, m2, gcd;
     12281  //printf("\n--------------------------------\n");
     12282  //pWrite(p);pWrite(si);
     12283  d = n_ExtGcd(pGetCoeff(p), pGetCoeff(q), &s, &t, currRing->cf);
     12284
     12285  if (nIsZero(s) || nIsZero(t))  // evtl. durch divBy tests ersetzen
     12286  {
     12287    nDelete(&d);
     12288    nDelete(&s);
     12289    nDelete(&t);
     12290    return FALSE;
     12291  }
     12292
     12293  assume(pIsInV(p));
     12294
     12295  k_GetStrongLeadTerms(p, q, currRing, m1, m2, gcd, strat->tailRing);
     12296
     12297  /* the V criterion */
     12298  if (!pmIsInV(gcd))
     12299  {
     12300    strat->cv++;
     12301    nDelete(&d);
     12302    nDelete(&s);
     12303    nDelete(&t);
     12304    pLmFree(gcd);
     12305    return FALSE;
     12306  }
     12307
     12308  // disabled for Letterplace because it is not so easy to check
     12309  /* if (!rHasLocalOrMixedOrdering(currRing)) { */
     12310  /*   unsigned long sev = pGetShortExpVector(gcd); */
     12311
     12312  /*   for (int j = 0; j < strat->sl; j++) { */
     12313  /*     if (j == i) */
     12314  /*       continue; */
     12315
     12316  /*     if (n_DivBy(d, pGetCoeff(strat->S[j]), currRing->cf) && */
     12317  /*         !(strat->sevS[j] & ~sev) && */
     12318  /*         p_LmDivisibleBy(strat->S[j], gcd, currRing)) { */
     12319  /*       nDelete(&d); */
     12320  /*       nDelete(&s); */
     12321  /*       nDelete(&t); */
     12322  /*       return FALSE; */
     12323  /*     } */
     12324  /*   } */
     12325  /* } */
     12326
     12327  poly m12, m22;
     12328  assume(p_mFirstVblock(p, currRing) <= 1 || p_mFirstVblock(q, currRing) <= 1);
     12329  k_SplitFrame(m1, m12, p_mFirstVblock(p, currRing), currRing);
     12330  k_SplitFrame(m2, m22, p_mFirstVblock(q, currRing), currRing);
     12331  // manually free the coeffs, because pSetCoeff0 is used in the next step
     12332  n_Delete(&(m1->coef), currRing->cf);
     12333  n_Delete(&(m2->coef), currRing->cf);
     12334
     12335  //p_Test(m1,strat->tailRing);
     12336  //p_Test(m2,strat->tailRing);
     12337  /*if(!enterTstrong)
     12338  {
     12339    while (! kCheckStrongCreation(atR, m1, i, m2, strat) )
     12340    {
     12341      memset(&(strat->P), 0, sizeof(strat->P));
     12342      kStratChangeTailRing(strat);
     12343      strat->P = *(strat->R[atR]);
     12344      p_LmFree(m1, strat->tailRing);
     12345      p_LmFree(m2, strat->tailRing);
     12346      p_LmFree(gcd, currRing);
     12347      k_GetStrongLeadTerms(p, si, currRing, m1, m2, gcd, strat->tailRing);
     12348    }
     12349  }*/
     12350  pSetCoeff0(m1, s);
     12351  pSetCoeff0(m2, t);
     12352  pSetCoeff0(gcd, d);
     12353  p_Test(m1,strat->tailRing);
     12354  p_Test(m2,strat->tailRing);
     12355  p_Test(m12,strat->tailRing);
     12356  p_Test(m22,strat->tailRing);
     12357  assume(pmIsInV(m1));
     12358  assume(pmIsInV(m2));
     12359  assume(pmIsInV(m12));
     12360  assume(pmIsInV(m22));
     12361  //printf("\n===================================\n");
     12362  //pWrite(m1);pWrite(m2);pWrite(gcd);
     12363#ifdef KDEBUG
     12364  if (TEST_OPT_DEBUG)
     12365  {
     12366    // Print("t = %d; s = %d; d = %d\n", nInt(t), nInt(s), nInt(d));
     12367    PrintS("m1 = ");
     12368    p_wrp(m1, strat->tailRing);
     12369    PrintS("m12 = ");
     12370    p_wrp(m12, strat->tailRing);
     12371    PrintS(" ; m2 = ");
     12372    p_wrp(m2, strat->tailRing);
     12373    PrintS(" ; m22 = ");
     12374    p_wrp(m22, strat->tailRing);
     12375    PrintS(" ; gcd = ");
     12376    wrp(gcd);
     12377    PrintS("\n--- create strong gcd poly: ");
     12378    PrintS("\n p: ");
     12379    wrp(p);
     12380    Print("\n q (strat->S[%d]): ", ifromS);
     12381    wrp(q);
     12382    PrintS(" ---> ");
     12383  }
     12384#endif
     12385
     12386  pNext(gcd) = p_Add_q(pp_Mult_mm(pp_mm_Mult(pNext(p), m1, strat->tailRing), m12, strat->tailRing), pp_Mult_mm(pp_mm_Mult(pNext(q), m2, strat->tailRing), m22, strat->tailRing), strat->tailRing);
     12387  p_LmDelete(m1, strat->tailRing);
     12388  p_LmDelete(m2, strat->tailRing);
     12389  p_LmDelete(m12, strat->tailRing);
     12390  p_LmDelete(m22, strat->tailRing);
     12391
     12392  assume(pIsInV(gcd));
     12393
     12394#ifdef KDEBUG
     12395  if (TEST_OPT_DEBUG)
     12396  {
     12397    wrp(gcd);
     12398    PrintLn();
     12399  }
     12400#endif
     12401
     12402  LObject h;
     12403  h.p = gcd;
     12404  h.tailRing = strat->tailRing;
     12405  int posx;
     12406  h.pCleardenom();
     12407  strat->initEcart(&h);
     12408  h.sev = pGetShortExpVector(h.p);
     12409  h.i_r1 = -1;h.i_r2 = -1;
     12410  if (currRing!=strat->tailRing)
     12411    h.t_p = k_LmInit_currRing_2_tailRing(h.p, strat->tailRing);
     12412#if 1
     12413  h.p1 = p;
     12414  h.p2 = q;
     12415#endif
     12416  if (atR >= 0 && shiftcount == 0 && ifromS >= 0)
     12417  {
     12418    h.i_r2 = kFindInT(h.p1, strat);
     12419    h.i_r1 = atR;
     12420  }
     12421  else
     12422  {
     12423    h.i_r1 = -1;
     12424    h.i_r2 = -1;
     12425  }
     12426  if (strat->Ll==-1)
     12427    posx =0;
     12428  else
     12429    posx = strat->posInL(strat->L,strat->Ll,&h,strat);
     12430
     12431  assume(pIsInV(h.p));
     12432  assume(pIsInV(h.p1));
     12433
     12434  enterL(&strat->L,&strat->Ll,&strat->Lmax,h,posx);
     12435  return TRUE;
     12436}
     12437
     12438/*2
     12439* put the pair (q,p)  into the set B, ecart=ecart(p), q is the shift of some s[i] (ring case)
     12440*/
     12441static void enterOnePairRingShift (poly q, poly p, int /*ecart*/, int isFromQ, kStrategy strat, int atR, int /*ecartq*/, int qisFromQ, int shiftcount, int ifromS)
     12442{
     12443  /* assume(atR >= 0); */
     12444  /* assume(i<=strat->sl); */
     12445  assume(p!=NULL);
     12446  assume(rField_is_Ring(currRing));
     12447  assume(pIsInV(p));
     12448  #if ALL_VS_JUST
     12449  //Over rings, if we construct the strong pair, do not add the spair
     12450  if(rField_is_Ring(currRing))
     12451  {
     12452    number s,t,d;
     12453    d = n_ExtGcd(pGetCoeff(p), pGetCoeff(q, &s, &t, currRing->cf);
     12454
     12455    if (!nIsZero(s) && !nIsZero(t))  // evtl. durch divBy tests ersetzen
     12456    {
     12457      nDelete(&d);
     12458      nDelete(&s);
     12459      nDelete(&t);
     12460      return;
     12461    }
     12462    nDelete(&d);
     12463    nDelete(&s);
     12464    nDelete(&t);
     12465  }
     12466  #endif
     12467  int      j,compare,compareCoeff;
     12468  LObject  h;
     12469
     12470#ifdef KDEBUG
     12471  h.ecart=0; h.length=0;
     12472#endif
     12473  /*- computes the lcm(s[i],p) -*/
     12474  if(pHasNotCFRing(p,q))
     12475  {
     12476      strat->cp++;
     12477      return;
     12478  }
     12479  h.lcm = p_Lcm(p,q,currRing);
     12480  pSetCoeff0(h.lcm, n_Lcm(pGetCoeff(p), pGetCoeff(q), currRing->cf));
     12481  if (nIsZero(pGetCoeff(h.lcm)))
     12482  {
     12483      strat->cp++;
     12484      pLmDelete(h.lcm);
     12485      return;
     12486  }
     12487
     12488  /* the V criterion */
     12489  if (!pmIsInV(h.lcm))
     12490  {
     12491    strat->cv++;
     12492    pLmDelete(h.lcm);
     12493    return;
     12494  }
     12495  // basic chain criterion
     12496  /*
     12497  *the set B collects the pairs of type (S[j],p)
     12498  *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p) != lcm(r,p)
     12499  *if the leading term of s devides lcm(r,p) then (r,p) will be canceled
     12500  *if the leading term of r devides lcm(s,p) then (s,p) will not enter B
     12501  */
     12502
     12503  for(j = strat->Bl;j>=0;j--)
     12504  {
     12505    compare=pDivCompRing(strat->B[j].lcm,h.lcm);
     12506    compareCoeff = n_DivComp(pGetCoeff(strat->B[j].lcm), pGetCoeff(h.lcm), currRing->cf);
     12507    if(compare == pDivComp_EQUAL)
     12508    {
     12509      //They have the same LM
     12510      if(compareCoeff == pDivComp_LESS)
     12511      {
     12512        if ((strat->fromQ==NULL) || (isFromQ==0) || (qisFromQ==0))
     12513        {
     12514          strat->c3++;
     12515          pLmDelete(h.lcm);
     12516          return;
     12517        }
     12518        break;
     12519      }
     12520      if(compareCoeff == pDivComp_GREATER)
     12521      {
     12522        deleteInL(strat->B,&strat->Bl,j,strat);
     12523        strat->c3++;
     12524      }
     12525      if(compareCoeff == pDivComp_EQUAL)
     12526      {
     12527        if ((strat->fromQ==NULL) || (isFromQ==0) || (qisFromQ==0))
     12528        {
     12529          strat->c3++;
     12530          pLmDelete(h.lcm);
     12531          return;
     12532        }
     12533        break;
     12534      }
     12535    }
     12536    if(compareCoeff == compare || compareCoeff == pDivComp_EQUAL)
     12537    {
     12538      if(compare == pDivComp_LESS)
     12539      {
     12540        if ((strat->fromQ==NULL) || (isFromQ==0) || (qisFromQ==0))
     12541        {
     12542          strat->c3++;
     12543          pLmDelete(h.lcm);
     12544          return;
     12545        }
     12546        break;
     12547      }
     12548      if(compare == pDivComp_GREATER)
     12549      {
     12550        deleteInL(strat->B,&strat->Bl,j,strat);
     12551        strat->c3++;
     12552      }
     12553    }
     12554  }
     12555  number s, t;
     12556  poly m1, m2, gcd = NULL;
     12557  s = pGetCoeff(q);
     12558  t = pGetCoeff(p);
     12559  k_GetLeadTerms(p,q,currRing,m1,m2,currRing);
     12560
     12561  poly m12, m22;
     12562  assume(p_mFirstVblock(p, currRing) <= 1 || p_mFirstVblock(q, currRing) <= 1);
     12563  k_SplitFrame(m1, m12, p_mFirstVblock(p, currRing), currRing);
     12564  k_SplitFrame(m2, m22, p_mFirstVblock(q, currRing), currRing);
     12565  // manually free the coeffs, because pSetCoeff0 is used in the next step
     12566  n_Delete(&(m1->coef), currRing->cf);
     12567  n_Delete(&(m2->coef), currRing->cf);
     12568
     12569  ksCheckCoeff(&s, &t, currRing->cf);
     12570  pSetCoeff0(m1, s);
     12571  pSetCoeff0(m2, t);
     12572  m2 = pNeg(m2);
     12573  p_Test(m1,strat->tailRing);
     12574  p_Test(m2,strat->tailRing);
     12575  p_Test(m12,strat->tailRing);
     12576  p_Test(m22,strat->tailRing);
     12577  assume(pmIsInV(m1));
     12578  assume(pmIsInV(m2));
     12579  assume(pmIsInV(m12));
     12580  assume(pmIsInV(m22));
     12581  poly pm1 = pp_Mult_mm(pp_mm_Mult(pNext(p), m1, strat->tailRing), m12, strat->tailRing);
     12582  poly sim2 = pp_Mult_mm(pp_mm_Mult(pNext(q), m2, strat->tailRing), m22, strat->tailRing);
     12583  assume(pIsInV(pm1));
     12584  assume(pIsInV(sim2));
     12585  p_LmDelete(m1, currRing);
     12586  p_LmDelete(m2, currRing);
     12587  p_LmDelete(m12, currRing);
     12588  p_LmDelete(m22, currRing);
     12589  if(sim2 == NULL)
     12590  {
     12591    if(pm1 == NULL)
     12592    {
     12593      if(h.lcm != NULL)
     12594      {
     12595        pLmDelete(h.lcm);
     12596        h.lcm=NULL;
     12597      }
     12598      h.Clear();
     12599      /* TEMPORARILY DISABLED FOR SHIFTS because there is no i*/
     12600      /* if (strat->pairtest==NULL) initPairtest(strat); */
     12601      /* strat->pairtest[i] = TRUE; */
     12602      /* strat->pairtest[strat->sl+1] = TRUE; */
     12603      return;
     12604    }
     12605    else
     12606    {
     12607      gcd = pm1;
     12608      pm1 = NULL;
     12609    }
     12610  }
     12611  else
     12612  {
     12613    if((pGetComp(q) == 0) && (0 != pGetComp(p)))
     12614    {
     12615      p_SetCompP(sim2, pGetComp(p), strat->tailRing);
     12616      pSetmComp(sim2);
     12617    }
     12618    //p_Write(pm1,strat->tailRing);p_Write(sim2,strat->tailRing);
     12619    gcd = p_Add_q(pm1, sim2, strat->tailRing);
     12620  }
     12621  p_Test(gcd, strat->tailRing);
     12622  assume(pIsInV(gcd));
     12623#ifdef KDEBUG
     12624  if (TEST_OPT_DEBUG)
     12625  {
     12626    wrp(gcd);
     12627    PrintLn();
     12628  }
     12629#endif
     12630  h.p = gcd;
     12631  h.i_r = -1;
     12632  if(h.p == NULL)
     12633  {
     12634    /* TEMPORARILY DISABLED FOR SHIFTS because there is no i*/
     12635    /* if (strat->pairtest==NULL) initPairtest(strat); */
     12636    /* strat->pairtest[i] = TRUE; */
     12637    /* strat->pairtest[strat->sl+1] = TRUE; */
     12638    return;
     12639  }
     12640  h.tailRing = strat->tailRing;
     12641  int posx;
     12642  //h.pCleardenom();
     12643  //pSetm(h.p);
     12644  h.i_r1 = -1;h.i_r2 = -1;
     12645  strat->initEcart(&h);
     12646  #if 1
     12647  h.p1 = p;
     12648  h.p2 = q;
     12649  #endif
     12650  #if 1
     12651  /* TEMPORARILY DISABLED FOR SHIFTS because there's no i*/
     12652  /* at the beginning we DO NOT set atR = -1 ANYMORE*/
     12653  if (atR >= 0 && shiftcount == 0 && ifromS >= 0)
     12654  {
     12655    h.i_r2 = kFindInT(h.p1, strat); //strat->S_2_R[i];
     12656    h.i_r1 = atR;
     12657  }
     12658  else
     12659  {
     12660    /* END _ TEMPORARILY DISABLED FOR SHIFTS */
     12661    h.i_r1 = -1;
     12662    h.i_r2 = -1;
     12663  }
     12664  #endif
     12665  if (strat->Bl==-1)
     12666    posx =0;
     12667  else
     12668    posx = strat->posInL(strat->B,strat->Bl,&h,strat);
     12669  h.sev = pGetShortExpVector(h.p);
     12670  if (currRing!=strat->tailRing)
     12671    h.t_p = k_LmInit_currRing_2_tailRing(h.p, strat->tailRing);
     12672
     12673  assume(pIsInV(h.p));
     12674  assume(pIsInV(h.p1));
     12675  assume(h.lcm != NULL);
     12676  assume(pIsInV(h.lcm));
     12677
     12678  enterL(&strat->B,&strat->Bl,&strat->Bmax,h,posx);
     12679  kTest_TS(strat);
     12680}
     12681
     12682// adds the strong pair and the normal pair for rings (aka gpoly and spoly)
     12683static void enterOneStrongPolyAndEnterOnePairRingShift(poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS)
     12684{
     12685  enterOneStrongPolyShift(q, p, ecart, isFromQ, strat, atR, ecartq, qisFromQ, shiftcount, ifromS); // "gpoly"
     12686  enterOnePairRingShift(q, p, ecart, isFromQ, strat, atR, ecartq, qisFromQ, shiftcount, ifromS); // "spoly"
     12687}
     12688
    1221112689// creates if possible (q,p), (shifts(q),p)
    1221212690static 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)
     
    1222612704    q_isFromQ = strat->fromQ[q_inS];
    1222712705
     12706  void (*enterPair)(poly, poly, int, int, kStrategy, int, int, int, int, int);
     12707#ifdef HAVE_RINGS
     12708  if (rField_is_Ring(currRing))
     12709    enterPair = enterOneStrongPolyAndEnterOnePairRingShift;
     12710  else
     12711#endif
     12712    enterPair = enterOnePairShift;
     12713
    1222812714  int degbound = currRing->N/currRing->isLPring;
    1222912715  int neededShift = p_lastVblock - 1;
     
    1223412720  {
    1223512721    poly qq = pLPCopyAndShiftLM(q, j);
    12236     enterOnePairShift(qq, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, j, q_inS);
    12237   }
     12722    enterPair(qq, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, j, q_inS);
     12723  }
     12724
     12725#ifdef HAVE_RINGS
     12726  if (rField_is_Ring(currRing) && p_lastVblock >= firstShift && p_lastVblock <= maxPossibleShift)
     12727  {
     12728    // add pairs (m*shifts(q), p) where m is a monomial and the pair has no overlap
     12729    for (int j = p_lastVblock; j <= maxPossibleShift; j++)
     12730    {
     12731      ideal fillers = id_MaxIdeal(j - p_lastVblock, currRing);
     12732      for (int k = 0; k < IDELEMS(fillers); k++)
     12733      {
     12734        poly qq = pLPCopyAndShiftLM(pp_mm_Mult(q, fillers->m[k], currRing), p_lastVblock);
     12735        enterPair(qq, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, p_lastVblock, q_inS);
     12736      }
     12737      idDelete(&fillers);
     12738    }
     12739  }
     12740#endif
    1223812741}
    1223912742#endif
    1224012743
    1224112744#ifdef HAVE_SHIFTBBA
    12242 // creates if possible (q,p), use it when q is already shifted
     12745// creates (q,p), use it when q is already shifted
    1224312746static 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)
    1224412747{
     
    1225612759    p_isFromQ = strat->fromQ[p_inS];
    1225712760
    12258   int maxNeededShift = p_lastVblock - 1;
    12259   if (q_shift <= maxNeededShift)
     12761#ifdef HAVE_RINGS
     12762  if (rField_is_Ring(currRing))
     12763  {
     12764    assume(q_shift <= p_lastVblock);
     12765    enterOneStrongPolyAndEnterOnePairRingShift(q, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, q_shift, -1);
     12766  }
     12767  else
     12768#endif
     12769  {
     12770    int maxNeededShift = p_lastVblock - 1;
     12771    assume(q_shift <= maxNeededShift);
    1226012772    enterOnePairShift(q, p, ecartp, p_isFromQ, strat, -1, ecartq, q_isFromQ, q_shift, -1);
     12773  }
    1226112774}
    1226212775#endif
     
    1259313106  }
    1259413107}
    12595 #endif
    12596 
    12597 #ifdef HAVE_SHIFTBBA
     13108
    1259813109/*3
    1259913110*(s[0], s \dot h),...,(s[k],s \dot h) will be put to the pairset L
     
    1270413215          {
    1270513216            poly s = strat->S[j];
    12706             enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i);
     13217            int s_lastVblock = pmLastVblock(s);
     13218            if (i < s_lastVblock)
     13219              enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, s_lastVblock, i);
     13220#ifdef HAVE_RINGS
     13221            else if (rField_is_Ring(currRing) && i == s_lastVblock)
     13222            {
     13223              for (int l = s_lastVblock; l <= maxShift; l++)
     13224              {
     13225                ideal fillers = id_MaxIdeal(l - s_lastVblock, currRing);
     13226                for (int k = 0; k < IDELEMS(fillers); k++)
     13227                {
     13228                  poly hhh = pLPCopyAndShiftLM(pp_mm_Mult(h, fillers->m[k], currRing), s_lastVblock);
     13229                  enterOnePairWithoutShifts(j, hhh, s, ecart, isFromQ, strat, atR, s_lastVblock, s_lastVblock);
     13230                }
     13231                idDelete(&fillers);
     13232              }
     13233            }
     13234#endif
    1270713235          }
    12708           enterOnePairWithoutShifts(-1, hh, h, ecart, isFromQ, strat, atR, h_lastVblock, i);
     13236          if (i < h_lastVblock)
     13237            enterOnePairWithoutShifts(-1, hh, h, ecart, isFromQ, strat, atR, h_lastVblock, i);
     13238#ifdef HAVE_RINGS
     13239          else if (rField_is_Ring(currRing) && i == h_lastVblock)
     13240          {
     13241            for (int l = h_lastVblock; l <= maxShift; l++)
     13242            {
     13243              ideal fillers = id_MaxIdeal(l - h_lastVblock, currRing);
     13244              for (int k = 0; k < IDELEMS(fillers); k++)
     13245              {
     13246                poly hhh = pLPCopyAndShiftLM(pp_mm_Mult(h, fillers->m[k], currRing), h_lastVblock);
     13247                enterOnePairWithoutShifts(-1, hhh, h, ecart, isFromQ, strat, atR, h_lastVblock, h_lastVblock);
     13248              }
     13249              idDelete(&fillers);
     13250            }
     13251          }
     13252#endif
    1270913253        }
    1271013254      }
     
    1275613300            {
    1275713301              poly s = strat->S[j];
     13302              int s_lastVblock = pmLastVblock(s);
     13303              if (i < s_lastVblock)
     13304                enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, s_lastVblock, i);
     13305#ifdef HAVE_RINGS
     13306              else if (rField_is_Ring(currRing) && i == s_lastVblock)
     13307              {
     13308                for (int l = s_lastVblock; l <= maxShift; l++)
     13309                {
     13310                  ideal fillers = id_MaxIdeal(l - s_lastVblock, currRing);
     13311                  for (int k = 0; k < IDELEMS(fillers); k++)
     13312                  {
     13313                    poly hhh = pLPCopyAndShiftLM(pp_mm_Mult(h, fillers->m[k], currRing), s_lastVblock);
     13314                    enterOnePairWithoutShifts(j, hhh, s, ecart, isFromQ, strat, atR, s_lastVblock, s_lastVblock);
     13315                  }
     13316                  idDelete(&fillers);
     13317                }
     13318              }
     13319#endif
     13320            }
     13321          }
     13322          if (i < h_lastVblock)
     13323            enterOnePairWithoutShifts(-1, hh, h, ecart, isFromQ, strat, atR, h_lastVblock, i);
     13324#ifdef HAVE_RINGS
     13325          else if (rField_is_Ring(currRing) && i == h_lastVblock)
     13326          {
     13327            for (int l = h_lastVblock; l <= maxShift; l++)
     13328            {
     13329              ideal fillers = id_MaxIdeal(l - h_lastVblock, currRing);
     13330              for (int k = 0; k < IDELEMS(fillers); k++)
     13331              {
     13332                poly hhh = pLPCopyAndShiftLM(pp_mm_Mult(h, fillers->m[k], currRing), h_lastVblock);
     13333                enterOnePairWithoutShifts(-1, hhh, h, ecart, isFromQ, strat, atR, h_lastVblock, h_lastVblock);
     13334              }
     13335              idDelete(&fillers);
     13336            }
     13337          }
     13338#endif
     13339        }
     13340      }
     13341    }
     13342
     13343    if (new_pair)
     13344    {
     13345      strat->chainCrit(h,ecart,strat);
     13346    }
     13347    kMergeBintoL(strat);
     13348  }
     13349}
     13350
     13351/*3
     13352*(s[0], s \dot h),...,(s[k],s \dot h) will be put to the pairset L
     13353* also the pairs (h, s\dot s[0]), ..., (h, s\dot s[k]) enter L
     13354* additionally we put the pairs (h, s \sdot h) for s>=1 to L
     13355*/
     13356void initenterstrongPairsShift (poly h,int k,int ecart,int isFromQ, kStrategy strat, int atR)
     13357{
     13358  int h_lastVblock = pmLastVblock(h);
     13359  assume(h_lastVblock != 0 || pLmIsConstantComp(h));
     13360  // TODO: is it allowed to skip pairs with constants? also with constants from other components?
     13361  if (h_lastVblock == 0) return;
     13362  assume(pmFirstVblock(h) == 1);
     13363  /* h comes from strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
     13364  //  atR = -1;
     13365  if ((strat->syzComp==0)
     13366  || (pGetComp(h)<=strat->syzComp))
     13367  {
     13368    int i,j;
     13369    BOOLEAN new_pair=FALSE;
     13370
     13371    int degbound = currRing->N/currRing->isLPring;
     13372    int maxShift = degbound - h_lastVblock;
     13373
     13374    if (pGetComp(h)==0)
     13375    {
     13376      if (strat->rightGB)
     13377      {
     13378        if (isFromQ)
     13379        {
     13380          // pairs (shifts(h),s[1..k]), (h, s[1..k])
     13381          for (i=0; i<=maxShift; i++)
     13382          {
     13383            poly hh = pLPCopyAndShiftLM(h, i);
     13384            for (j=0; j<=k; j++)
     13385            {
     13386              if (strat->fromQ == NULL || !strat->fromQ[j])
     13387              {
     13388                new_pair=TRUE;
     13389                poly s = strat->S[j];
     13390                enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i);
     13391              }
     13392            }
     13393          }
     13394        }
     13395        else
     13396        {
     13397          new_pair=TRUE;
     13398          for (j=0; j<=k; j++)
     13399          {
     13400            poly s = strat->S[j];
     13401            if (strat->fromQ != NULL && strat->fromQ[j])
     13402            {
     13403              // pairs (shifts(s[j]),h), (s[j],h)
     13404              enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
     13405            }
     13406            else
     13407            {
     13408              // pair (h, s[j])
     13409              enterOnePairWithoutShifts(j, h, s, ecart, isFromQ, strat, atR, pmLastVblock(s), 0);
     13410            }
     13411          }
     13412        }
     13413      }
     13414      /* for Q!=NULL: build pairs (f,q),(f1,f2), but not (q1,q2)*/
     13415      else if ((isFromQ)&&(strat->fromQ!=NULL))
     13416      {
     13417        // pairs (shifts(s[1..k]),h), (s[1..k],h)
     13418        for (j=0; j<=k; j++) {
     13419          if (!strat->fromQ[j])
     13420          {
     13421            new_pair=TRUE;
     13422            poly s = strat->S[j];
     13423            enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
     13424          }
     13425        }
     13426        // pairs (shifts(h),s[1..k])
     13427        if (new_pair)
     13428        {
     13429          for (i=1; i<=maxShift; i++)
     13430          {
     13431            poly hh = pLPCopyAndShiftLM(h, i);
     13432            for (j=0; j<=k; j++)
     13433            {
     13434              if (!strat->fromQ[j])
     13435              {
     13436                poly s = strat->S[j];
     13437                enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i);
     13438              }
     13439            }
     13440          }
     13441        }
     13442      }
     13443      else
     13444      {
     13445        new_pair=TRUE;
     13446        // pairs (shifts(s[1..k]),h), (s[1..k],h)
     13447        for (j=0; j<=k; j++) {
     13448          poly s = strat->S[j];
     13449          // TODO: cache lastVblock of s[1..k] for later use
     13450          enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
     13451        }
     13452        // pairs (shifts(h),s[1..k]), (shifts(h), h)
     13453        for (i=1; i<=maxShift; i++)
     13454        {
     13455          poly hh = pLPCopyAndShiftLM(h, i);
     13456          for (j=0; j<=k; j++)
     13457          {
     13458            poly s = strat->S[j];
     13459            enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i);
     13460          }
     13461          enterOnePairWithoutShifts(-1, hh, h, ecart, isFromQ, strat, atR, h_lastVblock, i);
     13462        }
     13463      }
     13464    }
     13465    else
     13466    {
     13467      new_pair=TRUE;
     13468      if (strat->rightGB)
     13469      {
     13470        for (j=0; j<=k; j++)
     13471        {
     13472          if ((pGetComp(h)==pGetComp(strat->S[j]))
     13473              || (pGetComp(strat->S[j])==0))
     13474          {
     13475            assume(isFromQ == 0); // this case is not handeled here and should also never happen
     13476            poly s = strat->S[j];
     13477            if (strat->fromQ != NULL && strat->fromQ[j])
     13478            {
     13479              // pairs (shifts(s[j]),h), (s[j],h)
     13480              enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
     13481            }
     13482            else
     13483            {
     13484              // pair (h, s[j])
     13485              enterOnePairWithoutShifts(j, h, s, ecart, isFromQ, strat, atR, pmLastVblock(s), 0);
     13486            }
     13487          }
     13488        }
     13489      }
     13490      else
     13491      {
     13492        // pairs (shifts(s[1..k]),h), (s[1..k],h)
     13493        for (j=0; j<=k; j++) {
     13494          if ((pGetComp(h)==pGetComp(strat->S[j]))
     13495              || (pGetComp(strat->S[j])==0))
     13496          {
     13497            poly s = strat->S[j];
     13498            enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s));
     13499          }
     13500        }
     13501        // pairs (shifts(h),s[1..k]), (shifts(h), h)
     13502        for (i=1; i<=maxShift; i++)
     13503        {
     13504          poly hh = pLPCopyAndShiftLM(h, i);
     13505          for (j=0; j<=k; j++)
     13506          {
     13507            if ((pGetComp(h)==pGetComp(strat->S[j]))
     13508                || (pGetComp(strat->S[j])==0))
     13509            {
     13510              poly s = strat->S[j];
    1275813511              enterOnePairWithoutShifts(j, hh, s, ecart, isFromQ, strat, atR, pmLastVblock(s), i);
    1275913512            }
     
    1277113524  }
    1277213525}
    12773 #endif
    12774 
    12775 #ifdef HAVE_SHIFTBBA
     13526
    1277613527/*2
    1277713528*(s[0],h),...,(s[k],h) will be put to the pairset L(via initenterpairs)
     
    1278413535  int j=pos;
    1278513536
    12786   assume (!rField_is_Ring(currRing));
     13537  /* if (!(rField_is_Domain(currRing))) enterExtendedSpoly(h, strat); */ // TODO: enterExtendedSpoly not for LP yet
    1278713538  initenterpairsShift(h,k,ecart,0,strat, atR);
    1278813539  if ( (!strat->fromT)
     
    1280113552  }
    1280213553}
    12803 #endif
    12804 
    12805 #ifdef HAVE_SHIFTBBA
     13554
    1280613555/*2
    1280713556* enteres all admissible shifts of p into T
  • kernel/GBEngine/kutil.h

    r7e4d60 r94b41d  
    595595/// returns index of p in TSet, or -1 if not found
    596596int kFindInT(poly p, TSet T, int tlength);
     597#ifdef HAVE_SHIFTBBA
     598int kFindInTShift(poly p, TSet T, int tlength);
     599#endif
    597600
    598601/// return -1 if no divisor is found
     
    857860void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR);
    858861
    859 void initBbaShift(kStrategy strat);
     862void superenterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR);
    860863
    861864poly redtailBbaShift (LObject* L, int pos, kStrategy strat, BOOLEAN withT, BOOLEAN normalize);
  • libpolys/polys/monomials/p_polys.h

    r7e4d60 r94b41d  
    997997}
    998998
     999// returns m*Copy(p), does neither destroy p nor m
     1000static inline poly pp_mm_Mult(poly p, poly m, const ring r)
     1001{
     1002  if (p==NULL) return NULL;
     1003  if (p_LmIsConstant(m, r))
     1004    return __pp_Mult_nn(p, pGetCoeff(m), r);
     1005  else
     1006    return r->p_Procs->pp_mm_Mult(p, m, r);
     1007}
     1008
    9991009// returns p*m, destroys p, const: m
    10001010static inline poly p_Mult_mm(poly p, poly m, const ring r)
     
    10051015  else
    10061016    return r->p_Procs->p_Mult_mm(p, m, r);
     1017}
     1018
     1019// returns m*p, destroys p, const: m
     1020static inline poly p_mm_Mult(poly p, poly m, const ring r)
     1021{
     1022  if (p==NULL) return NULL;
     1023  if (p_LmIsConstant(m, r))
     1024    return __p_Mult_nn(p, pGetCoeff(m), r);
     1025  else
     1026    return r->p_Procs->p_mm_Mult(p, m, r);
    10071027}
    10081028
  • libpolys/polys/shiftop.cc

    r7e4d60 r94b41d  
    599599{
    600600  int lV = r->isLPring;
    601 
    602   number m1Coeff = n_Copy(pGetCoeff(m1), r->cf); // important to copy
    603 
    604   int hole = lV * at;
    605   m2 = p_GetExp_k_n(m1, 1, hole, r);
    606   m1 = p_GetExp_k_n(m1, hole, r->N, r);
    607 
     601  int split = (lV * (at - 1));
     602
     603  m2 = p_GetExp_k_n(m1, 1, split, r);
    608604  p_mLPunshift(m2, r);
    609   p_SetCoeff(m1, m1Coeff, r);
     605
     606  m1 = p_Head(m1, r);
     607  for(int i = split + 1; i <= r->N; i++)
     608  {
     609    p_SetExp(m1, i, 0, r);
     610  }
     611  p_Setm(m1, r);
    610612
    611613  assume(p_FirstVblock(m1,r) <= 1);
  • libpolys/polys/shiftop.h

    r7e4d60 r94b41d  
    4242
    4343void k_SplitFrame(poly &m1, poly &m2, int at, const ring r);
    44 #define kSplitFrame(m1, m2, at) k_SplitFrame(m1, m2, at, currRing);
     44#define kSplitFrame(m1, m2, at) k_SplitFrame(m1, m2, at, currRing)
    4545
    4646int id_IsInV(ideal I, const ring r);
     
    5454BOOLEAN p_LPLmDivisibleBy(poly a, poly b, const ring r);
    5555BOOLEAN _p_LPLmDivisibleByNoComp(poly a, poly b, const ring r);
     56#define pLPDivisibleBy(a, b) p_LPLmDivisibleBy(a, b, currRing)
     57#define pLPLmDivisibleBy(a, b) p_LPLmDivisibleBy(a, b, currRing)
    5658
    5759BOOLEAN _p_mLPNCGenValid(int *mExpV, const ring r);
Note: See TracChangeset for help on using the changeset viewer.