Changeset 4d2ab5c in git
- Timestamp:
- Feb 23, 2008, 9:12:53 PM (15 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- 51e69e6599c603806d7fea8cc97d5e9f1bec09e9
- Parents:
- 8c35baa560440cca9bb7bbb44be0232fce1c79c9
- Location:
- kernel
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/kstd2.cc
r8c35ba r4d2ab5c 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kstd2.cc,v 1.6 1 2008-02-15 17:14:21 levandov Exp $ */4 /* $Id: kstd2.cc,v 1.62 2008-02-23 20:12:51 levandov Exp $ */ 5 5 /* 6 6 * ABSTRACT - Kernel: alg. of Buchberger … … 1600 1600 // enterT(strat->P, strat); // this was here before Shift stuff 1601 1601 //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 1603 1604 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 // } 1604 1614 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 ? 1605 1617 // posInS only depends on the leading term 1606 1618 if ((!TEST_OPT_IDLIFT) || (pGetComp(strat->P.p) <= strat->syzComp)) … … 1693 1705 */ 1694 1706 ideal RS = bbaShift(I,NULL, NULL, NULL, strat, uptodeg, lVblock); 1707 idSkipZeroes(RS); 1695 1708 return(RS); 1696 1709 } -
kernel/kutil.cc
r8c35ba r4d2ab5c 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kutil.cc,v 1.8 4 2008-02-15 17:14:22 levandov Exp $ */4 /* $Id: kutil.cc,v 1.85 2008-02-23 20:12:52 levandov Exp $ */ 5 5 /* 6 6 * ABSTRACT: kernel: utils for kStd … … 53 53 /* shiftgb stuff */ 54 54 #include "shiftgb.h" 55 #include "prCopy.h" 55 56 56 57 #ifdef KDEBUG … … 5674 5675 { 5675 5676 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); 5678 5680 assume(strat->tailRing != currRing); 5679 5681 5680 5682 if (! k_GetLeadTerms(L->p1, L->p2, currRing, m1, m2, strat->tailRing)) 5681 5683 return FALSE; 5684 // shift changes: extra case inserted 5685 if ((L->i_r1 == -1) || (L->i_r2 == -1) ) 5686 { 5687 return TRUE; 5688 } 5682 5689 poly p1_max = (strat->R[L->i_r1])->max; 5683 5690 poly p2_max = (strat->R[L->i_r2])->max; … … 6010 6017 6011 6018 #ifdef HAVE_PLURAL 6012 /* including the self pairs? */ 6013 6019 6020 poly 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 6032 poly 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 6047 poly 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 */ 6014 6138 void updateSShift(kStrategy strat,int uptodeg,int lV) 6015 6139 { … … 6022 6146 for (i=0; i<=strat->sl; i++) 6023 6147 { 6024 h.p = strat->S[i]; 6148 memset(&h,0,sizeof(h)); 6149 h.p = strat->S[i]; // lm in currRing, tail in TR 6025 6150 strat->initEcart(&h); 6026 6151 h.sev = strat->sevS[i]; 6152 h.t_p = NULL; 6153 h.GetTP(); // creates correct t_p 6027 6154 /*puts the elements of S with their shifts to T*/ 6028 6155 // 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 ? 6029 6159 enterTShift(h,strat,atT,uptodeg,lV); 6030 6160 } … … 6092 6222 if (!TEST_OPT_SB_1) 6093 6223 { 6094 /* the only change: do not fill the set T*/6224 /* the only change: we do not fill the set T*/ 6095 6225 updateS(FALSE,strat); 6096 6226 } … … 6101 6231 } 6102 6232 6103 // void initBuchMoraShift(ideal F,ideal Q,kStrategy strat)6104 // {6105 // initBuchMora(F,Q,strat);6106 // strat->fromT = TRUE;6107 // }6108 6109 6233 /*1 6110 6234 * put the pairs (sh \dot s[i],p) into the set B, ecart=ecart(p) … … 6112 6236 void enterOnePairManyShifts (int i, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV) 6113 6237 { 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]) */ 6116 6244 /* that is create the pairs (f, s \dot g) */ 6117 6245 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 6120 6252 6121 6253 /* determine how many elements we have to insert for a given s[i] */ … … 6123 6255 /* hence, a total number of elt's to add is: */ 6124 6256 /* 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 6126 6266 6127 6267 assume(i<=strat->sl); // from OnePair … … 6130 6270 /* these vars hold for all shifts of s[i] */ 6131 6271 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 } 6133 6282 6134 6283 int j; 6135 6284 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? 6137 6292 { 6138 6293 // 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); 6141 6301 /* 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); 6146 6317 } 6147 6318 … … 6151 6322 void enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV) 6152 6323 { 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; 6153 6337 6154 6338 /* should cycle through all shifts of q until uptodeg - lastVblock(q) */ … … 6159 6343 /* hence, a total number of elt's to add is: */ 6160 6344 /* 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; 6162 6367 6163 6368 // assume(i<=strat->sl); // from OnePair … … 6168 6373 int qfromQ = 0; // strat->fromQ[i]; 6169 6374 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? 6173 6376 { 6174 6377 // q = pLPshift(strat->S[i],j,uptodeg,lV); 6175 6378 /* 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 6177 6386 /* 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); 6179 6398 } 6180 6399 /* delete q? */ 6181 pDelete(&q);6400 // pDelete(&q); 6182 6401 } 6183 6402 … … 6185 6404 * put the pair (q,p) into the set B, ecart=ecart(p), q is the shift of some s[i] 6186 6405 */ 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 6406 void 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 */ 6190 6431 /* poly q stays for s[i], ecartq = ecart(q), qisFromQ = applies to q */ 6191 6432 … … 6194 6435 /* need additionally: int up_to_degree, poly V0 with the variables in (0) or just the number lV = the length of the first block */ 6195 6436 6196 atR = -1;6437 // atR = -1; 6197 6438 // assume(i<=strat->sl); // satisfied automatically 6198 6439 if (strat->interred_flag) return; … … 6208 6449 Lp.lcm = pInit(); 6209 6450 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 6211 6452 pSetm(Lp.lcm); 6212 6453 … … 6219 6460 { 6220 6461 PrintS("V crit applied to q = "); 6221 wrp( pHead(q));6462 wrp(q); // wrp(pHead(q)); 6222 6463 PrintS(", p = "); 6223 wrp(p Head(p));6464 wrp(p); //wrp(pHead(p)); 6224 6465 PrintLn(); 6225 6466 } … … 6400 6641 // else 6401 6642 // { 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); 6403 6648 // } 6404 6649 } … … 6406 6651 { 6407 6652 /*- 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; 6412 6657 /* END _ TEMPORARILY DISABLED FOR SHIFTS */ 6413 6658 /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/ … … 6426 6671 { 6427 6672 /*- 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 6430 6676 6431 6677 if ( !bIsPluralRing ) 6432 6678 pNext(Lp.p) = strat->tail; 6433 6679 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 //else6442 //{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 */ 6444 6690 Lp.i_r1 = -1; 6445 6691 Lp.i_r2 = -1; 6446 //}6692 } 6447 6693 strat->initEcartPair(&Lp,q,p,ecartq,ecart); 6448 6694 … … 6465 6711 void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR,int uptodeg, int lV) 6466 6712 { 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*/ 6468 6715 int j=pos; 6469 6716 … … 6490 6737 6491 6738 /*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 6493 6741 * additionally we put the pairs (h, s \sdot h) for s>=1 to L 6494 6742 */ 6495 6743 void initenterpairsShift (poly h,int k,int ecart,int isFromQ, kStrategy strat, int atR, int uptodeg, int lV) 6496 6744 { 6497 atR = -1; 6745 /* h comes from strat->P.p, that is LObject with LM in currRing and Tail in tailRing */ 6746 // atR = -1; 6498 6747 if ((strat->syzComp==0) 6499 6748 || (pGetComp(h)<=strat->syzComp)) … … 6513 6762 new_pair=TRUE; 6514 6763 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); 6515 6766 //Print("j:%d, Ll:%d\n",j,strat->Ll); 6516 6767 } … … 6523 6774 { 6524 6775 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); 6525 6778 } 6526 6779 /* HERE we put (h, s*h) pairs */ … … 6538 6791 new_pair=TRUE; 6539 6792 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); 6540 6795 //Print("j:%d, Ll:%d\n",j,strat->Ll); 6541 6796 } 6542 6797 } 6543 /* HERE we put (h, s*h) pairs TOO*/6798 /* HERE we put (h, s*h) pairs */ 6544 6799 enterOnePairSelfShifts (h, h, ecart, isFromQ, strat, atR, uptodeg, lV); 6545 6800 } … … 6565 6820 /* int toInsert = 1 + (uptodeg-1) - (pLastVblock(p.p, lV) -1); */ 6566 6821 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 6571 6830 int i; 6572 6831 … … 6574 6833 atT = strat->posInT(strat->T, strat->tl, p); 6575 6834 6576 LObject q;6577 poly s;6835 // LObject q; 6836 // poly s; 6578 6837 /* 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(); 6582 6863 /* shift p, that is create another LObject and shift its poly */ 6583 6864 /* change: p.p, p.t_p, */ 6584 6865 /* 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); 6592 6885 } 6593 6886 -
kernel/kutil.h
r8c35ba r4d2ab5c 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: kutil.h,v 1.3 2 2008-02-21 18:20:06 SingularExp $ */6 /* $Id: kutil.h,v 1.33 2008-02-23 20:12:52 levandov Exp $ */ 7 7 /* 8 8 * ABSTRACT: kernel: utils for kStd … … 620 620 #include "shiftgb.h" 621 621 622 poly pMove2CurrTail(poly p, kStrategy strat); 623 624 poly pMoveCurrTail2poly(poly p, kStrategy strat); 625 626 poly pCopyL2p(LObject h, kStrategy strat); 627 622 628 void enterTShift(LObject p, kStrategy strat, int atT, int uptodeg, int lV); 623 629 … … 628 634 void enterOnePairSelfShifts (poly qq, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int uptodeg, int lV); 629 635 630 void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int uptodeg, int lV); // ok636 void 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 631 637 632 638 void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR,int uptodeg, int lV); -
kernel/shiftgb.cc
r8c35ba r4d2ab5c 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 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 $ */ 5 5 /* 6 6 * ABSTRACT: kernel: utils for shift GB and free GB … … 39 39 #define freeT(A,v) omFreeSize((ADDRESS)A,(v+1)*sizeof(int)) 40 40 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 44 poly 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 73 poly p_LPshift(poly p, int sh, int uptodeg, int lV, const ring r) 42 74 { 43 75 /* assume shift takes place */ … … 47 79 /* assume sh and uptodeg agree */ 48 80 81 if (p==NULL) return(p); 49 82 if (sh == 0) return(p); /* the zero shift */ 50 83 … … 53 86 while (pp!=NULL) 54 87 { 55 q = p_Add_q(q, p mLPshift(pp,sh,uptodeg,lV),currRing);88 q = p_Add_q(q, p_mLPshift(pp,sh,uptodeg,lV,r),r); 56 89 pIter(pp); 57 90 } … … 61 94 } 62 95 96 poly 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 152 poly 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 63 174 poly pmLPshift(poly p, int sh, int uptodeg, int lV) 64 175 { 176 /* TODO: use a shortcut with p_ version */ 65 177 /* pm is a monomial */ 66 178 … … 110 222 /* appearing among the monomials of p */ 111 223 /* 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 ? */ 113 225 int ans = 0; 114 226 int ansnew = 0; … … 127 239 /* for a monomial p, returns the number of the last block */ 128 240 /* where a nonzero exponent is sitting */ 241 if (pIsConstantPoly(p)) 242 { 243 return(int(0)); 244 } 129 245 int *e=(int *)omAlloc0((currRing->N+1)*sizeof(int)); 130 246 pGetExpV(p,e); … … 143 259 return (b); 144 260 } 261 262 int 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 285 int 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 303 int 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 329 int 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 347 int 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 145 372 146 373 int isInV(poly p, int lV) … … 161 388 for (i=(j-1)*lV + 1; i<= j*lV; i++) 162 389 { 163 if ( !e[i]) B[j] = B[j]+1;390 if (e[i]) B[j] = B[j]+1; 164 391 } 165 392 } … … 187 414 } 188 415 416 int 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 189 438 /* shiftgb stuff */ 190 439 -
kernel/shiftgb.h
r8c35ba r4d2ab5c 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: shiftgb.h,v 1. 2 2007-06-24 16:44:42levandov Exp $ */6 /* $Id: shiftgb.h,v 1.3 2008-02-23 20:12:53 levandov Exp $ */ 7 7 /* 8 8 * ABSTRACT: kernel: utils for kStd … … 12 12 #include "gring.h" 13 13 14 poly p_LPshiftT(poly p, int sh, int uptodeg, int lV, kStrategy strat, const ring r); 15 int p_LastVblockT(poly p, int lV, kStrategy strat, const ring r); 16 17 poly p_LPshift(poly p, int sh, int uptodeg, int lV,const ring r); 18 poly p_mLPshift(poly p, int sh, int uptodeg, int lV,const ring r); 19 20 int p_mLastVblock(poly p, int lV,const ring r); 21 int p_LastVblock(poly p, int lV, const ring r); 22 14 23 poly pLPshift(poly p, int sh, int uptodeg, int lV); 15 24 poly pmLPshift(poly p, int sh, int uptodeg, int lV); … … 18 27 int pmLastVblock(poly p, int lV); 19 28 29 int pFirstVblock(poly p, int lV); 30 int pmFirstVblock(poly p, int lV); 31 20 32 int isInV(poly p, int lV); 21 33 34 int itoInsert(poly p, int uptodeg, int lV, const ring r); 35 22 36 #endif
Note: See TracChangeset
for help on using the changeset viewer.