Class Spline2DInterpolate
- All Implemented Interfaces:
Serializable,Cloneable
The class Spline2DInterpolate computes a tensor-product spline
interpolant. The tensor-product spline interpolant to data
\(\{(x_i, y_j, f_{ij})\}\), where
\(0 \le i \le (n_x - 1)\) and
\(0 \le j \le (n_y - 1)\) has the form
$$\sum_{m=0}^{n_y - 1} \sum_{n=0}^{n_x-1} c_{nm}B_{n,k_x,t_x}(x) B_{m,k_y,t_y}(y)$$
where \(k_x \) and \(k_y\) are the orders of
the splines. These numbers are defaulted to be 4, but can be set to any
positive integer using xOrder and yOrder in the constructor. Likewise, \(t_x\)
and \(t_y\) are the corresponding knot sequences (xKnots and
yKnots). These default values are selected by
Spline2DInterpolate. The algorithm requires that
$$t_x(k_x - 1) \le x_i \le t_x(n_x)\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,0 \le i \le n_x -1$$
$$t_y(k_y - 1) \le y_j \le t_y(n_y - 1)\,\,\,\,\,\,\,\,\,\,\,0 \le j \le n_y -1$$
Tensor-product spline interpolants in two dimensions can be computed quite
efficiently by solving (repeatedly) two univariate interpolation problems.
The computation is motivated by the following observations. It is necessary
to solve the system of equations
$$\sum_{m=0}^{n_y - 1} \sum_{n=0}^{n_x-1} c_{nm}B_{n,k_x,t_x}(x_i) B_{m,k_y,t_y}(y_j) = f_{ij}$$
Setting
$$h_{mi} = \sum_{n=0}^{n_x-1} c_{nm}B_{n,k_x,t_x}(x_i) $$
note that for each fixed i from 0 to \(n_x - 1\), we
have \(n_y\) linear equations in the same number of
unknowns as can be seen below:
$$\sum_{m=0}^{n_y - 1} h_{mi}B_{m,k_y,t_y}(y_j) = f_{ij}$$
$$\sum_{m=0}^{n_y - 1} \sum_{n=0}^{n_x-1} c_{nm}B_{n,k_x,t_x}(x_i) B_{m,k_y,t_y}(y_j) = f_{ij}$$
Setting
$$h_{mi} = \sum_{n=0}^{n_x-1} c_{nm}B_{m,k_x,t_x}(x_i)$$
note that for each fixed i from 0 to \(n_x - 1\), we
have \(n_y - 1\) linear equations in the same number of
unknowns as can be seen below:
$$\sum_{m=0}^{n_y - 1} h_{mi}B_{n,k_y,t_y}(y_j) = f_{ij}$$
The same matrix appears in all of the equations above:
$$\bigl[ B_{m,k_y,t_y}(y_j)\bigr]\,\,\,\,\,\,\,\,\,\,\, 0 \le m,j \le n_y - 1$$
Thus, only factor this matrix once and then apply this factorization to the
\(n_x\) right-hand sides. Once this is done and
\(h_{mi}\) is computed, then solve for the coefficients
\(c_{nm}\) using the relation
$$\sum_{n=0}^{n_x-1} c_{nm}B_{n,k_x,t_x}(x_i) = h_{mi}$$
for n from 0 to \(n_y - 1\), which again involves
one factorization and \(n_y\) solutions to the different
right-hand sides. The class Spline2DInterpolate is based on the
routine SPLI2D by de Boor (1978, p. 347).
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSpline2DInterpolate(double[] xData, double[] yData, double[][] fData) Constructor forSpline2DInterpolate.Spline2DInterpolate(double[] xData, double[] yData, double[][] fData, int xOrder, int yOrder) Constructor forSpline2DInterpolate.Spline2DInterpolate(double[] xData, double[] yData, double[][] fData, int xOrder, int yOrder, double[] xKnots, double[] yKnots) Constructor forSpline2DInterpolate. -
Method Summary
Methods inherited from class com.imsl.math.Spline2D
derivative, derivative, getCoefficients, getXKnots, getYKnots, integral, value, value
-
Constructor Details
-
Spline2DInterpolate
public Spline2DInterpolate(double[] xData, double[] yData, double[][] fData) Constructor forSpline2DInterpolate.- Parameters:
xData- adoublearray containing the data points in the x-direction.yData- adoublearray containing the data points in the y-direction.fData- adoublematrix of sizexData.lengthbyyData.lengthcontaining the values to be interpolated.
-
Spline2DInterpolate
public Spline2DInterpolate(double[] xData, double[] yData, double[][] fData, int xOrder, int yOrder) Constructor forSpline2DInterpolate.- Parameters:
xData- adoublearray containing the data points in the x-direction.yData- adoublearray containing the data points in the y-direction.fData- adoublematrix of sizexData.lengthbyyData.lengthcontaining the values to be interpolated.xOrder- anintscalar value specifying the order of the spline in the x-direction.xOrdermust be at least 1. Default:xOrder= 4, tensor-product cubic spline.yOrder- anintscalar value specifying the order of the spline in the y-direction.yOrdermust be at least 1. Default:yOrder= 4, tensor-product cubic spline.
-
Spline2DInterpolate
public Spline2DInterpolate(double[] xData, double[] yData, double[][] fData, int xOrder, int yOrder, double[] xKnots, double[] yKnots) Constructor forSpline2DInterpolate.- Parameters:
xData- adoublearray containing the data points in the x-direction.yData- adoublearray containing the data points in the y-direction.fData- adoublematrix of sizexData.lengthbyyData.lengthcontaining the values to be interpolated.xOrder- anintscalar value specifying the order of the spline in the x-direction.xOrdermust be at least 1. Default:xOrder= 4, tensor-product cubic spline.yOrder- anintscalar value specifying the order of the spline in the y-direction.yOrdermust be at least 1. Default:yOrder= 4, tensor-product cubic spline.xKnots- adoublearray of sizexData.length + xOrderspecifying the knot sequences of the spline in the x-direction. Default knot sequences are selected by the class.yKnots- adoublearray of sizeyData.length + yOrderspecifying the knot sequences of the spline in the y-direction. Default knot sequences are selected by the class.
-