SPLEZ

Computes the values of a spline that either interpolates or fits user-supplied data.

Required Arguments

XDATA — Array of length NDATA containing the data point abscissae.   (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 function values are desired.   (Input)
The entries of XVEC must be distinct.

VALUE — Array of length N containing the spline values.   (Output)
VALUE (I) = S(XVEC (I)) if IDER = 0, VALUE(I) = Sʹ(XVEC (I)) if IDER = 1, and so forth, where S is the computed spline.

Optional Arguments

NDATA — Number of data points.   (Input)
Default: NDATA = size (XDATA,1).

All choices of ITYPE are valid if NDATA is larger than 6. More specifically,

NDATA > ITYPE               or ITYPE = 1.

NDATA > 3                          for ITYPE = 2, 3.

NDATA > (ITYPE 3)              for ITYPE = 4, 5, 6, 7, 8.

NDATA > 3                          for ITYPE = 9, 10, 11, 12.

NDATA > KORDER             for ITYPE = 13, 14, 15.

ITYPE — Type of interpolant desired.   (Input)
Default: ITYPE = 1.

ITYPE

1                              yields CSINT

2                              yields CSAKM

3                              yields CSCON

4                              yields BSINT-BSNAK K = 2

5                              yields BSINT-BSNAK K = 3

6                              yields BSINT-BSNAK K = 4

7                              yields BSINT-BSNAK K = 5

8                              yields BSINT-BSNAK K = 6

9                              yields CSSCV

10                            yields BSLSQ K = 2

11                            yields BSLSQ K = 3

12                            yields BSLSQ K = 4

13                            yields BSVLS K = 2

14                            yields BSVLS K = 3

15                            yields BSVLS K = 4

IDER — Order of the derivative desired.   (Input)
Default: IDER = 0.

N — Number of function values desired.   (Input)
Default: N = size (XVEC,1).

FORTRAN 90 Interface

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

Specific:         The specific interface names are S_SPLEZ and D_SPLEZ.

FORTRAN 77 Interface

Single:            CALL SPLEZ (NDATA, XDATA, FDATA, ITYPE, IDER, N, XVEC, VALUE)

Double:          The double precision name is DSPLEZ.

Description

This routine is designed to let the user experiment with various interpolation and smoothing routines in the library.

The routine SPLEZ computes a spline interpolant to a set of data points (xi, fi) for i = 1, …, NDATA if ITYPE = 1, …, 8. If ITYPE 9, various smoothing or least squares splines are computed. The output for this routine consists of a vector of values of the computed spline or its derivatives. Specifically, let i = IDER, n = N, v = XVEC, and y = VALUE, then if s is the computed spline we set

yj = s(i)(vj)          j = 1, …, n

The routines called are listed above under the ITYPE heading. Additional documentation can be found by referring to these routines.

Example

In this example, all the ITYPE parameters are exercised. The values of the spline are then compared with the exact function values and derivatives.

 

      USE IMSL_LIBRARIES

 

      IMPLICIT   NONE

      INTEGER    NDATA, N

      PARAMETER  (NDATA=21, N=2*NDATA-1)

!                                  Specifications for local variables

      INTEGER    I, IDER, ITYPE, NOUT

      REAL       FDATA(NDATA), FPVAL(N), FVALUE(N),&

                 VALUE(N), XDATA(NDATA), XVEC(N), EMAX1(15),&

                 EMAX2(15), X

!                                  Specifications for intrinsics

      INTRINSIC  FLOAT, SIN, COS

      REAL       FLOAT, SIN, COS

!                                  Specifications for subroutines

!

      REAL       F, FP

!

!                                  Define a function

      F(X)  = SIN(X*X)

      FP(X) = 2*X*COS(X*X)

!

      CALL UMACH (2, NOUT)

!                                  Set up a grid

      DO 10  I=1, NDATA

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

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

   10 CONTINUE

      DO 20  I=1, N

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

         FVALUE(I)  = F(XVEC(I))

         FPVAL(I) = FP(XVEC(I))

   20 CONTINUE

!

      WRITE (NOUT,99999)

!                                  Loop to call SPLEZ for each ITYPE

      DO 40  ITYPE=1, 15

         DO 30  IDER=0, 1

            CALL SPLEZ (XDATA, FDATA, XVEC, VALUE, ITYPE=ITYPE, &

                        IDER=IDER)

!                                 Compute the maximum error

            IF (IDER .EQ. 0) THEN

               CALL SAXPY (N, -1.0, FVALUE, 1, VALUE, 1)

               EMAX1(ITYPE) = ABS(VALUE(ISAMAX(N,VALUE,1)))

            ELSE

               CALL SAXPY (N, -1.0, FPVAL, 1, VALUE, 1)

               EMAX2(ITYPE) = ABS(VALUE(ISAMAX(N,VALUE,1)))

            END IF

   30  CONTINUE

         WRITE (NOUT,'(I7,2F20.6)') ITYPE, EMAX1(ITYPE), EMAX2(ITYPE)

   40 CONTINUE

!

99999 FORMAT (4X, 'ITYPE', 6X, 'Max error for f', 5X,&

              'Max error for f''', /)

      END

Output

 

ITYPE      Max error for f     Max error for f'

 1            0.014082            0.658018
 2            0.024682            0.897757
 3            0.020896            0.813228
 4            0.083615            2.168083
 5            0.010403            0.508043
 6            0.014082            0.658020
 7            0.004756            0.228858
 8            0.001070            0.077159
 9            0.020896            0.813228
10            0.392603            6.047916
11            0.162793            1.983959
12            0.045404            1.582624
13            0.588370            7.680381
14            0.752475            9.673786
15            0.049340            1.713031


Visual Numerics, Inc.
Visual Numerics - Developers of IMSL and PV-WAVE
http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260