E01 Chapter Contents
E01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentE01THF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

E01THF evaluates the three-dimensional interpolating function generated by E01TGF and its first partial derivatives.

## 2  Specification

 SUBROUTINE E01THF ( M, X, Y, Z, F, IQ, LIQ, RQ, LRQ, N, U, V, W, Q, QX, QY, QZ, IFAIL)
 INTEGER M, IQ(LIQ), LIQ, LRQ, N, IFAIL REAL (KIND=nag_wp) X(M), Y(M), Z(M), F(M), RQ(LRQ), U(N), V(N), W(N), Q(N), QX(N), QY(N), QZ(N)

## 3  Description

E01THF takes as input the interpolant $Q\left(x,y,z\right)$ of a set of scattered data points $\left({x}_{r},{y}_{r},{z}_{r},{f}_{r}\right)$, for $\mathit{r}=1,2,\dots ,m$, as computed by E01TGF, and evaluates the interpolant and its first partial derivatives at the set of points $\left({u}_{i},{v}_{i},{w}_{i}\right)$, for $\mathit{i}=1,2,\dots ,n$.
E01THF must only be called after a call to E01TGF.
This routine is derived from the routine QS3GRD described by Renka (1988).

## 4  References

Renka R J (1988) Algorithm 661: QSHEP3D: Quadratic Shepard method for trivariate interpolation of scattered data ACM Trans. Math. Software 14 151–152

## 5  Arguments

1:     $\mathrm{M}$ – INTEGERInput
2:     $\mathrm{X}\left({\mathbf{M}}\right)$ – REAL (KIND=nag_wp) arrayInput
3:     $\mathrm{Y}\left({\mathbf{M}}\right)$ – REAL (KIND=nag_wp) arrayInput
4:     $\mathrm{Z}\left({\mathbf{M}}\right)$ – REAL (KIND=nag_wp) arrayInput
5:     $\mathrm{F}\left({\mathbf{M}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: M, X, Y, Z and F must be the same values as were supplied in the preceding call to E01TGF.
6:     $\mathrm{IQ}\left({\mathbf{LIQ}}\right)$ – INTEGER arrayInput
On entry: must be unchanged from the value returned from a previous call to E01TGF.
7:     $\mathrm{LIQ}$ – INTEGERInput
On entry: the dimension of the array IQ as declared in the (sub)program from which E01THF is called.
Constraint: ${\mathbf{LIQ}}\ge 2×{\mathbf{M}}+1$.
8:     $\mathrm{RQ}\left({\mathbf{LRQ}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: must be unchanged from the value returned from a previous call to E01TGF.
9:     $\mathrm{LRQ}$ – INTEGERInput
On entry: the dimension of the array RQ as declared in the (sub)program from which E01THF is called.
Constraint: ${\mathbf{LRQ}}\ge 10×{\mathbf{M}}+7$.
10:   $\mathrm{N}$ – INTEGERInput
On entry: $n$, the number of evaluation points.
Constraint: ${\mathbf{N}}\ge 1$.
11:   $\mathrm{U}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayInput
12:   $\mathrm{V}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayInput
13:   $\mathrm{W}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayInput
On entry: ${\mathbf{U}}\left(\mathit{i}\right)$, ${\mathbf{V}}\left(\mathit{i}\right)$, ${\mathbf{W}}\left(\mathit{i}\right)$ must be set to the evaluation point $\left({u}_{\mathit{i}},{v}_{\mathit{i}},{w}_{\mathit{i}}\right)$, for $\mathit{i}=1,2,\dots ,n$.
14:   $\mathrm{Q}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayOutput
On exit: ${\mathbf{Q}}\left(\mathit{i}\right)$ contains the value of the interpolant, at $\left({u}_{\mathit{i}},{v}_{\mathit{i}},{w}_{\mathit{i}}\right)$, for $\mathit{i}=1,2,\dots ,n$. If any of these evaluation points lie outside the region of definition of the interpolant the corresponding entries in Q are set to the largest machine representable number (see X02ALF), and E01THF returns with ${\mathbf{IFAIL}}={\mathbf{3}}$.
15:   $\mathrm{QX}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayOutput
16:   $\mathrm{QY}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayOutput
17:   $\mathrm{QZ}\left({\mathbf{N}}\right)$ – REAL (KIND=nag_wp) arrayOutput
On exit: ${\mathbf{QX}}\left(\mathit{i}\right)$, ${\mathbf{QY}}\left(\mathit{i}\right)$, ${\mathbf{QZ}}\left(\mathit{i}\right)$ contains the value of the partial derivatives of the interpolant $Q\left(x,y,z\right)$ at $\left({u}_{\mathit{i}},{v}_{\mathit{i}},{w}_{\mathit{i}}\right)$, for $\mathit{i}=1,2,\dots ,n$. If any of these evaluation points lie outside the region of definition of the interpolant, the corresponding entries in QX, QY and QZ are set to the largest machine representable number (see X02ALF), and E01THF returns with ${\mathbf{IFAIL}}={\mathbf{3}}$.
18:   $\mathrm{IFAIL}$ – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this argument, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{M}}<10$, or ${\mathbf{LIQ}}<2×{\mathbf{M}}+1$, or ${\mathbf{LRQ}}<10×{\mathbf{M}}+7$, or ${\mathbf{N}}<1$.
${\mathbf{IFAIL}}=2$
Values supplied in IQ or RQ appear to be invalid. Check that these arrays have not been corrupted between the calls to E01TGF and E01THF.
${\mathbf{IFAIL}}=3$
At least one evaluation point lies outside the region of definition of the interpolant. At all such points the corresponding values in Q, QX, QY and QZ have been set to the largest machine representable number (see X02ALF).
${\mathbf{IFAIL}}=-99$
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{IFAIL}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{IFAIL}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

## 7  Accuracy

Computational errors should be negligible in most practical situations.

## 8  Parallelism and Performance

E01THF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

The time taken for a call to E01THF will depend in general on the distribution of the data points. If X, Y and Z are approximately uniformly distributed, then the time taken should be only $\mathit{O}\left({\mathbf{N}}\right)$. At worst $\mathit{O}\left({\mathbf{M}}{\mathbf{N}}\right)$ time will be required.