hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_interp_2d_scat (e01sa)

Purpose

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

Syntax

[triang, grads, ifail] = e01sa(x, y, f, 'm', m)
[triang, grads, ifail] = nag_interp_2d_scat(x, y, f, 'm', m)

Description

nag_interp_2d_scat (e01sa) constructs an interpolating surface F(x,y)F(x,y) through a set of mm scattered data points (xr,yr,fr)(xr,yr,fr), for r = 1,2,,mr=1,2,,m, using a method due to Renka and Cline. In the (x,y)(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)(x,y) data points as nodes, the triangulation being as nearly equiangular as possible (see Cline and Renka (1984)). Then gradients in the xx- and yy-directions are estimated at node rr, for r = 1,2,,mr=1,2,,m, as the partial derivatives of a quadratic function of xx and yy which interpolates the data value frfr, 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 rr. The computed partial derivatives, with the frfr 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)F(x,y) can subsequently be evaluated at any point (x,y)(x,y) inside or outside the domain of the data by a call to nag_interp_2d_scat_eval (e01sb). Points outside the domain are evaluated by extrapolation.

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

Parameters

Compulsory Input Parameters

1:     x(m) – double array
2:     y(m) – double array
3:     f(m) – double array
m, the dimension of the array, must satisfy the constraint m3m3.
The coordinates of the rrth data point, for r = 1,2,,mr=1,2,,m. The data points are accepted in any order, but see Section [Further Comments].
Constraint: the (x,y)(x,y) nodes must not all be collinear, and each node must be unique.

Optional Input Parameters

1:     m – int64int32nag_int scalar
Default: The dimension of the arrays x, y, f. (An error is raised if these dimensions are not equal.)
mm, the number of data points.
Constraint: m3m3.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     triang(7 × m7×m) – int64int32nag_int array
A data structure defining the computed triangulation, in a form suitable for passing to nag_interp_2d_scat_eval (e01sb).
2:     grads(22,m) – double array
3:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,m < 3m<3.
  ifail = 2ifail=2
On entry,all the (x,y) pairs are collinear.
  ifail = 3ifail=3
On entry,(x(i),y(i)) = (x(j),y(j))(xi,yi)=(xj,yj) for some ijij.

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.

Further Comments

The time taken for a call of nag_interp_2d_scat (e01sa) is approximately proportional to the number of data points, mm. The function is more efficient if, before entry, the values in x, y and f are arranged so that the x array is in ascending order.

Example

function nag_interp_2d_scat_example
x = [11.16;
     12.85;
     19.85;
     19.72;
     15.91;
     0;
     20.87;
     3.45;
     14.26;
     17.43;
     22.8;
     7.58;
     25;
     0;
     9.66;
     5.22;
     17.25;
     25;
     12.13;
     22.23;
     11.52;
     15.2;
     7.54;
     17.32;
     2.14;
     0.51;
     22.69;
     5.47;
     21.67;
     3.31];
y = [1.24;
     3.06;
     10.72;
     1.39;
     7.74;
     20;
     20;
     12.78;
     17.87;
     3.46;
     12.39;
     1.98;
     11.87;
     0;
     20;
     14.66;
     19.57;
     3.87;
     10.79;
     6.21;
     8.53;
     0;
     10.69;
     13.78;
     15.03;
     8.37;
     19.63;
     17.13;
     14.36;
     0.33];
f = [22.15;
     22.11;
     7.97;
     16.83;
     15.3;
     34.6;
     5.74;
     41.24;
     10.74;
     18.6;
     5.47;
     29.87;
     4.4;
     58.2;
     4.73;
     40.36;
     6.43;
     8.74;
     13.71;
     10.25;
     15.74;
     21.6;
     19.31;
     12.11;
     53.1;
     49.43;
     3.25;
     28.63;
     5.52;
     44.08];
[triang, grads, ifail] = nag_interp_2d_scat(x, y, f)
 

triang =

                    2
                   12
                   30
                   22
                    5
                   21
                   12
                    1
                   22
                   10
                    5
                   20
                   11
                   29
                   24
                   18
                   20
                   10
                   22
                    0
                   21
                    2
                   10
                   20
                    3
                   24
                   19
                   14
                   26
                   25
                   28
                   15
                    0
                   15
                   17
                   29
                   27
                    0
                   16
                   25
                   26
                   23
                   17
                   15
                   19
                   24
                    2
                   22
                    4
                   20
                    5
                   29
                    3
                   20
                   13
                   30
                    1
                    2
                   21
                   23
                   26
                   27
                   29
                   11
                   20
                   18
                    0
                   22
                   30
                   26
                    6
                    0
                    6
                   28
                   16
                   19
                    9
                   17
                    7
                    0
                   25
                    8
                   23
                   19
                   15
                   28
                   24
                   29
                    7
                   15
                    9
                   13
                   20
                    4
                    0
                   15
                   16
                   23
                   21
                    5
                   24
                    9
                    4
                   18
                   13
                   11
                    3
                    5
                   10
                    5
                   19
                   23
                   12
                    2
                    4
                   10
                    2
                    1
                   30
                   14
                    0
                   19
                   16
                    8
                   26
                   12
                   21
                    5
                    3
                   29
                   17
                    9
                   19
                   16
                   28
                    6
                   26
                    8
                    6
                   14
                   30
                   12
                   23
                    8
                   25
                    7
                   29
                   13
                    0
                    6
                   25
                   16
                   15
                    3
                   11
                   13
                   27
                    7
                   17
                   24
                   12
                   26
                   14
                   22
                    1
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    4
                   10
                   15
                   20
                   27
                   33
                   38
                   42
                   46
                   51
                   55
                   61
                   67
                   72
                   80
                   86
                   91
                   95
                  102
                  109
                  114
                  121
                  127
                  133
                  138
                  145
                  149
                  153
                  160
                  165


grads =

  Columns 1 through 9

   -1.1404   -0.4357   -1.1617   -1.2770   -0.6278   -3.1328   -0.6231   -4.1162   -0.1496
    1.1024   -0.4120   -0.1997   -0.4772   -1.2760   -4.8673    0.4750    4.0498   -1.4064

  Columns 10 through 18

   -1.0252   -0.5330   -2.4193   -0.5942   -4.3053   -1.2108   -4.2773   -0.2324   -1.2172
   -0.6116   -0.4112   -1.5365   -0.5379   -0.7194   -4.7026   -0.4552   -1.3563   -0.6099

  Columns 19 through 27

   -0.7484   -1.1258   -0.1296   -0.4934   -2.9679   -1.1591   -4.9834   -4.4156   -1.7010
    0.0376   -0.9677   -1.3922   -0.4380    1.8909   -0.0578   -0.5508    0.1561   -0.2134

  Columns 28 through 30

   -3.8652   -1.1144   -3.5581
   -6.0070   -0.3749   -0.9580


ifail =

                    0


function e01sa_example
x = [11.16;
     12.85;
     19.85;
     19.72;
     15.91;
     0;
     20.87;
     3.45;
     14.26;
     17.43;
     22.8;
     7.58;
     25;
     0;
     9.66;
     5.22;
     17.25;
     25;
     12.13;
     22.23;
     11.52;
     15.2;
     7.54;
     17.32;
     2.14;
     0.51;
     22.69;
     5.47;
     21.67;
     3.31];
y = [1.24;
     3.06;
     10.72;
     1.39;
     7.74;
     20;
     20;
     12.78;
     17.87;
     3.46;
     12.39;
     1.98;
     11.87;
     0;
     20;
     14.66;
     19.57;
     3.87;
     10.79;
     6.21;
     8.53;
     0;
     10.69;
     13.78;
     15.03;
     8.37;
     19.63;
     17.13;
     14.36;
     0.33];
f = [22.15;
     22.11;
     7.97;
     16.83;
     15.3;
     34.6;
     5.74;
     41.24;
     10.74;
     18.6;
     5.47;
     29.87;
     4.4;
     58.2;
     4.73;
     40.36;
     6.43;
     8.74;
     13.71;
     10.25;
     15.74;
     21.6;
     19.31;
     12.11;
     53.1;
     49.43;
     3.25;
     28.63;
     5.52;
     44.08];
[triang, grads, ifail] = e01sa(x, y, f)
 

triang =

                    2
                   12
                   30
                   22
                    5
                   21
                   12
                    1
                   22
                   10
                    5
                   20
                   11
                   29
                   24
                   18
                   20
                   10
                   22
                    0
                   21
                    2
                   10
                   20
                    3
                   24
                   19
                   14
                   26
                   25
                   28
                   15
                    0
                   15
                   17
                   29
                   27
                    0
                   16
                   25
                   26
                   23
                   17
                   15
                   19
                   24
                    2
                   22
                    4
                   20
                    5
                   29
                    3
                   20
                   13
                   30
                    1
                    2
                   21
                   23
                   26
                   27
                   29
                   11
                   20
                   18
                    0
                   22
                   30
                   26
                    6
                    0
                    6
                   28
                   16
                   19
                    9
                   17
                    7
                    0
                   25
                    8
                   23
                   19
                   15
                   28
                   24
                   29
                    7
                   15
                    9
                   13
                   20
                    4
                    0
                   15
                   16
                   23
                   21
                    5
                   24
                    9
                    4
                   18
                   13
                   11
                    3
                    5
                   10
                    5
                   19
                   23
                   12
                    2
                    4
                   10
                    2
                    1
                   30
                   14
                    0
                   19
                   16
                    8
                   26
                   12
                   21
                    5
                    3
                   29
                   17
                    9
                   19
                   16
                   28
                    6
                   26
                    8
                    6
                   14
                   30
                   12
                   23
                    8
                   25
                    7
                   29
                   13
                    0
                    6
                   25
                   16
                   15
                    3
                   11
                   13
                   27
                    7
                   17
                   24
                   12
                   26
                   14
                   22
                    1
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    0
                    4
                   10
                   15
                   20
                   27
                   33
                   38
                   42
                   46
                   51
                   55
                   61
                   67
                   72
                   80
                   86
                   91
                   95
                  102
                  109
                  114
                  121
                  127
                  133
                  138
                  145
                  149
                  153
                  160
                  165


grads =

  Columns 1 through 9

   -1.1404   -0.4357   -1.1617   -1.2770   -0.6278   -3.1328   -0.6231   -4.1162   -0.1496
    1.1024   -0.4120   -0.1997   -0.4772   -1.2760   -4.8673    0.4750    4.0498   -1.4064

  Columns 10 through 18

   -1.0252   -0.5330   -2.4193   -0.5942   -4.3053   -1.2108   -4.2773   -0.2324   -1.2172
   -0.6116   -0.4112   -1.5365   -0.5379   -0.7194   -4.7026   -0.4552   -1.3563   -0.6099

  Columns 19 through 27

   -0.7484   -1.1258   -0.1296   -0.4934   -2.9679   -1.1591   -4.9834   -4.4156   -1.7010
    0.0376   -0.9677   -1.3922   -0.4380    1.8909   -0.0578   -0.5508    0.1561   -0.2134

  Columns 28 through 30

   -3.8652   -1.1144   -3.5581
   -6.0070   -0.3749   -0.9580


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013