Java Code Examples for org.apache.commons.math3.exception.util.LocalizedFormats#POLYNOMIAL

The following examples show how to use org.apache.commons.math3.exception.util.LocalizedFormats#POLYNOMIAL . 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 5 votes vote down vote up
/**
 * Find all complex roots for the polynomial with the given
 * coefficients, starting from the given initial value.
 *
 * @param coefficients Polynomial coefficients.
 * @param initial Start value.
 * @return the point at which the function value is zero.
 * @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.
 */
public Complex[] solveAll(Complex coefficients[], Complex initial)
    throws NullArgumentException,
           NoDataException,
           TooManyEvaluationsException {
    if (coefficients == null) {
        throw new NullArgumentException();
    }
    final int n = coefficients.length - 1;
    if (n == 0) {
        throw new NoDataException(LocalizedFormats.POLYNOMIAL);
    }
    // Coefficients for deflated polynomial.
    final Complex c[] = new Complex[n + 1];
    for (int i = 0; i <= n; i++) {
        c[i] = coefficients[i];
    }

    // Solve individual roots successively.
    final Complex root[] = new Complex[n];
    for (int i = 0; i < n; i++) {
        final Complex subarray[] = new Complex[n - i + 1];
        System.arraycopy(c, 0, subarray, 0, subarray.length);
        root[i] = solve(subarray, initial);
        // Polynomial deflation using synthetic division.
        Complex newc = c[n - i];
        Complex oldc = null;
        for (int j = n - i - 1; j >= 0; j--) {
            oldc = c[j];
            c[j] = newc;
            newc = oldc.add(newc.multiply(root[i]));
        }
    }

    return root;
}
 
Example 2
Source File: LaguerreSolver.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find all complex roots for the polynomial with the given
 * coefficients, starting from the given initial value.
 *
 * @param coefficients Polynomial coefficients.
 * @param initial Start value.
 * @return the point at which the function value is zero.
 * @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.
 */
public Complex[] solveAll(Complex coefficients[], Complex initial)
    throws NullArgumentException,
           NoDataException,
           TooManyEvaluationsException {
    if (coefficients == null) {
        throw new NullArgumentException();
    }
    final int n = coefficients.length - 1;
    if (n == 0) {
        throw new NoDataException(LocalizedFormats.POLYNOMIAL);
    }
    // Coefficients for deflated polynomial.
    final Complex c[] = new Complex[n + 1];
    for (int i = 0; i <= n; i++) {
        c[i] = coefficients[i];
    }

    // Solve individual roots successively.
    final Complex root[] = new Complex[n];
    for (int i = 0; i < n; i++) {
        final Complex subarray[] = new Complex[n - i + 1];
        System.arraycopy(c, 0, subarray, 0, subarray.length);
        root[i] = solve(subarray, initial);
        // Polynomial deflation using synthetic division.
        Complex newc = c[n - i];
        Complex oldc = null;
        for (int j = n - i - 1; j >= 0; j--) {
            oldc = c[j];
            c[j] = newc;
            newc = oldc.add(newc.multiply(root[i]));
        }
    }

    return root;
}
 
Example 3
Source File: LaguerreSolver.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find all complex roots for the polynomial with the given
 * coefficients, starting from the given initial value.
 *
 * @param coefficients Polynomial coefficients.
 * @param initial Start value.
 * @return the point at which the function value is zero.
 * @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.
 */
public Complex[] solveAll(Complex coefficients[], Complex initial) {
    if (coefficients == null) {
        throw new NullArgumentException();
    }
    final int n = coefficients.length - 1;
    if (n == 0) {
        throw new NoDataException(LocalizedFormats.POLYNOMIAL);
    }
    // Coefficients for deflated polynomial.
    final Complex c[] = new Complex[n + 1];
    for (int i = 0; i <= n; i++) {
        c[i] = coefficients[i];
    }

    // Solve individual roots successively.
    final Complex root[] = new Complex[n];
    for (int i = 0; i < n; i++) {
        final Complex subarray[] = new Complex[n - i + 1];
        System.arraycopy(c, 0, subarray, 0, subarray.length);
        root[i] = solve(subarray, initial);
        // Polynomial deflation using synthetic division.
        Complex newc = c[n - i];
        Complex oldc = null;
        for (int j = n - i - 1; j >= 0; j--) {
            oldc = c[j];
            c[j] = newc;
            newc = oldc.add(newc.multiply(root[i]));
        }
    }

    return root;
}
 
Example 4
Source File: LaguerreSolver.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find all complex roots for the polynomial with the given
 * coefficients, starting from the given initial value.
 *
 * @param coefficients Polynomial coefficients.
 * @param initial Start value.
 * @return the point at which the function value is zero.
 * @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.
 */
public Complex[] solveAll(Complex coefficients[], Complex initial)
    throws NullArgumentException,
           NoDataException,
           TooManyEvaluationsException {
    if (coefficients == null) {
        throw new NullArgumentException();
    }
    final int n = coefficients.length - 1;
    if (n == 0) {
        throw new NoDataException(LocalizedFormats.POLYNOMIAL);
    }
    // Coefficients for deflated polynomial.
    final Complex c[] = new Complex[n + 1];
    for (int i = 0; i <= n; i++) {
        c[i] = coefficients[i];
    }

    // Solve individual roots successively.
    final Complex root[] = new Complex[n];
    for (int i = 0; i < n; i++) {
        final Complex subarray[] = new Complex[n - i + 1];
        System.arraycopy(c, 0, subarray, 0, subarray.length);
        root[i] = solve(subarray, initial);
        // Polynomial deflation using synthetic division.
        Complex newc = c[n - i];
        Complex oldc = null;
        for (int j = n - i - 1; j >= 0; j--) {
            oldc = c[j];
            c[j] = newc;
            newc = oldc.add(newc.multiply(root[i]));
        }
    }

    return root;
}
 
Example 5
Source File: LaguerreSolver.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find all complex roots for the polynomial with the given
 * coefficients, starting from the given initial value.
 *
 * @param coefficients Polynomial coefficients.
 * @param initial Start value.
 * @return the point at which the function value is zero.
 * @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.
 */
public Complex[] solveAll(Complex coefficients[], Complex initial) {
    if (coefficients == null) {
        throw new NullArgumentException();
    }
    int n = coefficients.length - 1;
    if (n == 0) {
        throw new NoDataException(LocalizedFormats.POLYNOMIAL);
    }
    // Coefficients for deflated polynomial.
    Complex c[] = new Complex[n + 1];
    for (int i = 0; i <= n; i++) {
        c[i] = coefficients[i];
    }

    // Solve individual roots successively.
    Complex root[] = new Complex[n];
    for (int i = 0; i < n; i++) {
        Complex subarray[] = new Complex[n - i + 1];
        System.arraycopy(c, 0, subarray, 0, subarray.length);
        root[i] = solve(subarray, initial);
        // Polynomial deflation using synthetic division.
        Complex newc = c[n - i];
        Complex oldc = null;
        for (int j = n - i - 1; j >= 0; j--) {
            oldc = c[j];
            c[j] = newc;
            newc = oldc.add(newc.multiply(root[i]));
        }
    }

    return root;
}
 
Example 6
Source File: LaguerreSolver.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find all complex roots for the polynomial with the given
 * coefficients, starting from the given initial value.
 *
 * @param coefficients Polynomial coefficients.
 * @param initial Start value.
 * @return the point at which the function value is zero.
 * @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.
 */
public Complex[] solveAll(Complex coefficients[], Complex initial)
    throws NullArgumentException,
           NoDataException,
           TooManyEvaluationsException {
    if (coefficients == null) {
        throw new NullArgumentException();
    }
    final int n = coefficients.length - 1;
    if (n == 0) {
        throw new NoDataException(LocalizedFormats.POLYNOMIAL);
    }
    // Coefficients for deflated polynomial.
    final Complex c[] = new Complex[n + 1];
    for (int i = 0; i <= n; i++) {
        c[i] = coefficients[i];
    }

    // Solve individual roots successively.
    final Complex root[] = new Complex[n];
    for (int i = 0; i < n; i++) {
        final Complex subarray[] = new Complex[n - i + 1];
        System.arraycopy(c, 0, subarray, 0, subarray.length);
        root[i] = solve(subarray, initial);
        // Polynomial deflation using synthetic division.
        Complex newc = c[n - i];
        Complex oldc = null;
        for (int j = n - i - 1; j >= 0; j--) {
            oldc = c[j];
            c[j] = newc;
            newc = oldc.add(newc.multiply(root[i]));
        }
    }

    return root;
}
 
Example 7
Source File: LaguerreSolver.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find all complex roots for the polynomial with the given
 * coefficients, starting from the given initial value.
 *
 * @param coefficients Polynomial coefficients.
 * @param initial Start value.
 * @return the point at which the function value is zero.
 * @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.
 */
public Complex[] solveAll(Complex coefficients[], Complex initial)
    throws NullArgumentException,
           NoDataException,
           TooManyEvaluationsException {
    if (coefficients == null) {
        throw new NullArgumentException();
    }
    final int n = coefficients.length - 1;
    if (n == 0) {
        throw new NoDataException(LocalizedFormats.POLYNOMIAL);
    }
    // Coefficients for deflated polynomial.
    final Complex c[] = new Complex[n + 1];
    for (int i = 0; i <= n; i++) {
        c[i] = coefficients[i];
    }

    // Solve individual roots successively.
    final Complex root[] = new Complex[n];
    for (int i = 0; i < n; i++) {
        final Complex subarray[] = new Complex[n - i + 1];
        System.arraycopy(c, 0, subarray, 0, subarray.length);
        root[i] = solve(subarray, initial);
        // Polynomial deflation using synthetic division.
        Complex newc = c[n - i];
        Complex oldc = null;
        for (int j = n - i - 1; j >= 0; j--) {
            oldc = c[j];
            c[j] = newc;
            newc = oldc.add(newc.multiply(root[i]));
        }
    }

    return root;
}
 
Example 8
Source File: LaguerreSolver.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find all complex roots for the polynomial with the given
 * coefficients, starting from the given initial value.
 *
 * @param coefficients Polynomial coefficients.
 * @param initial Start value.
 * @return the point at which the function value is zero.
 * @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.
 */
public Complex[] solveAll(Complex coefficients[], Complex initial)
    throws NullArgumentException,
           NoDataException,
           TooManyEvaluationsException {
    if (coefficients == null) {
        throw new NullArgumentException();
    }
    final int n = coefficients.length - 1;
    if (n == 0) {
        throw new NoDataException(LocalizedFormats.POLYNOMIAL);
    }
    // Coefficients for deflated polynomial.
    final Complex c[] = new Complex[n + 1];
    for (int i = 0; i <= n; i++) {
        c[i] = coefficients[i];
    }

    // Solve individual roots successively.
    final Complex root[] = new Complex[n];
    for (int i = 0; i < n; i++) {
        final Complex subarray[] = new Complex[n - i + 1];
        System.arraycopy(c, 0, subarray, 0, subarray.length);
        root[i] = solve(subarray, initial);
        // Polynomial deflation using synthetic division.
        Complex newc = c[n - i];
        Complex oldc = null;
        for (int j = n - i - 1; j >= 0; j--) {
            oldc = c[j];
            c[j] = newc;
            newc = oldc.add(newc.multiply(root[i]));
        }
    }

    return root;
}