public abstract class AbstractInterpolator extends Object implements Interpolator
Interpolator
s.
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()
Interpolator
stepGuess
in interface Interpolator
public void setCoords(double[] x, double[] y, boolean check)
Interpolator
setCoords
in interface Interpolator
x
- 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()
Interpolator
isIncreasing
in interface Interpolator
public void appendValue(double newx, double newy)
Interpolator
appendValue
in interface Interpolator
public int getCount()
Interpolator
getCount
in interface Interpolator
public boolean isFull()
Interpolator
isFull
in interface Interpolator
public double[] getXCoords()
Interpolator
getXCoords
in interface Interpolator
setCoords
.public double getXCoord(int index)
Interpolator
getXCoord
in interface Interpolator
public double[] getYCoords()
Interpolator
getYCoords
in interface Interpolator
setCoords
.public double getYCoord(int index)
Interpolator
getYCoord
in interface Interpolator
public abstract double interpolate(double xp)
Interpolator
interpolate
in interface Interpolator
xp
- the X coordinate at which an interpolated Y
coordinate is required.public double evalYData(double xp)
Interpolator
evalYData
in interface Interpolator
xp
- the X coordinate at which an interpolated Y
coordinate is required.public double[] evalYDataArray(double[] xps)
Interpolator
evalYDataArray
in interface Interpolator
xps
- 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 © 2024 Central Laboratory of the Research Councils. All Rights Reserved.