final Complex z = complexSolver.solve(c, initial); if (complexSolver.isRoot(lo, hi, z)) { return z.getReal(); } else { double r = Double.NaN; Complex[] root = complexSolver.solveAll(c, initial); for (int i = 0; i < root.length; i++) { if (complexSolver.isRoot(lo, hi, root[i])) { r = root[i].getReal(); break;
final Complex subarray[] = new Complex[n - i + 1]; System.arraycopy(c, 0, subarray, 0, subarray.length); root[i] = solve(subarray, initial);
final Complex subarray[] = new Complex[n - i + 1]; System.arraycopy(c, 0, subarray, 0, subarray.length); root[i] = solve(subarray, initial);
final Complex z = complexSolver.solve(c, initial); if (complexSolver.isRoot(lo, hi, z)) { return z.getReal(); } else { double r = Double.NaN; Complex[] root = complexSolver.solveAll(c, initial); for (int i = 0; i < root.length; i++) { if (complexSolver.isRoot(lo, hi, root[i])) { r = root[i].getReal(); break;
final Complex z = complexSolver.solve(c, initial); if (complexSolver.isRoot(lo, hi, z)) { return z.getReal(); } else { double r = Double.NaN; Complex[] root = complexSolver.solveAll(c, initial); for (int i = 0; i < root.length; i++) { if (complexSolver.isRoot(lo, hi, root[i])) { r = root[i].getReal(); break;
/** * 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 * @param maxEval maximum number of evaluations * @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.5 */ public Complex[] solveAllComplex(double[] coefficients, double initial, int maxEval) throws NullArgumentException, NoDataException, TooManyEvaluationsException { setup(maxEval, new PolynomialFunction(coefficients), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, initial); return complexSolver.solveAll(ComplexUtils.convertToComplex(coefficients), new Complex(initial, 0d)); }
/** * Find a complex root 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 * @param maxEval maximum number of evaluations * @return a complex root of the polynomial * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum number of evaluations is exceeded * @throws NullArgumentException if the {@code coefficients} is * {@code null} * @throws NoDataException if the {@code coefficients} array is empty * @since 3.1 */ public Complex solveComplex(double[] coefficients, double initial, int maxEval) throws NullArgumentException, NoDataException, TooManyEvaluationsException { setup(maxEval, new PolynomialFunction(coefficients), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, initial); return complexSolver.solve(ComplexUtils.convertToComplex(coefficients), new Complex(initial, 0d)); }
/** * Find a complex root 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 * @param maxEval maximum number of evaluations * @return a complex root of the polynomial * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum number of evaluations is exceeded * @throws NullArgumentException if the {@code coefficients} is * {@code null} * @throws NoDataException if the {@code coefficients} array is empty * @since 3.1 */ public Complex solveComplex(double[] coefficients, double initial, int maxEval) throws NullArgumentException, NoDataException, TooManyEvaluationsException { setup(maxEval, new PolynomialFunction(coefficients), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, initial); return complexSolver.solve(ComplexUtils.convertToComplex(coefficients), new Complex(initial, 0d)); }
/** * 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 * @param maxEval maximum number of evaluations * @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.5 */ public Complex[] solveAllComplex(double[] coefficients, double initial, int maxEval) throws NullArgumentException, NoDataException, TooManyEvaluationsException { setup(maxEval, new PolynomialFunction(coefficients), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, initial); return complexSolver.solveAll(ComplexUtils.convertToComplex(coefficients), new Complex(initial, 0d)); }
final Complex subarray[] = new Complex[n - i + 1]; System.arraycopy(c, 0, subarray, 0, subarray.length); root[i] = solve(subarray, initial);
/** * Find a complex root 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 * @param maxEval maximum number of evaluations * @return a complex root of the polynomial * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum number of evaluations is exceeded * @throws NullArgumentException if the {@code coefficients} is * {@code null} * @throws NoDataException if the {@code coefficients} array is empty * @since 3.1 */ public Complex solveComplex(double[] coefficients, double initial, int maxEval) throws NullArgumentException, NoDataException, TooManyEvaluationsException { setup(maxEval, new PolynomialFunction(coefficients), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, initial); return complexSolver.solve(ComplexUtils.convertToComplex(coefficients), new Complex(initial, 0d)); }
/** * 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 * @param maxEval maximum number of evaluations * @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.5 */ public Complex[] solveAllComplex(double[] coefficients, double initial, int maxEval) throws NullArgumentException, NoDataException, TooManyEvaluationsException { setup(maxEval, new PolynomialFunction(coefficients), Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, initial); return complexSolver.solveAll(ComplexUtils.convertToComplex(coefficients), new Complex(initial, 0d)); }