Michael Thomas Flanagan's Java Scientific Library

QuadriCubicSpline Class:      Quadricubic Spline Interpolation

     

Last update: 31 October 2009                                                                                                                              PERMISSION TO COPY
Main Page of Michael Thomas Flanagan's Java Scientific Library

This class contains the constructor and methods for performing an interpolation within a four dimensional array of data points, y = f(x1,x2,x3, x4), using a natural quadricubic spline.

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

import directive: import flanagan.interpolation.QuadriCubicSpline;

SUMMARY OF CONSTRUCTOR AND METHODS

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



CONSTRUCTOR

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



METHODS

INTERPOLATION
public double interpolate(double xx1, double xx2, double xx3, double xx4)
Usage:                      y1 = aa.interpolate(xx1, xx2, xx3, xx4);
Returns the interpolated value of y, y1, for given values of xx1, xx2, xx3 and xx4, using the y=f(x1, x2, x3, x4) 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, xx3 or xx4 is outside the range of the values of x1[], x2[], x3[] or x4[] supplied to the constructor or if two x1, x2, x3 or x4 values within the y = f(x1,x2,x3,x4) data set are identical.



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



OTHER CLASSES USED BY THIS CLASS

This class uses the following classes in this library:


PERMISSION TO COPY

Permission to use, copy and modify this software and its documentation for NON-COMMERCIAL purposes is granted, without fee, provided that an acknowledgement to the author, Dr Michael Thomas Flanagan at www.ee.ucl.ac.uk/~mflanaga, appears in all copies and associated documentation or publications. Dr Michael Thomas Flanagan makes no representations about the suitability or fitness of the software for any or for a particular purpose. Dr Michael Thomas Flanagan shall not be liable for any damages suffered as a result of using, modifying or distributing this software or its derivatives.

Redistributions of the source code of this class, or parts of the source codes, must retain the copyright notice, this list of conditions and the following disclaimer (all at the top of the source code) and requires written permission from the Michael Thomas Flanagan:

Redistribution in binary form of all or parts of this class must reproduce the copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution and requires written permission from the Michael Thomas Flanagan:
.



This page was prepared by Dr Michael Thomas Flanagan