NAG CL Interface
e02bfc (dim1_spline_deriv_vector)
1
Purpose
e02bfc evaluates a cubic spline and up to its first three derivatives from its Bspline representation at a vector of points.
e02bfc can be used to compute the values and derivatives of cubic spline fits and interpolants produced by reference to
e01bac,
e02bac and
e02bec.
2
Specification
void 
e02bfc (Nag_SplineVectorSort start,
Nag_Spline *spline,
Nag_DerivType deriv,
Nag_Boolean xord,
const double x[],
Integer ixloc[],
Integer nx,
double s[],
Integer pds,
Integer iwrk[],
Integer liwrk,
NagError *fail) 

The function may be called by the names: e02bfc, nag_fit_dim1_spline_deriv_vector or nag_fit_1dspline_deriv_vector.
3
Description
e02bfc evaluates the cubic spline
$s\left(x\right)$ and optionally derivatives up to order
$3$ for a vector of points
${x}_{\mathit{j}}$, for
$\mathit{j}=1,2,\dots ,{n}_{x}$. It is assumed that
$s\left(x\right)$ is represented in terms of its Bspline coefficients
${c}_{\mathit{i}}$, for
$\mathit{i}=1,2,\dots ,\overline{n}+3$, and (augmented) ordered knot set
${\lambda}_{\mathit{i}}$, for
$\mathit{i}=1,2,\dots ,\overline{n}+7$,
(see
e02bac and
e02bec),
i.e.,
Here $q=\overline{n}+3$, $\overline{n}$ is the number of intervals of the spline and ${N}_{i}\left(x\right)$ denotes the normalized Bspline of degree $3$ (order $4$) defined upon the knots ${\lambda}_{i},{\lambda}_{i+1},\dots ,{\lambda}_{i+4}$. The knots ${\lambda}_{5},{\lambda}_{6},\dots ,{\lambda}_{\overline{n}+3}$ are the interior knots. The remaining knots, ${\lambda}_{1}$, ${\lambda}_{2}$, ${\lambda}_{3}$, ${\lambda}_{4}$ and ${\lambda}_{\overline{n}+4}$, ${\lambda}_{\overline{n}+5}$, ${\lambda}_{\overline{n}+6}$, ${\lambda}_{\overline{n+7}}$ are the exterior knots. The knots ${\lambda}_{4}$ and ${\lambda}_{\overline{n}+4}$ are the boundaries of the spline.
Only abscissae satisfying,
will be evaluated. At a simple knot
${\lambda}_{i}$ (i.e., one satisfying
${\lambda}_{i1}<{\lambda}_{i}<{\lambda}_{i+1}$), the third derivative of the spline is, in general, discontinuous. At a multiple knot (i.e., two or more knots with the same value), lower derivatives, and even the spline itself, may be discontinuous. Specifically, at a point
$x=u$ where (exactly)
$r$ knots coincide (such a point is termed a knot of multiplicity
$r$), the values of the derivatives of order
$4\mathit{j}$, for
$\mathit{j}=1,2,\dots ,r$, are, in general, discontinuous. (Here
$1\le r\le 4$;
$r>4$ is not meaningful.) The maximum order of the derivatives to be evaluated
${D}_{\mathrm{ord}}$, and the left or righthandedness of the computation when an abscissa corresponds exactly to an interior knot, are determined by the value of
deriv.
Each abscissa (point at which the spline is to be evaluated)
${x}_{j}$ contained in
x has an associated enclosing interval number,
${\mathit{ixloc}}_{j}$ either supplied or returned in
ixloc (see argument
start). A simple call to
e02bfc would set
${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Sorted}$ and the contents of
ixloc need never be set nor referenced, and the following description on modes of operation can be ignored. However, where efficiency is an important consideration, the following description will help to choose the appropriate mode of operation.
The interval numbers are used to determine which Bsplines must be evaluated for a given abscissa, and are defined as
The algorithm has two modes of vectorization, termed here sorted and unsorted, which are selectable by the argument
start.
Furthermore, if the supplied abscissae are sufficiently ordered, as indicated by the argument
xord, the algorithm will take advantage of significantly faster methods for the determination of both the interval numbers and the subsequent spline evaluations.
The sorted mode has two phases, a sorting phase and an evaluation phase. This mode is recommended if there are many abscissae to evaluate relative to the number of intervals of the spline, or the abscissae are distributed relatively densely over a subsection of the spline. In the first phase,
${\mathit{ixloc}}_{j}$ is determined for each
${x}_{j}$ and a permutation is calculated to sort the
${x}_{j}$ by interval number. The first phase may be either partially or completely bypassed using the argument
start if the enclosing segments and/or the subsequent ordering are already known
a priori, for example if multiple spline coefficients
$\mathbf{spline}\mathbf{\to}\mathbf{c}$ are to be evaluated over the same set of knots
$\mathbf{spline}\mathbf{\to}\mathbf{lamda}$.
In the second phase of the sorted mode, spline approximations are evaluated by segment, so that nonabscissa dependent calculations over a segment may be reused in the evaluation for all abscissae belonging to a specific segment. For example, all third derivatives of all abscissae in the same segment will be identical.
In the unsorted mode of vectorization, no
a priori segment sorting is performed, and if the abscissae are not sufficiently ordered, the evaluation at an abscissa will be independent of evaluations at other abscissae; also nonabscissa dependent calculations over a segment will be repeated for each abscissa in a segment. This may be quicker if the number of abscissa is small in comparison to the number of knots in the spline, and they are distributed sparsely throughout the domain of the spline. This is effectively a direct vectorization of
e02bbc and
e02bcc, although if the enclosing interval numbers
${\mathit{ixloc}}_{j}$ are known, these may again be provided.
If the abscissae are sufficiently ordered, then once the first abscissa in a segment is known, an efficient algorithm will be used to determine the location of the final abscissa in this segment. The spline will subsequently be evaluated in a vectorized manner for all the abscissae indexed between the first and last of the current segment.
If no derivatives are required, the spline evaluation is calculated by taking convex combinations due to
de Boor (1972). Otherwise, the calculation of
$s\left(x\right)$ and its derivatives is based upon,

(i)evaluating the nonzero Bsplines of orders $1$, $2$, $3$ and $4$ by recurrence (see Cox (1972) and Cox (1978)),

(ii)computing all derivatives of the Bsplines of order $4$ by applying a second recurrence to these computed Bspline values (see de Boor (1972)),

(iii)multiplying the fourthorder Bspline values and their derivative by the appropriate Bspline coefficients, and summing, to yield the values of $s\left(x\right)$ and its derivatives.
The method of convex combinations is significantly faster than the recurrence based method. If higher derivatives of order $2$ or $3$ are not required, as much computation as possible is avoided.
4
References
Cox M G (1972) The numerical evaluation of Bsplines J. Inst. Math. Appl. 10 134–149
Cox M G (1978) The numerical evaluation of a spline from its Bspline representation J. Inst. Math. Appl. 21 135–143
de Boor C (1972) On calculating with Bsplines J. Approx. Theory 6 50–62
5
Arguments

1:
$\mathbf{start}$ – Nag_SplineVectorSort
Input

On entry: indicates the completion state of the first phase of the algorithm.
 ${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Sorted}$
 The enclosing interval numbers ${\mathit{ixloc}}_{j}$ for the abscissae ${x}_{j}$ contained in x have not been determined, and you wish to use the sorted mode of vectorization.
 ${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Sorted\_Indexed}$
 The enclosing interval numbers ${\mathit{ixloc}}_{j}$ have been determined and are provided in ixloc, however the required permutation and interval related information has not been determined and you wish to use the sorted mode of vectorization.
 ${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Sorted\_Indexed\_Perm}$
 You wish to use the sorted mode of vectorization, and the entire first phase has been completed, with the enclosing interval numbers supplied in ixloc, and the required permutation and interval related information provided in iwrk (from a previous call to e02bfc).
 ${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Unsorted}$
 The enclosing interval numbers ${\mathit{ixloc}}_{j}$ for the abscissae ${x}_{j}$ contained in x have not been determined, and you wish to use the unsorted mode of vectorization.
 ${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Unsorted\_Indexed}$
 The enclosing interval numbers ${\mathit{ixloc}}_{j}$ for the abscissae ${x}_{j}$ contained in x have been supplied in ixloc, and you wish to use the unsorted mode of vectorization.
Constraint:
${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Sorted}$, $\mathrm{Nag\_SplineVectorSort\_Sorted\_Indexed}$, $\mathrm{Nag\_SplineVectorSort\_Sorted\_Indexed\_Perm}$, $\mathrm{Nag\_SplineVectorSort\_Unsorted}$ or $\mathrm{Nag\_SplineVectorSort\_Unsorted\_Indexed}$.
Additional: ${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Sorted}$ or $\mathrm{Nag\_SplineVectorSort\_Unsorted}$ should be used unless you are sure that the knot set is unchanged between calls.

2:
$\mathbf{spline}$ – Nag_Spline *

Pointer to structure of type Nag_Spline with the following members:
 n – IntegerInput

On entry: $\overline{n}+7$, where $\overline{n}$ is the number of intervals of the spline (which is one greater than the number of interior knots, i.e., the knots strictly within the range ${\lambda}_{4}$ to ${\lambda}_{\overline{n}+4}$ over which the spline is defined).
Constraint:
$\mathbf{spline}\mathbf{\to}\mathbf{n}\ge 8$.
 lamda – double *Input

On entry: a pointer to which memory of size $\mathbf{spline}\mathbf{\to}\mathbf{n}$ must be allocated.
$\mathbf{spline}\mathbf{\to}\mathbf{lamda}\left[\mathit{k}1\right]$ must be set to the value of the $\mathit{k}$th member of the complete set of knots, ${\lambda}_{\mathit{k}}$, for $\mathit{k}=1,2,\dots ,\overline{n}+7$.
Constraint:
the ${\lambda}_{k}$ must be in nondecreasing order with $\mathbf{spline}\mathbf{\to}\mathbf{lamda}\left[\mathbf{spline}\mathbf{\to}\mathbf{n}4\right]>\mathbf{spline}\mathbf{\to}\mathbf{lamda}\left[3\right]$.
 c – double *Input

On entry: a pointer to which memory of size $\mathbf{spline}\mathbf{\to}\mathbf{n}4$ must be allocated. $\mathbf{spline}\mathbf{\to}\mathbf{c}$ holds the coefficient
${c}_{\mathit{i}}$ of the Bspline ${N}_{\mathit{i}}\left(x\right)$, for $\mathit{i}=1,2,\dots ,\overline{n}+3$.
Under normal usage, the call to function
e02bfc will follow at least one call to
e01bac,
e02bac or
e02bec). In that case, the structure spline will have been set up correctly for input to
e02bfc. If multiple sets of Bspline coefficients are required for the same set of knots
$\lambda $ and the same set of abscissae
$x$, multiple calls to
e02bfc may be made with
$\mathbf{spline}\mathbf{\to}\mathbf{c}$ pointing to different coefficient sets, with
start set appropriately for efficiency.

3:
$\mathbf{deriv}$ – Nag_DerivType
Input

On entry: determines the maximum order of derivatives required,
${D}_{\mathrm{ord}}$, as well as the computational behaviour when absicssae correspond exactly to interior knots.
For abscissae satisfying
${x}_{j}={\lambda}_{4}$ or
${x}_{j}={\lambda}_{\overline{n}+4}$ only righthanded or lefthanded computation will be used respectively. For abscissae which do not coincide exactly with a knot, the handedness of the computation is immaterial.
 ${\mathbf{deriv}}=\mathrm{Nag\_NoDerivs}$
 No derivatives required. ${D}_{\mathrm{ord}}=0$. Only righthanded computation will be used at interior knots.
 ${\mathbf{deriv}}=\mathrm{Nag\_LeftDerivs\_1}$ or $\mathrm{Nag\_RightDerivs\_1}$
 Only $s\left(x\right)$ and its first derivative are required. ${D}_{\mathrm{ord}}=1$.
 ${\mathbf{deriv}}=\mathrm{Nag\_LeftDerivs\_2}$ or $\mathrm{Nag\_RightDerivs\_2}$
 Only $s\left(x\right)$ and its first and second derivatives are required. ${D}_{\mathrm{ord}}=2$.
 ${\mathbf{deriv}}=\mathrm{Nag\_LeftDerivs\_3}$ or $\mathrm{Nag\_RightDerivs\_3}$
 $s\left(x\right)$ and its first, second and third derivatives are required. ${D}_{\mathrm{ord}}=3$.
Constraint:
${\mathbf{deriv}}=\mathrm{Nag\_NoDerivs}$, $\mathrm{Nag\_LeftDerivs\_1}$, $\mathrm{Nag\_RightDerivs\_1}$, $\mathrm{Nag\_LeftDerivs\_2}$, $\mathrm{Nag\_RightDerivs\_2}$, $\mathrm{Nag\_LeftDerivs\_3}$ or $\mathrm{Nag\_RightDerivs\_3}$.
Additional: if lefthanded computation of the spline
$s$ is required, a value of
deriv must be chosen which computes at least the first derivative in a lefthanded manner. As mentioned in
Section 3, the handedness of the computation of
$s$ will only have an effect if at least
$4$ interior knots are identical.

4:
$\mathbf{xord}$ – Nag_Boolean
Input

On entry: indicates whether
x is supplied in a sufficiently ordered manner. If
x is sufficiently ordered
e02bfc will complete faster.
 ${\mathbf{xord}}=\mathrm{Nag\_TRUE}$
 The abscissae in x are ordered at least by ascending interval, in that any two abscissae contained in the same interval are only separated by abscissae in the same interval. For example, ${x}_{j}<{x}_{\mathit{j}+1}$, for $\mathit{j}=1,2,\dots ,{\mathbf{nx}}1$.
 ${\mathbf{xord}}=\mathrm{Nag\_FALSE}$
 The abscissae in x are not sufficiently ordered.

5:
$\mathbf{x}\left[{\mathbf{nx}}\right]$ – const double
Input

On entry: the abscissae
${x}_{\mathit{j}}$, for
$\mathit{j}=1,2,\dots ,{n}_{x}$. If
${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Sorted}$ or
$\mathrm{Nag\_SplineVectorSort\_Unsorted}$ then evaluations will only be performed for these
${x}_{j}$ satisfying
${\lambda}_{4}\le {x}_{j}\le {\lambda}_{\overline{n}+4}$. Otherwise evaluation will be performed unless the corresponding element of
ixloc contains an invalid interval number. Please note that if the
${\mathbf{ixloc}}\left[j\right]$ is a valid interval number then no check is made that
${\mathbf{x}}\left[j\right]$ actually lies in that interval.
Constraint:
at least one abscissa must fall between $\mathbf{spline}\mathbf{\to}\mathbf{lamda}\left[3\right]$ and $\mathbf{spline}\mathbf{\to}\mathbf{lamda}\left[\mathbf{spline}\mathbf{\to}\mathbf{n}4\right]$.

6:
$\mathbf{ixloc}\left[{\mathbf{nx}}\right]$ – Integer
Input/Output

On entry: if
${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Sorted\_Indexed}$,
$\mathrm{Nag\_SplineVectorSort\_Sorted\_Indexed\_Perm}$ or
$\mathrm{Nag\_SplineVectorSort\_Unsorted\_Indexed}$, if you wish
${x}_{j}$ to be evaluated,
${\mathbf{ixloc}}\left[j1\right]$ must be the enclosing interval number
${\mathit{ixloc}}_{j}$ of the abscissae
${x}_{j}$ (see
(1)). If you do not wish
${x}_{j}$ to be evaluated, you may set the interval number to be either less than
$4$ or greater than
$\overline{n}+4$.
Otherwise,
ixloc need not be set.
On exit: if
${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Sorted\_Indexed}$,
$\mathrm{Nag\_SplineVectorSort\_Sorted\_Indexed\_Perm}$ or
$\mathrm{Nag\_SplineVectorSort\_Unsorted\_Indexed}$,
ixloc is unchanged on exit.
Otherwise,
${\mathbf{ixloc}}\left[\mathit{j}1\right]$, contains the enclosing interval number ${\mathit{ixloc}}_{\mathit{j}}$, for the abscissa supplied in ${\mathbf{x}}\left[\mathit{j}1\right]$, for $\mathit{j}=1,2,\dots ,{n}_{x}$. Evaluations will only be performed for abscissae ${x}_{j}$ satisfying ${\lambda}_{4}\le {x}_{j}\le {\lambda}_{\overline{n}+4}$. If evaluation is not performed ${\mathbf{ixloc}}\left[j1\right]$ is set to $0$ if ${x}_{j}<{\lambda}_{4}$ or $\overline{n}+7$ if ${x}_{j}>{\lambda}_{\overline{n}+4}$.
Constraint:
if
${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Sorted\_Indexed}$,
$\mathrm{Nag\_SplineVectorSort\_Sorted\_Indexed\_Perm}$ or
$\mathrm{Nag\_SplineVectorSort\_Unsorted\_Indexed}$, at least one element of
ixloc must be between
$4$ and
$\mathbf{spline}\mathbf{\to}\mathbf{n}3$.

7:
$\mathbf{nx}$ – Integer
Input

On entry:
${n}_{x}$, the total number of abscissae contained in
x, including any that will not be evaluated.
Constraint:
${\mathbf{nx}}\ge 1$.

8:
$\mathbf{s}\left[\mathit{dim}\right]$ – double
Output

Note: the dimension,
dim, of the array
s
must be at least
${\mathbf{pds}}\times ({D}_{\mathrm{ord}}+1)$, see
deriv for the definition of
${D}_{\mathrm{ord}}$.
On exit: if
${x}_{j}$ is valid,
${\mathbf{S}}\left(\mathit{j},\mathit{d}\right)$ will contain the (
$\mathit{d}1$)th derivative of
$s\left(x\right)$, for
$\mathit{d}=1,2,\dots ,{D}_{\mathrm{ord}}+1$ and
$\mathit{j}=1,2,\dots ,{n}_{x}$. In particular,
${\mathbf{S}}\left(j,1\right)$ will contain the approximation of
$s\left({x}_{j}\right)$ for all legal values in
x.

9:
$\mathbf{pds}$ – Integer
Input

On entry: the stride separating row elements in the twodimensional data stored in the array
s.
Constraint:
${\mathbf{pds}}\ge {\mathbf{nx}}$, regardless of the acceptability of the elements of
x.

10:
$\mathbf{iwrk}\left[{\mathbf{liwrk}}\right]$ – Integer
Input/Output

On entry: if
${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Sorted\_Indexed\_Perm}$,
iwrk must be unchanged from a previous call to
e02bfc with
${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Sorted}$ or
$\mathrm{Nag\_SplineVectorSort\_Sorted\_Indexed}$.
Otherwise,
iwrk need not be set.
Furthermore,
iwrk may be
NULL if
${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Unsorted}$ or
$\mathrm{Nag\_SplineVectorSort\_Unsorted\_Indexed}$.
On exit: if
${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Unsorted}$ or
$\mathrm{Nag\_SplineVectorSort\_Unsorted\_Indexed}$,
iwrk is unchanged on exit.
Otherwise,
iwrk contains the required permutation of elements of
x, if any, and information related to the division of the abscissae
${x}_{j}$ between the intervals derived from
$\mathbf{spline}\mathbf{\to}\mathbf{lamda}$.

11:
$\mathbf{liwrk}$ – Integer
Input

On entry: the dimension of the array
iwrk.
Constraint:
if ${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Sorted}$, $\mathrm{Nag\_SplineVectorSort\_Sorted\_Indexed}$ or $\mathrm{Nag\_SplineVectorSort\_Sorted\_Indexed\_Perm}$, ${\mathbf{liwrk}}\ge 3+3\times {\mathbf{nx}}$.

12:
$\mathbf{fail}$ – NagError *
Input/Output

The NAG error argument (see
Section 7 in the Introduction to the NAG Library CL Interface).
6
Error Indicators and Warnings
 NE_ABSCI_OUTSIDE_KNOT_INTVL

On entry, all elements of
x had enclosing interval numbers in
ixloc outside the domain allowed by the provided spline.
$\u2329\mathit{\text{value}}\u232a$ entries of
x were indexed below the lower bound
$\u2329\mathit{\text{value}}\u232a$.
$\u2329\mathit{\text{value}}\u232a$ entries of
x were indexed above the upper bound
$\u2329\mathit{\text{value}}\u232a$.
 NE_ALLOC_FAIL

Dynamic memory allocation failed.
See
Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
 NE_BAD_PARAM

On entry, argument $\u2329\mathit{\text{value}}\u232a$ had an illegal value.
 NE_INT

On entry, ${\mathbf{nx}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{nx}}\ge 1$.
On entry, $\mathbf{spline}\mathbf{\to}\mathbf{n}=\u2329\mathit{\text{value}}\u232a$.
Constraint: $\mathbf{spline}\mathbf{\to}\mathbf{n}\ge 8$.
 NE_INT_2

On entry, ${\mathbf{liwrk}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{liwrk}}\ge 3\times {\mathbf{nx}}+3=\u2329\mathit{\text{value}}\u232a$.
On entry, ${\mathbf{pds}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{pds}}\ge {\mathbf{nx}}=\u2329\mathit{\text{value}}\u232a$.
 NE_INT_CHANGED

On entry,
${\mathbf{start}}=\mathrm{Nag\_SplineVectorSort\_Sorted\_Indexed\_Perm}$ and
nx is not consistent with the previous call to
e02bfc.
On entry,
${\mathbf{nx}}=\u2329\mathit{\text{value}}\u232a$.
Constraint:
${\mathbf{nx}}=\u2329\mathit{\text{value}}\u232a$.
 NE_INTERNAL_ERROR

An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact
NAG for assistance.
See
Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
 NE_NO_LICENCE

Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library CL Interface for further information.
 NE_SPLINE_RANGE_INVALID

On entry, $\mathbf{spline}\mathbf{\to}\mathbf{lamda}\left[3\right]=\u2329\mathit{\text{value}}\u232a$, $\mathbf{spline}\mathbf{\to}\mathbf{n}=\u2329\mathit{\text{value}}\u232a$ and $\mathbf{spline}\mathbf{\to}\mathbf{lamda}\left[\mathbf{spline}\mathbf{\to}\mathbf{n}4\right]=\u2329\mathit{\text{value}}\u232a$.
Constraint: $\mathbf{spline}\mathbf{\to}\mathbf{lamda}\left[3\right]<\mathbf{spline}\mathbf{\to}\mathbf{lamda}\left[\mathbf{spline}\mathbf{\to}\mathbf{n}4\right]$.
 NW_SOME_SOLUTIONS

On entry, at least one element of
x has an enclosing interval number in
ixloc outside the set allowed by the provided spline. The spline has been evaluated for all
x with enclosing interval numbers inside the allowable set.
$\u2329\mathit{\text{value}}\u232a$ entries of
x were indexed below the lower bound
$\u2329\mathit{\text{value}}\u232a$.
$\u2329\mathit{\text{value}}\u232a$ entries of
x were indexed above the upper bound
$\u2329\mathit{\text{value}}\u232a$.
7
Accuracy
The computed value of
$s\left(x\right)$ has negligible error in most practical situations. Specifically, this value has an absolute error bounded in modulus by
$18\times \mathit{cmax}\times \mathit{machineprecision}$, where
$\mathit{cmax}$ is the largest in modulus of
${c}_{j}$,
${c}_{j}+1$,
${c}_{j}+2$ and
${c}_{j}+3$, and
$j$ is an integer such that
${\lambda}_{j}+3<x\le {\lambda}_{j}+4$. If
${c}_{j}$,
${c}_{j}+1$,
${c}_{j}+2$ and
${c}_{j}+3$ are all of the same sign, then the computed value of
$s\left(x\right)$ has relative error bounded by
$20\times \mathit{machineprecision}$. For full details see
Cox (1978).
No complete error analysis is available for the computation of the derivatives of $s\left(x\right)$. However, for most practical purposes the absolute errors in the computed derivatives should be small. Note that this is in comparison to the derivatives of the spline, which may or may not be comparable to the derivatives of the function that has been approximated by the spline.
8
Parallelism and Performance
e02bfc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the
Users' Note for your implementation for any additional implementationspecific information.
If using the sorted mode of vectorization, the time required for the first phase to determine the enclosing intervals is approximately proportional to
$\mathit{O}\left({n}_{x}\mathrm{log}\left(\overline{n}\right)\right)$. The time required to then generate the required permutations and interval information is
$\mathit{O}\left({n}_{x}\right)$ if
x is ordered sufficiently, or at worst
$\mathit{O}\left({n}_{x}\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({n}_{x},\overline{n}\right)\mathrm{log}\left(\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({n}_{x},\overline{n}\right)\right)\right)$ if
x is not ordered. The time required by the second phase is then proportional to
$\mathit{O}\left({n}_{x}\right)$.
If using the unsorted mode of vectorization, the time required is proportional to $\mathit{O}\left({n}_{x}\mathrm{log}\left(\overline{n}\right)\right)$ if the enclosing interval numbers are not provided, or $\mathit{O}\left({n}_{x}\right)$ if they are provided. However, the repeated calculation of various quantities will typically make this slower than the sorted mode when the ratio of abscissae to knots is high, or the abscissae are densely distributed over a relatively small subset of the intervals of the spline.
Note: the function does not test all the conditions on the knots given in the description of
$\mathbf{spline}\mathbf{\to}\mathbf{lamda}$ in
Section 5, since to do this would result in a computation time with a linear dependency upon
$\overline{n}$ instead of
$\mathrm{log}\left(\overline{n}\right)$. All the conditions are tested in
e02bac and
e02bec, however.
10
Example
This example fits a spline through a set of data points using
e02bec and then evaluates the spline at a set of supplied abscissae.
10.1
Program Text
10.2
Program Data
10.3
Program Results