NAG Library Function Document
nag_1d_spline_evaluate (e02bbc) evaluates a cubic spline from its B-spline representation.
||nag_1d_spline_evaluate (double x,
evaluates the cubic spline
at a prescribed argument
from its augmented knot set
, (see nag_1d_spline_fit_knots (e02bac)
) and from the coefficients
, in its B-spline representation
is the number of intervals of the spline, and
denotes the normalized B-spline of degree 3 defined upon the knots
. The prescribed argument
It is assumed that , for , and .
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 (1978)
It is expected that a common use of nag_1d_spline_evaluate (e02bbc)
will be the evaluation of the cubic spline approximations produced by nag_1d_spline_fit_knots (e02bac)
. A generalization of nag_1d_spline_evaluate (e02bbc)
which also forms the derivative of
is nag_1d_spline_deriv (e02bcc)
. nag_1d_spline_deriv (e02bcc)
takes about 50% longer than nag_1d_spline_evaluate (e02bbc)
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
On entry: the argument at which the cubic spline is to be evaluated.
– double *Output
On exit: the value of the spline, .
– Nag_Spline *
Pointer to structure of type Nag_Spline with the following members:
- n – IntegerInput
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.
- lamda – double *Input
On entry: a pointer to which memory of size must be allocated. must be set to the value of the th member of the complete set of knots, for .
the must be in nondecreasing order with .
- c – double *Input
On entry: a pointer to which memory of size must be allocated. holds the coefficient of the B-spline , for .
Under normal usage, the call to nag_1d_spline_evaluate (e02bbc)
will follow a call to nag_1d_spline_fit_knots (e02bac)
, nag_1d_spline_interpolant (e01bac)
or nag_1d_spline_fit (e02bec)
. In that case, the structure spline
will have been set up correctly for input to nag_1d_spline_evaluate (e02bbc)
– NagError *Input/Output
The NAG error argument (see Section 3.7
in How to Use the NAG Library and its Documentation).
Error Indicators and Warnings
On entry, x
In this case s
is set arbitrarily to zero.
On entry, must not be less than 8: .
The computed value of
has negligible error in most practical situations. Specifically, this value has an absolute error bounded in modulus by machine precision
is the largest in modulus of
is an integer such that
are all of the same sign, then the computed value of
has a relative error not exceeding machine precision
in modulus. For further details see Cox (1978)
Parallelism and Performance
nag_1d_spline_evaluate (e02bbc) is not threaded in any implementation.
The time taken by nag_1d_spline_evaluate (e02bbc) is approximately C seconds, where C is a machine-dependent constant.
Note: the function does not test all the conditions on the knots given in the description of
in Section 5
, since to do this would result in a computation time approximately linear in
. All the conditions are tested in nag_1d_spline_fit_knots (e02bac)
, however, and the knots returned by nag_1d_spline_interpolant (e01bac)
or nag_1d_spline_fit (e02bec)
will satisfy the conditions.
Evaluate at 9 equally-spaced points in the interval the cubic spline with (augmented) knots 1.0, 1.0, 1.0, 1.0, 3.0, 6.0, 8.0, 9.0, 9.0, 9.0, 9.0 and normalized cubic B-spline coefficients 1.0, 2.0, 4.0, 7.0, 6.0, 4.0, 3.0.
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.
Program Text (e02bbce.c)
Program Data (e02bbce.d)
Program Results (e02bbce.r)