- Timestamp:
- Oct 17, 2018, 12:38:55 PM (6 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd08f5f0bb3329b8ca19f23b74cb1473686415c3a')
- Children:
- b2bceb6030806c7016ffc929e51bb5db6615e546
- Parents:
- 194f79909c91c263131614aafc678fe53c3c3d4a
- Location:
- kernel/GBEngine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/GBEngine/kspoly.cc
r194f799 r755d41 39 39 * 40 40 ***************************************************************/ 41 int ksReducePolyZ(LObject* PR, 42 TObject* PW, 43 poly spNoether, 44 number *coef, 45 kStrategy strat) 46 { 47 #ifdef KDEBUG 48 red_count++; 49 #ifdef TEST_OPT_DEBUG_RED 50 // if (TEST_OPT_DEBUG) 51 // { 52 // Print("Red %d:", red_count); PR->wrp(); Print(" with:"); 53 // PW->wrp(); 54 // //printf("\necart(PR)-ecart(PW): %i\n",PR->ecart-PW->ecart); 55 // //pWrite(PR->p); 56 // } 57 #endif 58 #endif 59 int ret = 0; 60 ring tailRing = PR->tailRing; 61 kTest_L(PR,tailRing); 62 kTest_T(PW); 63 64 poly p1 = PR->GetLmTailRing(); // p2 | p1 65 poly p2 = PW->GetLmTailRing(); // i.e. will reduce p1 with p2; lm = LT(p1) / LM(p2) 66 poly t2 = pNext(p2), lm = p1; // t2 = p2 - LT(p2); really compute P = LC(p2)*p1 - LT(p1)/LM(p2)*p2 67 assume(p1 != NULL && p2 != NULL);// Attention, we have rings and there LC(p2) and LC(p1) are special 68 p_CheckPolyRing(p1, tailRing); 69 p_CheckPolyRing(p2, tailRing); 70 71 pAssume1(p2 != NULL && p1 != NULL && 72 p_DivisibleBy(p2, p1, tailRing)); 73 74 pAssume1(p_GetComp(p1, tailRing) == p_GetComp(p2, tailRing) || 75 (p_GetComp(p2, tailRing) == 0 && 76 p_MaxComp(pNext(p2),tailRing) == 0)); 77 78 #ifdef HAVE_PLURAL 79 if (rIsPluralRing(currRing)) 80 { 81 // for the time being: we know currRing==strat->tailRing 82 // no exp-bound checking needed 83 // (only needed if exp-bound(tailring)<exp-b(currRing)) 84 if (PR->bucket!=NULL) nc_kBucketPolyRed_Z(PR->bucket, p2,coef); 85 else 86 { 87 poly _p = (PR->t_p != NULL ? PR->t_p : PR->p); 88 assume(_p != NULL); 89 nc_PolyPolyRed(_p, p2,coef, currRing); 90 if (PR->t_p!=NULL) PR->t_p=_p; else PR->p=_p; 91 PR->pLength=0; // usually not used, GetpLength re-computes it if needed 92 } 93 return 0; 94 } 95 #endif 96 97 /* if (t2==NULL) // Divisor is just one term, therefore it will 98 * { // just cancel the leading term 99 * PR->LmDeleteAndIter(); 100 * if (coef != NULL) *coef = n_Init(1, tailRing->cf); 101 * return 0; 102 * } */ 103 104 p_ExpVectorSub(lm, p2, tailRing); // Calculate the Monomial we must multiply to p2 105 106 //if (tailRing != currRing) 107 { 108 // check that reduction does not violate exp bound 109 while (PW->max_exp != NULL && !p_LmExpVectorAddIsOk(lm, PW->max_exp, tailRing)) 110 { 111 // undo changes of lm 112 p_ExpVectorAdd(lm, p2, tailRing); 113 if (strat == NULL) return 2; 114 if (! kStratChangeTailRing(strat, PR, PW)) return -1; 115 tailRing = strat->tailRing; 116 p1 = PR->GetLmTailRing(); 117 p2 = PW->GetLmTailRing(); 118 t2 = pNext(p2); 119 lm = p1; 120 p_ExpVectorSub(lm, p2, tailRing); 121 ret = 1; 122 } 123 } 124 125 // take care of coef buisness 126 if (! n_IsOne(pGetCoeff(p2), tailRing->cf)) 127 { 128 number bn = pGetCoeff(lm); 129 number an = pGetCoeff(p2); 130 int ct = ksCheckCoeff(&an, &bn, tailRing->cf); // Calculate special LC 131 p_SetCoeff(lm, bn, tailRing); 132 if ((ct == 0) || (ct == 2)) 133 PR->Tail_Mult_nn(an); 134 if (coef != NULL) *coef = an; 135 else n_Delete(&an, tailRing->cf); 136 } 137 else 138 { 139 if (coef != NULL) *coef = n_Init(1, tailRing->cf); 140 } 141 142 143 // and finally, 144 PR->Tail_Minus_mm_Mult_qq(lm, t2, pLength(t2) /*PW->GetpLength() - 1*/, spNoether); 145 assume(PW->GetpLength() == pLength(PW->p != NULL ? PW->p : PW->t_p)); 146 PR->LmDeleteAndIter(); 147 148 // the following is commented out: shrinking 149 #ifdef HAVE_SHIFTBBA_NONEXISTENT 150 if ( (currRing->isLPring) && (!strat->homog) ) 151 { 152 // assume? h->p in currRing 153 PR->GetP(); 154 poly qq = p_Shrink(PR->p, currRing->isLPring, currRing); 155 PR->Clear(); // does the right things 156 PR->p = qq; 157 PR->t_p = NULL; 158 PR->SetShortExpVector(); 159 } 160 #endif 161 162 return ret; 163 } 164 41 165 int ksReducePoly(LObject* PR, 42 166 TObject* PW, -
kernel/GBEngine/kutil.h
r194f799 r755d41 698 698 kStrategy strat = NULL); 699 699 700 /* like ksReducePoly, but if the reducer has only 1 term we still 701 * compute a possible coefficient multiplier for PR. this comes from 702 * a special situation in redRing_Z and it is used only there. */ 703 int ksReducePolyZ(LObject* PR, 704 TObject* PW, 705 poly spNoether = NULL, 706 number *coef = NULL, 707 kStrategy strat = NULL); 708 700 709 int ksReducePolyLC(LObject* PR, 701 710 TObject* PW,
Note: See TracChangeset
for help on using the changeset viewer.