public class CubicInterpolator
extends java.lang.Object
Piecewise cubic interpolators differ in the method they use to compute slopes y'(x) at specified x (knots). The classic cubic spline computes the slopes to obtain a continuous second derivative at the knots. These splines often yield unacceptable wiggliness (overshoot) between the knots. A linear spline yields no overshoot, but has discontinuous first (and higher) derivatives. A monotonic spline has continuous first derivatives and yields monotonic interpolation (with no overshoot) where function values at the knots are monotonically increasing or decreasing.
For x outside the range of values specified when an interpolator was constructed, the interpolator extrapolates using the cubic polynomial corresponding to the knot nearest to x.
Modifier and Type | Class and Description |
---|---|
static class |
CubicInterpolator.Method
The method used to compute 1st derivatives y'(x).
|
Constructor and Description |
---|
CubicInterpolator(CubicInterpolator.Method method,
float[] x,
float[] y)
Constructs an interpolator.
|
CubicInterpolator(CubicInterpolator.Method method,
int n,
float[] x,
float[] y)
Constructs an interpolator.
|
CubicInterpolator(float[] x,
float[] y)
Constructs an interpolator with default method monotonic.
|
CubicInterpolator(float[] x,
float[] y,
float[] y1)
Constructs an interpolator with specified 1st derivatives y'(x).
|
Modifier and Type | Method and Description |
---|---|
float |
interpolate(float x)
Interpolates a function value y(x).
|
float[] |
interpolate(float[] x)
Returns an array of interpolated function values y(x).
|
void |
interpolate(float[] x,
float[] y)
Interpolates an array of function values y(x).
|
void |
interpolate(int n,
float[] x,
float[] y)
Interpolates an array of function values y(x).
|
float |
interpolate0(float x)
Interpolates a function value y(x).
|
float[] |
interpolate0(float[] x)
Returns an array of interpolated function values y(x).
|
void |
interpolate0(float[] x,
float[] y)
Interpolates an array of function values y(x).
|
void |
interpolate0(int n,
float[] x,
float[] y)
Interpolates an array of function values y(x).
|
float |
interpolate1(float x)
Interpolates the first derivative y'(x).
|
float[] |
interpolate1(float[] x)
Returns an array of interpolated first derivatives y'(x).
|
void |
interpolate1(float[] x,
float[] y)
Interpolates an array of first derivatives y'(x).
|
void |
interpolate1(int n,
float[] x,
float[] y)
Interpolates an array of first derivatives y'(x).
|
float |
interpolate2(float x)
Interpolates the second derivative y''(x).
|
float[] |
interpolate2(float[] x)
Returns an array of interpolated second derivatives y''(x).
|
void |
interpolate2(float[] x,
float[] y)
Interpolates an array of second derivatives y''(x).
|
void |
interpolate2(int n,
float[] x,
float[] y)
Interpolates an array of second derivatives y''(x).
|
float |
interpolate3(float x)
Interpolates the third derivative y'''(x).
|
float[] |
interpolate3(float[] x)
Returns an array of interpolated third derivatives y'''(x).
|
void |
interpolate3(float[] x,
float[] y)
Interpolates an array of third derivatives y'''(x).
|
void |
interpolate3(int n,
float[] x,
float[] y)
Interpolates an array of third derivatives y'''(x).
|
public CubicInterpolator(float[] x, float[] y, float[] y1)
x
- array of values at which y(x) are specified.
These values must be monotonically increasing or decreasing,
with no equal values. (In other words, the array must be
monotonic-definite.)y
- array of function values y(x).y1
- array of 1st derivatives y'(x).public CubicInterpolator(float[] x, float[] y)
x
- array of values at which y(x) are specified.
These values must be monotonically increasing or decreasing,
with no equal values. (In other words, the array must be
monotonic-definite.)y
- array of function values y(x).public CubicInterpolator(CubicInterpolator.Method method, float[] x, float[] y)
method
- interpolation method: LINEAR, MONOTONIC, or SPLINE.x
- array of values at which y(x) are specified.
These values must be monotonically increasing or decreasing,
with no equal values. (In other words, the array must be
monotonic-definite.)y
- array of function values y(x).public CubicInterpolator(CubicInterpolator.Method method, int n, float[] x, float[] y)
method
- interpolation method: LINEAR, MONOTONIC, or SPLINE.n
- number of x and y(x) values specified.x
- array[n] of values at which y(x) are specified.
These values must be monotonically increasing or decreasing,
with no equal values. (In other words, the array must be
monotonic-definite.)y
- array[n] of function values y(x).public float interpolate(float x)
interpolate0(float)
.x
- value at which to interpolate.public float interpolate0(float x)
x
- value at which to interpolate.public float interpolate1(float x)
x
- value at which to interpolate.public float interpolate2(float x)
x
- value at which to interpolate.public float interpolate3(float x)
x
- value at which to interpolate.public float[] interpolate(float[] x)
interpolate0(float[])
.x
- array of values at which to interpolate.public float[] interpolate0(float[] x)
x
- array of values at which to interpolate.public void interpolate(float[] x, float[] y)
interpolate0(float[],float[])
.x
- array of values at which to interpolate.y
- array of interpolated function values.public void interpolate0(float[] x, float[] y)
x
- array of values at which to interpolate.y
- array of interpolated function values.public float[] interpolate1(float[] x)
x
- array of values at which to interpolate.public void interpolate1(float[] x, float[] y)
x
- array of values at which to interpolate.y
- array of interpolated first derivatives y'(x).public float[] interpolate2(float[] x)
x
- array of values at which to interpolate.public void interpolate2(float[] x, float[] y)
x
- array of values at which to interpolate.y
- array of interpolated second derivatives y''(x).public float[] interpolate3(float[] x)
x
- array of values at which to interpolate.public void interpolate3(float[] x, float[] y)
x
- array of values at which to interpolate.y
- array of interpolated third derivatives y'''(x).public void interpolate(int n, float[] x, float[] y)
interpolate0(int,float[],float[])
.n
- number of values to interpolate.x
- array of values at which to interpolate.y
- array of interpolated function values.public void interpolate0(int n, float[] x, float[] y)
n
- number of values to interpolate.x
- array of values at which to interpolate.y
- array of interpolated function values.public void interpolate1(int n, float[] x, float[] y)
n
- number of derivatives to interpolate.x
- array of values at which to interpolate.y
- array of interpolated first derivatives y'(x).public void interpolate2(int n, float[] x, float[] y)
n
- number of derivatives to interpolate.x
- array of values at which to interpolate.y
- array of interpolated second derivatives y''(x).public void interpolate3(int n, float[] x, float[] y)
n
- number of derivatives to interpolate.x
- array of values at which to interpolate.y
- array of interpolated third derivatives y'''(x).