Changeset b94a72 in git
 Timestamp:
 Apr 24, 2020, 6:38:31 PM (3 years ago)
 Branches:
 (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
 Children:
 8e903f23324de1e4ec1dc9926b6de0a16de605d6
 Parents:
 5f544e3856e15c729d9cd4aeb0a80d2c613f4be2
 Location:
 kernel/GBEngine
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

kernel/GBEngine/kspoly.cc
r5f544e rb94a72 312 312 } 313 313 314 #ifdef HAVE_RINGS 314 315 int ksReducePolyGCD(LObject* PR, 315 316 TObject* PW, … … 399 400 ct = n_ExtGcd(pGetCoeff(p1), pGetCoeff(p2), &an, &bn, tailRing>cf); // Calculate GCD 400 401 #ifdef HAVE_SHIFTBBA 401 if (n_IsZero(an, tailRing>cf)  n_IsZero(bn, tailRing>cf)) 402 { 403 // NOTE: not sure why this is not checked in the commutative case, this *does* happen and then zero coeff errors are reported 404 405 // NOTE: we are probably leaking memory of lm=pOne(), but we cannot delete it since it could also be lm=p1 406 n_Delete(&an, tailRing>cf); 407 n_Delete(&bn, tailRing>cf); 408 n_Delete(&ct, tailRing>cf); 409 return ret; 402 if(rIsLPRing(tailRing)) /* with this test: error at New/stdZtests.tst, infinite : Long/primdecint.tst */ 403 { 404 if (n_IsZero(an, tailRing>cf)  n_IsZero(bn, tailRing>cf)) 405 { 406 // NOTE: not sure why this is not checked in the commutative case, this *does* happen and then zero coeff errors are reported 407 // NOTE: we are probably leaking memory of lm=pOne(), but we cannot delete it since it could also be lm=p1 408 n_Delete(&an, tailRing>cf); 409 n_Delete(&bn, tailRing>cf); 410 n_Delete(&ct, tailRing>cf); 411 return ret; 412 } 410 413 } 411 414 #endif … … 437 440 return ret; 438 441 } 442 #endif 439 443 440 444 /* Computes a reduction of the lead coefficient only. We have already tested … … 1413 1417 #ifdef HAVE_SHIFTBBA 1414 1418 int shift1, shift2; 1415 if (tailRing>isLPring) { 1419 if (tailRing>isLPring) 1420 { 1416 1421 // assume: LM is shifted, tail unshifted 1417 1422 assume(p_FirstVblock(a1, tailRing) <= 1); 
kernel/GBEngine/kstd2.cc
r5f544e rb94a72 105 105 { 106 106 gcd = n_Gcd(pGetCoeff(p), pGetCoeff(T[j].p), r>cf); 107 if (o == 1  108 n_Greater(n_EucNorm(ogcd, r>cf), n_EucNorm(gcd, r>cf), r>cf) == TRUE) { 107 if (o == 1 108  n_Greater(n_EucNorm(ogcd, r>cf), n_EucNorm(gcd, r>cf), r>cf)) 109 { 109 110 ogcd = gcd; 110 111 o = j; … … 125 126 { 126 127 gcd = n_Gcd(pGetCoeff(p), pGetCoeff(T[j].p), r>cf); 127 if (o == 1  128 n_Greater(n_EucNorm(ogcd, r>cf), n_EucNorm(gcd, r>cf), r>cf) == TRUE) { 128 if (o == 1 129  n_Greater(n_EucNorm(ogcd, r>cf), n_EucNorm(gcd, r>cf), r>cf)) 130 { 129 131 ogcd = gcd; 130 132 o = j; … … 157 159 { 158 160 mult= n_QuotRem(pGetCoeff(p), pGetCoeff(T0p), &rest, r>cf); 159 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r>cf), n_EucNorm(rest, r>cf), r>cf) == TRUE) { 161 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r>cf), n_EucNorm(rest, r>cf), r>cf)) 162 { 160 163 return 0; 161 164 } … … 165 168 { 166 169 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T0p), &rest, r>cf); 167 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r>cf), n_EucNorm(rest, r>cf), r>cf) == TRUE) { 170 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r>cf), n_EucNorm(rest, r>cf), r>cf)) 171 { 168 172 return 0; 169 173 } … … 182 186 { 183 187 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T0p), &rest, r>cf); 184 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r>cf), n_EucNorm(rest, r>cf), r>cf) == TRUE) { 188 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r>cf), n_EucNorm(rest, r>cf), r>cf)) 189 { 185 190 return 0; 186 191 } … … 190 195 { 191 196 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T0p), &rest, r>cf); 192 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r>cf), n_EucNorm(rest, r>cf), r>cf) == TRUE) { 197 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r>cf), n_EucNorm(rest, r>cf), r>cf)) 198 { 193 199 return 0; 194 200 } … … 223 229 { 224 230 mult= n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].p), &rest, r>cf); 225 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r>cf), n_EucNorm(rest, r>cf), r>cf) == TRUE) { 231 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r>cf), n_EucNorm(rest, r>cf), r>cf)) 232 { 226 233 o = j; 227 234 orest = rest; … … 232 239 { 233 240 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].p), &rest, r>cf); 234 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r>cf), n_EucNorm(rest, r>cf), r>cf) == TRUE) { 241 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r>cf), n_EucNorm(rest, r>cf), r>cf)) 242 { 235 243 o = j; 236 244 orest = rest; … … 254 262 { 255 263 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].t_p), &rest, r>cf); 256 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r>cf), n_EucNorm(rest, r>cf), r>cf) == TRUE) { 264 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r>cf), n_EucNorm(rest, r>cf), r>cf)) 265 { 257 266 o = j; 258 267 orest = rest; … … 263 272 { 264 273 mult = n_QuotRem(pGetCoeff(p), pGetCoeff(T[j].t_p), &rest, r>cf); 265 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r>cf), n_EucNorm(rest, r>cf), r>cf) == TRUE) { 274 if (!n_IsZero(mult, r) && n_Greater(n_EucNorm(orest, r>cf), n_EucNorm(rest, r>cf), r>cf)) 275 { 266 276 o = j; 267 277 orest = rest; … … 648 658 /* check if a reducer of the lead term exists */ 649 659 j = kFindDivisibleByInT(strat, h); 650 if (j < 0) { 660 if (j < 0) 661 { 651 662 /* check if a reducer with the same lead monomial exists */ 652 663 j = kFindSameLMInT_Z(strat, h); 653 if (j < 0) { 664 if (j < 0) 665 { 654 666 /* check if a reducer of the lead monomial exists, by the above 655 667 * check this is a real divisor of the lead monomial */ … … 683 695 } 684 696 } 685 686 697 else 698 { 687 699 /* not(lc(reducer)  lc(poly)) && not(lc(poly)  lc(reducer)) 688 700 * => we try to cut down the lead coefficient at least */ … … 713 725 ksReducePolyZ(h, &(strat>T[j]), NULL, NULL, strat); 714 726 ksReducePolyGCD(&h2, &(strat>T[j]), NULL, NULL, strat); 715 if (!rHasLocalOrMixedOrdering(currRing)) { 727 if (!rHasLocalOrMixedOrdering(currRing)) 728 { 716 729 redtailBbaAlsoLC_Z(&h2, j, strat); 717 730 h2.pCleardenom(); … … 4350 4363 /* shiftgb stuff */ 4351 4364 #ifdef HAVE_SHIFTBBA 4352 4353 4354 4365 ideal bbaShift(ideal F, ideal Q,intvec *w,intvec *hilb,kStrategy strat) 4355 4366 { … … 4508 4519 // therefore we call pCleardenom instead of pNorm 4509 4520 strat>redTailChange=FALSE; 4510 4521 4511 4522 /* if we are computing over Z we always want to try and cut down 4512 4523 * the coefficients in the tail terms */ 4513 if (rField_is_Z(currRing) && !rHasLocalOrMixedOrdering(currRing)) { 4524 if (rField_is_Z(currRing) && !rHasLocalOrMixedOrdering(currRing)) 4525 { 4514 4526 redtailBbaAlsoLC_Z(&(strat>P), strat>tl, strat); 4515 4527 strat>P.pCleardenom(); … … 4630 4642 if (pLmShortDivisibleBy(strat>T[j].p, strat>sevT[j], strat>S[k], ~strat>sevS[k])) 4631 4643 { 4632 if (pLmCmp(strat>T[j].p, strat>S[k]) != 0) { // check whether LM is different 4644 if (pLmCmp(strat>T[j].p, strat>S[k]) != 0) 4645 { // check whether LM is different 4633 4646 deleteInS(k, strat); 4634 4647 k; … … 4710 4723 return (strat>Shdl); 4711 4724 } 4725 #endif 4712 4726 4713 4727 #ifdef HAVE_SHIFTBBA … … 4727 4741 * element in t with respect to the given pDivisibleBy 4728 4742 */ 4743 #ifdef HAVE_SHIFTBBA 4729 4744 int redFirstShift (LObject* h,kStrategy strat) 4730 4745 { 
kernel/GBEngine/kutil.cc
r5f544e rb94a72 234 234 235 235 #ifdef HAVE_SHIFTBBA 236 static inline int pLPDivComp(poly p, poly q) { 236 static inline int pLPDivComp(poly p, poly q) 237 { 237 238 if ((currRing>pCompIndex < 0)  (__p_GetComp(p,currRing) == __p_GetComp(q,currRing))) 238 239 { … … 755 756 return 1; 756 757 } 757 758 #endif 759 760 #ifdef HAVE_SHIFTBBA 758 761 int kFindInTShift(poly p, kStrategy strat) 759 762 { … … 1600 1603 k_GetStrongLeadTerms(p, si, currRing, m1, m2, gcd, strat>tailRing); 1601 1604 1602 if (!rHasLocalOrMixedOrdering(currRing)) { 1605 if (!rHasLocalOrMixedOrdering(currRing)) 1606 { 1603 1607 unsigned long sev = pGetShortExpVector(gcd); 1604 1608 1605 for (int j = 0; j < strat>sl; j++) { 1609 for (int j = 0; j < strat>sl; j++) 1610 { 1606 1611 if (j == i) 1607 1612 continue; 1608 1613 1609 if (n_DivBy(d, pGetCoeff(strat>S[j]), currRing>cf) && 1610 !(strat>sevS[j] & ~sev) && 1611 p_LmDivisibleBy(strat>S[j], gcd, currRing)) { 1614 if (n_DivBy(d, pGetCoeff(strat>S[j]), currRing>cf) 1615 && !(strat>sevS[j] & ~sev) 1616 && p_LmDivisibleBy(strat>S[j], gcd, currRing)) 1617 { 1612 1618 nDelete(&d); 1613 1619 nDelete(&s); … … 3230 3236 strat>Bl = 1; 3231 3237 } 3238 3232 3239 /*2 3233 3240 *the pairset B of pairs of type (s[i],p) is complete now. It will be updated … … 7287 7294 return FALSE; 7288 7295 int found = 1; 7289 for (int i=strat>Bl; i>1; i) { 7296 for (int i=strat>Bl; i>1; i) 7297 { 7290 7298 if (pLmEqual(strat>B[i].sig,sig)) 7291 7299 { … … 7823 7831 int j; 7824 7832 j = kFindDivisibleByInT(strat, &Ln); 7825 if (j < 0) { 7833 if (j < 0) 7834 { 7826 7835 j = kFindDivisibleByInT_Z(strat, &Ln); 7827 if (j < 0) { 7836 if (j < 0) 7837 { 7828 7838 break; 7829 } else { 7839 } 7840 else 7841 { 7830 7842 /* reduction not cancelling a tail term, but reducing its coefficient */ 7831 7843 With = &(strat>T[j]); … … 12325 12337 // } 12326 12338 12327 #ifdef HAVE_SHIFTBBA12328 12339 /*2 12329 12340 * put the lcm(q,p) into the set B, q is the shift of some s[i] 12330 12341 */ 12342 #ifdef HAVE_SHIFTBBA 12331 12343 static BOOLEAN enterOneStrongPolyShift (poly q, poly p, int /*ecart*/, int /*isFromQ*/, kStrategy strat, int atR, int /*ecartq*/, int qisFromQ, int shiftcount, int ifromS) 12332 12344 { … … 12492 12504 return TRUE; 12493 12505 } 12506 #endif 12507 12494 12508 12495 12509 /*2 12496 12510 * put the pair (q,p) into the set B, ecart=ecart(p), q is the shift of some s[i] (ring case) 12497 12511 */ 12512 #ifdef HAVE_SHIFTBBA 12498 12513 static void enterOnePairRingShift (poly q, poly p, int /*ecart*/, int isFromQ, kStrategy strat, int atR, int /*ecartq*/, int qisFromQ, int shiftcount, int ifromS) 12499 12514 { … … 12736 12751 kTest_TS(strat); 12737 12752 } 12738 12753 #endif 12754 12755 #ifdef HAVE_SHIFTBBA 12739 12756 // adds the strong pair and the normal pair for rings (aka gpoly and spoly) 12740 12757 static void enterOneStrongPolyAndEnterOnePairRingShift(poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS) … … 12743 12760 enterOnePairRingShift(q, p, ecart, isFromQ, strat, atR, ecartq, qisFromQ, shiftcount, ifromS); // "spoly" 12744 12761 } 12745 12762 #endif 12763 12764 #ifdef HAVE_SHIFTBBA 12746 12765 // creates if possible (q,p), (shifts(q),p) 12747 12766 static void enterOnePairWithShifts (int q_inS /*also i*/, poly q, poly p, int ecartp, int p_isFromQ, kStrategy strat, int atR, int p_lastVblock, int q_lastVblock) … … 12831 12850 #endif 12832 12851 12833 #ifdef HAVE_SHIFTBBA12834 12852 12835 12853 #ifdef KDEBUG … … 12840 12858 * put the pair (q,p) into the set B, ecart=ecart(p), q is the shift of some s[i] 12841 12859 */ 12860 #ifdef HAVE_SHIFTBBA 12842 12861 void enterOnePairShift (poly q, poly p, int ecart, int isFromQ, kStrategy strat, int atR, int ecartq, int qisFromQ, int shiftcount, int ifromS) 12843 12862 { … … 12950 12969 pLmFree(Lp.lcm); 12951 12970 #ifdef CRITERION_DEBUG 12952 if (TEST_OPT_DEBUG) { 12971 if (TEST_OPT_DEBUG) 12972 { 12953 12973 Print(" chain crit using B[%d].lcm=%s\n", j, pString(strat>B[j].lcm)); 12954 12974 } … … 12963 12983 { 12964 12984 #ifdef CRITERION_DEBUG 12965 if (TEST_OPT_DEBUG) { 12985 if (TEST_OPT_DEBUG) 12986 { 12966 12987 Print(" chain crit using pair to remove B[%d].lcm=%s\n", j, pString(strat>B[j].lcm)); 12967 12988 } … … 13027 13048 pLmFree(Lp.lcm); 13028 13049 #ifdef CRITERION_DEBUG 13029 if (TEST_OPT_DEBUG) { 13050 if (TEST_OPT_DEBUG) 13051 { 13030 13052 Print(" chain crit using B[%d].lcm=%s\n", j, pString(strat>B[j].lcm)); 13031 13053 } … … 13039 13061 { 13040 13062 #ifdef CRITERION_DEBUG 13041 if (TEST_OPT_DEBUG) { 13063 if (TEST_OPT_DEBUG) 13064 { 13042 13065 Print(" chain crit using pair to remove B[%d].lcm=%s\n", j, pString(strat>B[j].lcm)); 13043 13066 } … … 13169 13192 } 13170 13193 } 13194 #endif 13171 13195 13172 13196 /*3 … … 13175 13199 * additionally we put the pairs (h, s \sdot h) for s>=1 to L 13176 13200 */ 13201 #ifdef HAVE_SHIFTBBA 13177 13202 void initenterpairsShift (poly h,int k,int ecart,int isFromQ, kStrategy strat, int atR) 13178 13203 { … … 13237 13262 { 13238 13263 // pairs (shifts(s[1..k]),h), (s[1..k],h) 13239 for (j=0; j<=k; j++) { 13264 for (j=0; j<=k; j++) 13265 { 13240 13266 if (!strat>fromQ[j]) 13241 13267 { … … 13281 13307 new_pair=TRUE; 13282 13308 // pairs (shifts(s[1..k]),h), (s[1..k],h) 13283 for (j=0; j<=k; j++) { 13309 for (j=0; j<=k; j++) 13310 { 13284 13311 poly s = strat>S[j]; 13285 13312 enterOnePairWithShifts(j, s, h, ecart, isFromQ, strat, atR, h_lastVblock, pmLastVblock(s)); … … 13355 13382 { 13356 13383 // pairs (shifts(s[1..k]),h), (s[1..k],h) 13357 for (j=0; j<=k; j++) { 13384 for (j=0; j<=k; j++) 13385 { 13358 13386 if ((pGetComp(h)==pGetComp(strat>S[j])) 13359 13387  (pGetComp(strat>S[j])==0)) … … 13417 13445 } 13418 13446 } 13447 #endif 13419 13448 13420 13449 /*3 … … 13423 13452 * additionally we put the pairs (h, s \sdot h) for s>=1 to L 13424 13453 */ 13454 #ifdef HAVE_SHIFTBBA 13425 13455 void initenterstrongPairsShift (poly h,int k,int ecart,int isFromQ, kStrategy strat, int atR) 13426 13456 { … … 13485 13515 { 13486 13516 // pairs (shifts(s[1..k]),h), (s[1..k],h) 13487 for (j=0; j<=k; j++) { 13517 for (j=0; j<=k; j++) 13518 { 13488 13519 if (!strat>fromQ[j]) 13489 13520 { … … 13514 13545 new_pair=TRUE; 13515 13546 // pairs (shifts(s[1..k]),h), (s[1..k],h) 13516 for (j=0; j<=k; j++) { 13547 for (j=0; j<=k; j++) 13548 { 13517 13549 poly s = strat>S[j]; 13518 13550 // TODO: cache lastVblock of s[1..k] for later use … … 13560 13592 { 13561 13593 // pairs (shifts(s[1..k]),h), (s[1..k],h) 13562 for (j=0; j<=k; j++) { 13594 for (j=0; j<=k; j++) 13595 { 13563 13596 if ((pGetComp(h)==pGetComp(strat>S[j])) 13564 13597  (pGetComp(strat>S[j])==0)) … … 13593 13626 } 13594 13627 } 13628 #endif 13595 13629 13596 13630 /*2 … … 13598 13632 *superfluous elements in S will be deleted 13599 13633 */ 13634 #ifdef HAVE_SHIFTBBA 13600 13635 void enterpairsShift (poly h,int k,int ecart,int pos,kStrategy strat, int atR) 13601 13636 { … … 13621 13656 } 13622 13657 } 13658 #endif 13623 13659 13624 13660 /*2 … … 13626 13662 * assumes that p is already in T! 13627 13663 */ 13664 #ifdef HAVE_SHIFTBBA 13628 13665 void enterTShift(LObject p, kStrategy strat, int atT) 13629 13666 {
Note: See TracChangeset
for help on using the changeset viewer.