| 261 | } |
| 262 | |
| 263 | InternalCF* |
| 264 | InternalPoly::tryInvert ( const CanonicalForm& M, bool& fail) |
| 265 | { |
| 266 | if ( inExtension() && !getReduce ( var ) ) |
| 267 | { |
| 268 | CanonicalForm b, inverse; |
| 269 | CanonicalForm F ( this ->copyObject() ); |
| 270 | Variable a = M.mvar(); |
| 271 | Variable x = Variable(1); |
| 272 | F= mod (F, M); //reduce mod M |
| 273 | CanonicalForm g= extgcd (replacevar( F, a, x ), replacevar( M, a, x ), inverse, b ); |
| 274 | if(!g.isOne()) |
| 275 | fail = true; |
| 276 | else |
| 277 | inverse = replacevar( inverse, x, a ); // change back to alg var |
| 278 | CanonicalForm test= mod (inverse*F, M); |
| 279 | return inverse.getval(); |
| 280 | } |
| 281 | else |
| 282 | return CFFactory::basic( 0 ); |
| 283 | } |
| 284 | |
| 285 | InternalCF* |
| 286 | InternalPoly::addsame( InternalCF* aCoeff ) |
no test coverage detected