QD2VL
This function evaluates a function defined on a rectangular grid using quadratic interpolation.
Function Return Value
QD2VL — Value of the function at (X, Y). (Output)
Required Arguments
Xx-coordinate of the point at which the function is to be evaluated. (Input)
Yy-coordinate of the point at which the function is to be evaluated. (Input)
XDATA — Array of length NXDATA containing the location of the data points in the
x-direction. (Input)
XDATA must be increasing.
YDATA — Array of length NYDATA containing the location of the data points in the
y-direction. (Input)
YDATA must be increasing.
FDATA — Array of size NXDATA by NYDATA containing function values. (Input)
FDATA (I, J) is the value of the function at (XDATA (I), YDATA(J)).
Optional Arguments
NXDATA — Number of data points in the x-direction. (Input)
NXDATA must be at least three.
Default: NXDATA = size (XDATA,1).
NYDATA — Number of data points in the y-direction. (Input)
NYDATA must be at least three.
Default: NYDATA = size (YDATA,1).
LDF — Leading dimension of FDATA exactly as specified in the dimension statement of the calling program. (Input)
LDF must be at least as large as NXDATA.
Default: LDF = size (FDATA,1).
CHECK — Logical variable that is .TRUE. if checking of XDATA and YDATA is required or .FALSE. if checking is not required. (Input)
Default: CHECK = .TRUE.
FORTRAN 90 Interface
Generic: QD2VL(X, Y, XDATA, YDATA, FDATA [])
Specific: The specific interface names are S_QD2VL and D_QD2VL.
FORTRAN 77 Interface
Single: QD2VL(X, Y, NXDATA, XDATA, NYDATA, YDATA, FDATA, LDF, CHECK)
Double: The double precision function name is DQD2VL.
Description
The function QD2VL interpolates a table of values, using quadratic polynomials, returning an approximation to the tabulated function. Let (xiyjfij) for i = 1, nx and j = 1, ny be the tabular data. Given a point (xy) at which an interpolated value is desired, we first find the nearest interior grid point (xiyj). A bivariate quadratic interpolant q is then formed using six points near (xy). Five of the six points are (xiyj), (xi ±1yj), and (xiyj ±1). The sixth point is the nearest point to (xy) of the grid points (x1y1). The value q(xy) is returned by QD2VL.
Comments
Informational errors
Type
Code
Description
4
6
The XDATA values must be strictly increasing.
4
7
The YDATA values must be strictly increasing.
Example
In this example, the value of sin(x + y) at x = y = π/4 is approximated by using QDVAL on a table of size 21 × 42 equally spaced values on the unit square.
 
USE IMSL_LIBRARIES
 
IMPLICIT NONE
INTEGER LDF, NXDATA, NYDATA
PARAMETER (NXDATA=21, NYDATA=42, LDF=NXDATA)
!
INTEGER I, J, NOUT
REAL F, FDATA(LDF,NYDATA), FLOAT, PI, Q, &
SIN, X, XDATA(NXDATA), Y, YDATA(NYDATA)
INTRINSIC FLOAT, SIN
! Define function
F(X,Y) = SIN(X+Y)
! Set up X-grid
DO 10 I=1, NXDATA
XDATA(I) = FLOAT(I-1)/FLOAT(NXDATA-1)
10 CONTINUE
! Set up Y-grid
DO 20 I=1, NYDATA
YDATA(I) = FLOAT(I-1)/FLOAT(NYDATA-1)
20 CONTINUE
! Evaluate function on grid
DO 30 I=1, NXDATA
DO 30 J=1, NYDATA
FDATA(I,J) = F(XDATA(I),YDATA(J))
30 CONTINUE
! Get output unit number
CALL UMACH (2, NOUT)
! Write heading
WRITE (NOUT,99999)
! Get value for PI and set X and Y
PI = CONST('PI')
X = PI/4.0
Y = PI/4.0
! Evaluate quadratic at (X,Y)
Q = QD2VL(X,Y,XDATA,YDATA,FDATA)
! Print results
WRITE (NOUT,'(5F12.4)') X, Y, F(X,Y), Q, (Q-F(X,Y))
99999 FORMAT (10X, 'X', 11X, 'Y', 7X, 'F(X,Y)', 7X, 'QD2VL', 9X,&
'DIF')
END
Output
 
X Y F(X,Y) QD2VL DIF
0.7854 0.7854 1.0000 1.0000 0.0000