| 1069 | // |
| 1070 | |
| 1071 | number kBucketPolyRed(kBucket_pt bucket, |
| 1072 | poly p1, int l1, |
| 1073 | poly spNoether) |
| 1074 | { |
| 1075 | ring r=bucket->bucket_ring; |
| 1076 | assume((!rIsPluralRing(r))||p_LmEqual(p1,kBucketGetLm(bucket), r)); |
| 1077 | assume(p1 != NULL && |
| 1078 | p_DivisibleBy(p1, kBucketGetLm(bucket), r)); |
| 1079 | assume(pLength(p1) == l1); |
| 1080 | |
| 1081 | poly a1 = pNext(p1), lm = kBucketExtractLm(bucket); |
| 1082 | BOOLEAN reset_vec=FALSE; |
| 1083 | number rn; |
| 1084 | |
| 1085 | /* we shall reduce bucket=bn*lm+... by p1=an*t+a1 where t=lm(p1) |
| 1086 | and an,bn shall be defined further down only if lc(p1)!=1 |
| 1087 | we already know: an|bn and t|lm */ |
| 1088 | if(a1==NULL) |
| 1089 | { |
| 1090 | p_LmDelete(&lm, r); |
| 1091 | return n_Init(1,r->cf); |
| 1092 | } |
| 1093 | |
| 1094 | if (! n_IsOne(pGetCoeff(p1),r->cf)) |
| 1095 | { |
| 1096 | number an = pGetCoeff(p1), bn = pGetCoeff(lm); |
| 1097 | /* ksCheckCoeff: divide out gcd from an and bn: */ |
| 1098 | int ct = ksCheckCoeff(&an, &bn,r->cf); |
| 1099 | /* the previous command returns ct=0 or ct=2 iff an!=1 |
| 1100 | note: an is now 1 or -1 */ |
| 1101 | |
| 1102 | /* setup factor for p1 which cancels leading terms */ |
| 1103 | p_SetCoeff(lm, bn, r); |
| 1104 | if ((ct == 0) || (ct == 2)) |
| 1105 | { |
| 1106 | /* correct factor for cancelation by changing sign if an=-1 */ |
| 1107 | if (rField_is_Ring(r)) |
| 1108 | lm = __p_Mult_nn(lm, an, r); |
| 1109 | else |
| 1110 | kBucket_Mult_n(bucket, an); |
| 1111 | } |
| 1112 | rn = an; |
| 1113 | } |
| 1114 | else |
| 1115 | { |
| 1116 | rn = n_Init(1,r->cf); |
| 1117 | } |
| 1118 | |
| 1119 | if (p_GetComp(p1, r) != p_GetComp(lm, r)) |
| 1120 | { |
| 1121 | p_SetCompP(a1, p_GetComp(lm, r), r); |
| 1122 | reset_vec = TRUE; |
| 1123 | p_SetComp(lm, p_GetComp(p1, r), r); |
| 1124 | p_Setm(lm, r); |
| 1125 | } |
| 1126 | |
| 1127 | p_ExpVectorSub(lm, p1, r); |
| 1128 | l1--; |
no test coverage detected