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.
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.
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: .