Changeset 15a55a5 in git


Ignore:
Timestamp:
Sep 14, 2018, 4:50:10 PM (6 years ago)
Author:
Karim Abou Zeid <karim23697@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
b8c7320badf49a7c36b996413b1bf90743b4a312
Parents:
5292886b6f6adce1c6a27dacf4fe27712caac11f
Message:
New pairs
Location:
kernel/GBEngine
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/GBEngine/kspoly.cc

    r529288 r15a55a5  
    940940    // note: because of the crits, p2 is never shifted
    941941    int split = p_mFirstVblock(p1, tailRing);
    942     // TODO: shouldn't we use p1 AND p2 here??
    943942    k_SplitFrame(m1, m12, split, tailRing);
    944943    k_SplitFrame(m2, m22, split, tailRing);
     
    946945    n_Delete(&(m1->coef), tailRing->cf);
    947946    n_Delete(&(m2->coef), tailRing->cf);
    948 
    949     a1 = p_LPshift(p_Copy(a1, tailRing), 1 - split, tailRing); // unshift a1
    950947  }
    951948
     
    10081005    p_LmDelete(m22, tailRing);
    10091006    // m2 is already deleted
    1010     p_Delete(&a1, tailRing); // a1 is a copy: safe to destroy
    10111007  }
    10121008
     
    11271123{
    11281124  poly a1 = pNext(p1), a2 = pNext(p2);
     1125#ifdef HAVE_SHIFTBBA
     1126  int shift1, shift2;
     1127  if (tailRing->isLPring) {
     1128    // assume: LM is shifted, tail unshifted
     1129    assume(p_FirstVblock(a1, tailRing) <= 1);
     1130    assume(p_FirstVblock(a2, tailRing) <= 1);
     1131    // save the shift of the LM so we can shift the other monomials on demand
     1132    shift1 = p_mFirstVblock(p1, tailRing) - 1;
     1133    shift2 = p_mFirstVblock(p2, tailRing) - 1;
     1134  }
     1135#endif
    11291136  long c1=p_GetComp(p1, currRing),c2=p_GetComp(p2, currRing);
    11301137  long c;
     
    11571164#endif
    11581165
     1166#ifdef HAVE_SHIFTBBA
     1167  // shift the next monomial on demand
     1168  if (tailRing->isLPring)
     1169  {
     1170    a1 = p_LPCopyAndShiftLM(a1, shift1, tailRing);
     1171    a2 = p_LPCopyAndShiftLM(a2, shift2, tailRing);
     1172  }
     1173#endif
    11591174  if (a1==NULL)
    11601175  {
     
    13791394    }
    13801395#endif
     1396#ifdef HAVE_SHIFTBBA
     1397    if (tailRing->isLPring)
     1398    {
     1399      a1 = p_LPCopyAndShiftLM(a1, shift1, tailRing);
     1400      a2 = p_LPCopyAndShiftLM(a2, shift2, tailRing);
     1401    }
     1402#endif
    13811403    if (a2==NULL)
    13821404    {
  • kernel/GBEngine/kutil.cc

    r529288 r15a55a5  
    1204912049static void enterOnePairManyShifts (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR)
    1205012050{
    12051   /* p comes from strat->P.p, that is LObject with LM in currRing and Tail in tailRing */
    12052 
    12053   assume(p_LmCheckIsFromRing(p,currRing));
    12054   assume(p_CheckIsFromRing(pNext(p),strat->tailRing));
     12051  poly s = strat->S[i];
     12052  assume(i<=strat->sl); // from OnePair
    1205512053
    1205612054  /* cycles through all shifts of s[i] until uptodeg - lastVblock(s[i]) */
    1205712055  /* that is create the pairs (f, s \dot g)  */
    12058 
    12059   poly qq = strat->S[i]; //  lm in currRing, tail in tailRing
    1206012056
    1206112057  //  poly q = pCopy(pHead(strat->S[i])); // lm in currRing
     
    1206612062  /* hence, a total number of elt's to add is: */
    1206712063  /*  int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1);  */
    12068   int toInsert =  itoInsert(qq, strat->tailRing);
    12069 
    12070 #ifdef KDEBUG
    12071     if (TEST_OPT_DEBUG)
    12072     {
    12073       //      Print("entered ManyShifts: with toInsert=%d",toInsert); PrintLn();
    12074     }
    12075 #endif
    12076 
    12077   assume(i<=strat->sl); // from OnePair
     12064  int toInsert =  itoInsert(s, currRing);
     12065
    1207812066
    1207912067  /* these vars hold for all shifts of s[i] */
     
    1209012078  }
    1209112079
    12092   int j;
    12093 
    12094   poly q/*, s*/;
    12095 
    1209612080  // for the 0th shift: insert the orig. pair
    12097   enterOnePairShift(qq, p, ecart, isFromQ, strat, -1, ecartq, qfromQ, 0, i);
    12098 
    12099   for (j=1; j<= toInsert; j++)
    12100   {
    12101     //    q = pLPshift(strat->S[i],j,uptodeg,lV);
    12102     q = p_LPshiftT(qq, j, strat, currRing);
    12103     //    q = p_mLPshift(qq,j,uptodeg,lV,currRing); // lm in currRing, shift this monomial
    12104     //    s = p_LPshift(pNext(qq), j, uptodeg, lV, strat->tailRing); // from tailRing
    12105     //    pNext(q) = s; // in tailRing
    12106     /* here we need to call enterOnePair with two polys ... */
    12107 
    12108 #ifdef KDEBUG
    12109     //if (TEST_OPT_DEBUG)
    12110     //{
    12111     //      PrintS("ManyShifts: calling enterOnePairShift(q,p)");      PrintLn();
    12112     //}
    12113 #endif
    12114     //kFindInTShift(q,atR,strat);
     12081  enterOnePairShift(s, p, ecart, isFromQ, strat, -1, ecartq, qfromQ, 0, i);
     12082
     12083  for (int j = 1; j <= toInsert; j++)
     12084  {
     12085    poly q = pLPCopyAndShiftLM(s, j);
    1211512086    enterOnePairShift(q, p, ecart, isFromQ, strat, -1, ecartq, qfromQ, j, i);
    1211612087  }
     
    1212512096void enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int /*atR*/)
    1212612097{
    12127 
    12128   /* format: p,qq are in LObject form: lm in CR, tail in TR */
    12129   /* for true self pairs qq ==p  */
    12130   /* we test both qq and p */
    12131   assume(p_LmCheckIsFromRing(qq,currRing));
    12132   assume(p_CheckIsFromRing(pNext(qq),strat->tailRing));
    12133   assume(p_LmCheckIsFromRing(p,currRing));
    12134   assume(p_CheckIsFromRing(pNext(p),strat->tailRing));
    12135 
    12136   /* since this proc is applied twice for (h, s*g) and (g,s*h), init j with 1 only */
    12137 
    12138   //  int j = 0;
    12139   int j = 1;
    12140 
    12141   /* for such self pairs start with 1, not with 0 */
    12142   if (qq == p) j=1;
    12143 
    1214412098  /* should cycle through all shifts of q until uptodeg - lastVblock(q) */
    1214512099  /* that is create the pairs (f, s \dot g)  */
    1214612100
    12147   int toInsert =  itoInsert(qq, strat->tailRing);
    12148 
    12149 #ifdef KDEBUG
    12150   //if (TEST_OPT_DEBUG)
    12151   //{
    12152   //      Print("entered SelfShifts: with toInsert=%d",toInsert); PrintLn();
    12153   //}
    12154 #endif
    12155 
    12156   poly q;
     12101  int toInsert =  itoInsert(qq, currRing);
    1215712102
    1215812103  /* these vars hold for all shifts of s[i] */
     
    1216012105  int qfromQ = 0; // strat->fromQ[i];
    1216112106
    12162   for (; j<= toInsert; j++)
    12163   {
    12164     //    q = pLPshift(strat->S[i],j,uptodeg,lV);
    12165     /* we increase shifts by one; must delete q there*/
    12166     //    q = qq; q = pMoveCurrTail2poly(q,strat);
    12167     //    q = pLPshift(q,j,uptodeg,lV); //,currRing);
    12168     q = p_LPshiftT(qq, j, strat, currRing);
    12169     //    q = p_mLPshift(qq,j,uptodeg,lV,currRing); // lm in currRing, shift this monomial
    12170     //    s = p_LPshift(pNext(qq), j, uptodeg, lV, strat->tailRing); // from tailRing
    12171     //    pNext(q) = s; // in tailRing
    12172     /* here we need to call enterOnePair with two polys ... */
    12173 #ifdef KDEBUG
    12174     //if (TEST_OPT_DEBUG)
    12175     //{
    12176     //      PrintS("SelfShifts: calling enterOnePairShift(q,p)");      PrintLn();
    12177     //}
    12178 #endif
     12107  /* since this proc is applied twice for (h, s*g) and (g,s*h), init j with 1 */
     12108  for (int j = 1; j<= toInsert; j++)
     12109  {
     12110    poly q = pLPCopyAndShiftLM(qq, j);
    1217912111    enterOnePairShift(q, p, ecart, isFromQ, strat, -1, ecartq, qfromQ, j, -1);
    1218012112  }
     
    1259612528  for (int i = 1; i <= toInsert; i++)
    1259712529  {
    12598     poly shifted = p_mLPshift(p_Head(p.p, currRing), i, currRing);
    12599     pNext(shifted) = pNext(p.p);
    1260012530    LObject qq;
    12601     qq.p = shifted; // don't use Set() because it'll test the poly order
     12531    qq.p = pLPCopyAndShiftLM(p.p, i); // don't use Set() because it'll test the poly order
    1260212532    qq.shift = i;
    1260312533    strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
  • kernel/GBEngine/shiftgb.cc

    r529288 r15a55a5  
    3535#define freeT(A,v) omFreeSize((ADDRESS)A,(v+1)*sizeof(int))
    3636
    37 poly p_LPshiftT(poly p, int sh, kStrategy strat, const ring r)
    38 {
    39   /* assume shift takes place, shifts the poly p by sh */
    40   /* p is like TObject: lm in currRing = r, tail in tailRing  */
    41   /* copies p */
    42 
    43   if (p==NULL) return(p);
    44 
    45   assume(p_LmCheckIsFromRing(p,r));
    46   assume(p_CheckIsFromRing(pNext(p),strat->tailRing));
    47 
    48   /* assume sh and uptodeg agree  TODO check */
    49 
    50   if (sh == 0) return(p); /* the zero shift */
    51 
    52   poly q   = NULL;
    53   poly s   = p_mLPshift(p_Head(p,r), sh, r); // lm in currRing
    54   /* pNext(s) will be fixed below */
    55   poly pp = pNext(p);
    56 
    57   while (pp != NULL)
    58   {
    59     poly h=p_mLPshift(p_Head(pp,strat->tailRing),sh,strat->tailRing);
    60     pIter(pp);
    61 
    62     q = p_Add_q(q, h,strat->tailRing);
    63   }
    64   pNext(s) = q;
    65   /* int version: returns TRUE if it was successful */
    66   return(s);
    67 }
    68 
    6937poly p_LPshift(poly p, int sh, const ring r)
    7038{
    71   /* assume shift takes place */
    72   /* shifts the poly p from the ring r by sh */
    73 
    74   /* assume sh and uptodeg agree TODO check */
    75 
    76   if (sh == 0) return(p); /* the zero shift */
     39  if (sh == 0 || p == NULL) return(p);
    7740
    7841  poly q  = NULL;
     
    9154poly p_mLPshift(poly p, int sh, const ring r)
    9255{
    93   /* p is a monomial from the ring r */
    94 
    95   int lV = r->isLPring;
    96 
    9756  if (sh == 0 || p == NULL || p_LmIsConstantComp(p,r)) return(p);
     57
     58  int lV = r->isLPring;
    9859
    9960  int L = p_mLastVblock(p,r);
     
    12687  //  p_SetCoeff0(m,p_GetCoeff(p,r),r);
    12788  return(p);
     89}
     90
     91poly p_LPCopyAndShiftLM(poly p, int sh, const ring r)
     92{
     93  if (sh == 0 || p == NULL) return p;
     94  poly q = p_mLPshift(p_Head(p, r), sh, r);
     95  pNext(q) = pNext(p);
     96  return q;
    12897}
    12998
     
    328297  m1 = p_GetExp_k_n(m1, hole, r->N, r);
    329298
    330   p_LPshift(m2, 1 - p_mFirstVblock(m2, r), r);
     299  p_mLPshift(m2, 1 - p_mFirstVblock(m2, r), r);
    331300  p_SetCoeff(m1, m1Coeff, r);
    332301}
  • kernel/GBEngine/shiftgb.h

    r529288 r15a55a5  
    1212#include "polys/nc/nc.h"
    1313
    14 poly p_LPshiftT(poly p, int sh, kStrategy strat, const ring r);
    15 
    1614poly p_LPshift(poly p, int sh, const ring r);
    1715poly p_mLPshift(poly p, int sh, const ring r);
     16poly p_LPCopyAndShiftLM(poly p, int sh, const ring r);
    1817
     18#define pLPshift(p, sh) p_LPshift(p, sh, currRing)
     19#define pmLPshift(p, sh) p_mLPshift(p, sh, currRing)
     20#define pLPCopyAndShiftLM(p, sh) p_LPCopyAndShiftLM(p, sh, currRing)
     21
     22int p_LastVblock(poly p, const ring r);
    1923int p_mLastVblock(poly p, const ring r);
    20 int p_LastVblock(poly p, const ring r);
    2124
    2225#define pLastVblock(p) p_LastVblock(p,currRing)
Note: See TracChangeset for help on using the changeset viewer.