BS2GD
Evaluates the derivative of a two-dimensional tensor-product spline, given its tensor-product B-spline representation on a grid.
Required Arguments
IXDER — Order of the derivative in the X-direction. (Input)
IYDER — Order of the derivative in the Y-direction. (Input)
XVEC — Array of length NX containing the X-coordinates at which the spline is to be evaluated. (Input)
The points in XVEC should be strictly increasing.
YVEC — Array of length NY containing the Y-coordinates at which the spline is to be evaluated. (Input)
The points in YVEC should be strictly increasing.
KXORD — Order of the spline in the X-direction. (Input)
KYORD — Order of the spline in the Y-direction. (Input)
XKNOT — Array of length NXCOEF + KXORD containing the knot sequence in the X-direction. (Input)
XKNOT must be nondecreasing.
YKNOT — Array of length NYCOEF + KYORD containing the knot sequence in the Y-direction. (Input)
YKNOT must be nondecreasing.
BSCOEF — Array of length NXCOEF * NYCOEF containing the tensor-product B-spline coefficients. (Input)
BSCOEF is treated internally as a matrix of size NXCOEF by NYCOEF.
VALUE — Value of the (IXDER, IYDER) derivative of the spline on the NX by NY grid. (Output)
VALUE (I, J) contains the derivative of the spline at the point (XVEC(I), YVEC(J)).
Optional Arguments
NX — Number of grid points in the X-direction. (Input)
Default: NX = size (XVEC,1).
NY — Number of grid points in the Y-direction. (Input)
Default: NY = size (YVEC,1).
NXCOEF — Number of B-spline coefficients in the X-direction. (Input)
Default: NXCOEF = size (XKNOT,1) - KXORD.
NYCOEF — Number of B-spline coefficients in the Y-direction. (Input)
Default: NYCOEF = size (YKNOT,1) - KYORD.
LDVALU — Leading dimension of VALUE exactly as specified in the dimension statement of the calling program. (Input)
Default: LDVALU = SIZE (VALUE,1).
FORTRAN 90 Interface
Generic: CALL BS2GD (IXDER, IDER, XVEC, YVEC, KXORD, KYORD, XKNOT, YKNOT, BSCOEF, VALUE [])
Specific: The specific interface names are S_BS2GD and D_BS2GD.
FORTRAN 77 Interface
Single: CALL BS2GD (IXDER, IYDER, NX, XVEC, NY, YVEC, KXORD, KYORD, XKNOT, YKNOT, NXCOEF, NYCOEF, BSCOEF, VALUE, LDVALU)
Double: The double precision name is DBS2GD.
Description
The routine BS2GD evaluates a partial derivative of a bivariate tensor-product spline (represented as a linear combination of tensor-product B-splines) on a grid of points; see de Boor (1978, pages 351-353).
This routine returns the values of s(p,q)on the grid (xiyj) for i = 1, , nx and j = 1, ny given the coefficients c by computing (for all (xy) in the grid)
where kx and ky are the orders of the splines. (These numbers are passed to the subroutine in KXORD and KYORD, respectively.) Likewise, tx and ty are the corresponding knot sequences (XKNOT and YKNOT). The grid must be ordered in the sense that xi < xi+1 and yj < yj+1.
Comments
1. Workspace may be explicitly provided, if desired, by use of B22GD/DB22GD. The reference is:
CALL B22GD (IXDER, IYDER, NX, XVEC, NY, YVEC, KXORD, KYORD, XKNOT, YKNOT, NXCOEF, NYCOEF, BSCOEF, VALUE, LDVALU, LEFTX, LEFTY, A, B,  DBIATX, DBIATY, BX, BY)
The additional arguments are as follows:
LEFTX — Integer work array of length NX.
LEFTY — Integer work array of length NY.
A — Work array of length KXORD * KXORD.
B — Work array of length KYORD * KYORD.
DBIATX — Work array of length KXORD * (IXDER + 1).
DBIATY — Work array of length KYORD * (IYDER + 1).
BX — Work array of length KXORD * NX.
BY — Work array of length KYORD * NY.
2 Informational errors
Type
Code
Description
3
1
XVEC(I) does not satisfy XKNOT (KXORD) .LEXVEC(I) .LEXKNOT(NXCOEF + 1)
3
2
YVEC(I) does not satisfyYKNOT (KYORD) .LEYVEC(I) .LEYKNOT(NYCOEF + 1)
4
3
XVEC is not strictly increasing.
4
4
YVEC is not strictly increasing.
Example
In this example, a spline interpolant s to a function f is constructed. We use the IMSL routine BS2IN to compute the interpolant and then BS2GD is employed to compute s(2,1) (xy) on a grid. The values of this partial derivative and the error are computed on a 4 × 4 grid and then displayed.
 
USE BS2GD_INT
USE BS2IN_INT
USE BSNAK_INT
USE UMACH_INT
 
IMPLICIT NONE
! SPECIFICATIONS FOR LOCAL VARIABLES
INTEGER I, J, KXORD, KYORD, LDF, NOUT, NXCOEF, NXDATA,&
NYCOEF, NYDATA
REAL DCCFD(21,6), DOCBSC(21,6), DOCXD(21), DOCXK(26),&
DOCYD(6), DOCYK(9), F, F21, FLOAT, VALUE(4,4),&
X, XVEC(4), Y, YVEC(4)
INTRINSIC FLOAT
! Define function and derivative
F(X,Y) = X*X*X*X + X*X*X*Y*Y
F21(X,Y) = 12.0*X*Y
! Initialize/Setup
CALL UMACH (2, NOUT)
KXORD = 5
KYORD = 3
NXDATA = 21
NYDATA = 6
LDF = NXDATA
! Set up interpolation points
DO 10 I=1, NXDATA
DOCXD(I) = FLOAT(I-11)/10.0
10 CONTINUE
! Set up interpolation points
DO 20 I=1, NYDATA
DOCYD(I) = FLOAT(I-1)/5.0
20 CONTINUE
! Generate knot sequence
CALL BSNAK (NXDATA, DOCXD, KXORD, DOCXK)
! Generate knot sequence
CALL BSNAK (NYDATA, DOCYD, KYORD, DOCYK)
! Generate FDATA
DO 40 I=1, NYDATA
DO 30 J=1, NXDATA
DCCFD(J,I) = F(DOCXD(J),DOCYD(I))
30 CONTINUE
40 CONTINUE
! Interpolate
CALL BS2IN (DOCXD, DOCYD, DCCFD, KXORD, KYORD, &
DOCXK, DOCYK, DOCBSC)
! Print (2,1) derivative over a
! grid of [0.0,1.0] x [0.0,1.0]
! at 16 points.
NXCOEF = NXDATA
NYCOEF = NYDATA
WRITE (NOUT,99999)
DO 50 I=1, 4
XVEC(I) = FLOAT(I-1)/3.0
YVEC(I) = XVEC(I)
50 CONTINUE
CALL BS2GD (2, 1, XVEC, YVEC, KXORD, KYORD, DOCXK, DOCYK,&
DOCBSC, VALUE)
DO 70 I=1, 4
DO 60 J=1, 4
WRITE (NOUT,'(3F15.4,F15.6)') XVEC(I), YVEC(J),&
VALUE(I,J),&
F21(XVEC(I),YVEC(J)) -&
VALUE(I,J)
60 CONTINUE
70 CONTINUE
99999 FORMAT (39X, '(2,1)', /, 13X, 'X', 14X, 'Y', 10X, 'S (X,Y)',&
5X, 'Error')
END
Output
 
(2,1)
X Y S (X,Y) Error
0.0000 0.0000 0.0000 0.000000
0.0000 0.3333 0.0000 0.000000
0.0000 0.6667 0.0000 0.000000
0.0000 1.0000 0.0000 0.000001
0.3333 0.0000 0.0000 -0.000001
0.3333 0.3333 1.3333 0.000001
0.3333 0.6667 2.6667 -0.000004
0.3333 1.0000 4.0000 0.000008
0.6667 0.0000 0.0000 -0.000001
0.6667 0.3333 2.6667 -0.000008
0.6667 0.6667 5.3333 0.000038
0.6667 1.0000 8.0001 -0.000113
1.0000 0.0000 -0.0005 0.000488
1.0000 0.3333 4.0004 -0.000412
1.0000 0.6667 7.9995 0.000488
1.0000 1.0000 12.0002 -0.000244
Published date: 03/19/2020
Last modified date: 03/19/2020