same as fdivides but handles zero divisors in Z_p[t]/(f)[x1,...,xn] for reducible f
| 453 | |
| 454 | /// same as fdivides but handles zero divisors in Z_p[t]/(f)[x1,...,xn] for reducible f |
| 455 | bool |
| 456 | tryFdivides ( const CanonicalForm & f, const CanonicalForm & g, const CanonicalForm& M, bool& fail ) |
| 457 | { |
| 458 | fail= false; |
| 459 | // trivial cases |
| 460 | if ( g.isZero() ) |
| 461 | return true; |
| 462 | else if ( f.isZero() ) |
| 463 | return false; |
| 464 | |
| 465 | if (f.inCoeffDomain() || g.inCoeffDomain()) |
| 466 | { |
| 467 | // if we are in a field all elements not equal to zero are units |
| 468 | if ( f.inCoeffDomain() ) |
| 469 | { |
| 470 | CanonicalForm inv; |
| 471 | tryInvert (f, M, inv, fail); |
| 472 | return !fail; |
| 473 | } |
| 474 | else |
| 475 | { |
| 476 | return false; |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | // we may assume now that both levels either equal LEVELBASE |
| 481 | // or are greater zero |
| 482 | int fLevel = f.level(); |
| 483 | int gLevel = g.level(); |
| 484 | if ( (gLevel > 0) && (fLevel == gLevel) ) |
| 485 | { |
| 486 | if (degree( f ) > degree( g )) |
| 487 | return false; |
| 488 | bool dividestail= tryFdivides (f.tailcoeff(), g.tailcoeff(), M, fail); |
| 489 | |
| 490 | if (fail || !dividestail) |
| 491 | return false; |
| 492 | bool dividesLC= tryFdivides (f.LC(),g.LC(), M, fail); |
| 493 | if (fail || !dividesLC) |
| 494 | return false; |
| 495 | CanonicalForm q,r; |
| 496 | bool divides= tryDivremt (g, f, q, r, M, fail); |
| 497 | if (fail || !divides) |
| 498 | return false; |
| 499 | return r.isZero(); |
| 500 | } |
| 501 | else if ( gLevel < fLevel ) |
| 502 | { |
| 503 | // g is a coefficient w.r.t. f |
| 504 | return false; |
| 505 | } |
| 506 | else |
| 507 | { |
| 508 | // either f is a coefficient w.r.t. polynomial g or both |
| 509 | // f and g are from a base domain (should be Z or Z/p^n, |
| 510 | // then) |
| 511 | CanonicalForm q, r; |
| 512 | bool divides= tryDivremt (g, f, q, r, M, fail); |
no test coverage detected