destroys p
| 210 | |
| 211 | // destroys p |
| 212 | poly shift_p_mm_Mult(poly p, const poly m, const ring ri) |
| 213 | { |
| 214 | #ifdef SHIFT_MULT_DEBUG |
| 215 | PrintLn(); PrintS("shift_p_mm_Mult: "); p_wrp(m, ri, ri); PrintS(" * ("); p_wrp(p, ri, ri); PrintS(")"); |
| 216 | #endif |
| 217 | |
| 218 | p_Test(p, ri); |
| 219 | p_LmTest(m, ri); |
| 220 | pAssume(m != NULL); |
| 221 | assume(p!=NULL); |
| 222 | |
| 223 | int lV = ri->isLPring; |
| 224 | poly _m = m; // temp hack because m is const |
| 225 | #ifdef SHIFT_MULT_COMPAT_MODE |
| 226 | _m = p_Copy(_m, ri); |
| 227 | p_mLPunshift(_m, ri); |
| 228 | p_LPunshift(p, ri); |
| 229 | #else |
| 230 | assume(p_mFirstVblock(_m, ri) <= 1); |
| 231 | assume(p_FirstVblock(p, ri) <= 1); // TODO check that each block is <=1 |
| 232 | #endif |
| 233 | // at this point _m and p are shifted to 1 |
| 234 | |
| 235 | poly q = p; // we use p for iterating and q for the result |
| 236 | number mCoeff = pGetCoeff(_m); |
| 237 | number pCoeff; |
| 238 | pAssume(!n_IsZero(mCoeff, ri->cf)); |
| 239 | |
| 240 | int *mExpV = (int *) omAlloc((ri->N+1)*sizeof(int)); |
| 241 | p_GetExpV(_m,mExpV,ri); |
| 242 | int mLength = p_mLastVblock(_m, mExpV, ri) * lV; |
| 243 | int *pExpV = (int *) omAlloc((ri->N+1)*sizeof(int)); |
| 244 | while (p != NULL) |
| 245 | { |
| 246 | pCoeff = pGetCoeff(p); |
| 247 | pSetCoeff0(p, n_Mult(mCoeff, pCoeff, ri->cf)); |
| 248 | n_Delete(&pCoeff, ri->cf); // delete the old coeff |
| 249 | |
| 250 | p_GetExpV(p,pExpV,ri); |
| 251 | p_LPExpVprepend(pExpV, mExpV, p_mLastVblock(p, pExpV, ri) * lV, mLength, ri); |
| 252 | p_SetExpV(p, pExpV, ri); |
| 253 | |
| 254 | pIter(p); |
| 255 | } |
| 256 | omFreeSize((ADDRESS) pExpV, (ri->N+1)*sizeof(int)); |
| 257 | omFreeSize((ADDRESS) mExpV, (ri->N+1)*sizeof(int)); |
| 258 | #ifdef SHIFT_MULT_COMPAT_MODE |
| 259 | p_Delete(&_m, ri); // in this case we copied _m before |
| 260 | #endif |
| 261 | #ifdef SHIFT_MULT_DEBUG |
| 262 | PrintLn(); PrintS("shift_p_mm_Mult result: "); p_wrp(q, ri, ri); PrintLn(); |
| 263 | #endif |
| 264 | p_Test(q, ri); |
| 265 | return q; |
| 266 | } |
| 267 | |
| 268 | // p - m*q destroys p |
| 269 | poly shift_p_Minus_mm_Mult_qq(poly p, poly m, poly q, int& Shorter, const poly /*spNoether*/, const ring ri) { |
nothing calls this directly
no test coverage detected