Changeset cea6f3 in git for kernel/kspoly.cc
- Timestamp:
- Jan 13, 2006, 7:10:06 PM (17 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 2e4de3d33d0bea3780e1932fdaf8a41c161f473e
- Parents:
- 4cbb61ba5014a593b9bc6569b497e9a8151bc15f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/kspoly.cc
r4cbb61 rcea6f3 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kspoly.cc,v 1. 2 2005-11-27 15:28:44 wienand Exp $ */4 /* $Id: kspoly.cc,v 1.3 2006-01-13 18:10:04 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT - Routines for Spoly creation and reductions … … 49 49 kTest_T(PW); 50 50 51 poly p1 = PR->GetLmTailRing(); 52 poly p2 = PW->GetLmTailRing(); 53 poly t2 = pNext(p2), lm = p1; 54 assume(p1 != NULL && p2 != NULL); 51 poly p1 = PR->GetLmTailRing(); // p2 | p1 52 poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2) 53 poly t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2 54 assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special 55 55 p_CheckPolyRing(p1, tailRing); 56 56 p_CheckPolyRing(p2, tailRing); … … 83 83 } 84 84 85 if (t2==NULL) 86 { 85 if (t2==NULL) // Divisor is just one term, therefore it will 86 { // just cancel the leading term 87 87 PR->LmDeleteAndIter(); 88 88 if (coef != NULL) *coef = n_Init(1, tailRing); … … 90 90 } 91 91 92 p_ExpVectorSub(lm, p2, tailRing); 92 p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2 93 93 94 94 if (tailRing != currRing) … … 116 116 number bn = pGetCoeff(lm); 117 117 number an = pGetCoeff(p2); 118 #ifdef HAVE_RING2TOM 119 if (currRing->cring == 1) { 120 while (((long) an)%2 == 0 && ((long) bn)%2 == 0) { 121 an = (number) (((long) an) / 2); 122 bn = (number) (((long) bn) / 2); 123 } 124 } 125 #endif 126 int ct = ksCheckCoeff(&an, &bn); 127 p_SetCoeff(lm, bn,tailRing); 118 int ct = ksCheckCoeff(&an, &bn); // Calculate special LC 119 p_SetCoeff(lm, bn, tailRing); 128 120 if ((ct == 0) || (ct == 2)) 129 121 PR->Tail_Mult_nn(an); … … 139 131 // and finally, 140 132 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether); 133 assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p)); 141 134 PR->LmDeleteAndIter(); 142 135 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED) … … 148 141 return ret; 149 142 } 150 151 #ifdef HAVE_RING2TOM152 /***************************************************************153 *154 * Reduces PR with PW155 * Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR)156 * as above, just for rings157 *158 ***************************************************************/159 int ksRingReducePoly(LObject* PR,160 TObject* PW,161 poly spNoether,162 number *coef,163 kStrategy strat)164 {165 #ifdef KDEBUG166 red_count++;167 #ifdef TEST_OPT_DEBUG_RED168 if (TEST_OPT_DEBUG)169 {170 Print("Red %d:", red_count); PR->wrp(); Print(" with:");171 PW->wrp();172 }173 #endif174 #endif175 int ret = 0;176 ring tailRing = PR->tailRing;177 kTest_L(PR);178 kTest_T(PW);179 180 poly p1 = PR->GetLmTailRing();181 poly p2 = PW->GetLmTailRing();182 poly t2 = pNext(p2), lm = p1;183 assume(p1 != NULL && p2 != NULL);184 p_CheckPolyRing(p1, tailRing);185 p_CheckPolyRing(p2, tailRing);186 187 pAssume1(p2 != NULL && p1 != NULL &&188 p_RingDivisibleBy(p2, p1, tailRing));189 190 pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) ||191 (p_GetComp(p2, tailRing) == 0 &&192 p_MaxComp(pNext(p2),tailRing) == 0));193 194 if (t2==NULL)195 {196 PR->LmDeleteAndIter();197 if (coef != NULL) *coef = n_Init(1, tailRing);198 return 0;199 }200 201 p_ExpVectorSub(lm, p2, tailRing);202 203 if (tailRing != currRing)204 {205 // check that reduction does not violate exp bound206 while (PW->max != NULL && !p_LmExpVectorAddIsOk(lm, PW->max, tailRing))207 {208 // undo changes of lm209 p_ExpVectorAdd(lm, p2, tailRing);210 if (strat == NULL) return 2;211 if (! kStratChangeTailRing(strat, PR, PW)) return -1;212 tailRing = strat->tailRing;213 p1 = PR->GetLmTailRing();214 p2 = PW->GetLmTailRing();215 t2 = pNext(p2);216 lm = p1;217 p_ExpVectorSub(lm, p2, tailRing);218 ret = 1;219 }220 }221 222 // take care of coef buisness223 if (! n_IsOne(pGetCoeff(p2), tailRing))224 {225 number bn = pGetCoeff(lm);226 number an = pGetCoeff(p2);227 while (((long) an)%2 == 0 && ((long) bn)%2 == 0) {228 an = (number) (((long) an) / 2);229 bn = (number) (((long) bn) / 2);230 }231 int ct = ksCheckCoeff(&an, &bn);232 p_SetCoeff(lm, bn,tailRing);233 if ((ct == 0) || (ct == 2))234 PR->Tail_Mult_nn(an);235 if (coef != NULL) *coef = an;236 else n_Delete(&an, tailRing);237 }238 else239 {240 if (coef != NULL) *coef = n_Init(1, tailRing);241 }242 243 244 // and finally,245 PR->Tail_Minus_mm_Mult_qq(lm, t2, PW->GetpLength() - 1, spNoether);246 PR->LmDeleteAndIter();247 #if defined(KDEBUG) && defined(TEST_OPT_DEBUG_RED)248 if (TEST_OPT_DEBUG)249 {250 Print(" to: "); PR->wrp(); Print("\n");251 }252 #endif253 return ret;254 }255 #endif256 143 257 144 /*************************************************************** … … 280 167 poly a1 = pNext(p1), a2 = pNext(p2); 281 168 number lc1 = pGetCoeff(p1), lc2 = pGetCoeff(p2); 282 #ifdef HAVE_RING2TOM 283 if (currRing->cring == 1) { 284 while (((long) lc1)%2 == 0 && ((long) lc2)%2 == 0) { 285 lc1 = (number) (((long) lc1) / 2); 286 lc2 = (number) (((long) lc2) / 2); 287 } 288 } 289 #endif 290 int co=0, ct = ksCheckCoeff(&lc1, &lc2); 169 int co=0, ct = ksCheckCoeff(&lc1, &lc2); // gcd and zero divisors 291 170 292 171 int l1=0, l2=0; … … 329 208 else 330 209 a2 = tailRing->p_Procs->pp_Mult_mm(a2, m2, tailRing,last); 210 #ifdef HAVE_RING2TOM 211 if (currRing->cring == 1) l2 = pLength(a2); 212 #endif 213 331 214 Pair->SetLmTail(m2, a2, l2, use_buckets, tailRing, last); 332 215 … … 429 312 bn = nIntDiv(bn, cn); 430 313 } 314 #ifdef HAVE_RING2TOM 315 if (currRing->cring == 1) { 316 while (((long) an)%2 == 0 && ((long) bn)%2 == 0) { 317 an = (number) (((long) an) / 2); 318 bn = (number) (((long) bn) / 2); 319 } 320 } 321 #endif 431 322 nDelete(&cn); 432 323 if (nIsOne(an))
Note: See TracChangeset
for help on using the changeset viewer.