| 242 | |
| 243 | #ifndef HAVE_NTL |
| 244 | void tryDivrem (const CanonicalForm& F, const CanonicalForm& G, CanonicalForm& Q, |
| 245 | CanonicalForm& R, CanonicalForm& inv, const CanonicalForm& mipo, |
| 246 | bool& fail) |
| 247 | { |
| 248 | if (F.inCoeffDomain()) |
| 249 | { |
| 250 | Q= 0; |
| 251 | R= F; |
| 252 | return; |
| 253 | } |
| 254 | |
| 255 | CanonicalForm A, B; |
| 256 | Variable x= F.mvar(); |
| 257 | A= F; |
| 258 | B= G; |
| 259 | int degA= degree (A, x); |
| 260 | int degB= degree (B, x); |
| 261 | |
| 262 | if (degA < degB) |
| 263 | { |
| 264 | R= A; |
| 265 | Q= 0; |
| 266 | return; |
| 267 | } |
| 268 | |
| 269 | tryInvert (Lc (B), mipo, inv, fail); |
| 270 | if (fail) |
| 271 | return; |
| 272 | |
| 273 | R= A; |
| 274 | Q= 0; |
| 275 | CanonicalForm Qi; |
| 276 | for (int i= degA -degB; i >= 0; i--) |
| 277 | { |
| 278 | if (degree (R, x) == i + degB) |
| 279 | { |
| 280 | Qi= Lc (R)*inv*power (x, i); |
| 281 | Qi= reduce (Qi, mipo); |
| 282 | R -= Qi*B; |
| 283 | R= reduce (R, mipo); |
| 284 | Q += Qi; |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | void tryEuclid( const CanonicalForm & A, const CanonicalForm & B, const CanonicalForm & M, CanonicalForm & result, bool & fail ) |
| 290 | { |