NAG Library Function Document
nag_1d_spline_evaluate (e02bbc)
1
Purpose
nag_1d_spline_evaluate (e02bbc) evaluates a cubic spline from its B-spline representation.
2
Specification
#include <nag.h> |
#include <nage02.h> |
void |
nag_1d_spline_evaluate (double x,
double *s,
Nag_Spline *spline,
NagError *fail) |
|
3
Description
nag_1d_spline_evaluate (e02bbc) evaluates the cubic spline
at a prescribed argument
from its augmented knot set
, for
, (see
nag_1d_spline_fit_knots (e02bac)) 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 3 defined upon the knots
. The prescribed argument
must satisfy
.
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).
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:
– doubleInput
-
On entry: the argument at which the cubic spline is to be evaluated.
Constraint:
.
- 2:
– double *Output
-
On exit: the value of the spline, .
- 3:
– 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.
Constraint:
.
- 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 .
Constraint:
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).
- 4:
– NagError *Input/Output
-
The NAG error argument (see
Section 3.7 in How to Use the NAG Library and its Documentation).
6
Error Indicators and Warnings
- NE_ABSCI_OUTSIDE_KNOT_INTVL
-
On entry,
x must satisfy
:
,
,
.
In this case
s is set arbitrarily to zero.
- NE_INT_ARG_LT
-
On entry, must not be less than 8: .
7
Accuracy
The computed value of
has negligible error in most practical situations. Specifically, this value has an absolute error bounded in modulus by
machine precision, 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
machine precision in modulus. For further details see
Cox (1978).
8
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
instead of
. 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.
10
Example
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.
10.1
Program Text
Program Text (e02bbce.c)
10.2
Program Data
Program Data (e02bbce.d)
10.3
Program Results
Program Results (e02bbce.r)