@Test public void testUnitRootd() { int N=12; double[] c=new double[N+1]; c[0]=1; c[N]=-1; GrantHitchinsSolver solver=new GrantHitchinsSolver(); assertTrue(solver.factorize(Polynomial.of(c))); }
@Override public boolean factorize(Polynomial p) { int degree = p.getDegree(); while ((degree > 0) && (p.get(degree) == 0)) --degree; if (degree == 0) return false; double[] a = new double[degree + 1]; for (int i = 0; i <= degree; ++i) a[i] = p.get(degree - i); double[] rez = new double[degree]; double[] imz = new double[degree]; try { if (this.solve(a, a.length, rez, imz)) { m_roots = new ec.tstoolkit.maths.Complex[degree]; for (int i = 0; i < degree; ++i) m_roots[i] = ec.tstoolkit.maths.Complex .cart(rez[i], imz[i]); m_remainder = Polynomial.valueOf(p.get(p.getDegree())); return true; } else return false; } catch (PolynomialException ex) { return false; } }
GrantHitchinsSolver implements IRootsSolver { @Override public boolean factorize(Polynomial p) { int degree = p.getDegree(); while ((degree > 0) && (p.get(degree) == 0)) --degree; if (degree == 0) return false; double[] a = new double[degree + 1]; for (int i = 0; i <= degree; ++i) a[i] = p.get(degree - i); double[] rez = new double[degree]; double[] imz = new double[degree]; try { if (this.solve(a, a.length, rez, imz)) { m_roots = new ec.tstoolkit.maths.Complex[degree]; for (int i = 0; i < degree; ++i) m_roots[i] = ec.tstoolkit.maths.Complex .cart(rez[i], imz[i]); m_remainder = Polynomial.valueOf(p.get(p.getDegree())); return true; } else return false; } catch (PolynomialException ex) { return false; } } }
GrantHitchinsSolver implements IRootsSolver { @Override public boolean factorize(Polynomial p) { int degree = p.getDegree(); while ((degree > 0) && (p.get(degree) == 0)) --degree; if (degree == 0) return false; double[] a = new double[degree + 1]; for (int i = 0; i <= degree; ++i) a[i] = p.get(degree - i); double[] rez = new double[degree]; double[] imz = new double[degree]; try { if (this.solve(a, a.length, rez, imz)) { m_roots = new ec.tstoolkit.maths.Complex[degree]; for (int i = 0; i < degree; ++i) m_roots[i] = ec.tstoolkit.maths.Complex .cart(rez[i], imz[i]); m_remainder = Polynomial.valueOf(p.get(p.getDegree())); return true; } else return false; } catch (PolynomialException ex) { return false; } } GrantHitchinsSolver(); }
GrantHitchinsSolver implements IRootsSolver { @Override public boolean factorize(Polynomial p) { int degree = p.getDegree(); while ((degree > 0) && (p.get(degree) == 0)) --degree; if (degree == 0) return false; double[] a = new double[degree + 1]; for (int i = 0; i <= degree; ++i) a[i] = p.get(degree - i); double[] rez = new double[degree]; double[] imz = new double[degree]; try { if (this.solve(a, a.length, rez, imz)) { m_roots = new ec.tstoolkit.maths.Complex[degree]; for (int i = 0; i < degree; ++i) m_roots[i] = ec.tstoolkit.maths.Complex .cart(rez[i], imz[i]); m_remainder = Polynomial.valueOf(p.get(p.getDegree())); return true; } else return false; } catch (PolynomialException ex) { return false; } } GrantHitchinsSolver(); @Override void clear(); @Override boolean factorize(Polynomial p); double getTol(); @Override Polynomial remainder(); @Override GrantHitchinsSolver exemplar(); @Override Complex[] roots(); void setTol(double tol); }
GrantHitchinsSolver implements IRootsSolver { @Override public boolean factorize(Polynomial p) { int degree = p.getDegree(); while ((degree > 0) && (p.get(degree) == 0)) --degree; if (degree == 0) return false; double[] a = new double[degree + 1]; for (int i = 0; i <= degree; ++i) a[i] = p.get(degree - i); double[] rez = new double[degree]; double[] imz = new double[degree]; try { if (this.solve(a, a.length, rez, imz)) { m_roots = new ec.tstoolkit.maths.Complex[degree]; for (int i = 0; i < degree; ++i) m_roots[i] = ec.tstoolkit.maths.Complex .cart(rez[i], imz[i]); m_remainder = Polynomial.valueOf(p.get(p.getDegree())); return true; } else return false; } catch (PolynomialException ex) { return false; } } GrantHitchinsSolver(); @Override void clear(); @Override boolean factorize(Polynomial p); double getTol(); @Override Polynomial remainder(); @Override GrantHitchinsSolver exemplar(); @Override Complex[] roots(); void setTol(double tol);  }