public abstract class AbstractInterpolator extends Object implements Interpolator
Interpolators.
Interpolation assumes a monotonic set of X coordinates
(the ordinates) and an arbitrary set of Y coordinates
(the data values). Interpolation of the Y coordinates
is provided by the specification of any possible X
coordinate or array of X coordinates.
Extenders of this class need to at implement the
interpolate(double), and probably a few others.
| Modifier and Type | Field and Description |
|---|---|
protected double[] |
c
Some coefficients, if any associated with the fit.
|
protected boolean |
decr
Whether the X coordinates are monotonically decreasing.
|
protected double[] |
x
The X coordinates.
|
protected double[] |
y
The Y coordinates.
|
| Constructor and Description |
|---|
AbstractInterpolator()
Create an instance with no coordinates.
|
AbstractInterpolator(double[] x,
double[] y)
Create an instance with the given coordinates.
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendValue(double newx,
double newy)
Append a new position to the existing coordinates.
|
protected int[] |
binarySearch(double[] array,
double value)
Return two indices of the values in an array that lie above and
below a given value.
|
double |
evalYData(double xp)
Return the interpolated value corresponding to some arbitrary
X coordinate.
|
double[] |
evalYDataArray(double[] xps)
Return an array of interpolated value corresponding to some
array of arbitrary X coordinates.
|
int |
getCount()
Get the number of coordinate positions that are being used by
this interpolator.
|
double |
getXCoord(int index)
Get an X coordinate by index.
|
double[] |
getXCoords()
Get the X coordinates.
|
double |
getYCoord(int index)
Get a Y coordinate by index.
|
double[] |
getYCoords()
Get the Y coordinates.
|
abstract double |
interpolate(double xp)
Return the interpolated value corresponding to some arbitrary
X coordinate.
|
boolean |
isFull()
Return if the Interpolator is full.
|
boolean |
isIncreasing()
Return the direction being used by this interpolator.
|
void |
setCoords(double[] x,
double[] y,
boolean check)
Set or reset the coordinates used by this interpolator.
|
int |
stepGuess()
A guess at the number of steps needed between the actual X
coordinates that may be used to draw a reasonable representation
of the curve being interpolated.
|
protected double[] x
protected double[] y
protected double[] c
protected boolean decr
public AbstractInterpolator()
setCoords must be made before any other methods.public AbstractInterpolator(double[] x,
double[] y)
interpolate method. The X
coordinates should be monotonic, either increasing or
decreasing. Same value X coordinates are not allowed.x - the X coordinates.y - the Y coordinates.public int stepGuess()
InterpolatorstepGuess in interface Interpolatorpublic void setCoords(double[] x,
double[] y,
boolean check)
InterpolatorsetCoords in interface Interpolatorx - the X coordinates.y - the Y coordinates.check - whether to check the monotonic direction (compares
0 and 1 values of x). Use this when you need to
preserve the direction temporarily even though the
order may currently be switched, but take care to
reorder before interpolating.public boolean isIncreasing()
InterpolatorisIncreasing in interface Interpolatorpublic void appendValue(double newx,
double newy)
InterpolatorappendValue in interface Interpolatorpublic int getCount()
InterpolatorgetCount in interface Interpolatorpublic boolean isFull()
InterpolatorisFull in interface Interpolatorpublic double[] getXCoords()
InterpolatorgetXCoords in interface InterpolatorsetCoords.public double getXCoord(int index)
InterpolatorgetXCoord in interface Interpolatorpublic double[] getYCoords()
InterpolatorgetYCoords in interface InterpolatorsetCoords.public double getYCoord(int index)
InterpolatorgetYCoord in interface Interpolatorpublic abstract double interpolate(double xp)
Interpolatorinterpolate in interface Interpolatorxp - the X coordinate at which an interpolated Y
coordinate is required.public double evalYData(double xp)
InterpolatorevalYData in interface Interpolatorxp - the X coordinate at which an interpolated Y
coordinate is required.public double[] evalYDataArray(double[] xps)
InterpolatorevalYDataArray in interface Interpolatorxps - the X coordinates at which interpolated Y
coordinates are required.protected int[] binarySearch(double[] array,
double value)
array - the array of values to be searchedvalue - the value to be locatedCopyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.