The routine may be called by the names e01baf or nagf_interp_dim1_spline.
3Description
e01baf determines a cubic spline , defined in the range , which interpolates (passes exactly through) the set of data points , for , where and . Unlike some other spline interpolation algorithms, derivative end conditions are not imposed. The spline interpolant chosen has interior knots , which are set to the values of respectively. This spline is represented in its B-spline form (see Cox (1975)):
where denotes the normalized B-spline of degree ,
defined upon the knots , and denotes its coefficient, whose value is to be determined by the routine.
The use of B-splines requires eight additional knots , ,
, ,
, ,
and to be specified; e01baf sets the first four of these to
and the last four to .
The algorithm for determining the coefficients is as described in
Cox (1975) except that factorization is used instead of decomposition. The implementation of the algorithm involves setting up appropriate information for the related
routine e02baf followed by a call of that routine. (See e02baf for further details.)
Values of the spline interpolant, or of its derivatives or definite integral, can subsequently be computed as detailed in
Section 9.
4References
Cox M G (1975) An algorithm for spline interpolation J. Inst. Math. Appl.15 95–108
Cox M G (1977) A survey of numerical methods for data and function approximation The State of the Art in Numerical Analysis (ed D A H Jacobs) 627–668 Academic Press
5Arguments
1: – IntegerInput
On entry: , the number of data points.
Constraint:
.
2: – Real (Kind=nag_wp) arrayInput
On entry: must be set to , the th data value of the independent variable , for .
Constraint:
, for .
3: – Real (Kind=nag_wp) arrayInput
On entry: must be set to , the th data value of the dependent variable , for .
4: – Real (Kind=nag_wp) arrayOutput
On exit: the value of
, the th knot, for .
5: – Real (Kind=nag_wp) arrayOutput
On exit: the coefficient
of the B-spline , for . The remaining elements of the array are not used.
6: – IntegerInput
On entry: the dimension of the arrays lamda and c as declared in the (sub)program from which e01baf is called.
Constraint:
.
7: – Real (Kind=nag_wp) arrayWorkspace
8: – IntegerInput
On entry: the dimension of the array wrk as declared in the (sub)program from which e01baf is called.
Constraint:
.
9: – 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, and .
Constraint: .
On entry, lwrk is too small. . Minimum possible dimension: .
On entry, .
Constraint: .
On entry, , and .
Constraint: .
An unexpected error has been triggered by this routine. Please
contact NAG.
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.
7Accuracy
The rounding errors incurred are such that the computed spline is an exact interpolant for a slightly perturbed set of ordinates . The ratio of the root-mean-square value of the to that of the is no greater than a small multiple of the relative machine precision.
8Parallelism and Performance
e01baf is not threaded in any implementation.
9Further Comments
The time taken by e01baf is approximately proportional to .
All the are used as knot positions except and . This choice of knots
(see Cox (1977)) means that is composed of cubic arcs as follows. If , there is just a single arc space spanning the whole interval to . If , the first and last arcs span the intervals to and to respectively. Additionally if , the th arc, for , spans the interval to .
This example sets up data from values of the exponential function in the interval to . e01baf is then called to compute a spline interpolant to these data.
The spline is evaluated by e02bbf, at the data points and at points halfway between each adjacent pair of data points, and the spline values and the values of are printed out.