Class GridAxis
 All Implemented Interfaces:
Serializable
This class is intended to be used for interpolating inside grids.
It works on any sorted data without duplication and size at least
n
where n
is the number of points required for
interpolation (i.e. 2 for linear interpolation, 3 for quadratic...)
The method uses linear interpolation to select the nodes indices. It should be O(1) for sufficiently regular data, therefore much faster than bisection. It also features caching, which improves speed when interpolating several points in raw in the close locations, i.e. when successive calls have a high probability to return the same interpolation nodes. This occurs for example when scanning with small steps a loose grid. The method also works on nonregular grids, but may be slower in this case.
This class is threadsafe.
 Since:
 1.4
 See Also:

Constructor Summary

Method Summary
Modifier and TypeMethodDescriptionint
getN()
Get the number of points required for interpolation.int
interpolationIndex
(double t) Get the index of the first interpolation node for some coordinate along the grid.double
node
(int index) Get the interpolation node at specified index.int
size()
Get the number of points of the grid.

Constructor Details

GridAxis
Simple constructor. Parameters:
grid
 coordinates of the interpolation points, sorted in increasing ordern
 number of points required for interpolation, i.e. 2 for linear, 3 for quadratic... Throws:
MathIllegalArgumentException
 if grid size is smaller thann
or if the grid is not sorted in strict increasing order


Method Details

size
public int size()Get the number of points of the grid. Returns:
 number of points of the grid

getN
public int getN()Get the number of points required for interpolation. Returns:
 number of points required for interpolation

node
public double node(int index) Get the interpolation node at specified index. Parameters:
index
 node index Returns:
 coordinate of the node at specified index

interpolationIndex
public int interpolationIndex(double t) Get the index of the first interpolation node for some coordinate along the grid.The index return is the one for the lowest interpolation node suitable for
t
. This means that ifi
is returned the nodes to use for interpolation at coordinatet
are at indicesi
,i+1
, ...,i+n1
, wheren
is the number of points required for interpolation passed at construction.The index is selected in order to have the subset of nodes from
i
toi+n1
as balanced as possible aroundt
:
if
t
is inside the grid and sufficiently far from the endpoints
if
n
is even, the returned nodes will be perfectly balanced: there will ben/2
nodes smaller thant
andn/2
nodes larger thant

if
n
is odd, the returned nodes will be slightly unbalanced by one point: there will be(n+1)/2
nodes smaller thant
and(n1)/2
nodes larger thant

if

if
t
is inside the grid and close to endpoints, the returned nodes will be unbalanced: there will be less nodes on the endpoints side and more nodes on the interior side 
if
t
is outside of the grid, the returned nodes will completely off balance: all nodes will be on the same side with respect tot
It is not an error to call this method with
t
outside of the grid, it simply implies that the interpolation will become an extrapolation and accuracy will decrease ast
goes farther from the grid points. This is intended so interpolation does not fail near the end of the grid. Parameters:
t
 coordinate of the point to interpolate Returns:
 index
i
suchnode(i)
,node(i+1)
, ...node(i+n1)
can be used for interpolating a value at coordinatet
 Since:
 1.4

if
