Package io.github.ai4ci.util
Class SplineInterpolator
java.lang.Object
io.github.ai4ci.util.SplineInterpolator
- All Implemented Interfaces:
Serializable
Performs spline interpolation given a set of control points.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic SplineInterpolator
createMonotoneCubicSpline
(double[] x, double[] y) Creates a monotone cubic spline from a given set of control points.double
interpolate
(double x) Interpolates the value of Y = f(X) for given X.double
interpolateDifferential
(double x) Interpolates the value of Y = f(X) for given X.toString()
-
Method Details
-
createMonotoneCubicSpline
Creates a monotone cubic spline from a given set of control points. The spline is guaranteed to pass through each control point exactly. Moreover, assuming the control points are monotonic (Y is non-decreasing or non-increasing) then the interpolated values will also be monotonic. This function uses the Fritsch-Carlson method for computing the spline parameters. http://en.wikipedia.org/wiki/Monotone_cubic_interpolation- Parameters:
x
- The X component of the control points, strictly increasing.y
- The Y component of the control points- Throws:
IllegalArgumentException
- if the X or Y arrays are null, have different lengths or have fewer than 2 values.
-
interpolateDifferential
public double interpolateDifferential(double x) Interpolates the value of Y = f(X) for given X. Clamps X to the domain of the spline.- Parameters:
x
- The X value.- Returns:
- The interpolated Y = f(X) value.
-
interpolate
public double interpolate(double x) Interpolates the value of Y = f(X) for given X. Clamps X to the domain of the spline.- Parameters:
x
- The X value.- Returns:
- The interpolated Y = f(X) value.
-
toString
-