Michael Thomas Flanagan's Java Scientific Library

BiCubicSplineFirstDerivative Class:     BiCubic Spline Interpolation of First Derivatives

     

Last update: 11 September 2012                                                                                                                              Main Page of Michael Thomas Flanagan's Java Scientific Library

This class contains the constructor and methods for performing an interpolation within a two dimensional array of data points, y = f(x1,x2), using natural bicubic splines.
The interpolation method returns the interpolated value of y and of the two first derivatives, dy/dx1 and dy/dx2.

See also Gradient for the calculation of the bicubic spline interpolated first derivatives for each element of a 2D array.

import directive: import flanagan.interpolation.BiCubicSplineFirstDerivatives;

SUMMARY OF CONSTRUCTOR AND METHODS

Constructor public BiCubicSplineFirstDerivatives(double[] x1, double[] x2, double[][] y)
Interpolate public double[] interpolate(double xx1, double xx2)
Rounding Error Options public static void noRoundingErrorCheck()
public static void potentialRoundingError(double potentialRoundingError)



CONSTRUCTOR

CONSTRUCTOR
public BiCubicSplineFirstDerivatives(double[] x1, double[] x2, double[][] y)
Usage:                      BiCubicSpline aa = new BiCubicSpline(x1, x2, y);
Creates an instance of the BiCubicSpline object with its internal data arrays initialised to copies of the values in the x1, x2 and y arrays where y is the tabulated function y = f(x1,x2). The variables x1 and x2 are are one dimensional arrays of type double and y is a two dimensional array of type double. The y elements are ordered as {{f(x1[0],x2[0], . . . f(x1[0],x2[m-1]} {f(x1[1],x2[0] . . . f(x1[1],x2[m-1]} ......{f(x1[n-1],x2[0], . . . f(x1[n-1],x2[m-1]} } where m is the number of x1 values and n is the number of x2 values, i.e. as in the order of the following nested for loops if you were reading in or calculating the tabulated data:
for(int i=0; i<x1.length; i++){
       for(int j=0; j<x2.length; j++){
              yValues[i][j] = 'read statement' or 'calculation of f(x1, x2)';
       }
}

This construcor also creares and stores a transpose of y; yT = f(x2,x1),.



METHODS

INTERPOLATION
public double[] interpolate(double xx1, double xx2)
Usage:                      ret = aa.interpolate(x1, x2);
This method returns, for given values of x1 [argument x1] and x2 [argument x2], an array of doubles [ret] containing the following:
This method may be called as often as required. The second derivatives needed for the interpolation are calculated and stored on instantiation and are not recalculated on each call to this method. This method throws an IllegalArgumentException if xx1 or xx2 is outside the range of the values of x1[] or x2[] supplied to the constructor or if two x1 or x2 values within the y = f(x1,x2) data set are identical.



ROUNDING ERROR OPTIONS
public static void noRoundingErrorCheck()
Usage:                      BiCubicSpline.noRoundingErrorCheck();
Seveveral applications that call BiCubicSpline, e.g. plotting programs, may calculate an array of points to be fed to an instance of cubic spline that should lie between the limits initially supplied to the instance but which, due to rounding errors in the calculation of the array, may have extreme values that lie outside the limits by the an amount equal to the rounding error, e.g. an array that should lie between limits of 0 and 4 may run from 0 to 4.0000000000000003. The default option of the BiCubicSpline class is to check for such violations of the order of a rounding error and round the extreme value to the limit thus preventing an out of range exception being thrown. This method allows this default option to be ignored so that an out of range exception is thrown if any value lies outside he range of the limis no matter how small the violation is.

public static void potentialRoundingError(double potentialRoundingError)
Usage:                      BiCubicSpline.potentialRoundingError(potentialRoundingError);
Seveveral applications that call BiCubicSpline, e.g. plotting programs, may calculate an array of points to be fed to an instance of cubic spline that should lie between the limits initially supplied to the instance but which, due to rounding errors in the calculation of the array, may have extreme values that lie outside the limits by the an amount equal to the rounding error, e.g. an array that should lie between limits of 0 and 4 may run from 0 to 4.0000000000000003. The default option of the BiCubicSpline class is to check for such violations of the order of a rounding error and round the extreme value to the limit thus preventing an out of range exception being thrown. The default calculculation of the potential rounding error is the multiplication of 5x10-15 by 10 raised to the exponent of the value lying outside the limits. This method allows the value of 5x10-15 to be reset to the user's choice, potentialRoundingError.



EXAMPLE PROGAM

An example program may be found on BiCubicSplineExample.java



OTHER CLASSES USED BY THIS CLASS

This class uses the following classes in this library:


This page was prepared by Dr Michael Thomas Flanagan