Java Code Examples for org.apache.commons.math3.complex.ComplexUtils#convertToComplex()

The following examples show how to use org.apache.commons.math3.complex.ComplexUtils#convertToComplex() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LaguerreSolver.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Find a real root in the given interval.
 *
 * Despite the bracketing condition, the root returned by
 * {@link LaguerreSolver.ComplexSolver#solve(Complex[],Complex)} may
 * not be a real zero inside {@code [min, max]}.
 * For example, <code>p(x) = x<sup>3</sup> + 1,</code>
 * with {@code min = -2}, {@code max = 2}, {@code initial = 0}.
 * When it occurs, this code calls
 * {@link LaguerreSolver.ComplexSolver#solveAll(Complex[],Complex)}
 * in order to obtain all roots and picks up one real root.
 *
 * @param lo Lower bound of the search interval.
 * @param hi Higher bound of the search interval.
 * @param fLo Function value at the lower bound of the search interval.
 * @param fHi Function value at the higher bound of the search interval.
 * @return the point at which the function value is zero.
 * @deprecated This method should not be part of the public API: It will
 * be made private in version 4.0.
 */
@Deprecated
public double laguerre(double lo, double hi,
                       double fLo, double fHi) {
    final Complex c[] = ComplexUtils.convertToComplex(getCoefficients());

    final Complex initial = new Complex(0.5 * (lo + hi), 0);
    final Complex z = complexSolver.solve(c, initial);
    if (complexSolver.isRoot(lo, hi, z)) {
        return z.getReal();
    } else {
        double r = Double.NaN;
        // Solve all roots and select the one we are seeking.
        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;
            }
        }
        return r;
    }
}
 
Example 2
Source File: LaguerreSolver.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Find a real root in the given interval.
 *
 * Despite the bracketing condition, the root returned by
 * {@link LaguerreSolver.ComplexSolver#solve(Complex[],Complex)} may
 * not be a real zero inside {@code [min, max]}.
 * For example, <code>p(x) = x<sup>3</sup> + 1,</code>
 * with {@code min = -2}, {@code max = 2}, {@code initial = 0}.
 * When it occurs, this code calls
 * {@link LaguerreSolver.ComplexSolver#solveAll(Complex[],Complex)}
 * in order to obtain all roots and picks up one real root.
 *
 * @param lo Lower bound of the search interval.
 * @param hi Higher bound of the search interval.
 * @param fLo Function value at the lower bound of the search interval.
 * @param fHi Function value at the higher bound of the search interval.
 * @return the point at which the function value is zero.
 * @deprecated This method should not be part of the public API: It will
 * be made private in version 4.0.
 */
@Deprecated
public double laguerre(double lo, double hi,
                       double fLo, double fHi) {
    final Complex c[] = ComplexUtils.convertToComplex(getCoefficients());

    final Complex initial = new Complex(0.5 * (lo + hi), 0);
    final Complex z = complexSolver.solve(c, initial);
    if (complexSolver.isRoot(lo, hi, z)) {
        return z.getReal();
    } else {
        double r = Double.NaN;
        // Solve all roots and select the one we are seeking.
        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;
            }
        }
        return r;
    }
}
 
Example 3
Source File: LaguerreSolver.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Find a real root in the given interval.
 *
 * Despite the bracketing condition, the root returned by
 * {@link LaguerreSolver.ComplexSolver#solve(Complex[],Complex)} may
 * not be a real zero inside {@code [min, max]}.
 * For example, <code>p(x) = x<sup>3</sup> + 1,</code>
 * with {@code min = -2}, {@code max = 2}, {@code initial = 0}.
 * When it occurs, this code calls
 * {@link LaguerreSolver.ComplexSolver#solveAll(Complex[],Complex)}
 * in order to obtain all roots and picks up one real root.
 *
 * @param lo Lower bound of the search interval.
 * @param hi Higher bound of the search interval.
 * @param fLo Function value at the lower bound of the search interval.
 * @param fHi Function value at the higher bound of the search interval.
 * @return the point at which the function value is zero.
 * @deprecated This method should not be part of the public API: It will
 * be made private in version 4.0.
 */
@Deprecated
public double laguerre(double lo, double hi,
                       double fLo, double fHi) {
    final Complex c[] = ComplexUtils.convertToComplex(getCoefficients());

    final Complex initial = new Complex(0.5 * (lo + hi), 0);
    final Complex z = complexSolver.solve(c, initial);
    if (complexSolver.isRoot(lo, hi, z)) {
        return z.getReal();
    } else {
        double r = Double.NaN;
        // Solve all roots and select the one we are seeking.
        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;
            }
        }
        return r;
    }
}
 
Example 4
Source File: LaguerreSolver.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Find a real root in the given interval.
 *
 * Despite the bracketing condition, the root returned by
 * {@link LaguerreSolver.ComplexSolver#solve(Complex[],Complex)} may
 * not be a real zero inside {@code [min, max]}.
 * For example, <code>p(x) = x<sup>3</sup> + 1,</code>
 * with {@code min = -2}, {@code max = 2}, {@code initial = 0}.
 * When it occurs, this code calls
 * {@link LaguerreSolver.ComplexSolver#solveAll(Complex[],Complex)}
 * in order to obtain all roots and picks up one real root.
 *
 * @param lo Lower bound of the search interval.
 * @param hi Higher bound of the search interval.
 * @param fLo Function value at the lower bound of the search interval.
 * @param fHi Function value at the higher bound of the search interval.
 * @return the point at which the function value is zero.
 * @deprecated This method should not be part of the public API: It will
 * be made private in version 4.0.
 */
@Deprecated
public double laguerre(double lo, double hi,
                       double fLo, double fHi) {
    final Complex c[] = ComplexUtils.convertToComplex(getCoefficients());

    final Complex initial = new Complex(0.5 * (lo + hi), 0);
    final Complex z = complexSolver.solve(c, initial);
    if (complexSolver.isRoot(lo, hi, z)) {
        return z.getReal();
    } else {
        double r = Double.NaN;
        // Solve all roots and select the one we are seeking.
        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;
            }
        }
        return r;
    }
}
 
Example 5
Source File: LaguerreSolver.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Find a real root in the given interval.
 *
 * Despite the bracketing condition, the root returned by
 * {@link LaguerreSolver.ComplexSolver#solve(Complex[],Complex)} may
 * not be a real zero inside {@code [min, max]}.
 * For example, <code>p(x) = x<sup>3</sup> + 1,</code>
 * with {@code min = -2}, {@code max = 2}, {@code initial = 0}.
 * When it occurs, this code calls
 * {@link LaguerreSolver.ComplexSolver#solveAll(Complex[],Complex)}
 * in order to obtain all roots and picks up one real root.
 *
 * @param lo Lower bound of the search interval.
 * @param hi Higher bound of the search interval.
 * @param fLo Function value at the lower bound of the search interval.
 * @param fHi Function value at the higher bound of the search interval.
 * @return the point at which the function value is zero.
 * @deprecated This method should not be part of the public API: It will
 * be made private in version 4.0.
 */
@Deprecated
public double laguerre(double lo, double hi,
                       double fLo, double fHi) {
    final Complex c[] = ComplexUtils.convertToComplex(getCoefficients());

    final Complex initial = new Complex(0.5 * (lo + hi), 0);
    final Complex z = complexSolver.solve(c, initial);
    if (complexSolver.isRoot(lo, hi, z)) {
        return z.getReal();
    } else {
        double r = Double.NaN;
        // Solve all roots and select the one we are seeking.
        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;
            }
        }
        return r;
    }
}
 
Example 6
Source File: LaguerreSolver.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Find a real root in the given interval.
 *
 * Despite the bracketing condition, the root returned by
 * {@link LaguerreSolver.ComplexSolver#solve(Complex[],Complex)} may
 * not be a real zero inside {@code [min, max]}.
 * For example, <code>p(x) = x<sup>3</sup> + 1,</code>
 * with {@code min = -2}, {@code max = 2}, {@code initial = 0}.
 * When it occurs, this code calls
 * {@link LaguerreSolver.ComplexSolver#solveAll(Complex[],Complex)}
 * in order to obtain all roots and picks up one real root.
 *
 * @param lo Lower bound of the search interval.
 * @param hi Higher bound of the search interval.
 * @param fLo Function value at the lower bound of the search interval.
 * @param fHi Function value at the higher bound of the search interval.
 * @return the point at which the function value is zero.
 * @deprecated This method should not be part of the public API: It will
 * be made private in version 4.0.
 */
@Deprecated
public double laguerre(double lo, double hi,
                       double fLo, double fHi) {
    final Complex c[] = ComplexUtils.convertToComplex(getCoefficients());

    final Complex initial = new Complex(0.5 * (lo + hi), 0);
    final Complex z = complexSolver.solve(c, initial);
    if (complexSolver.isRoot(lo, hi, z)) {
        return z.getReal();
    } else {
        double r = Double.NaN;
        // Solve all roots and select the one we are seeking.
        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;
            }
        }
        return r;
    }
}
 
Example 7
Source File: LaguerreSolver.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Find a real root in the given interval.
 *
 * Despite the bracketing condition, the root returned by
 * {@link LaguerreSolver.ComplexSolver#solve(Complex[],Complex)} may
 * not be a real zero inside {@code [min, max]}.
 * For example, <code>p(x) = x<sup>3</sup> + 1,</code>
 * with {@code min = -2}, {@code max = 2}, {@code initial = 0}.
 * When it occurs, this code calls
 * {@link LaguerreSolver.ComplexSolver#solveAll(Complex[],Complex)}
 * in order to obtain all roots and picks up one real root.
 *
 * @param lo Lower bound of the search interval.
 * @param hi Higher bound of the search interval.
 * @param fLo Function value at the lower bound of the search interval.
 * @param fHi Function value at the higher bound of the search interval.
 * @return the point at which the function value is zero.
 * @deprecated This method should not be part of the public API: It will
 * be made private in version 4.0.
 */
@Deprecated
public double laguerre(double lo, double hi,
                       double fLo, double fHi) {
    final Complex c[] = ComplexUtils.convertToComplex(getCoefficients());

    final Complex initial = new Complex(0.5 * (lo + hi), 0);
    final Complex z = complexSolver.solve(c, initial);
    if (complexSolver.isRoot(lo, hi, z)) {
        return z.getReal();
    } else {
        double r = Double.NaN;
        // Solve all roots and select the one we are seeking.
        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;
            }
        }
        return r;
    }
}