static Polynomial[] linearize(Polynomial polynomial, Variable variable) { List l = new ArrayList(); Generic x = variable.expressionValue(); Polynomial s = polynomial; try { Polynomial r = s.valueOf(x); s = s.divide(r); l.add(r); while (true) s = s.divide(r); } catch (NotDivisibleException e) { } IntegerDivisor d[] = new IntegerDivisor[2]; Generic p[] = new Generic[2]; Generic q[] = new Generic[2]; d[1] = IntegerDivisor.create(JsclInteger.valueOf(1)); loop: while (d[1].hasNext()) { p[1] = (Generic) d[1].next(); q[1] = d[1].integer(d[1].complementary()); d[0] = IntegerDivisor.create(s.tail().coef().integerValue()); while (d[0].hasNext()) { p[0] = (Generic) d[0].next(); q[0] = d[0].integer(d[0].complementary()); if (ArrayComparator.comparator.compare(q, p) < 0) break loop; for (int i = 0; i < 2; i++) { Polynomial r = s.valueOf(i == 0 ? p[1].multiply(x).subtract(p[0]) : p[1].multiply(x).add(p[0])); for (boolean flag = true; true; flag = false) { try { s = s.divide(r); } catch (NotDivisibleException e) { break; } d[1].divide(); d[0].divide(); if (flag) l.add(r); } } } } return (Polynomial[]) ArrayUtils.toArray(l, new Polynomial[l.size()]); }
Generic[][] getValue() { return (Generic[][]) ArrayUtils.toArray(result, new Generic[result.size()][]); }