E01 Chapter Contents
E01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentE01SHF

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

E01SHF evaluates the two-dimensional interpolating function generated by E01SGF and its first partial derivatives.

## 2  Specification

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

## 3  Description

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

## 4  References

Renka R J (1988) Algorithm 660: QSHEP2D: Quadratic Shepard method for bivariate interpolation of scattered data ACM Trans. Math. Software 14 149–150

## 5  Parameters

1:     M – INTEGERInput
2:     X(M) – REAL (KIND=nag_wp) arrayInput
3:     Y(M) – REAL (KIND=nag_wp) arrayInput
4:     F(M) – REAL (KIND=nag_wp) arrayInput
On entry: M, X, Y and F must be the same values as were supplied in the preceding call to E01SGF.
5:     IQ(LIQ) – INTEGER arrayInput
On entry: must be unchanged from the value returned from a previous call to E01SGF.
6:     LIQ – INTEGERInput
On entry: the dimension of the array IQ as declared in the (sub)program from which E01SHF is called.
Constraint: ${\mathbf{LIQ}}\ge 2×{\mathbf{M}}+1$.
7:     RQ(LRQ) – REAL (KIND=nag_wp) arrayInput
On entry: must be unchanged from the value returned from a previous call to E01SGF.
8:     LRQ – INTEGERInput
On entry: the dimension of the array RQ as declared in the (sub)program from which E01SHF is called.
Constraint: ${\mathbf{LRQ}}\ge 6×{\mathbf{M}}+5$.
9:     N – INTEGERInput
On entry: $n$, the number of evaluation points.
Constraint: ${\mathbf{N}}\ge 1$.
10:   U(N) – REAL (KIND=nag_wp) arrayInput
11:   V(N) – REAL (KIND=nag_wp) arrayInput
On entry: the evaluation points $\left({u}_{\mathit{i}},{v}_{\mathit{i}}\right)$, for $\mathit{i}=1,2,\dots ,n$.
12:   Q(N) – REAL (KIND=nag_wp) arrayOutput
On exit: the values of the interpolant at $\left({u}_{\mathit{i}},{v}_{\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 E01SHF returns with ${\mathbf{IFAIL}}={\mathbf{3}}$.
13:   QX(N) – REAL (KIND=nag_wp) arrayOutput
14:   QY(N) – REAL (KIND=nag_wp) arrayOutput
On exit: the values of the partial derivatives of the interpolant $Q\left(x,y\right)$ at $\left({u}_{\mathit{i}},{v}_{\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 and QY are set to the largest machine representable number (see X02ALF), and E01SHF returns with ${\mathbf{IFAIL}}={\mathbf{3}}$.
15:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction 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 parameter, 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}}={\mathbf{0}}$ or $-{\mathbf{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}}<6$, or ${\mathbf{LIQ}}<2×{\mathbf{M}}+1$, or ${\mathbf{LRQ}}<6×{\mathbf{M}}+5$, 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 E01SGF and E01SHF.
${\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 and QY have been set to the largest machine representable number (see X02ALF).

## 7  Accuracy

Computational errors should be negligible in most practical situations.

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

## 9  Example

See Section 9 in E01SGF.