Changeset 4d2ab5c in git


Ignore:
Timestamp:
Feb 23, 2008, 9:12:53 PM (15 years ago)
Author:
Viktor Levandovskyy <levandov@…>
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
51e69e6599c603806d7fea8cc97d5e9f1bec09e9
Parents:
8c35baa560440cca9bb7bbb44be0232fce1c79c9
Message:
*levandov: major update in freegb impl


git-svn-id: file:///usr/local/Singular/svn/trunk@10602 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
kernel
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • kernel/kstd2.cc

    r8c35ba r4d2ab5c  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kstd2.cc,v 1.61 2008-02-15 17:14:21 levandov Exp $ */
     4/* $Id: kstd2.cc,v 1.62 2008-02-23 20:12:51 levandov Exp $ */
    55/*
    66*  ABSTRACT -  Kernel: alg. of Buchberger
     
    16001600      //        enterT(strat->P, strat); // this was here before Shift stuff
    16011601      //enterTShift(LObject p, kStrategy strat, int atT, int uptodeg, int lV); // syntax
    1602       // the default value for atT = -1
     1602      // the default value for atT = -1 as in bba
     1603      strat->P.GetP(); // because shifts are counted with .p structure
    16031604      enterTShift(strat->P,strat,-1,uptodeg, lV);
     1605//       poly vw;
     1606//       if (strat->P.t_p!=NULL)
     1607//       {
     1608//          vw = pCopyL2p(strat->P,strat);     
     1609//       }
     1610//       else
     1611//       {
     1612//          vw = pCopy(strat->P.p);
     1613//       }
    16041614      enterpairsShift(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl,uptodeg,lV);
     1615      //      enterpairsShift(vw,strat->sl,strat->P.ecart,pos,strat, strat->tl,uptodeg,lV);
     1616      // delete vw ?
    16051617      // posInS only depends on the leading term
    16061618      if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp))
     
    16931705  */
    16941706  ideal RS = bbaShift(I,NULL, NULL, NULL, strat, uptodeg, lVblock);
     1707  idSkipZeroes(RS);
    16951708  return(RS);
    16961709}
  • kernel/kutil.cc

    r8c35ba r4d2ab5c  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kutil.cc,v 1.84 2008-02-15 17:14:22 levandov Exp $ */
     4/* $Id: kutil.cc,v 1.85 2008-02-23 20:12:52 levandov Exp $ */
    55/*
    66* ABSTRACT: kernel: utils for kStd
     
    5353/* shiftgb stuff */
    5454#include "shiftgb.h"
     55#include "prCopy.h"
    5556
    5657#ifdef KDEBUG
     
    56745675{
    56755676  assume(L->p1 != NULL && L->p2 != NULL);
    5676   assume(L->i_r1 >= 0 && L->i_r1 <= strat->tl);
    5677   assume(L->i_r2 >= 0 && L->i_r2 <= strat->tl);
     5677  // shift changes: from 0 to -1
     5678  assume(L->i_r1 >= -1 && L->i_r1 <= strat->tl);
     5679  assume(L->i_r2 >= -1 && L->i_r2 <= strat->tl);
    56785680  assume(strat->tailRing != currRing);
    56795681
    56805682  if (! k_GetLeadTerms(L->p1, L->p2, currRing, m1, m2, strat->tailRing))
    56815683    return FALSE;
     5684  // shift changes: extra case inserted
     5685  if ((L->i_r1 == -1) || (L->i_r2 == -1) )
     5686  {
     5687    return TRUE;
     5688  }
    56825689  poly p1_max = (strat->R[L->i_r1])->max;
    56835690  poly p2_max = (strat->R[L->i_r2])->max;
     
    60106017
    60116018#ifdef HAVE_PLURAL
    6012 /* including the self pairs? */
    6013 
     6019
     6020poly pMove2CurrTail(poly p, kStrategy strat)
     6021{
     6022  /* assume: p is completely in currRing */
     6023  /* produces an object with LM in curring
     6024     and TAIL in tailring */
     6025  if (pNext(p)!=NULL)
     6026  {
     6027    pNext(p) = prMoveR(pNext(p), /* src */ currRing, /* dest */ strat->tailRing);
     6028  }
     6029  return(p);
     6030}
     6031
     6032poly pMoveCurrTail2poly(poly p, kStrategy strat)
     6033{
     6034  /* assume: p has  LM in curring and TAIL in tailring */
     6035  /* convert it to complete currRing */
     6036
     6037  /* check that LM is in currRing */
     6038  assume(p_LmCheckIsFromRing(p, currRing));
     6039
     6040  if (pNext(p)!=NULL)
     6041  {
     6042    pNext(p) = prMoveR(pNext(p), /* src */ strat->tailRing, /* dest */currRing);
     6043  }
     6044  return(p);
     6045}
     6046
     6047poly pCopyL2p(LObject H, kStrategy strat)
     6048{
     6049    /* restores a poly in currRing from LObject */
     6050    LObject h = H;
     6051    h.Copy();
     6052    poly p;
     6053    if (h.p == NULL)
     6054    {
     6055      if (h.t_p != NULL)
     6056      {
     6057         p = prMoveR(h.t_p, /* source ring: */ strat->tailRing, /* dest. ring: */ currRing);
     6058        return(p);
     6059      }
     6060      else
     6061      {
     6062        /* h.tp == NULL -> the object is NULL */
     6063        return(NULL);
     6064      }
     6065    }
     6066    /* we're here if h.p != NULL */
     6067    if (h.t_p == NULL)
     6068    {
     6069       /* then h.p is the whole poly in currRing */
     6070       p = h.p;
     6071      return(p);
     6072    }
     6073    /* we're here if h.p != NULL and h.t_p != NULL */
     6074    // clean h.p, get poly from t_p
     6075     pNext(h.p)=NULL;
     6076     pDelete(&h.p);
     6077     p = prMoveR(h.t_p, /* source ring: */ strat->tailRing,
     6078                         /* dest. ring: */ currRing);
     6079     // no need to clean h: we re-used the polys
     6080    return(p);
     6081}
     6082
     6083//LObject pCopyp2L(poly p, kStrategy strat)
     6084//{
     6085    /* creates LObject from the poly in currRing */
     6086  /* actually put p into L.p and make L.t_p=NULL : does not work */
     6087 
     6088//}
     6089
     6090// poly pCopyL2p(LObject H, kStrategy strat)
     6091// {
     6092//   /* restores a poly in currRing from LObject */
     6093//   LObject h = H;
     6094//   h.Copy();
     6095//   poly p;
     6096//   if (h.p == NULL)
     6097//   {
     6098//     if (h.t_p != NULL)
     6099//     {
     6100//       p = p_ShallowCopyDelete(h.t_p, (strat->tailRing != NULL ? strat->tailRing : currRing), strat->tailBin);
     6101//       return(p);
     6102//     }
     6103//     else
     6104//     {
     6105//       /* h.tp == NULL -> the object is NULL */
     6106//       return(NULL);
     6107//     }
     6108//   }
     6109//   /* we're here if h.p != NULL */
     6110
     6111//   if (h.t_p == NULL)
     6112//   {
     6113//     /* then h.p is the whole poly in tailRing */
     6114//     if (strat->tailBin != NULL && (pNext(h.p) != NULL))
     6115//     {
     6116//       p = p_ShallowCopyDelete(h.p, (strat->tailRing != NULL ? strat->tailRing : currRing), strat->tailBin);
     6117//     }
     6118//     return(p);
     6119//   }
     6120//   /* we're here if h.p != NULL and h.t_p != NULL */
     6121//   p = pCopy(pHead(h.p)); // in currRing
     6122//   if (strat->tailBin != NULL && (pNext(h.p) != NULL))
     6123//   {
     6124//     //    pNext(p) = p_ShallowCopyDelete(pNext(h.t_p), (strat->tailRing != NULL ? strat->tailRing : currRing), strat->tailBin);
     6125//     poly pp = p_Copy(pNext(h.p), strat->tailRing);
     6126//     //    poly p3 = p_Copy(pNext(h.p), currRing); // error
     6127//       // p_ShallowCopyDelete(pNext(h.p), currRing, strat->tailBin); // the same as pp
     6128//     poly p5 = p_ShallowCopyDelete(pNext(h.p), strat->tailRing, strat->tailBin);
     6129//     pNext(p) = p_ShallowCopyDelete(h.t_p, strat->tailRing, strat->tailBin);
     6130//     poly p4 = p_Copy(h.t_p, strat->tailRing);
     6131//     //    if (p.t_p != NULL) pNext(p.t_p) = pNext(p.p);
     6132//   }
     6133//   //  pTest(p);
     6134//   return(p);
     6135// }
     6136
     6137/* including the self pairs */
    60146138void updateSShift(kStrategy strat,int uptodeg,int lV)
    60156139{
     
    60226146  for (i=0; i<=strat->sl; i++)
    60236147  {
    6024     h.p =  strat->S[i];
     6148    memset(&h,0,sizeof(h));
     6149    h.p =  strat->S[i]; // lm in currRing, tail in TR
    60256150    strat->initEcart(&h);
    60266151    h.sev = strat->sevS[i];
     6152    h.t_p = NULL;
     6153    h.GetTP(); // creates correct t_p
    60276154    /*puts the elements of S with their shifts to T*/
    60286155    //    int atT, int uptodeg, int lV)
     6156    strat->S_2_R[i] = strat->tl + 1; // the el't with shift 0 will be inserted first
     6157    // need a small check for above; we insert >=1 elements
     6158    // insert this check into kTest_TS ?
    60296159    enterTShift(h,strat,atT,uptodeg,lV);
    60306160  }
     
    60926222  if (!TEST_OPT_SB_1)
    60936223  {
    6094     /* the only change: do not fill the set T*/
     6224    /* the only change: we do not fill the set T*/
    60956225    updateS(FALSE,strat);
    60966226  }
     
    61016231}
    61026232
    6103 // void initBuchMoraShift(ideal F,ideal Q,kStrategy strat)
    6104 // {
    6105 //   initBuchMora(F,Q,strat);
    6106 //   strat->fromT = TRUE;
    6107 // }
    6108 
    61096233/*1
    61106234* put the pairs (sh \dot s[i],p)  into the set B, ecart=ecart(p)
     
    61126236void enterOnePairManyShifts (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV)
    61136237{
    6114 
    6115   /* should cycle through all shifts of s[i] until uptodeg - lastVblock(s[i]) */
     6238  /* p comes from strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
     6239
     6240  assume(p_LmCheckIsFromRing(p,currRing));
     6241  assume(p_CheckIsFromRing(pNext(p),strat->tailRing));
     6242
     6243  /* cycles through all shifts of s[i] until uptodeg - lastVblock(s[i]) */
    61166244  /* that is create the pairs (f, s \dot g)  */
    61176245
    6118   poly q;
    6119   q = pCopy(strat->S[i]); // zero shift
     6246  poly qq = strat->S[i]; // previously thought and now again: lm in currRing, tail in tailRing
     6247// elt's of S are compl. in currRing
     6248// previously thought: lm in currRing, tail in tailRing
     6249
     6250  //  poly q = pCopy(pHead(strat->S[i])); // lm in currRing
     6251  //  pNext(q) = prCopyR(pNext(strat->S[i]),strat->tailRing,currRing); // zero shift
    61206252
    61216253 /* determine how many elements we have to insert for a given s[i] */
     
    61236255  /* hence, a total number of elt's to add is: */
    61246256  /*  int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1);  */
    6125   int toInsert = uptodeg  - pLastVblock(q, lV) +1;
     6257  //  int toInsert = uptodeg  - pLastVblock(q, lV) +1;
     6258  int toInsert =  itoInsert(qq, uptodeg,  lV, strat->tailRing);
     6259
     6260#ifdef KDEBUG
     6261    if (TEST_OPT_DEBUG)
     6262    {
     6263      Print("entered ManyShifts: with toInsert=%d",toInsert); PrintLn();
     6264    }
     6265#endif
    61266266
    61276267  assume(i<=strat->sl); // from OnePair
     
    61306270  /* these vars hold for all shifts of s[i] */
    61316271  int ecartq = 0; //Hans says it's ok; we're in the homog case, no ecart
    6132   int qfromQ = strat->fromQ[i];
     6272 
     6273  int qfromQ;
     6274  if (strat->fromQ != NULL)
     6275  {
     6276    qfromQ = strat->fromQ[i];
     6277  }
     6278  else
     6279  {
     6280    qfromQ = -1;
     6281  }
    61336282
    61346283  int j;
    61356284
    6136   for (j=1; j<= toInsert -1; j++)
     6285  poly q, s;
     6286
     6287  // for the 0th shift: insert the orig. pair
     6288
     6289  enterOnePairShift(qq, p, ecart, isFromQ, strat, -1, ecartq, qfromQ, j, i, uptodeg, lV);
     6290
     6291  for (j=1; j<= toInsert; j++) // toIns - 1?
    61376292  {
    61386293    //    q = pLPshift(strat->S[i],j,uptodeg,lV);
    6139     /* we increase shifts by one; must delete q there*/
    6140     q = pLPshift(q,1,uptodeg,lV);
     6294    q = p_LPshiftT(qq, j, uptodeg, lV, strat, currRing);
     6295    //    q = p_mLPshift(qq,j,uptodeg,lV,currRing); // lm in currRing, shift this monomial
     6296    //    s = p_LPshift(pNext(qq), j, uptodeg, lV, strat->tailRing); // from tailRing
     6297    //    pNext(q) = s; // in tailRing
     6298    //    qq = pLPshift(q,j,uptodeg,lV); // need move
     6299    // ??? no move needed: in currRing
     6300    //    qq = pMoveCurrTail2poly(qq,strat);
    61416301    /* here we need to call enterOnePair with two polys ... */
    6142     enterOnePairShift(q, p, ecart, isFromQ, strat, -1, ecartq, qfromQ, uptodeg, lV);
    6143   }
    6144   /* delete q? */
    6145   pDelete(&q);
     6302
     6303#ifdef KDEBUG
     6304    if (TEST_OPT_DEBUG)
     6305    {
     6306      PrintS("ManyShifts: calling enterOnePairShift(q,p)");
     6307//       wrp(q); //     wrp(pHead(q));
     6308//       PrintS(", p = ");
     6309//       wrp(p); //wrp(pHead(p));
     6310      PrintLn();
     6311    }
     6312#endif
     6313    enterOnePairShift(q, p, ecart, isFromQ, strat, -1, ecartq, qfromQ, j, i, uptodeg, lV);
     6314  }
     6315  /* delete qq */
     6316  //  pDelete(&qq);
    61466317}
    61476318
     
    61516322void enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV)
    61526323{
     6324
     6325  /* format: p,qq are in LObject form: lm in CR, tail in TR */
     6326  /* for true self pairs qq ==p  */
     6327  /* we test both */
     6328  assume(p_LmCheckIsFromRing(qq,currRing));
     6329  assume(p_CheckIsFromRing(pNext(qq),strat->tailRing));
     6330  assume(p_LmCheckIsFromRing(p,currRing));
     6331  assume(p_CheckIsFromRing(pNext(p),strat->tailRing));
     6332
     6333  int j = 0;
     6334
     6335  /* for such pairs start with 1, not with 0 */
     6336  if (qq == p) j=1;
    61536337
    61546338  /* should cycle through all shifts of q until uptodeg - lastVblock(q) */
     
    61596343  /* hence, a total number of elt's to add is: */
    61606344  /*  int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1);  */
    6161   int toInsert = uptodeg  - pLastVblock(qq, lV) +1;
     6345
     6346  //  poly q = pHead(qq); // lm in currRing
     6347  //  pNext(q) = prCopyR(pNext(qq), strat->tailRing, currRing);
     6348  //  pTest(q);
     6349
     6350  int toInsert =  itoInsert(qq, uptodeg,  lV, strat->tailRing);
     6351
     6352#ifdef KDEBUG
     6353    if (TEST_OPT_DEBUG)
     6354    {
     6355      Print("entered SelfShifts: with toInsert=%d",toInsert); PrintLn();
     6356    }
     6357#endif
     6358
     6359//   int toInsert = p_mLastVblock(qq, lV,currRing);
     6360//   if (pNext(qq) != NULL)
     6361//   {
     6362//     toInsert = si_max(toInsert, p_LastVblock(pNext(qq), lV,strat->tailRing) );
     6363//   }
     6364//   toInsert = uptodeg  - toInsert +1;
     6365
     6366  poly q, s;
    61626367
    61636368  //  assume(i<=strat->sl); // from OnePair
     
    61686373  int qfromQ = 0; // strat->fromQ[i];
    61696374
    6170   int j;
    6171   poly q = pCopy(qq);   // q has zero shift
    6172   for (j=1; j<= toInsert -1; j++)
     6375  for (; j<= toInsert; j++) // toIns - 1?
    61736376  {
    61746377    //    q = pLPshift(strat->S[i],j,uptodeg,lV);
    61756378    /* we increase shifts by one; must delete q there*/
    6176     q = pLPshift(q,1,uptodeg,lV);
     6379    //    q = qq; q = pMoveCurrTail2poly(q,strat);
     6380    //    q = pLPshift(q,j,uptodeg,lV); //,currRing);
     6381    q = p_LPshiftT(qq, j, uptodeg, lV, strat, currRing);
     6382    //    q = p_mLPshift(qq,j,uptodeg,lV,currRing); // lm in currRing, shift this monomial
     6383    //    s = p_LPshift(pNext(qq), j, uptodeg, lV, strat->tailRing); // from tailRing
     6384    //    pNext(q) = s; // in tailRing
     6385    //prMoveR(s,strat->tailRing,currRing); // in currRing
    61776386    /* here we need to call enterOnePair with two polys ... */
    6178     enterOnePairShift(q, p, ecart, isFromQ, strat, -1, ecartq, qfromQ, uptodeg, lV);
     6387#ifdef KDEBUG
     6388    if (TEST_OPT_DEBUG)
     6389    {
     6390      PrintS("SelfShifts: calling enterOnePairShift(q,p)");
     6391//       wrp(q); //     wrp(pHead(q));
     6392//       PrintS(", p = ");
     6393//       wrp(p); //wrp(pHead(p));
     6394      PrintLn();
     6395    }
     6396#endif
     6397    enterOnePairShift(q, p, ecart, isFromQ, strat, -1, ecartq, qfromQ, j, -1, uptodeg, lV);
    61796398  }
    61806399  /* delete q? */
    6181   pDelete(&q);
     6400  //  pDelete(&q);
    61826401}
    61836402
     
    61856404* put the pair (q,p)  into the set B, ecart=ecart(p), q is the shift of some s[i]
    61866405*/
    6187 void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int uptodeg, int lV)
    6188 {
    6189 
     6406void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS, int uptodeg, int lV)
     6407{
     6408
     6409  /* New Format: q and p are like strat->P.p, so lm in CR, tail in TR */
     6410  /* Format: q is a poly compl. in currRing, p is like strat->P.p, so lm in CR, tail in TR */
     6411
     6412  /* check this Formats: */
     6413  //  assume(p_CheckIsFromRing(q,currRing));
     6414  assume(p_LmCheckIsFromRing(q,currRing));
     6415  assume(p_CheckIsFromRing(pNext(q),strat->tailRing));
     6416  assume(p_LmCheckIsFromRing(p,currRing));
     6417  assume(p_CheckIsFromRing(pNext(p),strat->tailRing));
     6418
     6419#ifdef KDEBUG
     6420    if (TEST_OPT_DEBUG)
     6421    {
     6422      PrintS("enterOnePairShift(q,p) invoked with q = ");
     6423      wrp(q); //      wrp(pHead(q));
     6424      PrintS(", p = ");
     6425      wrp(p); //wrp(pHead(p));
     6426      PrintLn();
     6427    }
     6428#endif
     6429
     6430  /* indeed we need LM only before real spoly */
    61906431  /* poly q stays for s[i], ecartq = ecart(q), qisFromQ = applies to q */
    61916432
     
    61946435  /* need additionally: int up_to_degree, poly V0 with the variables in (0)  or just the number lV = the length of the first block */
    61956436
    6196   atR = -1;
     6437  //  atR = -1;
    61976438  //  assume(i<=strat->sl); // satisfied automatically
    61986439  if (strat->interred_flag) return;
     
    62086449  Lp.lcm = pInit();
    62096450
    6210   pLcm(p,q,Lp.lcm);
     6451  pLcm(p,q, Lp.lcm); // q is what was strat->S[i], so a poly in LM/TR presentation
    62116452  pSetm(Lp.lcm);
    62126453
     
    62196460    {
    62206461      PrintS("V crit applied to q = ");
    6221       wrp(pHead(q));
     6462      wrp(q); //      wrp(pHead(q));
    62226463      PrintS(", p = ");
    6223       wrp(pHead(p));
     6464      wrp(p); //wrp(pHead(p));
    62246465      PrintLn();
    62256466    }
     
    64006641//     else
    64016642//     {
    6402     Lp.p = ksCreateShortSpoly(q,p, strat->tailRing);
     6643   
     6644    /* ksCreateShortSpoly needs two Lobject-kind presentations */
     6645    /* p is already in this form, so convert q */
     6646    //    q = pMove2CurrTail(q, strat);
     6647    Lp.p = ksCreateShortSpoly(q, p, strat->tailRing);
    64036648      //  }
    64046649  }
     
    64066651  {
    64076652    /*- the case that the s-poly is 0 -*/
    6408     /* TEMPORARILY DISABLED FOR SHIFTS */
    6409 //     if (strat->pairtest==NULL) initPairtest(strat);
    6410 //     strat->pairtest[i] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/
    6411 //     strat->pairtest[strat->sl+1] = TRUE;
     6653    /* TEMPORARILY DISABLED FOR SHIFTS because there is no i*/
     6654//      if (strat->pairtest==NULL) initPairtest(strat);
     6655//      strat->pairtest[i] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/
     6656//      strat->pairtest[strat->sl+1] = TRUE;
    64126657    /* END _ TEMPORARILY DISABLED FOR SHIFTS */
    64136658    /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/
     
    64266671  {
    64276672    /*- the pair (S[i],p) enters B -*/
    6428     Lp.p1 = q;
    6429     Lp.p2 = p;
     6673    /* both of them should have their LM in currRing and TAIL in tailring */
     6674    Lp.p1 = q;  // already converted with pMove2CurrTail(q,strat);
     6675    Lp.p2 = p; // already in the needed form
    64306676
    64316677    if ( !bIsPluralRing )
    64326678      pNext(Lp.p) = strat->tail;
    64336679
    6434     /* TEMPORARILY DISABLED FOR SHIFTS */
    6435     /* at the beginning we set atR = -1 */
    6436 //     if (atR >= 0)
    6437 //     {
    6438       /*      Lp.i_r1 = strat->S_2_R[i]; */
    6439 //       Lp.i_r2 = atR;
    6440 //     }
    6441 //     else
    6442 //     {
    6443     /* END _ TEMPORARILY DISABLED FOR SHIFTS */
     6680    /* TEMPORARILY DISABLED FOR SHIFTS because there's no i*/
     6681    /* at the beginning we DO NOT set atR = -1 ANYMORE*/
     6682    if ( (atR >= 0) && (shiftcount==0) && (ifromS >=0) )
     6683    {
     6684      Lp.i_r1 = kFindInT(Lp.p1,strat); //strat->S_2_R[ifromS];
     6685      Lp.i_r2 = atR;
     6686    }
     6687    else
     6688    {
     6689      /* END _ TEMPORARILY DISABLED FOR SHIFTS */
    64446690      Lp.i_r1 = -1;
    64456691      Lp.i_r2 = -1;
    6446       //    }
     6692     }
    64476693    strat->initEcartPair(&Lp,q,p,ecartq,ecart);
    64486694
     
    64656711void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR,int uptodeg, int lV)
    64666712{
    6467   /* Q: what is exactly the strat->fromT ? */
     6713  /* h is strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
     6714  /* Q: what is exactly the strat->fromT ? A: a local case trick; don't need it yet*/
    64686715  int j=pos;
    64696716
     
    64906737
    64916738/*3
    6492 *(s[0],h),...,(s[k],h) will be put to the pairset L
     6739*(s[0], s \dot h),...,(s[k],s \dot h) will be put to the pairset L
     6740* also the pairs (h, s\dot s[0]), ..., (h, s\dot s[k]) enter L
    64936741* additionally we put the pairs (h, s \sdot h) for s>=1 to L
    64946742*/
    64956743void initenterpairsShift (poly h,int k,int ecart,int isFromQ, kStrategy strat, int atR, int uptodeg, int lV)
    64966744{
    6497   atR = -1;
     6745  /* h comes from strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
     6746  //  atR = -1;
    64986747  if ((strat->syzComp==0)
    64996748  || (pGetComp(h)<=strat->syzComp))
     
    65136762            new_pair=TRUE;
    65146763            enterOnePairManyShifts(j,h,ecart,isFromQ,strat, atR,uptodeg,lV);
     6764            // other side pairs:
     6765            enterOnePairSelfShifts(h,strat->S[j],ecart,isFromQ,strat, atR,uptodeg,lV);
    65156766          //Print("j:%d, Ll:%d\n",j,strat->Ll);
    65166767          }
     
    65236774        {
    65246775          enterOnePairManyShifts(j,h,ecart,isFromQ,strat, atR,uptodeg,lV);
     6776          // other side pairs
     6777          enterOnePairSelfShifts(h,strat->S[j],ecart,isFromQ,strat, atR,uptodeg,lV);
    65256778        }
    65266779        /* HERE we put (h, s*h) pairs */
     
    65386791          new_pair=TRUE;
    65396792          enterOnePairManyShifts(j,h,ecart,isFromQ,strat, atR, uptodeg, lV);
     6793          // other side pairs
     6794          enterOnePairSelfShifts(h,strat->S[j],ecart,isFromQ,strat, atR,uptodeg,lV);
    65406795        //Print("j:%d, Ll:%d\n",j,strat->Ll);
    65416796        }
    65426797      }
    6543       /* HERE we put (h, s*h) pairs TOO */
     6798      /* HERE we put (h, s*h) pairs */
    65446799      enterOnePairSelfShifts (h, h, ecart, isFromQ, strat, atR, uptodeg, lV);
    65456800    }
     
    65656820  /*  int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1);  */
    65666821
    6567   pp_Test(p.p, currRing, p.tailRing);
    6568 
    6569   int toInsert = uptodeg  - pLastVblock(pCopy(p.p), lV) +1;
    6570 
     6822  //  int toInsert = uptodeg  - pLastVblock(pCopy(p.p), lV) +1;
     6823  //  int toInsert = uptodeg  - pLastVblock(p.p, lV) +1;
     6824 
     6825  int toInsert =  itoInsert(p.p, uptodeg,  lV, strat->tailRing);
     6826
     6827#ifdef PDEBUG
     6828  Print("enterTShift uses toInsert: %d", toInsert);  PrintLn();
     6829#endif
    65716830  int i;
    65726831
     
    65746833    atT = strat->posInT(strat->T, strat->tl, p);
    65756834 
    6576   LObject q;
    6577   poly s;
     6835  //  LObject q;
     6836  //  poly s;
    65786837  /* can call enterT in a sequence, e.g. */
    6579   for (i=0; i<=toInsert-1; i++)
    6580   {
    6581     q = p;
     6838
     6839  /* first we create the 0th shift */
     6840  //  q = p;
     6841//   if (q.t_p!=NULL)
     6842//   {
     6843//     q.p = pHead(s); // in currRing
     6844//     q.t_p = prMoveR(s, /* sourcering: */currRing, /* destring: */ strat->tailRing);
     6845//     if (pNext(q.t_p)!=NULL)
     6846//     {
     6847//       pNext(q.p)=pNext(q.t_p);
     6848//     }
     6849//   }
     6850//   else
     6851//   {
     6852//     q.p=s;
     6853//   }
     6854  /* shift0 = it's our model for further shifts */
     6855  enterT(p,strat,atT);
     6856  LObject qq;
     6857  for (i=1; i<=toInsert; i++) // toIns - 1?
     6858  {
     6859    qq       = p; //qq.Copy();
     6860    qq.p    = NULL;
     6861    qq.t_p = p_LPshift(p.t_p, i, uptodeg, lV, strat->tailRing); // direct shift
     6862    qq.GetP();
    65826863    /* shift p, that is create another LObject and shift its poly */
    65836864    /* change: p.p, p.t_p, */
    65846865    /* change: i_r (must be -1 because we're not yet in T ? */
    6585     q.Copy(); // following
    6586     /*   pLPshift(poly p, int sh, int uptodeg, int lV); */
    6587     s = pLPshift(pCopy(q.p), i, uptodeg, lV); // deletes 1st arg, hence pCopy
    6588     q.p = pCopy(s); pDelete(&s);
    6589     if (q.t_p != NULL) pNext(q.t_p) = pNext(q.p); // from enterT
    6590     /* enter it into T */
    6591     enterT(q,strat,atT+i);
     6866    //    s = pLPshift(pCopyL2p(q,strat), i, uptodeg, lV); // deletes 1st arg, hence pCopy
     6867    //    q.p = pLPshift(q.p, 1, uptodeg, lV);
     6868//       qq.p = pHead(s); // in currRing
     6869//       qq.t_p = prMoveR(s, /* sourcering: */currRing, /* destring: */ strat->tailRing);
     6870//       if (pNext(q.t_p)!=NULL)
     6871//       {
     6872//         pNext(q.p)=pNext(q.t_p);
     6873//       }
     6874//     }
     6875//     else
     6876//     {
     6877//       q.p=s;
     6878//     }
     6879    // update q.sev
     6880    qq.sev = pGetShortExpVector(qq.p);
     6881    /* enter it into T, first el't is with the shift 0 */
     6882    // compute the position for qq
     6883    atT = strat->posInT(strat->T, strat->tl, qq);
     6884    enterT(qq,strat,atT);
    65926885  }
    65936886
  • kernel/kutil.h

    r8c35ba r4d2ab5c  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: kutil.h,v 1.32 2008-02-21 18:20:06 Singular Exp $ */
     6/* $Id: kutil.h,v 1.33 2008-02-23 20:12:52 levandov Exp $ */
    77/*
    88* ABSTRACT: kernel: utils for kStd
     
    620620#include "shiftgb.h"
    621621
     622poly pMove2CurrTail(poly p, kStrategy strat);
     623
     624poly pMoveCurrTail2poly(poly p, kStrategy strat);
     625
     626poly pCopyL2p(LObject h, kStrategy strat);
     627
    622628void enterTShift(LObject p, kStrategy strat, int atT, int uptodeg, int lV);
    623629
     
    628634void enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV);
    629635
    630 void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int uptodeg, int lV); // ok
     636void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS, int uptodeg, int lV); // ok
    631637
    632638void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR,int uptodeg, int lV);
  • kernel/shiftgb.cc

    r8c35ba r4d2ab5c  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: shiftgb.cc,v 1.4 2008-02-15 17:14:23 levandov Exp $ */
     4/* $Id: shiftgb.cc,v 1.5 2008-02-23 20:12:53 levandov Exp $ */
    55/*
    66* ABSTRACT: kernel: utils for shift GB and free GB
     
    3939#define freeT(A,v) omFreeSize((ADDRESS)A,(v+1)*sizeof(int))
    4040
    41 poly pLPshift(poly p, int sh, int uptodeg, int lV)
     41
     42/* TODO: write p* stuff as instances of p_* for all the functions */
     43
     44poly p_LPshiftT(poly p, int sh, int uptodeg, int lV, kStrategy strat, const ring r)
     45{
     46  /* assume shift takes place, shifts the poly p by sh */
     47  /* p is like TObject: lm in currRing = r, tail in tailRing  */
     48
     49  if (p==NULL) return(p);
     50
     51  assume(p_LmCheckIsFromRing(p,r));
     52  assume(p_CheckIsFromRing(pNext(p),strat->tailRing));
     53
     54  /* assume sh and uptodeg agree */
     55
     56  if (sh == 0) return(p); /* the zero shift */
     57
     58  poly q   = NULL;
     59  poly s   = p_mLPshift(p, sh, uptodeg, lV, r); // lm in currRing
     60  poly pp = pNext(p);
     61 
     62  while (pp != NULL)
     63  {
     64    q = p_Add_q(q, p_mLPshift(pp,sh,uptodeg,lV,strat->tailRing),strat->tailRing);
     65    pIter(pp);
     66  }
     67  pNext(s) = q;
     68  /* int version: returns TRUE if it was successful */
     69  return(s);
     70}
     71
     72
     73poly p_LPshift(poly p, int sh, int uptodeg, int lV, const ring r)
    4274{
    4375  /* assume shift takes place */
     
    4779  /* assume sh and uptodeg agree */
    4880
     81  if (p==NULL) return(p);
    4982  if (sh == 0) return(p); /* the zero shift */
    5083
     
    5386  while (pp!=NULL)
    5487  {
    55     q = p_Add_q(q, pmLPshift(pp,sh,uptodeg,lV),currRing);
     88    q = p_Add_q(q, p_mLPshift(pp,sh,uptodeg,lV,r),r);
    5689    pIter(pp);
    5790  }
     
    6194}
    6295
     96poly p_mLPshift(poly p, int sh, int uptodeg, int lV, const ring r)
     97{
     98  /* pm is a monomial */
     99
     100  if (sh == 0) return(p); /* the zero shift */
     101
     102  if (sh < 0 )
     103  {
     104#ifdef PDEBUG
     105    Print("pmLPshift: negative shift requested");
     106#endif
     107    return(NULL); /* violation, 2check */
     108  }
     109
     110  int L = p_mLastVblock(p,lV,r);
     111  if (L+sh-1 > uptodeg)
     112  {
     113#ifdef PDEBUG
     114    Print("p_mLPshift: too big shift requested");
     115#endif
     116    return(NULL); /* violation, 2check */
     117  }
     118  int *e=(int *)omAlloc0((r->N+1)*sizeof(int));
     119  int *s=(int *)omAlloc0((r->N+1)*sizeof(int));
     120  p_GetExpV(p,e,r);
     121  number c = pGetCoeff(p);
     122  int j;
     123  //  for (j=1; j<=r->N; j++)
     124  // L*lV gives the last position of the last block
     125  for (j=1; j<= L*lV ; j++)
     126  {
     127    if (e[j]==1)
     128    {
     129      s[j + (sh*lV)] = e[j]; /* actually 1 */
     130      omCheckAddr(s);
     131    }
     132    else
     133    {
     134      if (e[j]!=0)
     135      {
     136#ifdef PDEBUG
     137         Print("p_mLPshift: ex[%d]=%d\n",j,e[j]);
     138#endif
     139      }
     140    }
     141  }
     142  poly m = p_ISet(1,r);
     143  p_SetExpV(m,s,r);
     144  /*  pSetm(m); */ /* done in the pSetExpV */
     145  /* think on the component */
     146  pSetCoeff0(m,c);
     147  freeT(e, r->N);
     148  freeT(s, r->N);
     149  return(m);
     150}
     151
     152poly pLPshift(poly p, int sh, int uptodeg, int lV)
     153{
     154  /* assume shift takes place */
     155  /* shifts the poly p by sh */
     156  /* deletes p */
     157
     158  /* assume sh and uptodeg agree */
     159
     160  if (sh == 0) return(p); /* the zero shift */
     161
     162  poly q  = NULL;
     163  poly pp = p; // pCopy(p);
     164  while (pp!=NULL)
     165  {
     166    q = p_Add_q(q, pmLPshift(pp,sh,uptodeg,lV),currRing);
     167    pIter(pp);
     168  }
     169  /* delete pp? */
     170  /* int version: returns TRUE if it was successful */
     171  return(q);
     172}
     173
    63174poly pmLPshift(poly p, int sh, int uptodeg, int lV)
    64175{
     176  /* TODO: use a shortcut with p_ version */
    65177  /* pm is a monomial */
    66178
     
    110222  /* appearing among the monomials of p */
    111223  /* the 0th block is the 1st one */
    112   poly q = p_Copy(p,currRing); /* need it ? */
     224  poly q = p; //p_Copy(p,currRing); /* need it ? */
    113225  int ans = 0;
    114226  int ansnew = 0;
     
    127239  /* for a monomial p, returns the number of the last block */
    128240  /* where a nonzero exponent is sitting */
     241  if (pIsConstantPoly(p))
     242  {
     243    return(int(0));
     244  }
    129245  int *e=(int *)omAlloc0((currRing->N+1)*sizeof(int));
    130246  pGetExpV(p,e);
     
    143259  return (b);
    144260}
     261
     262int p_LastVblockT(poly p, int lV, kStrategy strat, const ring r)
     263{
     264  /* returns the number of maximal block */
     265  /* appearing among the monomials of p */
     266  /* the 0th block is the 1st one */
     267
     268  /* p is like TObject: lm in currRing = r, tail in tailRing  */
     269  assume(p_LmCheckIsFromRing(p,r));
     270  assume(p_CheckIsFromRing(pNext(p),strat->tailRing));
     271
     272  int ans = p_mLastVblock(p, lV, r); // Block of LM
     273  poly q = pNext(p);
     274  int ansnew = 0;
     275  while (q != NULL)
     276  {
     277    ansnew = p_mLastVblock(q, lV, strat->tailRing);
     278    ans       = si_max(ans,ansnew);
     279    pIter(q);
     280  }
     281  /* do not need to delete q */
     282  return(ans);
     283}
     284
     285int p_LastVblock(poly p, int lV, const ring r)
     286{
     287  /* returns the number of maximal block */
     288  /* appearing among the monomials of p */
     289  /* the 0th block is the 1st one */
     290  poly q = p; //p_Copy(p,currRing); /* need it ? */
     291  int ans = 0;
     292  int ansnew = 0;
     293  while (q!=NULL)
     294  {
     295    ansnew = p_mLastVblock(q, lV, r);
     296    ans    = si_max(ans,ansnew);
     297    pIter(q);
     298  }
     299  /* do not need to delete q */
     300  return(ans);
     301}
     302
     303int p_mLastVblock(poly p, int lV, const ring r)
     304{
     305  /* for a monomial p, returns the number of the last block */
     306  /* where a nonzero exponent is sitting */
     307  if (p_LmIsConstant(p,r))
     308  {
     309    return(0);
     310  }
     311  int *e=(int *)omAlloc0((r->N+1)*sizeof(int));
     312  p_GetExpV(p,e,r);
     313  int j,b;
     314  j = r->N;
     315  while ( (!e[j]) && (j>=1) ) j--;
     316  if (j==0)
     317  {
     318#ifdef PDEBUG
     319    Print("pmLastVblock: unexpected zero exponent vector");
     320    PrintLn();
     321#endif   
     322    return(j);
     323  }
     324  b = (int)((j+lV-1)/lV); /* the number of the block, >=1 */
     325  freeT(e,r->N);
     326  return (b);
     327}
     328
     329int pFirstVblock(poly p, int lV)
     330{
     331  /* returns the number of maximal block */
     332  /* appearing among the monomials of p */
     333  /* the 0th block is the 1st one */
     334  poly q = p; //p_Copy(p,currRing); /* need it ? */
     335  int ans = 0;
     336  int ansnew = 0;
     337  while (q!=NULL)
     338  {
     339    ansnew = pmFirstVblock(q,lV);
     340    ans    = si_min(ans,ansnew);
     341    pIter(q);
     342  }
     343  /* do not need to delete q */
     344  return(ans);
     345}
     346
     347int pmFirstVblock(poly p, int lV)
     348{
     349  if (pIsConstantPoly(p))
     350  {
     351    return(int(0));
     352  }
     353  /* for a monomial p, returns the number of the first block */
     354  /* where a nonzero exponent is sitting */
     355  int *e=(int *)omAlloc0((currRing->N+1)*sizeof(int));
     356  pGetExpV(p,e);
     357  int j,b;
     358  j = 1;
     359  while ( (!e[j]) && (j<=currRing->N-1) ) j++;
     360  if (j==currRing->N + 1)
     361  {
     362#ifdef PDEBUG
     363    Print("pmFirstVblock: unexpected zero exponent vector");
     364    PrintLn();
     365#endif   
     366    return(j);
     367  }
     368  b = (int)(j/lV)+1; /* the number of the block, 1<= N <= currRing->N  */
     369  return (b);
     370}
     371
    145372
    146373int isInV(poly p, int lV)
     
    161388    for (i=(j-1)*lV + 1; i<= j*lV; i++)
    162389    {
    163       if (!e[i]) B[j] = B[j]+1;
     390      if (e[i]) B[j] = B[j]+1;
    164391    }
    165392  }
     
    187414}
    188415
     416int itoInsert(poly p, int uptodeg, int lV, const ring r)
     417{
     418  /* for poly in lmCR/tailTR presentation */
     419  /* the below situation might happen! */
     420//   if (r == currRing)
     421//   {
     422//     "Current ring is not expected in toInsert";
     423//     return(0);
     424//   }
     425  /* compute the number of insertions */
     426  int i = p_mLastVblock(p, lV, currRing);
     427  if (pNext(p) != NULL)
     428  {
     429    i = si_max(i, p_LastVblock(pNext(p), lV, r) );
     430  }
     431  //  i = uptodeg  - i +1;
     432  i = uptodeg  - i;
     433  p_wrp(p,currRing,r); Print("----i:%d",i); PrintLn();
     434  return(i);
     435}
     436
     437
    189438/* shiftgb stuff */
    190439
  • kernel/shiftgb.h

    r8c35ba r4d2ab5c  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: shiftgb.h,v 1.2 2007-06-24 16:44:42 levandov Exp $ */
     6/* $Id: shiftgb.h,v 1.3 2008-02-23 20:12:53 levandov Exp $ */
    77/*
    88* ABSTRACT: kernel: utils for kStd
     
    1212#include "gring.h"
    1313
     14poly p_LPshiftT(poly p, int sh, int uptodeg, int lV, kStrategy strat, const ring r);
     15int p_LastVblockT(poly p, int lV, kStrategy strat, const ring r);
     16
     17poly p_LPshift(poly p, int sh, int uptodeg, int lV,const ring r);
     18poly p_mLPshift(poly p, int sh, int uptodeg, int lV,const ring r);
     19
     20int p_mLastVblock(poly p, int lV,const ring r);
     21int p_LastVblock(poly p, int lV, const ring r);
     22
    1423poly pLPshift(poly p, int sh, int uptodeg, int lV);
    1524poly pmLPshift(poly p, int sh, int uptodeg, int lV);
     
    1827int pmLastVblock(poly p, int lV);
    1928
     29int pFirstVblock(poly p, int lV);
     30int pmFirstVblock(poly p, int lV);
     31
    2032int isInV(poly p, int lV);
    2133
     34int itoInsert(poly p, int uptodeg, int lV, const ring r);
     35
    2236#endif
Note: See TracChangeset for help on using the changeset viewer.