Example usage for org.apache.commons.math3.analysis.polynomials PolynomialSplineFunction getN

List of usage examples for org.apache.commons.math3.analysis.polynomials PolynomialSplineFunction getN

Introduction

In this page you can find the example usage for org.apache.commons.math3.analysis.polynomials PolynomialSplineFunction getN.

Prototype

public int getN() 

Source Link

Document

Get the number of spline segments.

Usage

From source file:org.micromanager.plugins.magellan.acq.AcqDurationEstimator.java

private double interpolateOrExtrapolate(double[] x, double[] y, double xVal) {
    if (x.length == 1) {
        return y[0];
    }/*from   w w  w  . ja  va  2  s .c om*/
    LinearInterpolator interpolator = new LinearInterpolator();
    PolynomialSplineFunction interpolant = interpolator.interpolate(x, y);
    if (xVal < interpolant.getKnots()[0]) {
        return interpolant.getKnots()[0];
    } else if (xVal > interpolant.getKnots()[interpolant.getN() - 1]) {
        return interpolant.getKnots()[interpolant.getN() - 1];
    } else {
        return interpolant.value(xVal);
    }
}