dim1_spline_eval evaluates a cubic spline from its B-spline representation.
2Specification
#include "e02/nagcpp_e02bb.hpp"
template <typename LAMDA, typename C>
void function dim1_spline_eval(const LAMDA &lamda, const C &c, const double x, double &s, OptionalE02BBopt)
template <typename LAMDA, typename C>
void function dim1_spline_eval(const LAMDA &lamda, const C &c, const double x, double &s)
3Description
dim1_spline_eval evaluates the cubic spline at a prescribed argument from its augmented knot set , for , (see e02baf (no CPP interface)) 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 dim1_spline_eval will be the evaluation of the cubic spline approximations produced by e02baf (no CPP interface). A generalization of dim1_spline_eval which also forms the derivative of is e02bcf (no CPP interface). e02bcf (no CPP interface) takes about longer than dim1_spline_eval.
4References
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. Theory6 50–62
5Arguments
1: – double arrayInput
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 .
2: – double arrayInput
On entry: the coefficient
of the B-spline , for . The remaining elements of the array are not referenced.
3: – doubleInput
On entry: the argument at which the cubic spline is to be evaluated.
Constraint:
.
4: – doubleOutput
On exit: the value of the spline, .
5: – OptionalE02BBInput/Output
Optional parameter container, derived from Optional.
5.1Additional Quantities
1:
, 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.
6Exceptions and Warnings
Errors or warnings detected by the function:
All errors and warnings have an associated numeric error code field, errorid, stored either as a member of the thrown exception object (see errorid), or as a member of
opt.ifail, depending on how errors
and warnings are being handled (see Error Handling for more details).
On entry, argument must be a vector of size array. Supplied argument has dimensions.
On entry, argument must be a vector of size array. Supplied argument was a vector of size .
On entry, argument must be a vector of size array. The size for the supplied array could not be ascertained.
On entry, the raw data component of is null.
On entry, unable to ascertain a value for .
An unexpected error has been triggered by this routine.
Your licence key may have expired or may not have been installed correctly.
Dynamic memory allocation failed.
7Accuracy
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).
8Parallelism and Performance
Please see the description for the underlying computational routine in this section of the
FL Interface documentation.
9Further Comments
The time taken is approximately 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 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 (no CPP interface), however.
10Example
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.