Changeset 585bbcb in git for kernel/kspoly.cc
- Timestamp:
- Nov 27, 2005, 4:28:46 PM (17 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 6a972af1108afd9ad6a0a74a519e0b3107421d16
- Parents:
- f498f1081627c853c4d77077fcaa2ea32d82a711
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/kspoly.cc
rf498f10 r585bbcb 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: kspoly.cc,v 1. 1.1.1 2003-10-06 12:15:56 SingularExp $ */4 /* $Id: kspoly.cc,v 1.2 2005-11-27 15:28:44 wienand Exp $ */ 5 5 /* 6 6 * ABSTRACT - Routines for Spoly creation and reductions … … 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 118 126 int ct = ksCheckCoeff(&an, &bn); 119 127 p_SetCoeff(lm, bn,tailRing); … … 140 148 return ret; 141 149 } 150 151 #ifdef HAVE_RING2TOM 152 /*************************************************************** 153 * 154 * Reduces PR with PW 155 * Assumes PR != NULL, PW != NULL, Lm(PW) divides Lm(PR) 156 * as above, just for rings 157 * 158 ***************************************************************/ 159 int ksRingReducePoly(LObject* PR, 160 TObject* PW, 161 poly spNoether, 162 number *coef, 163 kStrategy strat) 164 { 165 #ifdef KDEBUG 166 red_count++; 167 #ifdef TEST_OPT_DEBUG_RED 168 if (TEST_OPT_DEBUG) 169 { 170 Print("Red %d:", red_count); PR->wrp(); Print(" with:"); 171 PW->wrp(); 172 } 173 #endif 174 #endif 175 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 bound 206 while (PW->max != NULL && !p_LmExpVectorAddIsOk(lm, PW->max, tailRing)) 207 { 208 // undo changes of lm 209 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 buisness 223 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 else 239 { 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 #endif 253 return ret; 254 } 255 #endif 142 256 143 257 /*************************************************************** … … 166 280 poly a1 = pNext(p1), a2 = pNext(p2); 167 281 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 168 290 int co=0, ct = ksCheckCoeff(&lc1, &lc2); 169 291
Note: See TracChangeset
for help on using the changeset viewer.