org.esa.beam.util.math
Class LookupTable

java.lang.Object
  extended by org.esa.beam.util.math.LookupTable

public class LookupTable
extends Object

The class 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)

Version:
$Revision$ $Date$
Author:
Ralf Quast

Constructor Summary
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.
 
Method Summary
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.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LookupTable

public LookupTable(double[] values,
                   IntervalPartition... dimensions)
Constructs a lookup table for the lookup values and dimensions supplied as arguments.

Parameters:
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.
Throws:
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.

LookupTable

public LookupTable(float[] values,
                   IntervalPartition... dimensions)
Constructs a lookup table for the lookup values and dimensions supplied as arguments.

Parameters:
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.
Throws:
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.

LookupTable

public LookupTable(double[] values,
                   double[]... dimensions)
Constructs a lookup table for the lookup values and dimensions supplied as arguments.

Parameters:
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.
Throws:
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.

LookupTable

public LookupTable(float[] values,
                   float[]... dimensions)
Constructs a lookup table for the lookup values and dimensions supplied as arguments.

Parameters:
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.
Throws:
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.
Method Detail

getDimensionCount

public final int getDimensionCount()
Returns the number of dimensions associated with the lookup table.

Returns:
the number of dimensions.

getDimensions

public final IntervalPartition[] getDimensions()
Returns the dimensions associated with the lookup table.

Returns:
the dimensions.

getDimension

public final IntervalPartition getDimension(int i)
Returns the the ith dimension associated with the lookup table.

Parameters:
i - the index number of the dimension of interest
Returns:
the ith dimension.

getValue

public final double getValue(double... coordinates)
                      throws IllegalArgumentException,
                             NullPointerException
Returns an interpolated value for the given coordinates.

Parameters:
coordinates - the coordinates of the lookup point.
Returns:
the interpolated value.
Throws:
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.

getValue

public final double getValue(double[] coordinates,
                             FracIndex[] fracIndexes,
                             double[] v)
                      throws IllegalArgumentException,
                             IndexOutOfBoundsException,
                             NullPointerException
Returns an interpolated value for the given coordinates.

Parameters:
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.
Returns:
the interpolated value.
Throws:
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

getValue

public final double getValue(FracIndex[] fracIndexes,
                             double[] v)
Returns an interpolated value for the given fractional indices.

Parameters:
fracIndexes - workspace array of (at least) the same length as coordinates.
v - workspace array of (at least) length 1 << coordinates.length.
Returns:
the interpolated value.
Throws:
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.

computeFracIndex

public static final void computeFracIndex(IntervalPartition partition,
                                          double coordinate,
                                          FracIndex fracIndex)
Computes the 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.

Parameters:
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 © 2002-2013 Brockmann Consult GmbH. All Rights Reserved.