Search in sources :

Example 1 with UnivariateInterpolator

use of org.hipparchus.analysis.interpolation.UnivariateInterpolator in project symja_android_library by axkr.

the class InterpolatingFunction method interpolateSpline.

private double interpolateSpline(RealMatrix matrix, double interpolationX) {
    int rowDim = matrix.getRowDimension();
    double[] x = new double[rowDim];
    double[] y = new double[rowDim];
    double[][] data = matrix.getData();
    for (int i = 0; i < rowDim; i++) {
        x[i] = data[i][0];
        y[i] = data[i][1];
    }
    UnivariateInterpolator interpolator = new SplineInterpolator();
    UnivariateFunction function = interpolator.interpolate(x, y);
    double interpolatedY = function.value(interpolationX);
    return interpolatedY;
}
Also used : UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) SplineInterpolator(org.hipparchus.analysis.interpolation.SplineInterpolator) UnivariateInterpolator(org.hipparchus.analysis.interpolation.UnivariateInterpolator)

Aggregations

UnivariateFunction (org.hipparchus.analysis.UnivariateFunction)1 SplineInterpolator (org.hipparchus.analysis.interpolation.SplineInterpolator)1 UnivariateInterpolator (org.hipparchus.analysis.interpolation.UnivariateInterpolator)1