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

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

Introduction

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

Prototype

DividedDifferenceInterpolator

Source Link

Usage

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

/**
 * Make interpolation function//from   w  w  w.j av 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;
}