• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PolynomialFunctionLagrangeForm类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



PolynomialFunctionLagrangeForm类属于org.apache.commons.math3.analysis.polynomials包,在下文中一共展示了PolynomialFunctionLagrangeForm类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例4: unwrap

import org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm; //导入依赖的package包/类
/**
 * Unwraps a Lagrange.
 * 
 * @param lagrange  a Commons polynomial in Lagrange form
 * @return an OG 1-D function mapping doubles to doubles
 */
public static Function<Double, Double> unwrap(PolynomialFunctionLagrangeForm lagrange) {
  ArgChecker.notNull(lagrange, "lagrange");
  return new Function<Double, Double>() {

    @Override
    public Double apply(Double x) {
      try {
        return lagrange.value(x);
      } catch (DimensionMismatchException | NonMonotonicSequenceException | NumberIsTooSmallException e) {
        throw new MathException(e);
      }
    }

  };
}
 
开发者ID:OpenGamma,项目名称:Strata,代码行数:22,代码来源:CommonsMathWrapper.java


示例5: Device

import org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm; //导入依赖的package包/类
public Device(Integer deviceID, String MACAddress, String name, List<Position> positions)
{
	this.deviceID = deviceID;
	this.MACAddress = MACAddress;
	this.name = name;
	this.positions = new ArrayList<Position>(positions);
	this.path = new ArrayList<PolynomialFunctionLagrangeForm>();
}
 
开发者ID:QSchulz,项目名称:wifi-indoor-positioning,代码行数:9,代码来源:Device.java


示例6: createInterpolationFunction

import org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm; //导入依赖的package包/类
public UnivariateFunction createInterpolationFunction(List<Double> x, List<Double> y) {
	if (y.size() != x.size()) {
		throw new DimensionMismatchException(y.size(), x.size());
	}

	int n = x.size();
	List<Double> nonNullX = new ArrayList<>(n);
	List<Double> nonNullY = new ArrayList<>(n);

	for (int i = 0; i < n; i++) {
		if (x.get(i) != null && y.get(i) != null) {
			nonNullX.add(x.get(i));
			nonNullY.add(y.get(i));
		}
	}

	switch (type) {
	case STEP:
		return new StepFunction(Doubles.toArray(nonNullX), Doubles.toArray(nonNullY));
	case LINEAR:
		return new LinearFunction(Doubles.toArray(nonNullX), Doubles.toArray(nonNullY));
	case SPLINE:
		return new SplineInterpolator().interpolate(Doubles.toArray(nonNullX), Doubles.toArray(nonNullY));
	case LAGRANGE:
		return new PolynomialFunctionLagrangeForm(Doubles.toArray(nonNullX), Doubles.toArray(nonNullY));
	default:
		throw new RuntimeException("Unknown type of InterpolationFactory: " + type);
	}
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:30,代码来源:InterpolationFactory.java


示例7: testLagrange

import org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm; //导入依赖的package包/类
@Test
public void testLagrange() {
  int n = OG_POLYNOMIAL.getCoefficients().length;
  double[] x = new double[n];
  double[] y = new double[n];
  for (int i = 0; i < n; i++) {
    x[i] = i;
    y[i] = OG_POLYNOMIAL.applyAsDouble(x[i]);
  }
  Function<Double, Double> unwrapped = CommonsMathWrapper.unwrap(new PolynomialFunctionLagrangeForm(x, y));
  for (int i = 0; i < 100; i++) {
    assertEquals(unwrapped.apply(i + 0.5), OG_POLYNOMIAL.applyAsDouble(i + 0.5), 1e-9);
  }
}
 
开发者ID:OpenGamma,项目名称:Strata,代码行数:15,代码来源:CommonsMathWrapperTest.java


示例8: getPath

import org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm; //导入依赖的package包/类
public List<PolynomialFunctionLagrangeForm> getPath() {
	return path;
}
 
开发者ID:QSchulz,项目名称:wifi-indoor-positioning,代码行数:4,代码来源:Device.java


示例9: setPath

import org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm; //导入依赖的package包/类
public void setPath(List<PolynomialFunctionLagrangeForm> path) {
	this.path = path;
}
 
开发者ID:QSchulz,项目名称:wifi-indoor-positioning,代码行数:4,代码来源:Device.java


示例10: testNullLagrange

import org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm; //导入依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void testNullLagrange() {
  CommonsMathWrapper.unwrap((PolynomialFunctionLagrangeForm) null);
}
 
开发者ID:OpenGamma,项目名称:Strata,代码行数:5,代码来源:CommonsMathWrapperTest.java


示例11: interpolate

import org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm; //导入依赖的package包/类
/**
 * Computes an interpolating function for the data set.
 *
 * @param x Interpolating points.
 * @param y Interpolating values.
 * @return a function which interpolates the data set
 * @throws DimensionMismatchException if the array lengths are different.
 * @throws NumberIsTooSmallException if the number of points is less than 2.
 * @throws NonMonotonicSequenceException if two abscissae have the same
 * value.
 */
public PolynomialFunctionLagrangeForm interpolate(double x[], double y[])
    throws DimensionMismatchException,
           NumberIsTooSmallException,
           NonMonotonicSequenceException {
    return new PolynomialFunctionLagrangeForm(x, y);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:18,代码来源:NevilleInterpolator.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CMSAlgorithm类代码示例发布时间:2022-05-22
下一篇:
Java ActionToolbarPosition类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap