CSIEZ

Computes the cubic spline interpolant with the ‘not-a-knot’ condition and return values of the interpolant at specified points.

Required Arguments

XDATA — Array of length NDATA containing the data point abscissas. (Input)
The data point abscissas must be distinct.

FDATA — Array of length NDATA containing the data point ordinates. (Input)

XVEC — Array of length N containing the points at which the spline is to be evaluated. (Input)

VALUE — Array of length N containing the values of the spline at the points in XVEC. (Output)

Optional Arguments

NDATA — Number of data points. (Input)
NDATA must be at least 2.
Default: NDATA = size (XDATA,1).

N — Length of vector XVEC. (Input)
Default: N = size (XVEC,1).

FORTRAN 90 Interface

Generic: CALL CSIEZ (XDATA, FDATA, XVEC, VALUE [])

Specific: The specific interface names are S_CSIEZ and D_CSIEZ.

FORTRAN 77 Interface

Single: CALL CSIEZ (NDATA, XDATA, FDATA, N, XVEC, VALUE)

Double: The double precision name is DCSIEZ.

Description

This routine is designed to let the user easily compute the values of a cubic spline interpolant. The routine CSIEZ computes a spline interpolant to a set of data points (xifi) for i = 1, , NDATA. The output for this routine consists of a vector of values of the computed cubic spline. Specifically, let n = N, v = XVEC, and y = VALUE, then if s is the computed spline we set

yj  = s(vj )   j = 1, n

Additional documentation can be found by referring to the IMSL routines CSINT or SPLEZ.

Comments

Workspace may be explicitly provided, if desired, by use of C2IEZ/DC2IEZ. The reference is:

CALL C2IEZ (NDATA, XDATA, FDATA, N, XVEC, VALUE, IWK, WK1, WK2)

The additional arguments are as follows:

IWK — Integer work array of length MAX0(N, NDATA) + N.

WK1 — Real work array of length 5 * NDATA.

WK2 — Real work array of length 2 * N.

Example

In this example, a cubic spline interpolant to a function F is computed. The values of this spline are then compared with the exact function values.

 

USE CSIEZ_INT

USE UMACH_INT

 

IMPLICIT NONE

INTEGER NDATA

PARAMETER (NDATA=11)

!

INTEGER I, NOUT

REAL F, FDATA(NDATA), FLOAT, SIN, VALUE(2*NDATA-1), X,&

XDATA(NDATA), XVEC(2*NDATA-1)

INTRINSIC FLOAT, SIN

! Define function

F(X) = SIN(15.0*X)

! Set up a grid

DO 10 I=1, NDATA

XDATA(I) = FLOAT(I-1)/FLOAT(NDATA-1)

FDATA(I) = F(XDATA(I))

10 CONTINUE

DO 20 I=1, 2*NDATA - 1

XVEC(I) = FLOAT(I-1)/FLOAT(2*NDATA-2)

20 CONTINUE

! Compute cubic spline interpolant

CALL CSIEZ (XDATA, FDATA, XVEC, VALUE)

! Get output unit number

CALL UMACH (2, NOUT)

! Write heading

WRITE (NOUT,99998)

99998 FORMAT (13X, 'X', 9X, 'INTERPOLANT', 5X, 'ERROR')

! Print the interpolant and the error

! on a finer grid

DO 30 I=1, 2*NDATA - 1

WRITE (NOUT,99999) XVEC(I), VALUE(I), F(XVEC(I)) - VALUE(I)

30 CONTINUE

99999 FORMAT(' ', 2F15.3, F15.6)

END

Output

 

X INTERPOLANT ERROR

0.000 0.000 0.000000

0.050 0.809 -0.127025

0.100 0.997 0.000000

0.150 0.723 0.055214

0.200 0.141 0.000000

0.250 -0.549 -0.022789

0.300 -0.978 0.000000

0.350 -0.843 -0.016246

0.400 -0.279 0.000000

0.450 0.441 0.009348

0.500 0.938 0.000000

0.550 0.903 0.019947

0.600 0.412 0.000000

0.650 -0.315 -0.004895

0.700 -0.880 0.000000

0.750 -0.938 -0.029541

0.800 -0.537 0.000000

0.850 0.148 0.034693

0.900 0.804 0.000000

0.950 1.086 -0.092559

1.000 0.650 0.000000