Java Code Examples for org.apache.commons.math3.analysis.polynomials.PolynomialFunction#multiply()

The following examples show how to use org.apache.commons.math3.analysis.polynomials.PolynomialFunction#multiply() . 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: HermiteInterpolator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** Compute the interpolation polynomials.
 * @return interpolation polynomials array
 * @exception NoDataException if sample is empty
 */
public PolynomialFunction[] getPolynomials()
    throws NoDataException {

    // safety check
    checkInterpolation();

    // iteration initialization
    final PolynomialFunction zero = polynomial(0);
    PolynomialFunction[] polynomials = new PolynomialFunction[topDiagonal.get(0).length];
    for (int i = 0; i < polynomials.length; ++i) {
        polynomials[i] = zero;
    }
    PolynomialFunction coeff = polynomial(1);

    // build the polynomials by iterating on the top diagonal of the divided differences array
    for (int i = 0; i < topDiagonal.size(); ++i) {
        double[] tdi = topDiagonal.get(i);
        for (int k = 0; k < polynomials.length; ++k) {
            polynomials[k] = polynomials[k].add(coeff.multiply(polynomial(tdi[k])));
        }
        coeff = coeff.multiply(polynomial(-abscissae.get(i), 1.0));
    }

    return polynomials;

}
 
Example 2
Source File: HermiteInterpolator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** Compute the interpolation polynomials.
 * @return interpolation polynomials array
 * @exception NoDataException if sample is empty
 */
public PolynomialFunction[] getPolynomials()
    throws NoDataException {

    // safety check
    checkInterpolation();

    // iteration initialization
    final PolynomialFunction zero = polynomial(0);
    PolynomialFunction[] polynomials = new PolynomialFunction[topDiagonal.get(0).length];
    for (int i = 0; i < polynomials.length; ++i) {
        polynomials[i] = zero;
    }
    PolynomialFunction coeff = polynomial(1);

    // build the polynomials by iterating on the top diagonal of the divided differences array
    for (int i = 0; i < topDiagonal.size(); ++i) {
        double[] tdi = topDiagonal.get(i);
        for (int k = 0; k < polynomials.length; ++k) {
            polynomials[k] = polynomials[k].add(coeff.multiply(polynomial(tdi[k])));
        }
        coeff = coeff.multiply(polynomial(-abscissae.get(i), 1.0));
    }

    return polynomials;

}
 
Example 3
Source File: HermiteInterpolator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** Compute the interpolation polynomials.
 * @return interpolation polynomials array
 * @exception MathIllegalStateException if sample is empty
 */
public PolynomialFunction[] getPolynomials()
    throws MathIllegalStateException {

    // safety check
    checkInterpolation();

    // iteration initialization
    final PolynomialFunction zero = polynomial(0);
    PolynomialFunction[] polynomials = new PolynomialFunction[topDiagonal.get(0).length];
    for (int i = 0; i < polynomials.length; ++i) {
        polynomials[i] = zero;
    }
    PolynomialFunction coeff = polynomial(1);

    // build the polynomials by iterating on the top diagonal of the divided differences array
    for (int i = 0; i < topDiagonal.size(); ++i) {
        double[] tdi = topDiagonal.get(i);
        for (int k = 0; k < polynomials.length; ++k) {
            polynomials[k] = polynomials[k].add(coeff.multiply(polynomial(tdi[k])));
        }
        coeff = coeff.multiply(polynomial(-abscissae.get(i), 1.0));
    }

    return polynomials;

}
 
Example 4
Source File: HermiteInterpolator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** Compute the interpolation polynomials.
 * @return interpolation polynomials array
 * @exception NoDataException if sample is empty
 */
public PolynomialFunction[] getPolynomials()
    throws NoDataException {

    // safety check
    checkInterpolation();

    // iteration initialization
    final PolynomialFunction zero = polynomial(0);
    PolynomialFunction[] polynomials = new PolynomialFunction[topDiagonal.get(0).length];
    for (int i = 0; i < polynomials.length; ++i) {
        polynomials[i] = zero;
    }
    PolynomialFunction coeff = polynomial(1);

    // build the polynomials by iterating on the top diagonal of the divided differences array
    for (int i = 0; i < topDiagonal.size(); ++i) {
        double[] tdi = topDiagonal.get(i);
        for (int k = 0; k < polynomials.length; ++k) {
            polynomials[k] = polynomials[k].add(coeff.multiply(polynomial(tdi[k])));
        }
        coeff = coeff.multiply(polynomial(-abscissae.get(i), 1.0));
    }

    return polynomials;

}
 
Example 5
Source File: HermiteInterpolator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** Compute the interpolation polynomials.
 * @return interpolation polynomials array
 * @exception NoDataException if sample is empty
 */
public PolynomialFunction[] getPolynomials()
    throws NoDataException {

    // safety check
    checkInterpolation();

    // iteration initialization
    final PolynomialFunction zero = polynomial(0);
    PolynomialFunction[] polynomials = new PolynomialFunction[topDiagonal.get(0).length];
    for (int i = 0; i < polynomials.length; ++i) {
        polynomials[i] = zero;
    }
    PolynomialFunction coeff = polynomial(1);

    // build the polynomials by iterating on the top diagonal of the divided differences array
    for (int i = 0; i < topDiagonal.size(); ++i) {
        double[] tdi = topDiagonal.get(i);
        for (int k = 0; k < polynomials.length; ++k) {
            polynomials[k] = polynomials[k].add(coeff.multiply(polynomial(tdi[k])));
        }
        coeff = coeff.multiply(polynomial(-abscissae.get(i), 1.0));
    }

    return polynomials;

}
 
Example 6
Source File: HermiteInterpolator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** Compute the interpolation polynomials.
 * @return interpolation polynomials array
 * @exception NoDataException if sample is empty
 */
public PolynomialFunction[] getPolynomials()
    throws NoDataException {

    // safety check
    checkInterpolation();

    // iteration initialization
    final PolynomialFunction zero = polynomial(0);
    PolynomialFunction[] polynomials = new PolynomialFunction[topDiagonal.get(0).length];
    for (int i = 0; i < polynomials.length; ++i) {
        polynomials[i] = zero;
    }
    PolynomialFunction coeff = polynomial(1);

    // build the polynomials by iterating on the top diagonal of the divided differences array
    for (int i = 0; i < topDiagonal.size(); ++i) {
        double[] tdi = topDiagonal.get(i);
        for (int k = 0; k < polynomials.length; ++k) {
            polynomials[k] = polynomials[k].add(coeff.multiply(polynomial(tdi[k])));
        }
        coeff = coeff.multiply(polynomial(-abscissae.get(i), 1.0));
    }

    return polynomials;

}
 
Example 7
Source File: HermiteInterpolator.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** Compute the interpolation polynomials.
 * @return interpolation polynomials array
 * @exception NoDataException if sample is empty
 */
public PolynomialFunction[] getPolynomials()
    throws NoDataException {

    // safety check
    checkInterpolation();

    // iteration initialization
    final PolynomialFunction zero = polynomial(0);
    PolynomialFunction[] polynomials = new PolynomialFunction[topDiagonal.get(0).length];
    for (int i = 0; i < polynomials.length; ++i) {
        polynomials[i] = zero;
    }
    PolynomialFunction coeff = polynomial(1);

    // build the polynomials by iterating on the top diagonal of the divided differences array
    for (int i = 0; i < topDiagonal.size(); ++i) {
        double[] tdi = topDiagonal.get(i);
        for (int k = 0; k < polynomials.length; ++k) {
            polynomials[k] = polynomials[k].add(coeff.multiply(polynomial(tdi[k])));
        }
        coeff = coeff.multiply(polynomial(-abscissae.get(i), 1.0));
    }

    return polynomials;

}