#include <iostream>
using namespace std;
-static symbol w("w"), x("x"), y("y"), z("z");
-
static unsigned check_factor(const ex& e)
{
ex ee = e.expand();
unsigned result = 0;
ex e;
symbol x("x");
- lst syms;
- syms.append(x);
+ lst syms = {x};
e = ex("1+x-x^3", syms);
result += check_factor(e);
// "An Improved Multivariate Polynomial Factoring Algorithm"
unsigned result = 0;
ex e;
- symbol x("x"), y("y"), z("z"), u("u");
+ symbol u("u"), w("w"), x("x"), y("y"), z("z");
e = ex("(z+x*y+10)*(x*z+y+30)*(y*z+x+20)", lst{x, y, z});
result += check_factor_expanded(e);
poly.unitcontprim(x, unit, cont, prim_ex);
upoly prim;
upoly_from_ex(prim, prim_ex, x);
+ if (prim_ex.is_equal(1)) {
+ return poly;
+ }
// determine proper prime and minimize number of modular factors
prime = 3;
if ( findsymbols.syms.size() == 1 ) {
// univariate case
const ex& x = *(findsymbols.syms.begin());
- if ( poly.ldegree(x) > 0 ) {
+ int ld = poly.ldegree(x);
+ if ( ld > 0 ) {
// pull out direct factors
- int ld = poly.ldegree(x);
ex res = factor_univariate(expand(poly/pow(x, ld)), x);
return res * pow(x,ld);
} else {