NAG FL Interface
e02bbf (dim1_spline_eval)
1
Purpose
e02bbf evaluates a cubic spline from its B-spline representation.
2
Specification
Fortran Interface
Integer, Intent (In) |
:: |
ncap7 |
Integer, Intent (Inout) |
:: |
ifail |
Real (Kind=nag_wp), Intent (In) |
:: |
lamda(ncap7), c(ncap7), x |
Real (Kind=nag_wp), Intent (Out) |
:: |
s |
|
C Header Interface
#include <nag.h>
void |
e02bbf_ (const Integer *ncap7, const double lamda[], const double c[], const double *x, double *s, Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
e02bbf_ (const Integer &ncap7, const double lamda[], const double c[], const double &x, double &s, Integer &ifail) |
}
|
The routine may be called by the names e02bbf or nagf_fit_dim1_spline_eval.
3
Description
e02bbf evaluates the cubic spline
at a prescribed argument
from its augmented knot set
, for
, (see
e02baf) and from the coefficients
, for
in its B-spline representation
Here
, where
is the number of intervals of the spline, and
denotes the normalized B-spline of degree
defined upon the knots
. The prescribed argument
must satisfy
.
It is assumed that , for , and .
If
is a point at which
knots coincide,
is discontinuous at
; in this case,
s contains the value defined as
is approached from the right.
The method employed is that of evaluation by taking convex combinations due to
de Boor (1972). For further details of the algorithm and its use see
Cox (1972) and
Cox and Hayes (1973).
It is expected that a common use of
e02bbf will be the evaluation of the cubic spline approximations produced by
e02baf. A generalization of
e02bbf which also forms the derivative of
is
e02bcf.
e02bcf takes about
longer than
e02bbf.
4
References
Cox M G (1972) The numerical evaluation of B-splines J. Inst. Math. Appl. 10 134–149
Cox M G (1978) The numerical evaluation of a spline from its B-spline representation J. Inst. Math. Appl. 21 135–143
Cox M G and Hayes J G (1973) Curve fitting: a guide and suite of algorithms for the non-specialist user NPL Report NAC26 National Physical Laboratory
de Boor C (1972) On calculating with B-splines J. Approx. Theory 6 50–62
5
Arguments
-
1:
– Integer
Input
-
On entry: , where is the number of intervals (one greater than the number of interior knots, i.e., the knots strictly within the range to ) over which the spline is defined.
Constraint:
.
-
2:
– Real (Kind=nag_wp) array
Input
-
On entry: must be set to the value of the th member of the complete set of knots, , for .
Constraint:
the must be in nondecreasing order with .
-
3:
– Real (Kind=nag_wp) array
Input
-
On entry: the coefficient
of the B-spline , for . The remaining elements of the array are not referenced.
-
4:
– Real (Kind=nag_wp)
Input
-
On entry: the argument at which the cubic spline is to be evaluated.
Constraint:
.
-
5:
– Real (Kind=nag_wp)
Output
-
On exit: the value of the spline, .
-
6:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 4 in the Introduction to the NAG Library FL Interface 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 argument, 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, , and .
Constraint: .
On entry, and .
Constraint: .
-
On entry, .
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.
7
Accuracy
The computed value of
has negligible error in most practical situations. Specifically, this value has an
absolute error bounded in modulus by
, where
is the largest in modulus of
and
, and
is an integer such that
. If
and
are all of the same sign, then the computed value of
has a
relative error not exceeding
in modulus. For further details see
Cox (1978).
8
Parallelism and Performance
e02bbf is not threaded in any implementation.
The time taken is approximately
seconds, where
c is a machine-dependent constant.
Note: the routine does not test all the conditions on the knots given in the description of
lamda in
Section 5, since to do this would result in a computation time approximately linear in
instead of
. All the conditions are tested in
e02baf, however.
10
Example
Evaluate at nine equally-spaced points in the interval the cubic spline with (augmented) knots , , , , , , , , , , and normalized cubic B-spline coefficients , , , , , , .
The example program is written in a general form that will enable a cubic spline with intervals, in its normalized cubic B-spline form, to be evaluated at equally-spaced points in the interval . The program is self-starting in that any number of datasets may be supplied.
10.1
Program Text
10.2
Program Data
10.3
Program Results