@Override public boolean process(Polynomial poly) { try { alg.process(poly); } catch( RuntimeException e ) { return false; } roots.clear(); double found[] = alg.getRoots(); int N = alg.getNumberOfRoots(); for( int i = 0; i < N; i++ ) { Complex_F64 c = storage[i]; c.real = found[i]; c.imaginary = 0; roots.add(c); } return true; }
@Override public boolean process(Polynomial poly) { try { alg.process(poly); } catch( RuntimeException e ) { return false; } roots.clear(); double found[] = alg.getRoots(); int N = alg.getNumberOfRoots(); for( int i = 0; i < N; i++ ) { Complex_F64 c = storage[i]; c.real = found[i]; c.imaginary = 0; roots.add(c); } return true; }
@Override public List<Double> computeRealRoots(Polynomial poly) { FindRealRootsSturm alg = new FindRealRootsSturm(poly.size,-1,1e-16,500,500); alg.process(poly); int N = alg.getNumberOfRoots(); double[] roots = alg.getRoots(); List<Double> ret = new ArrayList<Double>(); for( int i = 0; i < N; i++ ) ret.add(roots[i]); return ret; }