e01da computes a bicubic spline interpolating surface through a set of data values, given on a rectangular grid in the x-y plane.

Syntax

C#
public static void e01da(
	int mx,
	int my,
	double[] x,
	double[] y,
	double[] f,
	out int px,
	out int py,
	double[] lamda,
	double[] mu,
	double[] c,
	out int ifail
)
Visual Basic
Public Shared Sub e01da ( _
	mx As Integer, _
	my As Integer, _
	x As Double(), _
	y As Double(), _
	f As Double(), _
	<OutAttribute> ByRef px As Integer, _
	<OutAttribute> ByRef py As Integer, _
	lamda As Double(), _
	mu As Double(), _
	c As Double(), _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void e01da(
	int mx, 
	int my, 
	array<double>^ x, 
	array<double>^ y, 
	array<double>^ f, 
	[OutAttribute] int% px, 
	[OutAttribute] int% py, 
	array<double>^ lamda, 
	array<double>^ mu, 
	array<double>^ c, 
	[OutAttribute] int% ifail
)
F#
static member e01da : 
        mx : int * 
        my : int * 
        x : float[] * 
        y : float[] * 
        f : float[] * 
        px : int byref * 
        py : int byref * 
        lamda : float[] * 
        mu : float[] * 
        c : float[] * 
        ifail : int byref -> unit 

Parameters

mx
Type: System..::..Int32
On entry: mx and my must specify mx and my respectively, the number of points along the x and y axis that define the rectangular grid.
Constraint: mx4 and my4.
my
Type: System..::..Int32
On entry: mx and my must specify mx and my respectively, the number of points along the x and y axis that define the rectangular grid.
Constraint: mx4 and my4.
x
Type: array<System..::..Double>[]()[][]
An array of size [mx]
On entry: x[q-1] and y[r-1] must contain xq, for q=1,2,,mx, and yr, for r=1,2,,my, respectively.
Constraints:
  • x[q-1]<x[q], for q=1,2,,mx-1;
  • y[r-1]<y[r], for r=1,2,,my-1.
y
Type: array<System..::..Double>[]()[][]
An array of size [mx]
On entry: x[q-1] and y[r-1] must contain xq, for q=1,2,,mx, and yr, for r=1,2,,my, respectively.
Constraints:
  • x[q-1]<x[q], for q=1,2,,mx-1;
  • y[r-1]<y[r], for r=1,2,,my-1.
f
Type: array<System..::..Double>[]()[][]
An array of size [mx×my]
On entry: f[my×q-1+r-1] must contain fq,r, for q=1,2,,mx and r=1,2,,my.
px
Type: System..::..Int32%
On exit: px and py contain mx+4 and my+4, the total number of knots of the computed spline with respect to the x and y variables, respectively.
py
Type: System..::..Int32%
On exit: px and py contain mx+4 and my+4, the total number of knots of the computed spline with respect to the x and y variables, respectively.
lamda
Type: array<System..::..Double>[]()[][]
An array of size [mx+4]
On exit: lamda contains the complete set of knots λi associated with the x variable, i.e., the interior knots lamda[4],lamda[5],,lamda[px-5], as well as the additional knots
lamda[0]=lamda[1]=lamda[2]=lamda[3]=x[0]
and
lamda[px-4]=lamda[px-3]=lamda[px-2]=lamda[px-1]=x[mx-1]
needed for the B-spline representation.
mu
Type: array<System..::..Double>[]()[][]
An array of size [mx+4]
On exit: lamda contains the complete set of knots λi associated with the x variable, i.e., the interior knots lamda[4],lamda[5],,lamda[px-5], as well as the additional knots
lamda[0]=lamda[1]=lamda[2]=lamda[3]=x[0]
and
lamda[px-4]=lamda[px-3]=lamda[px-2]=lamda[px-1]=x[mx-1]
needed for the B-spline representation.
c
Type: array<System..::..Double>[]()[][]
An array of size [mx×my]
On exit: the coefficients of the spline interpolant. c[my×i-1+j-1] contains the coefficient cij described in [Description].
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

e01da determines a bicubic spline interpolant to the set of data points xq,yr,fq,r, for q=1,2,,mx and r=1,2,,my. The spline is given in the B-spline representation
sx,y=i=1mxj=1mycijMixNjy,
such that
sxq,yr=fq,r,
where Mix and Njy denote normalized cubic B-splines, the former defined on the knots λi to λi+4 and the latter on the knots μj to μj+4, and the cij are the spline coefficients. These knots, as well as the coefficients, are determined by the method, which is derived from the method B2IRE in Anthony et al. (1982). The method used is described in [Outline of Method Used].
For further information on splines, see Hayes and Halliday (1974) for bicubic splines and de Boor (1972) for normalized B-splines.
Values and derivatives of the computed spline can subsequently be computed by calling e02de e02df (E02DHF not in this release) as described in [Evaluation of Computed Spline].

References

Anthony G T, Cox M G and Hayes J G (1982) DASL – Data Approximation Subroutine Library National Physical Laboratory
Cox M G (1975) An algorithm for spline interpolation J. Inst. Math. Appl. 15 95–108
de Boor C (1972) On calculating with B-splines J. Approx. Theory 6 50–62
Hayes J G and Halliday J (1974) The least squares fitting of cubic spline surfaces to general data sets J. Inst. Math. Appl. 14 89–103

Error Indicators and Warnings

Errors or warnings detected by the method:
ifail=1
On entry,mx<4,
ormy<4.
ifail=2
On entry, either the values in the x array or the values in the y array are not in increasing order if not already there.
ifail=3
A system of linear equations defining the B-spline coefficients was singular; the problem is too ill-conditioned to permit solution.
ifail=-9000
An error occured, see message report.
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

The main sources of rounding errors are in steps 2, 3, 6 and 7 of the algorithm described in [Outline of Method Used]. It can be shown (see Cox (1975)) that the matrix Ax formed in step 2 has elements differing relatively from their true values by at most a small multiple of 3ε, where ε is the machine precision. Ax is ‘totally positive’, and a linear system with such a coefficient matrix can be solved quite safely by elimination without pivoting. Similar comments apply to steps 6 and 7. Thus the complete process is numerically stable.

Parallelism and Performance

None.

Further Comments

Timing

The time taken by e01da is approximately proportional to mxmy.

Outline of Method Used

The process of computing the spline consists of the following steps:
1. choice of the interior x-knots λ5, λ6,,λmx as λi=xi-2, for i=5,6,,mx,
2. formation of the system
AxE=F,
where Ax is a band matrix of order mx and bandwidth 4, containing in its qth row the values at xq of the B-splines in x, f is the mx by my rectangular matrix of values fq,r, and E denotes an mx by my rectangular matrix of intermediate coefficients,
3. use of Gaussian elimination to reduce this system to band triangular form,
4. solution of this triangular system for E,
5. choice of the interior y knots μ5, μ6,,μmy as μi=yi-2, for i=5,6,,my,
6. formation of the system
AyCT=ET,
where Ay is the counterpart of Ax for the y variable, and C denotes the mx by my rectangular matrix of values of cij,
7. use of Gaussian elimination to reduce this system to band triangular form,
8. solution of this triangular system for CT and hence C.
For computational convenience, steps 2 and 3, and likewise steps 6 and 7, are combined so that the formation of Ax and Ay and the reductions to triangular form are carried out one row at a time.

Evaluation of Computed Spline

The values of the computed spline at the points xk,yk, for k=1,2,,m, may be obtained in the real array ff (see e02de), of length at least m, by the following call: where M=m and the coordinates xk, yk are stored in Xk, Yk. PX and PY, LAMDA, MU and C have the same values as px and py lamda, mu and c output from e01da. WRK is a real workspace array of length at least PY, and IWRK is an integer workspace array of length at least PY-4. (See e02de.)
To evaluate the computed spline on an mx by my rectangular grid of points in the x-y plane, which is defined by the x coordinates stored in Xj, for j=1,2,,mx, and the y coordinates stored in Yk, for k=1,2,,my, returning the results in the real array ff (see e02df) which is of length at least mx×my, the following call may be used: where MX=mx, MY=my. PX and PY, LAMDA, MU and C have the same values as px, py, lamda, mu and c output from e01da. WRK is a real workspace array of length at least LWRK=minnwrk1,nwrk2, for nwrk1=MX×4+PX, nwrk2=MY×4+PY, and IWRK is an integer workspace array of length at least LIWRK=MY+PY-4 if nwrk1>nwrk2, or MX+PX-4 otherwise.
The result of the spline evaluated at grid point j,k is returned in element (MY×j-1+k-1) of the array FG.

Example

This example reads in values of mx, xq, for q=1,2,,mx, my and yr, for r=1,2,,my, followed by values of the ordinates fq,r defined at the grid points xq,yr.
It then calls e01da to compute a bicubic spline interpolant of the data values, and prints the values of the knots and B-spline coefficients. Finally it evaluates the spline at a small sample of points on a rectangular grid.

Example program (C#): e01dae.cs

Example program data: e01dae.d

Example program results: e01dae.r

See Also