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 cubic splines.
This is a stripped down version of BiCubicSpline in which all the data checking statements and methods have been removed both from this class and from the CubicSplineFast class 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 two 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.
CONSTRUCTOR public BiCubicSplineFast(double[] x1, double[] x2, double[][] y) Usage:
BiCubicSplineFast aa = new BiCubicSplineFast(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)';
}
}
METHODS
INTERPOLATION public double interpolate(double xx1, double xx2) Usage:
y1 = aa.interpolate(xx1, xx2);
Returns the interpolated value of y, y1, for given values of xx1 and xx2, using 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. 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.
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: .