hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_fit_1dspline_eval (e02bb)

Purpose

nag_fit_1dspline_eval (e02bb) evaluates a cubic spline from its B-spline representation.

Syntax

[s, ifail] = e02bb(lamda, c, x, 'ncap7', ncap7)
[s, ifail] = nag_fit_1dspline_eval(lamda, c, x, 'ncap7', ncap7)

Description

nag_fit_1dspline_eval (e02bb) evaluates the cubic spline s(x)s(x) at a prescribed argument xx from its augmented knot set λiλi, for i = 1,2,,n + 7i=1,2,,n+7, (see nag_fit_1dspline_knots (e02ba)) and from the coefficients cici, for i = 1,2,,qi=1,2,,qin its B-spline representation
q
s(x) = ciNi(x).
i = 1
s(x)=i=1qciNi(x).
Here q = n + 3q=n-+3, where nn- is the number of intervals of the spline, and Ni(x)Ni(x) denotes the normalized B-spline of degree 33 defined upon the knots λi,λi + 1,,λi + 4λi,λi+1,,λi+4. The prescribed argument xx must satisfy λ4xλn + 4λ4xλn-+4.
It is assumed that λjλj1λjλj-1, for j = 2,3,,n + 7j=2,3,,n-+7, and λn + 4 > λ4λn-+4>λ4.
If xx is a point at which 44 knots coincide, s(x)s(x) is discontinuous at xx; in this case, s contains the value defined as xx 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 nag_fit_1dspline_eval (e02bb) will be the evaluation of the cubic spline approximations produced by nag_fit_1dspline_knots (e02ba). A generalization of nag_fit_1dspline_eval (e02bb) which also forms the derivative of s(x)s(x) is nag_fit_1dspline_deriv (e02bc). nag_fit_1dspline_deriv (e02bc) takes about 50%50% longer than nag_fit_1dspline_eval (e02bb).

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

Parameters

Compulsory Input Parameters

1:     lamda(ncap7) – double array
ncap7, the dimension of the array, must satisfy the constraint ncap78ncap78.
lamda(j)lamdaj must be set to the value of the jjth member of the complete set of knots, λjλj, for j = 1,2,,n + 7j=1,2,,n-+7.
Constraint: the lamda(j)lamdaj must be in nondecreasing order with lamda(ncap73) > lamda(4)lamdancap7-3> lamda4.
2:     c(ncap7) – double array
ncap7, the dimension of the array, must satisfy the constraint ncap78ncap78.
The coefficient cici of the B-spline Ni(x)Ni(x), for i = 1,2,,n + 3i=1,2,,n-+3. The remaining elements of the array are not referenced.
3:     x – double scalar
The argument xx at which the cubic spline is to be evaluated.
Constraint: lamda(4)xlamda(ncap73)lamda4xlamdancap7-3.

Optional Input Parameters

1:     ncap7 – int64int32nag_int scalar
Default: The dimension of the arrays lamda, c. (An error is raised if these dimensions are not equal.)
n + 7n-+7, where nn- is the number of intervals (one greater than the number of interior knots, i.e., the knots strictly within the range λ4λ4 to λn + 4λn-+4) over which the spline is defined.
Constraint: ncap78ncap78.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     s – double scalar
The value of the spline, s(x)s(x).
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
The parameter x does not satisfy lamda(4)xlamda(ncap73)lamda4xlamdancap7-3.
In this case the value of s is set arbitrarily to zero.
  ifail = 2ifail=2
ncap7 < 8ncap7<8, i.e., the number of interior knots is negative.

Accuracy

The computed value of s(x)s(x) has negligible error in most practical situations. Specifically, this value has an absolute error bounded in modulus by 18 × cmax × machine precision18×cmax×machine precision, where cmaxcmax is the largest in modulus of cj,cj + 1,cj + 2cj,cj+1,cj+2 and cj + 3cj+3, and jj is an integer such that λj + 3xλj + 4λj+3xλj+4. If cj,cj + 1,cj + 2cj,cj+1,cj+2 and cj + 3cj+3 are all of the same sign, then the computed value of s(x)s(x) has a relative error not exceeding 20 × machine precision20×machine precision in modulus. For further details see Cox (1978).

Further Comments

The time taken is approximately c × (1 + 0.1 × log(n + 7))c×(1+0.1×log(n-+7)) 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 [Parameters], since to do this would result in a computation time approximately linear in n + 7n-+7 instead of log(n + 7)log(n-+7). All the conditions are tested in nag_fit_1dspline_knots (e02ba), however.

Example

function nag_fit_1dspline_eval_example
lamda = [1;
     1;
     1;
     1;
     3;
     6;
     8;
     9;
     9;
     9;
     9];
c = [1;
     2;
     4;
     7;
     6;
     4;
     3;
     0;
     0;
     0;
     0];
x = 1;
[s, ifail] = nag_fit_1dspline_eval(lamda, c, x)
 

s =

     1


ifail =

                    0


function e02bb_example
lamda = [1;
     1;
     1;
     1;
     3;
     6;
     8;
     9;
     9;
     9;
     9];
c = [1;
     2;
     4;
     7;
     6;
     4;
     3;
     0;
     0;
     0;
     0];
x = 1;
[s, ifail] = e02bb(lamda, c, x)
 

s =

     1


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013