BS1GD
Evaluates the derivative of a spline on a grid, given its B-spline representation.
Required Arguments
IDERIV — Order of the derivative to be evaluated. (Input)
In particular, IDERIV = 0 returns the value of the spline.
XVEC — Array of length N containing the points at which the spline is to be evaluated. (Input)
XVEC should be strictly increasing.
KORDER — Order of the spline. (Input)
XKNOT — Array of length NCOEF + KORDER containing the knot sequence. (Input)
XKNOT must be nondecreasing.
BSCOEF — Array of length NCOEF containing the B-spline coefficients. (Input)
VALUE — Array of length N containing the values of the IDERIV-th derivative of the spline at the points in XVEC. (Output)
Optional Arguments
N — Length of vector XVEC. (Input)
Default: N = size (XVEC,1).
NCOEF — Number of B-spline coefficients. (Input)
Default: NCOEF = size (BSCOEF,1).
FORTRAN 90 Interface
Generic: CALL BS1GD (IDERIV, XVEC, KORDER, XKNOT, BSCOEF, VALUE [, …])
Specific: The specific interface names are S_BS1GD and D_BS1GD.
FORTRAN 77 Interface
Single: CALL BS1GD (IDERIV, N, XVEC, KORDER, XKNOT, NCOEF, BSCOEF, VALUE)
Double: The double precision name is DBS1GD.
Description
The routine BS1GD evaluates a B-spline (or its derivative) at a vector of points. That is, given a vector x of length n satisfying xi < xi + 1 for i = 1, …, n − 1, a derivative value j, and a B-spline s that is represented by a knot sequence and coefficient sequence, this routine returns the values
s(j)(xi) i = 1, …, n
in the array VALUE. The functionality of this routine is the same as that of BSDER called in a loop, however BS1GD should be much more efficient. This routine converts the B-spline representation to piecewise polynomial form using the IMSL routine BSCPP, and then uses the IMSL routine PPVAL for evaluation.
Comments
1. Workspace may be explicitly provided, if desired, by use of B21GD/DB21GD. The reference is:
CALL B21GD (IDERIV, N, XVEC, KORDER, XKNOT, NCOEF, BSCOEF, VALUE, RWK1, RWK2, IWK3, RWK4, RWK5, RWK6)
The additional arguments are as follows:
RWK1 — Real array of length KORDER * (NCOEF − KORDER + 1).
RWK2 — Real array of length NCOEF − KORDER + 2.
IWK3 — Integer array of length N.
RWK4 — Real array of length N.
RWK5 — Real array of length N.
RWK6 — Real array of length (KORDER + 3) * KORDER
2. Informational error
Type |
Code |
Description |
4 |
5 |
The points in XVEC must be strictly increasing. |
Example
To illustrate the use of BS1GD, we modify the example program for BSDER. In this example, a quadratic (order 3) spline interpolant to F is computed. The values and derivatives of this spline are then compared with the exact function and derivative values. The routine BS1GD is based on the routines BSPLPP and PPVALU in de Boor (1978, page 89).
USE BS1GD_INT
USE BSINT_INT
USE BSNAK_INT
USE UMACH_INT
IMPLICIT NONE
INTEGER KORDER, NDATA, NKNOT, NFGRID
PARAMETER (KORDER=3, NDATA=5, NKNOT=NDATA+KORDER, NFGRID = 9)
! SPECIFICATIONS FOR LOCAL VARIABLES
INTEGER I, NCOEF, NOUT
REAL ANS0(NFGRID), ANS1(NFGRID), BSCOEF(NDATA),&
FDATA(NDATA),&
X, XDATA(NDATA), XKNOT(NKNOT), XVEC(NFGRID)
! SPECIFICATIONS FOR INTRINSICS
INTRINSIC FLOAT, SQRT
REAL FLOAT, SQRT
! SPECIFICATIONS FOR SUBROUTINES
REAL DF, F
!
F(X) = SQRT(X)
DF(X) = 0.5/SQRT(X)
!
CALL UMACH (2, NOUT)
! Set up interpolation points
DO 10 I=1, NDATA
XDATA(I) = FLOAT(I)/FLOAT(NDATA)
FDATA(I) = F(XDATA(I))
10 CONTINUE
CALL BSNAK (NDATA, XDATA, KORDER, XKNOT)
! Interpolate
CALL BSINT (NDATA, XDATA, FDATA, KORDER, XKNOT, BSCOEF)
WRITE (NOUT,99999)
! Print on a finer grid
NCOEF = NDATA
XVEC(1) = XDATA(1)
DO 20 I=2, 2*NDATA - 2, 2
XVEC(I) = (XDATA(I/2+1)+XDATA(I/2))/2.0
XVEC(I+1) = XDATA(I/2+1)
20 CONTINUE
CALL BS1GD (0, XVEC, KORDER, XKNOT, BSCOEF, ANS0)
CALL BS1GD (1, XVEC, KORDER, XKNOT, BSCOEF, ANS1)
DO 30 I=1, 2*NDATA - 1
WRITE (NOUT,99998) XVEC(I), ANS0(I), F(XVEC(I)) - ANS0(I),&
ANS1(I), DF(XVEC(I)) - ANS1(I)
30 CONTINUE
99998 FORMAT (' ', F6.4, 5X, F7.4, 5X, F8.4, 5X, F8.4, 5X, F8.4)
99999 FORMAT (6X, 'X', 8X, 'S(X)', 7X, 'Error', 8X, 'S''(X)', 8X,&
'Error', /)
END
X S(X) Error S’(X) Error
0.2000 0.4472 0.0000 1.0423 0.0757
0.3000 0.5456 0.0021 0.9262 -0.0133
0.4000 0.6325 0.0000 0.8101 -0.0196
0.5000 0.7077 -0.0006 0.6940 0.0131
0.6000 0.7746 0.0000 0.6446 0.0009
0.7000 0.8366 0.0001 0.5952 0.0024
0.8000 0.8944 0.0000 0.5615 -0.0025
0.9000 0.9489 -0.0002 0.5279 -0.0008
1.0000 1.0000 0.0000 0.4942 0.0058