next up previous index
Next: E222 Solution of Up: CERNLIB Previous: E210 Polynomial Splines

E211 Cubic Splines and their Integrals

Routine ID: E211
Author(s): K.S. Kölbig, H. LippsLibrary: MATHLIB
Submitter: K.S. KölbigSubmitted: 01.05.1990
Language: FortranRevised:

Subroutines RCSPLN and DCSPLN compute a (vector-valued) cubic spline function F(x) which interpolates between a given set of points. Entries RCSPNT and DCSPNT compute the first and second integral over F(x) .

On computers other than CDC or Cray, only the double-precision versions DCSPLN and DCSPNT are available. On CDC and Cray computers, only the single-precision versions RCSPLN and RCSPNT are available.

Given an interval [a,b] , a subdivision of this interval into n ≥2

subintervals

a = x0< x1< ... < xn-1< xn= b,

and n+1 function values Yk= yk1,...,ykm on the n+1 abscissae (called `knots') xk (k=0,1,...,n ), RCSPLN and DCSPLN compute a function F(x) of class C2 , defined on [a,b] , which assumes the given value Yk at the knot xk (i.e. F(xk) = Yk ), and which, when restricted to the ith sub-interval [xi-1, xi] is identical with a set of m polynomials pi1,...,pim , each of degree at most 3. Any function F(x) which satisfies the above two conditions is called a `cubic spline' through the n + 1 points (xk, Yk) . To define the spline function F(x) uniquely the subroutines impose an additional boundary condition, specified by their MODE parameter:

MODE = 0: F''(x0) = F''(xn)=0 (the so-called natural spline).
MODE = 1: F''(x0) = F''(x1) and F''(xn-1) = F''(xn) .

Structure:

SUBROUTINE subprograms
User Entry Names: RCSPLN, RCSPNT, DCSPLN, DCSPNT
Files referenced: Unit 6

Usage:

For t=R (type REAL), t=D (type DOUBLE PRECISION),
Spline:CALL tCSPLN(N,X,M,Y,NDIM,MODE,A,B,C,D)
Integrals:CALL tCSPNT(N,X,M,Y,NDIM,MODE,A,B,C,D)

N
( INTEGER) Number n of subintervals [xi-1, xi] . Must contain a value of at least 2 on entry. Unchanged on return.
X
(type according to t) One-dimensional array of dimension (0:d) of at least n + 1 elements. On entry, X(k) must contain the abscissa xk , (k=0,1,...,n) . Unchanged on return.
M
( INTEGER) Number m of components of the vector-valued spline function F(x) . Must contain a value of at least 1 on entry. Unchanged on return.
Y
(type according to t) Two-dimensional array of dimension (0:NDIM,d) where d is a value not less than m. On entry, Y(k,j) must contain the value ykj of the jth component of the vector Yk , (k=0,1,...,n ; j=1,...,m) . Unchanged on return.
NDIM
( INTEGER) Upper bound of the first dimension of arrays A, B, C, D and Y. Must contain a value of at least n on entry. Unchanged on return.
MODE
( INTEGER) Type of boundary condition (see description above). Must contain the value 0 or 1 on entry. Unchanged on return.
A,B,C,D
(type according to t) Two-dimensional arrays of dimension (NDIM,d), where d≥m .
On return from RCSPLN, A(i,j), B(i,j), C(i,j) and D(i,j) will contain the four coefficients aij, bij, cij, and dij of the polynomial

pij= aij+ bij(x - xi-1) + cij(x - xi-1)2+ dij(x - xi-1)3

that determines the jth component fj(x) of the spline in the ith subinterval [xi-1, xi] , i=l,...,n , j=1,...,m .
On return from RCSPNT,
A(i,j) = axifj(t) dt and B(i,j) = axiaxfj(t) dt dx ,
with i=1,...,n; j=1,...,m .
Arrays C and D have been used as working space.

Restrictions:

N ≥2 , M ≥1 , NDIM ≥N , MODE = 0 or 1.

Error handling:

Error E211.1: N<2 .
Error E211.2: M<1 .
Error E211.3: NDIM<N .
Error E211.4: MODE ≠0 and MODE ≠1 .
A message is written on Unit 6, unless subroutine MTLSET (N002) has been called.

E222

K.S. Kölbig



next up previous index
Next: E222 Solution of Up: CERNLIB Previous: E210 Polynomial Splines


Janne Saarela
Mon Apr 3 15:06:23 METDST 1995