com.isti.util.bilinearinterp
Class BilinearInterp

java.lang.Object
  extended by com.isti.util.bilinearinterp.BilinearInterp

public class BilinearInterp
extends java.lang.Object

Class BilinearInterp calculate results via bilinear interpolation. The class is instantiated with two-dimensional data from an input stream. The formulas used are described as "bilinear interpolation" in the book "Numerical Recipies in C".


Nested Class Summary
 class BilinearInterp.ResultBlock
          Class ResultBlock holds result of a bilinear interpolation operation.
 
Constructor Summary
BilinearInterp(java.io.Reader readerObj)
          Constructs an object for calculating the results of bilinear interpolations using a given data set.
 
Method Summary
 int getDataColSize()
          Returns the data grid "column" size.
 int getDataRowSize()
          Returns the data grid "row" size.
 boolean getErrorFlag()
          Returns true if an error was detected in the data set used to construct this object.
 java.lang.String getErrorMessage()
          Returns the text message associated with the first error detected in the data set used to construct this object.
 double getMaxX1Value()
          Returns the maximum 'x1' values in the data set.
 double getMaxX2Value()
          Returns the maximum 'x2' values in the data set.
 double getMinX1Value()
          Returns the minimum 'x1' values in the data set.
 double getMinX2Value()
          Returns the minimum 'x2' values in the data set.
 BilinearInterp.ResultBlock[] interpolateMultiString(java.lang.String valuesStr)
          Calculates, via bilinear interpolation, a set of resultant values given one or more sets of data value pairs, using the data set held by this object.
 BilinearInterp.ResultBlock interpolateValues(double x1Val, double x2Val)
          Calculates, via bilinear interpolation, a resultant value given the two data values and the data set held by this object.
static void main(java.lang.String[] args)
          Test program for class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BilinearInterp

public BilinearInterp(java.io.Reader readerObj)
Constructs an object for calculating the results of bilinear interpolations using a given data set. If an error was detected in the given data set, the 'getErrorFlag()' method will return 'true' and the 'getErrorMessage()' method will report the error message text.

Parameters:
readerObj - an input stream Reader object references a data set made up of lines in the following format: x1 x2 y where 'y' is the result value for the given (x1,x2) point, and the set of x1,x2 values must define a "grid" pattern.
Method Detail

getErrorFlag

public boolean getErrorFlag()
Returns true if an error was detected in the data set used to construct this object.

Returns:
true if an error was detected in the data set used to construct this object.

getErrorMessage

public java.lang.String getErrorMessage()
Returns the text message associated with the first error detected in the data set used to construct this object.

Returns:
the text message associated with the first error detected in the data set used to construct this object.

interpolateValues

public BilinearInterp.ResultBlock interpolateValues(double x1Val,
                                                    double x2Val)
Calculates, via bilinear interpolation, a resultant value given the two data values and the data set held by this object.

Parameters:
x1Val - the given 'x1' data value.
x2Val - the given 'x2' data value.
Returns:
A 'ResultBlock' object holding the resultant value or with error flag(s) set to true.

interpolateMultiString

public BilinearInterp.ResultBlock[] interpolateMultiString(java.lang.String valuesStr)
Calculates, via bilinear interpolation, a set of resultant values given one or more sets of data value pairs, using the data set held by this object. This method uses a very "friendly" parse, in that any characters that cannot be part of a valid numeric value are simply ignored.

Parameters:
valuesStr - a string containing pairs of numeric strings representing sets of (x1,x2) values.
Returns:
An array of 'ResultBlock' objects holding the resultant values or with error flag(s) set to true. If a parsing error occurs anywhere in the given 'valuesStr' string then the returned array will contain a single 'ResultBlock' object holding the error message.

getDataRowSize

public int getDataRowSize()
Returns the data grid "row" size.

Returns:
the data grid "row" size.

getDataColSize

public int getDataColSize()
Returns the data grid "column" size.

Returns:
the data grid "column" size.

getMinX1Value

public double getMinX1Value()
Returns the minimum 'x1' values in the data set.

Returns:
the minimum 'x1' values in the data set.

getMaxX1Value

public double getMaxX1Value()
Returns the maximum 'x1' values in the data set.

Returns:
the maximum 'x1' values in the data set.

getMinX2Value

public double getMinX2Value()
Returns the minimum 'x2' values in the data set.

Returns:
the minimum 'x2' values in the data set.

getMaxX2Value

public double getMaxX2Value()
Returns the maximum 'x2' values in the data set.

Returns:
the maximum 'x2' values in the data set.

main

public static void main(java.lang.String[] args)
Test program for class.

Parameters:
args - arguments