NAG FL Interface
e02bdf (dim1_​spline_​integ)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

e02bdf computes the definite integral of a cubic spline from its B-spline representation.

2 Specification

Fortran Interface
Subroutine e02bdf ( ncap7, lamda, c, dint, ifail)
Integer, Intent (In) :: ncap7
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: lamda(ncap7), c(ncap7)
Real (Kind=nag_wp), Intent (Out) :: dint
C Header Interface
#include <nag.h>
void  e02bdf_ (const Integer *ncap7, const double lamda[], const double c[], double *dint, Integer *ifail)
The routine may be called by the names e02bdf or nagf_fit_dim1_spline_integ.

3 Description

e02bdf computes the definite integral of the cubic spline s(x) between the limits x=a and x=b, where a and b are respectively the lower and upper limits of the range over which s(x) is defined. It is assumed that s(x) is represented in terms of its B-spline coefficients ci, for i=1,2,,n¯+3 and (augmented) ordered knot set λi, for i=1,2,,n¯+7, with λi=a, for i=1,2,3,4 and λi=b, for i=n¯+4,,n¯+7, (see e02baf), i.e.,
s(x)=i=1qciNi(x).  
Here q=n¯+3, n¯ is the number of intervals of the spline and Ni(x) denotes the normalized B-spline of degree 3 (order 4) defined upon the knots λi,λi+1,,λi+4.
The method employed uses the formula given in Section 3 of Cox (1975).
e02bdf can be used to determine the definite integrals of cubic spline fits and interpolants produced by e02baf.

4 References

Cox M G (1975) An algorithm for spline interpolation J. Inst. Math. Appl. 15 95–108

5 Arguments

1: ncap7 Integer Input
On entry: n¯+7, where 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 a to b) over which the spline is defined.
Constraint: ncap78.
2: lamda(ncap7) Real (Kind=nag_wp) array Input
On entry: lamda(j) must be set to the value of the jth member of the complete set of knots, λj, for j=1,2,,n¯+7.
Constraint: the lamda(j) must be in nondecreasing order with lamda(ncap7-3)> lamda(4) and satisfy lamda(1)=lamda(2)=lamda(3)=lamda(4) and lamda(ncap7-3)=lamda(ncap7-2)= lamda(ncap7-1)=lamda(ncap7).
3: c(ncap7) Real (Kind=nag_wp) array Input
On entry: the coefficient ci of the B-spline Ni(x), for i=1,2,,n¯+3. The remaining elements of the array are not referenced.
4: dint Real (Kind=nag_wp) Output
On exit: the value of the definite integral of s(x) between the limits x=a and x=b, where a=λ4 and b=λn¯+4.
5: ifail Integer Input/Output
On entry: ifail must be set to 0, −1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of −1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value −1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry ifail=0 or −1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, ncap7=value.
Constraint: ncap78.
ifail=2
On entry, J=value, lamda(J)=value and lamda(J-1)=value.
Constraint: lamda(J)lamda(J-1).
On entry, lamda(1)=value and lamda(2)=value.
Constraint: lamda(1)=lamda(2).
On entry, lamda(2)=value and lamda(3)=value.
Constraint: lamda(2)=lamda(3).
On entry, lamda(3)=value and lamda(4)=value.
Constraint: lamda(3)=lamda(4).
On entry, lamda(4)=value, NCAP4=value and lamda(NCAP4)=value.
Constraint: lamda(4)<lamda(NCAP4).
On entry, ncap7=value, lamda(ncap7-1)=value and lamda(ncap7)=value.
Constraint: lamda(ncap7-1)=lamda(ncap7).
On entry, ncap7=value, lamda(ncap7-2)=value and lamda(ncap7-1)=value.
Constraint: lamda(ncap7-2)=lamda(ncap7-1).
On entry, ncap7=value, lamda(ncap7-3)=value and lamda(ncap7-3)=value.
Constraint: lamda(ncap7-3)=lamda(ncap7-2).
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

The rounding errors are such that the computed value of the integral is exact for a slightly perturbed set of B-spline coefficients ci differing in a relative sense from those supplied by no more than 2.2×(n¯+3)×machine precision.

8 Parallelism and Performance

e02bdf is not threaded in any implementation.

9 Further Comments

The time taken is approximately proportional to n¯+7.

10 Example

This example determines the definite integral over the interval 0x6 of a cubic spline having 6 interior knots at the positions λ=1, 3, 3, 3, 4, 4, the 8 additional knots 0, 0, 0, 0, 6, 6, 6, 6, and the 10 B-spline coefficients 10, 12, 13, 15, 22, 26, 24, 18, 14, 12.
The input data items (using the notation of Section 5) comprise the following values in the order indicated:
n¯
lamda(j), for j=1,2,,ncap7
c(j), for j=1,2,,ncap7-3

10.1 Program Text

Program Text (e02bdfe.f90)

10.2 Program Data

Program Data (e02bdfe.d)

10.3 Program Results

Program Results (e02bdfe.r)