class 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)) {
		// create roots...
		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;
	}
    }

    public  GrantHitchinsSolver();

}