Michael Thomas Flanagan's Java Scientific Library

PolyCubicSplineFast Class:      Multi-dimensional Cubic Spline Interpolation (fast version)

     

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

This class contains the constructor and method for performing a multi-dimensional cubic spline interpolation, i.e. an interpolation within a n-dimensional array of data points, y = f(x1,x2,x3 . . . xn), using a natural cubic splines and where n may take any integer value. The interpolation procedure is recursive.

This is a stripped down version of PolyCubicSpline in which all the data checking statements and methods have been removed both from this class and from the BiCubicSplineFast and CubicSplineFast classes which it calls. This removal allows a faster execution time. The decrease in execution time may be significant if repeated interpolation within very large data arrays is required. However the user must ensure that all the multi-dimensional data arrays x-values are in ascending order, that there are adequate numbers of data points and that the x-values of the point for which an interpolated y-value is required lie within the bounds of the supplied data.

If the number of dimension, n, of the data array, y = f(x1,x2,x3 . . . xn), is less than three you may find CubicSplineFast [n = 1] and BiCubicSplineFast [n = 2] more convenient and these classes are slightly more efficient.

import directive: import flanagan.interpolation.PolyCubicSplineFast;

SUMMARY OF CONSTRUCTOR AND METHODS

Constructor public PolyCubicSplineFast(Object xValues, Object yValues)
Interpolate public double interpolate(double[] xCoordinates)



CONSTRUCTOR

CONSTRUCTOR
public PolyCubicSplineFast(Object xValues, Object yValues)
Usage:                      PolyCubicSplineFast aa = new PolyCubicSplineFast(xValues, yValues);
Creates an instance of the PolyCubicSplineFast object with its internal data arrays initialised the values in xValues and yValues containing the tabulated data for the arrays x1,x2,x3 . . . xn and for y = f(x1,x2,x3 . . . xn).
The argument xValues is a two dimensional array of doubles in which xValues[0] is the array of x1 values, i.e. {xValue[0][0] to xValue[0][p-1]}, xValues[1] is the array of x2 values i.e. {xValue[1][0] to xValue[1][q-1]}, . . . and xValues[n-1] is the array of xn i.e. {xValue[n-1][0] to xValue[n-1][r-1]} where there are p values x1, q values of x2, ..... r values of xn.
The argument yValues is an n-dimensional array of doubles containing the tabulated values of y = f(x1,x2,x3 . . . xn). The yValues elements are ordered 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++){
                            for(int m=0; m<x5.length; m++){
                                   yValues[i][j][k][l][m] = 'read statement' or 'calculation of f(x1, x2, x3, x4, x5)';
                            }
                     }
              }
       }
}



METHODS

INTERPOLATION
public double interpolate(double[] xCoordinates)
Usage:                      y1 = aa.interpolate(xx);
Returns the interpolated value of y, y1, for n given values of x1, x2, x3 . . . xn, entered as the two dimensional array, xx, using the y = f(x1,x2,x3 . . . xn) data entered via the constructor. This method may be called as often as required. The interpolation procedure is recursive. g the y = f(x1,x2) 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.



EXAMPLE PROGAM

An example program may be found on PolyCubicSplineFastExample.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