E01SAF (PDF version)
E01 Chapter Contents
E01 Chapter Introduction
NAG Library Manual

NAG Library Routine Document


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.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

E01SAF generates a two-dimensional surface interpolating a set of scattered data points, using the method of Renka and Cline.

2  Specification

REAL (KIND=nag_wp)  X(M), Y(M), F(M), GRADS(2,M)

3  Description

E01SAF constructs an interpolating surface Fx,y through a set of m scattered data points xr,yr,fr, for r=1,2,,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 r, for r=1,2,,m, as the partial derivatives of a quadratic function of x and y which interpolates the data value fr, 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 fr 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 Fx,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.

4  References

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 C1 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 C1 interpolation method Rocky Mountain J. Math. 14 223–237

5  Parameters

1:     M – INTEGERInput
On entry: m, the number of data points.
Constraint: M3.
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: the coordinates of the rth data point, for r=1,2,,m. The data points are accepted in any order, but see Section 8.
Constraint: the x,y nodes must not all be collinear, and each node must be unique.
5:     TRIANG(7×M) – INTEGER arrayOutput
On exit: a data structure defining the computed triangulation, in a form suitable for passing to E01SBF.
6:     GRADS(2,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 r with respect to x and y are contained in GRADS1r and GRADS2r respectively, for r=1,2,,m.
7:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ 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​ 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 -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry 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:
On entry,M<3.
On entry,all the (X,Y) pairs are collinear.
On entry,Xi,Yi=Xj,Yj for some ij.

7  Accuracy

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.

8  Further 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.

9  Example

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.

9.1  Program Text

Program Text (e01safe.f90)

9.2  Program Data

Program Data (e01safe.d)

9.3  Program Results

Program Results (e01safe.r)

E01SAF (PDF version)
E01 Chapter Contents
E01 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012