Michael Thomas Flanagan's Java Scientific Library

TriCubicSpline Class:      Tricubic Spline Interpolation

     

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 three dimensional array of data points, y = f(x1,x2,x3), using a natural tricubic spline.

The inner interpolations at the bicubic spline level are obtained as the mean of the values obtained for the two dimensional tabulated values submatrix and for its transpose. At higher levels the only interpolations performed are on the data as entered.

The class, PolyCubicSplineFast, may be faster if repeated interpolation within large data arrays is to be performed.

See TriCubicInterpolation for a general tricubic interpolation method.

import directive: import flanagan.interpolation.TriCubicSpline;

SUMMARY OF CONSTRUCTOR AND METHODS

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



CONSTRUCTOR

CONSTRUCTOR
public TriCubicSpline(double[] x1, double[] x2, double[] x3, double[][][] y)
Usage:                      TriCubicSpline aa = new TriCubicSpline(x1, x2, x3, y);
Creates an instance of the TriCubicSpline object with its internal data arrays initialised to copies of the values in the x1, x2, x3 and y arrays where y is the tabulated function y = f(x1, x2). The variables x1, x2 and x3 are are one dimensional arrays of type double and y is an three-dimensional array of doubles containing the tabulated values of y = f(x1,x2,x3 . . . xn). The y elements are ordered as {{{f(x1[0],x2[0],x3[0] . . . f(x1[0],x2[0],x3[r-1]} {{f(x1[0],x2[1],x3[0] . . . f(x1[0],x2[1],x3[r-1]} ......{f(x1[0],x2[q-1],x3[0] . . . f(x1[0],x2[q-1],x3[r-1]} } ... etc.
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++){
              for(int k=0; k<x3.length; k++){
                     yValues[i][j][k]= 'read statement' or 'calculation of f(x1, x2, x3)';
              }
       }
}



METHODS

INTERPOLATION
public double interpolate(double xx1, double xx2, double xx3)
Usage:                      y1 = aa.interpolate(xx1, xx2, xx3);
Returns the interpolated value of y, y1, for given values of xx1, xx2 and xx3, using the y=f(x1, x2, x3) data entered via the constructor. This method may be called as often as required. The inner second derivatives needed for the interpolation are calculated and stored on instantiation so that they need not be recalculated on each call to this method. This method throws an IllegalArgumentException if xx1, xx2 or xx3 is outside the range of the values of x1[], x2[] or x3[] supplied to the constructor or if two x1, x2 or x3 values within the y = f(x1, x2,x3) data set are identical.



ROUNDING ERROR OPTIONS
public static void noRoundingErrorCheck()
Usage:                      TriCubicSpline.noRoundingErrorCheck();
Seveveral applications that call TriCubicSpline, 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 TriCubicSpline 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:                      TriCubicSpline.potentialRoundingError(potentialRoundingError);
Seveveral applications that call TriCubicSpline, 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 TriCubicSpline 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

TriCubicExampleOne

This program uses calculated data and compares the interpolated y values obtained using This example program may be found on TriCubicExampleOne.java



This page was prepared by Dr Michael Thomas Flanagan