Michael Thomas Flanagan's Java Scientific Library

BiCubicSplineFast Class:     BiCubic 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 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.

import directive: import flanagan.interpolation.BiCubicSplineFast;

SUMMARY OF CONSTRUCTOR AND METHODS

Constructor public BiCubicSplineFast(double[] x1, double[] x2, double[][] y)
Interpolate public double interpolate(double xx1, double xx2)



CONSTRUCTOR

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.



EXAMPLE PROGAM

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