当前位置: 首页>>代码示例>>Java>>正文


Java PolynomialFunctionLagrangeForm.verifyInterpolationArray方法代码示例

本文整理汇总了Java中org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm.verifyInterpolationArray方法的典型用法代码示例。如果您正苦于以下问题:Java PolynomialFunctionLagrangeForm.verifyInterpolationArray方法的具体用法?Java PolynomialFunctionLagrangeForm.verifyInterpolationArray怎么用?Java PolynomialFunctionLagrangeForm.verifyInterpolationArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm的用法示例。


在下文中一共展示了PolynomialFunctionLagrangeForm.verifyInterpolationArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: interpolate

import org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm; //导入方法依赖的package包/类
/**
 * Compute an interpolating function for the dataset.
 *
 * @param x Interpolating points array.
 * @param y Interpolating values array.
 * @return a function which interpolates the dataset.
 * @throws DimensionMismatchException if the array lengths are different.
 * @throws NumberIsTooSmallException if the number of points is less than 2.
 * @throws NonMonotonicSequenceException if {@code x} is not sorted in
 * strictly increasing order.
 */
public PolynomialFunctionNewtonForm interpolate(double x[], double y[])
    throws DimensionMismatchException,
           NumberIsTooSmallException,
           NonMonotonicSequenceException {
    /**
     * a[] and c[] are defined in the general formula of Newton form:
     * p(x) = a[0] + a[1](x-c[0]) + a[2](x-c[0])(x-c[1]) + ... +
     *        a[n](x-c[0])(x-c[1])...(x-c[n-1])
     */
    PolynomialFunctionLagrangeForm.verifyInterpolationArray(x, y, true);

    /**
     * When used for interpolation, the Newton form formula becomes
     * p(x) = f[x0] + f[x0,x1](x-x0) + f[x0,x1,x2](x-x0)(x-x1) + ... +
     *        f[x0,x1,...,x[n-1]](x-x0)(x-x1)...(x-x[n-2])
     * Therefore, a[k] = f[x0,x1,...,xk], c[k] = x[k].
     * <p>
     * Note x[], y[], a[] have the same length but c[]'s size is one less.</p>
     */
    final double[] c = new double[x.length-1];
    System.arraycopy(x, 0, c, 0, c.length);

    final double[] a = computeDividedDifference(x, y);
    return new PolynomialFunctionNewtonForm(a, c);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:37,代码来源:DividedDifferenceInterpolator.java

示例2: computeDividedDifference

import org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm; //导入方法依赖的package包/类
/**
 * Return a copy of the divided difference array.
 * <p>
 * The divided difference array is defined recursively by <pre>
 * f[x0] = f(x0)
 * f[x0,x1,...,xk] = (f[x1,...,xk] - f[x0,...,x[k-1]]) / (xk - x0)
 * </pre>
 * <p>
 * The computational complexity is \(O(n^2)\) where \(n\) is the common
 * length of {@code x} and {@code y}.</p>
 *
 * @param x Interpolating points array.
 * @param y Interpolating values array.
 * @return a fresh copy of the divided difference array.
 * @throws DimensionMismatchException if the array lengths are different.
 * @throws NumberIsTooSmallException if the number of points is less than 2.
 * @throws NonMonotonicSequenceException
 * if {@code x} is not sorted in strictly increasing order.
 */
protected static double[] computeDividedDifference(final double x[], final double y[])
    throws DimensionMismatchException,
           NumberIsTooSmallException,
           NonMonotonicSequenceException {
    PolynomialFunctionLagrangeForm.verifyInterpolationArray(x, y, true);

    final double[] divdiff = y.clone(); // initialization

    final int n = x.length;
    final double[] a = new double [n];
    a[0] = divdiff[0];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n-i; j++) {
            final double denominator = x[j+i] - x[j];
            divdiff[j] = (divdiff[j+1] - divdiff[j]) / denominator;
        }
        a[i] = divdiff[0];
    }

    return a;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:41,代码来源:DividedDifferenceInterpolator.java

示例3: computeDividedDifference

import org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm; //导入方法依赖的package包/类
/**
 * Return a copy of the divided difference array.
 * <p>
 * The divided difference array is defined recursively by <pre>
 * f[x0] = f(x0)
 * f[x0,x1,...,xk] = (f[x1,...,xk] - f[x0,...,x[k-1]]) / (xk - x0)
 * </pre></p>
 * <p>
 * The computational complexity is O(N^2).</p>
 *
 * @param x Interpolating points array.
 * @param y Interpolating values array.
 * @return a fresh copy of the divided difference array.
 * @throws DimensionMismatchException if the array lengths are different.
 * @throws NumberIsTooSmallException if the number of points is less than 2.
 * @throws NonMonotonicSequenceException
 * if {@code x} is not sorted in strictly increasing order.
 */
protected static double[] computeDividedDifference(final double x[], final double y[])
    throws DimensionMismatchException,
           NumberIsTooSmallException,
           NonMonotonicSequenceException {
    PolynomialFunctionLagrangeForm.verifyInterpolationArray(x, y, true);

    final double[] divdiff = y.clone(); // initialization

    final int n = x.length;
    final double[] a = new double [n];
    a[0] = divdiff[0];
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n-i; j++) {
            final double denominator = x[j+i] - x[j];
            divdiff[j] = (divdiff[j+1] - divdiff[j]) / denominator;
        }
        a[i] = divdiff[0];
    }

    return a;
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:40,代码来源:DividedDifferenceInterpolator.java


注:本文中的org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm.verifyInterpolationArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。