# NAG FL Interfacee01shf (dim2_​scat_​shep_​eval)

## 1Purpose

e01shf evaluates the two-dimensional interpolating function generated by e01sgf and its first partial derivatives.

## 2Specification

Fortran Interface
 Subroutine e01shf ( m, x, y, f, iq, liq, rq, lrq, n, u, v, q, qx, qy,
 Integer, Intent (In) :: m, iq(liq), liq, lrq, n Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: x(m), y(m), f(m), rq(lrq), u(n), v(n) Real (Kind=nag_wp), Intent (Out) :: q(n), qx(n), qy(n)
#include <nag.h>
 void e01shf_ (const Integer *m, const double x[], const double y[], const double f[], const Integer iq[], const Integer *liq, const double rq[], const Integer *lrq, const Integer *n, const double u[], const double v[], double q[], double qx[], double qy[], Integer *ifail)
The routine may be called by the names e01shf or nagf_interp_dim2_scat_shep_eval.

## 3Description

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).
Renka R J (1988) Algorithm 660: QSHEP2D: Quadratic Shepard method for bivariate interpolation of scattered data ACM Trans. Math. Software 14 149–150

## 5Arguments

1: $\mathbf{m}$Integer Input
2: $\mathbf{x}\left({\mathbf{m}}\right)$Real (Kind=nag_wp) array Input
3: $\mathbf{y}\left({\mathbf{m}}\right)$Real (Kind=nag_wp) array Input
4: $\mathbf{f}\left({\mathbf{m}}\right)$Real (Kind=nag_wp) array Input
On entry: m, x, y and f must be the same values as were supplied in the preceding call to e01sgf.
5: $\mathbf{iq}\left({\mathbf{liq}}\right)$Integer array Input
On entry: must be unchanged from the value returned from a previous call to e01sgf.
6: $\mathbf{liq}$Integer Input
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: $\mathbf{rq}\left({\mathbf{lrq}}\right)$Real (Kind=nag_wp) array Input
On entry: must be unchanged from the value returned from a previous call to e01sgf.
8: $\mathbf{lrq}$Integer Input
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: $\mathbf{n}$Integer Input
On entry: $n$, the number of evaluation points.
Constraint: ${\mathbf{n}}\ge 1$.
10: $\mathbf{u}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Input
11: $\mathbf{v}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Input
On entry: the evaluation points $\left({u}_{\mathit{i}},{v}_{\mathit{i}}\right)$, for $\mathit{i}=1,2,\dots ,n$.
12: $\mathbf{q}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Output
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: $\mathbf{qx}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Output
14: $\mathbf{qy}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Output
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: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, . If you are unfamiliar with this argument you should refer to Section 4 in the Introduction to the NAG Library FL Interface for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value 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 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).

## 6Error 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, liq is too small: ${\mathbf{liq}}=〈\mathit{\text{value}}〉$.
On entry, lrq is too small: ${\mathbf{lrq}}=〈\mathit{\text{value}}〉$.
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{m}}\ge 6$.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 1$.
${\mathbf{ifail}}=2$
On entry, values in iq appear to be invalid. Check that iq has not been corrupted between calls to e01sgf and e01shf.
On entry, values in rq appear to be invalid. Check that rq has not been corrupted between calls to e01sgf and e01shf.
${\mathbf{ifail}}=3$
On entry, at least one evaluation point lies outside the region of definition of the interpolant. At such points the corresponding values in q and qx contain extrapolated approximations. Points should be evaluated one by one to identify extrapolated values.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

Computational errors should be negligible in most practical situations.

## 8Parallelism and Performance

e01shf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
e01shf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
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 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.