Changeset 6a90def in git
- Timestamp:
- Oct 5, 2018, 11:13:14 AM (6 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
- Children:
- 117034855fb14b4ecc7a656722da1e9050bdbb48
- Parents:
- d2565e22eae9b311f4ae3ee67235dbfd4d59e501
- git-author:
- Christian Eder <ederc@mathematik.uni-kl.de>2018-10-05 11:13:14+02:00
- git-committer:
- Christian Eder <ederc@mathematik.uni-kl.de>2018-10-05 12:37:42+02:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/GBEngine/kspoly.cc
rd2565e r6a90def 163 163 } 164 164 165 int ksReducePolyGCD(LObject* PR, 166 TObject* PW, 167 poly spNoether, 168 number *coef, 169 kStrategy strat) 170 { 171 #ifdef KDEBUG 172 red_count++; 173 #ifdef TEST_OPT_DEBUG_RED 174 // if (TEST_OPT_DEBUG) 175 // { 176 // Print("Red %d:", red_count); PR->wrp(); Print(" with:"); 177 // PW->wrp(); 178 // //printf("\necart(PR)-ecart(PW): %i\n",PR->ecart-PW->ecart); 179 // //pWrite(PR->p); 180 // } 181 #endif 182 #endif 183 int ret = 0; 184 ring tailRing = PR->tailRing; 185 kTest_L(PR); 186 kTest_T(PW); 187 188 poly p1 = PR->GetLmTailRing(); 189 poly p2 = PW->GetLmTailRing(); 190 poly t2 = pNext(p2), lm = pOne(); 191 assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special 192 p_CheckPolyRing(p1, tailRing); 193 p_CheckPolyRing(p2, tailRing); 194 195 pAssume1(p2 != NULL && p1 != NULL && 196 p_DivisibleBy(p2, p1, tailRing)); 197 198 pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) || 199 (p_GetComp(p2, tailRing) == 0 && 200 p_MaxComp(pNext(p2),tailRing) == 0)); 201 202 #ifdef HAVE_PLURAL 203 if (rIsPluralRing(currRing)) 204 { 205 // for the time being: we know currRing==strat->tailRing 206 // no exp-bound checking needed 207 // (only needed if exp-bound(tailring)<exp-b(currRing)) 208 if (PR->bucket!=NULL) nc_kBucketPolyRed_Z(PR->bucket, p2,coef); 209 else 210 { 211 poly _p = (PR->t_p != NULL ? PR->t_p : PR->p); 212 assume(_p != NULL); 213 nc_PolyPolyRed(_p, p2,coef, currRing); 214 if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p; 215 PR->pLength=0; // usually not used, GetpLength re-computes it if needed 216 } 217 return 0; 218 } 219 #endif 220 // check that reduction does not violate exp bound 221 while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing)) 222 { 223 // undo changes of lm 224 p_ExpVectorAdd(lm, p2, tailRing); 225 if (strat == NULL) return 2; 226 if (! kStratChangeTailRing(strat, PR, PW)) return -1; 227 tailRing = strat->tailRing; 228 p1 = PR->GetLmTailRing(); 229 p2 = PW->GetLmTailRing(); 230 t2 = pNext(p2); 231 lm = p1; 232 p_ExpVectorSub(lm, p2, tailRing); 233 ret = 1; 234 } 235 236 number ct, an, bn; 237 // take care of coef buisness 238 if (! n_IsOne(pGetCoeff(p2), tailRing->cf)) 239 { 240 ct = n_ExtGcd(pGetCoeff(p1), pGetCoeff(p2), &an, &bn, tailRing->cf); // Calculate GCD 241 /* negate bn since we subtract in Tail_Minus_mm_Mult_qq */ 242 bn = n_InpNeg(bn, tailRing->cf); 243 p_SetCoeff(lm, bn, tailRing); 244 PR->Tail_Mult_nn(an); 245 } 246 else 247 { 248 if (coef != NULL) *coef = n_Init(1, tailRing->cf); 249 } 250 251 252 // and finally, 253 PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether); 254 assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p)); 255 pSetCoeff(PR->p, ct); 256 257 // the following is commented out: shrinking 258 #ifdef HAVE_SHIFTBBA_NONEXISTENT 259 if ( (currRing->isLPring) && (!strat->homog) ) 260 { 261 // assume? h->p in currRing 262 PR->GetP(); 263 poly qq = p_Shrink(PR->p, currRing->isLPring, currRing); 264 PR->Clear(); // does the right things 265 PR->p = qq; 266 PR->t_p = NULL; 267 PR->SetShortExpVector(); 268 } 269 #endif 270 271 return ret; 272 } 273 165 274 /* Computes a reduction of the lead coefficient only. We have already tested 166 275 * that lm(PW) divides lm(PR), but lc(PW) does not divide lc(PR). We have … … 227 336 } 228 337 #endif 229 /* printf("PR->P2: ");230 * pWrite(PR->p); */231 232 /* this part never happens since t2 = p2 and NOT t2 = pNext(p2) */233 /* if (t2==NULL) // Divisor is just one term, therefore it will234 * { // just cancel the leading term235 * PR->LmDeleteAndIter();236 * if (coef != NULL) *coef = n_Init(1, tailRing->cf);237 * return 0;238 * } */239 338 240 339 p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2 241 340 p_SetCoeff(lm, n_Init(1, tailRing), tailRing); 242 //if (tailRing != currRing) 243 { 244 // check that reduction does not violate exp bound 245 while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing)) 246 { 247 // undo changes of lm 248 p_ExpVectorAdd(lm, p2, tailRing); 249 if (strat == NULL) return 2; 250 /* if (! kStratChangeTailRing(strat, PR, PW)) return -1; */ 251 tailRing = strat->tailRing; 252 p1 = PR->GetLmTailRing(); 253 p2 = PW->GetLmTailRing(); 254 t2 = pNext(p2); 255 lm = p1; 256 p_ExpVectorSub(lm, p2, tailRing); 257 ret = 1; 258 } 259 } 260 261 // take care of coef buisness 262 // we have done this already in redRingNew 263 /* if (! n_IsOne(pGetCoeff(p2), tailRing->cf)) 264 * { 265 * number bn = pGetCoeff(lm); 266 * number an = pGetCoeff(p2); 267 * int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC 268 * p_SetCoeff(lm, bn, tailRing); 269 * if ((ct == 0) || (ct == 2)) 270 * PR->Tail_Mult_nn(an); 271 * if (coef != NULL) *coef = an; 272 * else n_Delete(&an, tailRing->cf); 273 * } 274 * else 275 * { 276 * if (coef != NULL) *coef = n_Init(1, tailRing->cf); 277 * } */ 341 while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing)) 342 { 343 // undo changes of lm 344 p_ExpVectorAdd(lm, p2, tailRing); 345 if (strat == NULL) return 2; 346 /* if (! kStratChangeTailRing(strat, PR, PW)) return -1; */ 347 tailRing = strat->tailRing; 348 p1 = PR->GetLmTailRing(); 349 p2 = PW->GetLmTailRing(); 350 t2 = pNext(p2); 351 lm = p1; 352 p_ExpVectorSub(lm, p2, tailRing); 353 ret = 1; 354 } 278 355 279 356 // and finally, 280 /* printf("NOW WE REDUCE:\n");281 * p_Write(lm, tailRing);282 * p_Write(p2, tailRing); */283 /* we use p2, since then lm(p2) is the gcd lead monomial and we are done! */284 357 PR->Tail_Minus_mm_Mult_qq(lm, p2, pLength(p2) /*PW->GetpLength() - 1*/, spNoether); 285 /* PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) [>PW->GetpLength() - 1<], spNoether); */286 358 assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p)); 287 359 288 360 PR->LmDeleteAndIter(); 289 361 p_SetCoeff(PR->p, *coef, currRing); 290 /* p_SetCoeff(PR->t_p, *coef, tailRing); */291 362 292 363 … … 1017 1088 } 1018 1089 #endif 1019 1020 1090 } 1021 1091
Note: See TracChangeset
for help on using the changeset viewer.