NAG Library Routine Document
E01DAF
1 Purpose
E01DAF computes a bicubic spline interpolating surface through a set of data values, given on a rectangular grid in the - plane.
2 Specification
SUBROUTINE E01DAF ( |
MX, MY, X, Y, F, PX, PY, LAMDA, MU, C, WRK, IFAIL) |
INTEGER |
MX, MY, PX, PY, IFAIL |
REAL (KIND=nag_wp) |
X(MX), Y(MY), F(MX*MY), LAMDA(MX+4), MU(MY+4), C(MX*MY), WRK((MX+6)*(MY+6)) |
|
3 Description
E01DAF determines a bicubic spline interpolant to the set of data points
, for
and
. The spline is given in the B-spline representation
such that
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.
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
E02DEF,
E02DFF or
E02DHF as described in
Section 9.3.
4 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
5 Parameters
- 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.
Constraint:
and .
- 3: – REAL (KIND=nag_wp) arrayInput
- 4: – REAL (KIND=nag_wp) arrayInput
-
On entry: and must contain , for , and
, for , respectively.
Constraints:
- , 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
and
needed for the B-spline representation.
- 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
,
. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value 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).
6 Error 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, either the values in the
X array or the values in the
Y array are not in increasing order if not already there.
-
A system of linear equations defining the B-spline coefficients was singular; the problem is too ill-conditioned to permit solution.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.8 in the Essential Introduction for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction for further information.
7 Accuracy
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.
8 Parallelism and Performance
E01DAF is not threaded by NAG in any implementation.
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 .
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 by rectangular matrix of values , and denotes an by 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 by 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.
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:
IFAIL = 0
CALL E02DEF(M,PX,PY,X,Y,LAMDA,MU,C,FF,WRK,IWRK,IFAIL)
where
and the coordinates
,
are stored in
,
.
PX and
PY,
LAMDA,
MU and
C have the same values as
PX and
PY
LAMDA,
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
.
(See
E02DEF.)
To evaluate the computed spline on an
by
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:
IFAIL = 0
CALL E02DFF(MX,MY,PX,PY,X,Y,LAMDA,MU,C,FG,WRK,LWRK,
* IWRK,LIWRK,IFAIL)
where
,
.
PX and
PY,
LAMDA,
MU and
C have the same values as
PX,
PY,
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.
10 Example
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.
10.1 Program Text
Program Text (e01dafe.f90)
10.2 Program Data
Program Data (e01dafe.d)
10.3 Program Results
Program Results (e01dafe.r)