# NAG Library Routine Document

## 1Purpose

e01ebf performs barycentric interpolation, at a given set of points, using a set of function values on a scattered grid and a triangulation of that grid computed by e01eaf.

## 2Specification

Fortran Interface
 Subroutine e01ebf ( m, n, x, y, f, px, py, pf,
 Integer, Intent (In) :: m, n, triang(7*n) Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: x(n), y(n), f(n), px(m), py(m) Real (Kind=nag_wp), Intent (Out) :: pf(m)
#include nagmk26.h
 void e01ebf_ (const Integer *m, const Integer *n, const double x[], const double y[], const double f[], const Integer triang[], const double px[], const double py[], double pf[], Integer *ifail)

## 3Description

e01ebf takes as input a set of scattered data points $\left({x}_{\mathit{r}},{y}_{\mathit{r}},{f}_{\mathit{r}}\right)$, for $\mathit{r}=1,2,\dots ,n$, and a Thiessen triangulation of the $\left({x}_{r},{y}_{r}\right)$ computed by e01eaf, and interpolates at a set of points $\left({\mathit{px}}_{i},{\mathit{py}}_{i}\right)$, for $\mathit{i}=1,2,\dots ,m$.
If the $i$th interpolation point $\left({\mathit{px}}_{i},{\mathit{py}}_{i}\right)$ is equal to $\left({x}_{r},{y}_{r}\right)$ for some value of $r$, the returned value will be equal to ${f}_{r}$; otherwise a barycentric transformation will be used to calculate the interpolant.
For each point $\left({\mathit{px}}_{i},{\mathit{py}}_{i}\right)$, a triangle is sought which contains the point; the vertices of the triangle and ${f}_{r}$ values at the vertices are then used to compute the value $F\left({\mathit{px}}_{i},{\mathit{py}}_{i}\right)$.
If any interpolation point lies outside the triangulation defined by the input arguments, the returned value is the value provided, ${f}_{s}$, at the closest node $\left({x}_{s},{y}_{s}\right)$.
e01ebf must only be called after a call to e01eaf.

## 4References

Cline A K and Renka R L (1984) A storage-efficient method for construction of a Thiessen triangulation Rocky Mountain J. Math. 14 119–139
Lawson C L (1977) Software for ${C}^{1}$ surface interpolation Mathematical Software III (ed J R Rice) 161–194 Academic Press
Renka R L (1984) Algorithm 624: triangulation and interpolation of arbitrarily distributed points in the plane ACM Trans. Math. Software 10 440–442
Renka R L and Cline A K (1984) A triangle-based ${C}^{1}$ interpolation method Rocky Mountain J. Math. 14 223–237

## 5Arguments

1:     $\mathbf{m}$ – IntegerInput
On entry: $m$, the number of points to interpolate.
Constraint: ${\mathbf{m}}\ge 1$.
2:     $\mathbf{n}$ – IntegerInput
On entry: $n$, the number of data points. n must be unchanged from the previous call of e01eaf.
Constraint: ${\mathbf{n}}\ge 3$.
3:     $\mathbf{x}\left({\mathbf{n}}\right)$ – Real (Kind=nag_wp) arrayInput
4:     $\mathbf{y}\left({\mathbf{n}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: the coordinates of the $\mathit{r}$th data point, $\left({x}_{r},{y}_{r}\right)$, for $\mathit{r}=1,2,\dots ,n$. x and y must be unchanged from the previous call of e01eaf.
5:     $\mathbf{f}\left({\mathbf{n}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: the function values ${f}_{\mathit{r}}$ at $\left({x}_{\mathit{r}},{y}_{\mathit{r}}\right)$, for $\mathit{r}=1,2,\dots ,n$.
6:     $\mathbf{triang}\left(7×{\mathbf{n}}\right)$ – Integer arrayInput
On entry: the triangulation computed by the previous call of e01eaf. See Section 9 in e01eaf for details of how the triangulation used is encoded in triang.
7:     $\mathbf{px}\left({\mathbf{m}}\right)$ – Real (Kind=nag_wp) arrayInput
8:     $\mathbf{py}\left({\mathbf{m}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: the coordinates $\left({\mathit{px}}_{\mathit{i}},{\mathit{py}}_{\mathit{i}}\right)$, for $\mathit{i}=1,2,\dots ,m$, at which interpolated function values are sought.
9:     $\mathbf{pf}\left({\mathbf{m}}\right)$ – Real (Kind=nag_wp) arrayOutput
On exit: the interpolated values $F\left({\mathit{px}}_{\mathit{i}},{\mathit{py}}_{\mathit{i}}\right)$, for $\mathit{i}=1,2,\dots ,m$.
10:   $\mathbf{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).

## 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, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 3$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{m}}\ge 1$.
${\mathbf{ifail}}=3$
On entry, the triangulation information held in the array triang does not specify a valid triangulation of the data points. triang has been corrupted since the call to e01eaf.
${\mathbf{ifail}}=4$
At least one evaluation point lies outside the nodal triangulation. For each such point the value returned in pf is that corresponding to a node on the closest boundary line segment.
${\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.

Not applicable.

## 8Parallelism and Performance

e01ebf is not threaded in any implementation.

The time taken for a call of e01ebf is approximately proportional to the number of interpolation points, $m$.