public class LookupTable extends Object
LookupTable
performs the function of multilinear
interpolation for lookup tables with an arbitrary number of dimensions.
todo - method for degrading a table (see C++ code below)
Constructor and Description |
---|
LookupTable(double[] values,
double[]... dimensions)
Constructs a lookup table for the lookup values and dimensions supplied as arguments.
|
LookupTable(double[] values,
IntervalPartition... dimensions)
Constructs a lookup table for the lookup values and dimensions supplied as arguments.
|
LookupTable(float[] values,
float[]... dimensions)
Constructs a lookup table for the lookup values and dimensions supplied as arguments.
|
LookupTable(float[] values,
IntervalPartition... dimensions)
Constructs a lookup table for the lookup values and dimensions supplied as arguments.
|
Modifier and Type | Method and Description |
---|---|
static void |
computeFracIndex(IntervalPartition partition,
double coordinate,
FracIndex fracIndex)
Computes the
FracIndex of a coordinate value with respect to a given
interval partition. |
IntervalPartition |
getDimension(int i)
Returns the the ith dimension associated with the lookup table.
|
int |
getDimensionCount()
Returns the number of dimensions associated with the lookup table.
|
IntervalPartition[] |
getDimensions()
Returns the dimensions associated with the lookup table.
|
protected int[] |
getOffsets() |
protected int[] |
getStrides() |
double |
getValue(double... coordinates)
Returns an interpolated value for the given coordinates.
|
double |
getValue(double[] coordinates,
FracIndex[] fracIndexes,
double[] v)
Returns an interpolated value for the given coordinates.
|
double |
getValue(FracIndex[] fracIndexes,
double[] v)
Returns an interpolated value for the given fractional indices.
|
protected Array |
getValues() |
double[] |
getValues(FracIndex[] fracIndexes)
Returns an array of interpolated values for the given fractional indices.
|
public LookupTable(double[] values, IntervalPartition... dimensions)
values
- the lookup values. The values
array must be laid out in row-major
order, so that the dimension associated with the last axis varies fastest.dimensions
- the interval partitions defining the dimensions associated with the lookup
table. An interval partition is a strictly increasing sequence of at least
two real numbers, see IntervalPartition
.IllegalArgumentException
- if the length of the values
array is not equal to
the number of coordinate grid vertices.NullPointerException
- if the values
array or the dimensions
array
is null
or any dimension is null
.public LookupTable(float[] values, IntervalPartition... dimensions)
values
- the lookup values. The values
array must be laid out in row-major
order, so that the dimension associated with the last axis varies fastest.dimensions
- the interval partitions defining the dimensions associated with the lookup
table. An interval partition is a strictly increasing sequence of at least
two real numbers, see IntervalPartition
.IllegalArgumentException
- if the length of the values
array is not equal to
the number of coordinate grid vertices.NullPointerException
- if the values
array or the dimensions
array
is null
or any dimension is null
.public LookupTable(double[] values, double[]... dimensions)
values
- the lookup values. The values
array must be laid out in row-major
order, so that the dimension associated with the last axis varies fastest.dimensions
- the interval partitions defining the dimensions associated with the lookup
table. An interval partition is a strictly increasing sequence of at least
two real numbers, see IntervalPartition
.IllegalArgumentException
- if the length of the values
array is is not equal to
the number of coordinate grid vertices or any dimension is
not an interval partion.NullPointerException
- if the values
array or the dimensions
array
is null
or any dimension is null
.public LookupTable(float[] values, float[]... dimensions)
values
- the lookup values. The values
array must be laid out in row-major
order, so that the dimension associated with the last axis varies fastest.dimensions
- the interval partitions defining the dimensions associated with the lookup
table. An interval partition is a strictly increasing sequence of at least
two real numbers, see IntervalPartition
.IllegalArgumentException
- if the length of the values
array is is not equal to
the number of coordinate grid vertices or any dimension is
not an interval partion.NullPointerException
- if the values
array or the dimensions
array
is null
or any dimension is null
.public final int getDimensionCount()
public final IntervalPartition[] getDimensions()
protected int[] getStrides()
protected int[] getOffsets()
protected Array getValues()
public final IntervalPartition getDimension(int i)
i
- the index number of the dimension of interestpublic final double getValue(double... coordinates) throws IllegalArgumentException, NullPointerException
coordinates
- the coordinates of the lookup point.IllegalArgumentException
- if the length of the coordinates
array is
not equal to the number of dimensions associated
with the lookup table.NullPointerException
- if the coordinates
array is null
.public final double getValue(double[] coordinates, FracIndex[] fracIndexes, double[] v) throws IllegalArgumentException, IndexOutOfBoundsException, NullPointerException
coordinates
- the coordinates of the lookup point.fracIndexes
- workspace array of (at least) the same length as coordinates
.v
- workspace array of (at least) length 1 << coordinates.length
.ArrayIndexOutOfBoundsException
- if the fracIndexes
and v
arrays
do not have proper length.IllegalArgumentException
- if the length of the coordinates
array is
not equal to the number of dimensions associated
with the lookup table.NullPointerException
- if any parameter is null
or exhibits any
element, which is null
.IndexOutOfBoundsException
public final double getValue(FracIndex[] fracIndexes, double[] v)
fracIndexes
- workspace array of (at least) the same length as coordinates
.v
- workspace array of (at least) length 1 << coordinates.length
.ArrayIndexOutOfBoundsException
- if the fracIndexes
and v
arrays
do not have proper length.IllegalArgumentException
- if the length of the coordinates
array is
not equal to the number of dimensions associated
with the lookup table.NullPointerException
- if any parameter is null
or exhibits any
element, which is null
.public final double[] getValues(FracIndex[] fracIndexes)
fracIndexes
- workspace array of length coordinates - 1
.ArrayIndexOutOfBoundsException
- if the fracIndexes
and v
arrays
do not have proper length.IllegalArgumentException
- if the length of the coordinates
array is
not exactly one less than the number of dimensions associated
with the lookup table.NullPointerException
- if fracIndexes
is null
or exhibits any
element, which is null
.public static final void computeFracIndex(IntervalPartition partition, double coordinate, FracIndex fracIndex)
FracIndex
of a coordinate value with respect to a given
interval partition. The integral component of the returned FracIndex
corresponds to the index of the maximum partition member which is less than
or equal to the coordinate value. The [0, 1) fractional component describes
the position of the coordinate value within its bracketing subinterval.
Exception: If the given coordinate value is equal to the partition maximum,
the fractional component of the returned FracIndex
is equal to 1.0,
and the integral component is set to the index of the next to last partition
member.
partition
- the interval partition.coordinate
- the coordinate value. If the coordinate value is less (greater)
than the minimum (maximum) of the given interval partition,
the returned FracIndex
is the same as if the coordinate.
value was equal to the partition minimum (maximum).fracIndex
- the FracIndex
.Copyright © 2014–2017 European Space Agency (ESA). All rights reserved.