Package smile.interpolation
Class AbstractInterpolation
java.lang.Object
smile.interpolation.AbstractInterpolation
- All Implemented Interfaces:
Serializable
,Interpolation
- Direct Known Subclasses:
CubicSplineInterpolation1D
,LinearInterpolation
Abstract base class of one-dimensional interpolation methods.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
interpolate
(double x) Given a value x, return an interpolated value.abstract double
rawinterp
(int jlo, double x) Subclasses provide this as the actual interpolation method.protected int
search
(double x) Given a value x, return a value j such that x is (insofar as possible) centered in the subrange xx[j..j+m-1], where xx is the stored data.
-
Constructor Details
-
AbstractInterpolation
public AbstractInterpolation(double[] x, double[] y) Constructor. Setup for interpolation on a table of x and y. The value in x must be monotonic, either increasing or decreasing.- Parameters:
x
- the tabulated points.y
- the function values atx
.
-
-
Method Details
-
interpolate
public double interpolate(double x) Description copied from interface:Interpolation
Given a value x, return an interpolated value.- Specified by:
interpolate
in interfaceInterpolation
- Parameters:
x
- a real number.- Returns:
- the interpolated function value.
-
search
protected int search(double x) Given a value x, return a value j such that x is (insofar as possible) centered in the subrange xx[j..j+m-1], where xx is the stored data. The returned value is not less than 0, nor greater than n-1, where n is the length of xx.- Parameters:
x
- a real number.- Returns:
- the index
j
of x in the tabulated points.
-
rawinterp
public abstract double rawinterp(int jlo, double x) Subclasses provide this as the actual interpolation method.- Parameters:
jlo
- the value jlo is such that x is (insofar as possible) centered in the subrange xx[j..j+m-1], where xx is the stored data.x
- interpolate at this value- Returns:
- the raw interpolated value.
-