| 219 | } |
| 220 | |
| 221 | void tryInvert( const CanonicalForm & F, const CanonicalForm & M, CanonicalForm & inv, bool & fail ) |
| 222 | { // F, M are required to be "univariate" polynomials in an algebraic variable |
| 223 | // we try to invert F modulo M |
| 224 | if(F.inBaseDomain()) |
| 225 | { |
| 226 | if(F.isZero()) |
| 227 | { |
| 228 | fail = true; |
| 229 | return; |
| 230 | } |
| 231 | inv = 1/F; |
| 232 | return; |
| 233 | } |
| 234 | CanonicalForm b; |
| 235 | Variable a = M.mvar(); |
| 236 | Variable x = Variable(1); |
| 237 | if(!extgcd( replacevar( F, a, x ), replacevar( M, a, x ), inv, b ).isOne()) |
| 238 | fail = true; |
| 239 | else |
| 240 | inv = replacevar( inv, x, a ); // change back to alg var |
| 241 | } |
| 242 | |
| 243 | #ifndef HAVE_NTL |
| 244 | void tryDivrem (const CanonicalForm& F, const CanonicalForm& G, CanonicalForm& Q, |
no test coverage detected