/** * Find all complex roots for the polynomial with the given * coefficients, starting from the given initial value. * <p> * Note: This method is not part of the API of {@link BaseUnivariateSolver}.</p> * * @param coefficients Polynomial coefficients. * @param initial Start value. * @return the full set of complex roots of the polynomial * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum number of evaluations is exceeded when solving for one of the roots * @throws NullArgumentException if the {@code coefficients} is * {@code null}. * @throws NoDataException if the {@code coefficients} array is empty. * @since 3.1 */ public Complex[] solveAllComplex(double[] coefficients, double initial) throws NullArgumentException, NoDataException, TooManyEvaluationsException { return solveAllComplex(coefficients, initial, Integer.MAX_VALUE); }
/** * Find all complex roots for the polynomial with the given * coefficients, starting from the given initial value. * <p> * Note: This method is not part of the API of {@link BaseUnivariateSolver}.</p> * * @param coefficients Polynomial coefficients. * @param initial Start value. * @return the full set of complex roots of the polynomial * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum number of evaluations is exceeded when solving for one of the roots * @throws NullArgumentException if the {@code coefficients} is * {@code null}. * @throws NoDataException if the {@code coefficients} array is empty. * @since 3.1 */ public Complex[] solveAllComplex(double[] coefficients, double initial) throws NullArgumentException, NoDataException, TooManyEvaluationsException { return solveAllComplex(coefficients, initial, Integer.MAX_VALUE); }
/** * Find all complex roots for the polynomial with the given * coefficients, starting from the given initial value. * <p> * Note: This method is not part of the API of {@link BaseUnivariateSolver}.</p> * * @param coefficients Polynomial coefficients. * @param initial Start value. * @return the full set of complex roots of the polynomial * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum number of evaluations is exceeded when solving for one of the roots * @throws NullArgumentException if the {@code coefficients} is * {@code null}. * @throws NoDataException if the {@code coefficients} array is empty. * @since 3.1 */ public Complex[] solveAllComplex(double[] coefficients, double initial) throws NullArgumentException, NoDataException, TooManyEvaluationsException { return solveAllComplex(coefficients, initial, Integer.MAX_VALUE); }
final LaguerreSolver solver = new LaguerreSolver(); final Complex[] result = solver.solveAllComplex(coeff, 0);
laguerreSolver = new LaguerreSolver(); complexRoots = laguerreSolver.solveAllComplex(real, LAGUERRE_START); } catch (Exception e) { Log.debug("Problem solving with LaguerreSolver"
/** * {@inheritDoc} * @throws MathException If there are no real roots; if the Commons method could not evaluate the function; if the Commons method could not converge. */ @Override public Double[] getRoots(RealPolynomialFunction1D function) { ArgChecker.notNull(function, "function"); try { Complex[] roots = ROOT_FINDER.solveAllComplex(function.getCoefficients(), 0); List<Double> realRoots = new ArrayList<>(); for (Complex c : roots) { if (DoubleMath.fuzzyEquals(c.getImaginary(), 0d, EPS)) { realRoots.add(c.getReal()); } } if (realRoots.isEmpty()) { throw new MathException("Could not find any real roots"); } return realRoots.toArray(new Double[realRoots.size()]); } catch (TooManyEvaluationsException e) { throw new MathException(e); } }
public void design() { reset(); for (int i = 0; i < degree + 1; ++i) { m_a[i] = reversebessel(i, degree); } LaguerreSolver laguerreSolver = new LaguerreSolver(); m_root = laguerreSolver.solveAllComplex(m_a,0.0); Complex inf = Complex.INF; int pairs = degree / 2; for (int i = 0; i < pairs; ++i) { Complex c = m_root[i]; addPoleZeroConjugatePairs(c, inf); } if ((degree & 1) == 1) add(new Complex(m_root[pairs].getReal()), inf); }
complexRoots = laguerreSolver.solveAllComplex(eqn, LAGUERRE_START, LAGUERRE_MAX_EVAL); } catch (ArithmeticException e) {
final Complex[] roots = solver.solveAllComplex(derivative.getCoefficients(), initialGuess, getMaxEvaluations()); if (roots == null) return null;