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
X — x-coordinate of the point at which the function is to be evaluated. (Input)
Y — y-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 (xi, yj, fij) for i = 1, …, nx and j = 1, …, ny be the tabular data. Given a point (x, y) at which an interpolated value is desired, we first find the nearest interior grid point (xi, yj). A bivariate quadratic interpolant q is then formed using six points near (x, y). Five of the six points are (xi, yj), (xi ±1, yj), and (xi, yj ±1). The sixth point is the nearest point to (x, y) of the grid points (xi±1, yj±1). The value q(x, y) 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
X Y F(X,Y) QD2VL DIF
0.7854 0.7854 1.0000 1.0000 0.0000