Example usage for org.apache.commons.math3.analysis.interpolation NevilleInterpolator NevilleInterpolator

List of usage examples for org.apache.commons.math3.analysis.interpolation NevilleInterpolator NevilleInterpolator

Introduction

In this page you can find the example usage for org.apache.commons.math3.analysis.interpolation NevilleInterpolator NevilleInterpolator.

Prototype

NevilleInterpolator

Source Link

Usage

From source file:org.lightjason.agentspeak.action.builtin.TestCActionMathInterpolate.java

/**
 * test multiple interpolate/*from  w  ww. ja v a 2s  .c o m*/
 */
@Test
public final void multipleinterpolate() {
    final List<ITerm> l_return = new ArrayList<>();

    new CMultipleInterpolate()
            .execute(false, IContext.EMPTYPLAN, Stream
                    .of(5, new LinearInterpolator().interpolate(new double[] { 3, 6 }, new double[] { 11, 13 }),
                            new NevilleInterpolator().interpolate(new double[] { 2, 3, 8 },
                                    new double[] { 11, 13, 20 }))
                    .map(CRawTerm::from).collect(Collectors.toList()), l_return);

    Assert.assertEquals(l_return.size(), 2);
    Assert.assertEquals(l_return.get(0).<Number>raw(), 12.333333333333334);
    Assert.assertEquals(l_return.get(1).<Number>raw(), 16.400000000000002);
}

From source file:org.meteoinfo.math.interpolate.InterpUtil.java

/**
 * Make interpolation function// w  w w  .j  a v a2 s .  c o  m
 * @param x X data
 * @param y Y data
 * @param kind Specifies the kind of interpolation as a string (linear, 'spline').
 * @return Interpolation function
 */
public static UnivariateFunction getInterpFunc(Array x, Array y, String kind) {
    double[] xd = (double[]) ArrayUtil.copyToNDJavaArray(x);
    double[] yd = (double[]) ArrayUtil.copyToNDJavaArray(y);
    UnivariateInterpolator li;
    switch (kind) {
    case "spline":
    case "cubic":
        li = new SplineInterpolator();
        break;
    case "akima":
        li = new AkimaSplineInterpolator();
        break;
    case "divided":
        li = new DividedDifferenceInterpolator();
        break;
    case "loess":
        li = new LoessInterpolator();
        break;
    case "neville":
        li = new NevilleInterpolator();
        break;
    default:
        li = new LinearInterpolator();
        break;
    }
    UnivariateFunction psf = li.interpolate(xd, yd);

    return psf;
}