Package com.imsl.math

Class Spline2DInterpolate

java.lang.Object
com.imsl.math.Spline2D
com.imsl.math.Spline2DInterpolate
All Implemented Interfaces:
Serializable, Cloneable

public class Spline2DInterpolate extends Spline2D
Computes a two-dimensional, tensor-product spline interpolant from two-dimensional, tensor-product data.

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 Details

    • Spline2DInterpolate

      public Spline2DInterpolate(double[] xData, double[] yData, double[][] fData)
      Constructor for Spline2DInterpolate.
      Parameters:
      xData - a double array containing the data points in the x-direction.
      yData - a double array containing the data points in the y-direction.
      fData - a double matrix of size xData.length by yData.length containing the values to be interpolated.
    • Spline2DInterpolate

      public Spline2DInterpolate(double[] xData, double[] yData, double[][] fData, int xOrder, int yOrder)
      Constructor for Spline2DInterpolate.
      Parameters:
      xData - a double array containing the data points in the x-direction.
      yData - a double array containing the data points in the y-direction.
      fData - a double matrix of size xData.length by yData.length containing the values to be interpolated.
      xOrder - an int scalar value specifying the order of the spline in the x-direction. xOrder must be at least 1. Default: xOrder = 4, tensor-product cubic spline.
      yOrder - an int scalar value specifying the order of the spline in the y-direction. yOrder must 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 for Spline2DInterpolate.
      Parameters:
      xData - a double array containing the data points in the x-direction.
      yData - a double array containing the data points in the y-direction.
      fData - a double matrix of size xData.length by yData.length containing the values to be interpolated.
      xOrder - an int scalar value specifying the order of the spline in the x-direction. xOrder must be at least 1. Default: xOrder = 4, tensor-product cubic spline.
      yOrder - an int scalar value specifying the order of the spline in the y-direction. yOrder must be at least 1. Default: yOrder = 4, tensor-product cubic spline.
      xKnots - a double array of size xData.length + xOrder specifying the knot sequences of the spline in the x-direction. Default knot sequences are selected by the class.
      yKnots - a double array of size yData.length + yOrder specifying the knot sequences of the spline in the y-direction. Default knot sequences are selected by the class.