The routine may be called by the names e01saf or nagf_interp_dim2_scat.
3Description
e01saf constructs an interpolating surface $F(x,y)$
through a set of $m$ scattered data points $({x}_{\mathit{r}},{y}_{\mathit{r}},{f}_{\mathit{r}})$, for $\mathit{r}=1,2,\dots ,m$, using a method due to Renka and Cline. In the $(x,y)$ plane, the data points must be distinct. The constructed surface is continuous and has continuous first derivatives.
The method involves firstly creating a triangulation with all the $(x,y)$ data points as nodes, the triangulation being as nearly equiangular as possible (see Cline and Renka (1984)). Then gradients in the $x$- and $y$-directions are estimated at node $\mathit{r}$, for $\mathit{r}=1,2,\dots ,m$,
as the partial derivatives of a quadratic function of $x$
and $y$ which interpolates the data value ${f}_{r}$,
and which fits the data values at nearby nodes (those within a certain distance chosen by the algorithm) in a weighted least squares sense. The weights are chosen such that closer nodes have more influence than more distant nodes on derivative estimates at node $r$. The computed partial derivatives, with the ${f}_{r}$ values, at the three nodes of each triangle define a piecewise polynomial surface of a certain form which is the interpolant on that triangle. See Renka and Cline (1984) for more detailed information on the algorithm,
a development of that by Lawson (1977). The code is derived from Renka (1984).
The interpolant $F(x,y)$ can subsequently be evaluated at any point $(x,y)$ inside or outside the domain of the data by a call to
e01sbf.
Points outside the domain are evaluated by extrapolation.
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. Software10 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 data points.
Constraint:
${\mathbf{m}}\ge 3$.
2: $\mathbf{x}\left({\mathbf{m}}\right)$ – Real (Kind=nag_wp) arrayInput
3: $\mathbf{y}\left({\mathbf{m}}\right)$ – Real (Kind=nag_wp) arrayInput
4: $\mathbf{f}\left({\mathbf{m}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: the coordinates of the
$\mathit{r}$th data point, for $\mathit{r}=1,2,\dots ,m$. The data points are accepted in any order, but see Section 9.
Constraint:
the $(x,y)$ nodes must not all be collinear, and each node must be unique.
On exit: a data structure defining the computed triangulation, in a form suitable for passing to e01sbf.
6: $\mathbf{grads}(2,{\mathbf{m}})$ – Real (Kind=nag_wp) arrayOutput
On exit: the estimated partial derivatives at the nodes, in a form suitable for passing to e01sbf. The derivatives at node
$\mathit{r}$ with respect to $x$ and $y$ are contained in ${\mathbf{grads}}(1,\mathit{r})$ and ${\mathbf{grads}}(2,\mathit{r})$ respectively, for $\mathit{r}=1,2,\dots ,m$.
7: $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, $\mathrm{-1}$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $\mathrm{-1}$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $\mathrm{-1}$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ 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 $\mathrm{-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}}=\u27e8\mathit{\text{value}}\u27e9$.
Constraint: ${\mathbf{m}}\ge 3$.
${\mathbf{ifail}}=2$
All nodes are collinear. There is no unique solution.
${\mathbf{ifail}}=3$
On entry, $({\mathbf{x}}\left(\mathit{I}\right),{\mathbf{y}}\left(\mathit{I}\right))=({\mathbf{x}}\left(\mathit{J}\right),{\mathbf{y}}\left(\mathit{J}\right))$, for $\mathit{I},\mathit{J}=\u27e8\mathit{\text{value}}\u27e9\u27e8\mathit{\text{value}}\u27e9$, ${\mathbf{x}}\left(\mathit{I}\right)$, ${\mathbf{y}}\left(\mathit{I}\right)=\u27e8\mathit{\text{value}}\u27e9\u27e8\mathit{\text{value}}\u27e9$.
${\mathbf{ifail}}=-99$
An unexpected error has been triggered by this routine. Please
contact NAG.
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
On successful exit, the computational errors should be negligible in most situations but you should always check the computed surface for acceptability, by drawing contours for instance. The surface always interpolates the input data exactly.
8Parallelism and Performance
e01saf is not threaded in any implementation.
9Further Comments
The time taken for a call of e01saf is approximately proportional to the number of data points, $m$. The routine is more efficient if, before entry, the values in x, y and f are arranged so that the x array is in ascending order.
10Example
This example reads in a set of $30$ data points and calls e01saf
to construct an interpolating surface. It then calls
e01sbf
to evaluate the interpolant at a sample of points on a rectangular grid.
Note that this example is not typical of a realistic problem: the number of data points would normally be larger, and the interpolant would need to be evaluated on a finer grid to obtain an accurate plot, say.