The routine may be called by the names e01daf or nagf_interp_dim2_spline_grid.
e01daf determines a bicubic spline interpolant to the set of data points
, for and . The spline is given in the B-spline representation
where and denote normalized cubic B-splines, the former defined on the knots to and the latter on the knots to , and the are the spline coefficients. These knots, as well as the coefficients, are determined by the routine, which is derived from the routine B2IRE in Anthony et al. (1982). The method used is described in Section 9.2.
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. Theory6 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
1: – IntegerInput
2: – IntegerInput
On entry: mx and my must specify and respectively, the number of points along the and axis that define the rectangular grid.
3: – Real (Kind=nag_wp) arrayInput
4: – Real (Kind=nag_wp) arrayInput
On entry: and must contain , for , and
, for , respectively.
, for ;
, for .
5: – Real (Kind=nag_wp) arrayInput
On entry: must contain , for and .
6: – IntegerOutput
7: – IntegerOutput
On exit: px and py contain and , the total number of knots of the computed spline with respect to the and variables, respectively.
8: – Real (Kind=nag_wp) arrayOutput
9: – Real (Kind=nag_wp) arrayOutput
On exit: lamda contains the complete set of knots associated with the variable, i.e., the interior knots , as well as the additional knots
needed for the B-spline representation.
In a similar way, mu contains the set of knots associated with the variable.
10: – Real (Kind=nag_wp) arrayOutput
On exit: the coefficients of the spline interpolant. contains the coefficient described in Section 3.
11: – Real (Kind=nag_wp) arrayWorkspace
12: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or is used it is essential to test the value of ifail on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
On entry, .
On entry, .
On entry, the x or the y mesh points are not in strictly ascending order.
An intermediate set of linear equations is singular – the data is too ill-conditioned to compute -spline coefficients.
An unexpected error has been triggered by this routine. Please
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
The main sources of rounding errors are in steps , , and of the algorithm described in Section 9.2. It can be shown (see Cox (1975)) that the matrix formed in step has elements differing relatively from their true values by at most a small multiple of , where is the machine precision. 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 and . Thus the complete process is numerically stable.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
e01daf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.
The time taken by e01daf is approximately proportional to .
9.2Outline of Method Used
The process of computing the spline consists of the following steps:
1.choice of the interior -knots , as , for ,
2.formation of the system
where is a band matrix of order and bandwidth , containing in its th row the values at of the B-splines in , is the rectangular matrix of values , and denotes an 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 ,
5.choice of the interior knots , as , for ,
6.formation of the system
where is the counterpart of for the variable, and denotes the rectangular matrix of values of ,
7.use of Gaussian elimination to reduce this system to band triangular form,
8.solution of this triangular system for and hence .
For computational convenience, steps and , and likewise steps and , are combined so that the formation of and and the reductions to triangular form are carried out one row at a time.
9.3Evaluation of Computed Spline
The values of the computed spline at the points , for , may be obtained
in the real array ff (see e02def), of length at least , by the following call:
where and the coordinates , are stored in , .
PX and PY,
LAMDA, MU and C have the same values as
px and pylamda, mu and c output from e01daf.
WRK is a real workspace array of length at least PY, and IWRK is an integer workspace array of length at least .
To evaluate the computed spline on an rectangular grid of points in the - plane, which is defined by the coordinates stored in , for , and the coordinates stored in , for
, returning the results in the real array ff (see e02dff) which is of length at least , the following call may be used:
where , .
PX and PY,
LAMDA, MU and C have the same values as
lamda, mu and c output from e01daf.
WRK is a real workspace array of length at least , for , , and IWRK is an integer workspace array of length at least if , or otherwise.
The result of the spline evaluated at grid point is returned in element () of the array FG.
This example reads in values of , , for , and , for , followed by values of the ordinates defined at the grid points .
It then calls e01daf 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.