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_eval (e01sb)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_interp_2d_scat_eval (e01sb) evaluates at a given point the two-dimensional interpolant function computed by nag_interp_2d_scat (e01sa).

Syntax

[pf, ifail] = e01sb(x, y, f, triang, grads, px, py, 'm', m)
[pf, ifail] = nag_interp_2d_scat_eval(x, y, f, triang, grads, px, py, 'm', m)

Description

nag_interp_2d_scat_eval (e01sb) takes as input the arguments defining the interpolant Fx,y of a set of scattered data points xr,yr,fr, for r=1,2,,m, as computed by nag_interp_2d_scat (e01sa), and evaluates the interpolant at the point px,py.
If px,py is equal to xr,yr for some value of r, the returned value will be equal to fr.
If px,py is not equal to xr,yr for any r, the derivatives in grads will be used to compute the interpolant. A triangle is sought which contains the point px,py, and the vertices of the triangle along with the partial derivatives and fr values at the vertices are used to compute the value Fpx,py. If the point px,py lies outside the triangulation defined by the input arguments, the returned value is obtained by extrapolation. In this case, the interpolating function f is extended linearly beyond the triangulation boundary. The method is described in more detail in Renka and Cline (1984) and the code is derived from Renka (1984).
nag_interp_2d_scat_eval (e01sb) must only be called after a call to nag_interp_2d_scat (e01sa).

References

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

Parameters

Compulsory Input Parameters

1:     xm – double array
2:     ym – double array
3:     fm – double array
4:     triang7×m int64int32nag_int array
5:     grads2m – double array
m, x, y, f, triang and grads must be unchanged from the previous call of nag_interp_2d_scat (e01sa).
6:     px – double scalar
7:     py – double scalar
The point px,py at which the interpolant is to be evaluated.

Optional Input Parameters

1:     m int64int32nag_int scalar
Default: the dimension of the arrays x, y, f, grads. (An error is raised if these dimensions are not equal.)
m, x, y, f, triang and grads must be unchanged from the previous call of nag_interp_2d_scat (e01sa).

Output Parameters

1:     pf – double scalar
The value of the interpolant evaluated at the point px,py.
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

   ifail=1
On entry,m<3.
   ifail=2
On entry, the triangulation information held in the array triang does not specify a valid triangulation of the data points. triang may have been corrupted since the call to nag_interp_2d_scat (e01sa).
W  ifail=3
The evaluation point (px,py) lies outside the nodal triangulation, and the value returned in pf is computed by extrapolation.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

Computational errors should be negligible in most practical situations.

Further Comments

The time taken for a call of nag_interp_2d_scat_eval (e01sb) is approximately proportional to the number of data points, m.
The results returned by this function are particularly suitable for applications such as graph plotting, producing a smooth surface from a number of scattered points.

Example

See Example in nag_interp_2d_scat (e01sa).
function e01sb_example


fprintf('e01sb example results\n\n');

x = [11.16; 12.85; 19.85; 19.72; 15.91;  0.00; 20.87;  3.45; 14.26; ...
     17.43; 22.80;  7.58; 25.00;  0.00;  9.66;  5.22; 17.25; 25.00; ...
     12.13; 22.23; 11.52; 15.20;  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.00; 20.00; 12.78; 17.87; ...
      3.46; 12.39;  1.98; 11.87;  0.00; 20.00; 14.66; 19.57;  3.87; ...
     10.79;  6.21;  8.53;  0.00; 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.30; 34.60;  5.74; 41.24; 10.74; ...
     18.60;  5.47; 29.87;  4.40; 58.20;  4.73; 40.36;  6.43;  8.74; ...
     13.71; 10.25; 15.74; 21.60; 19.31; 12.11; 53.10; 49.43;  3.25; ...
     28.63;  5.52; 44.08];

% Triangulate and obtain details of interpolant
[triang,grads,ifail] = e01sa( ...
                              x,y,f);

px = [3:3:21];
py = [2:3:17];
% Evaluate interpolant at on regular mesh (px,py)
for i = 1:6
  for j = 1:7
    [pf(i,j), ifail] = e01sb( ...
                              x, y, f, triang, grads, px(j), py(i));
  end
end

% Display interpolated values
matrix = 'General';
diag = 'Non-unit';
format = 'F7.2';
title  = 'Spline evaluated on a regular mesh (x across, y down):';
chlab  = 'Character';
rlabs  = cellstr(num2str(py'));
clabs  = cellstr(num2str(px'));
ncols  = int64(80);
indent = int64(0);
[ifail] =  x04cb( ...
                  matrix, diag, pf, format, title, chlab, ...
                  rlabs, chlab, clabs, ncols, indent);



e01sb example results

 Spline evaluated on a regular mesh (x across, y down):
          3      6      9     12     15     18     21
  2   43.52  33.91  26.59  22.23  21.15  18.67  14.88
  5   40.49  29.26  22.51  20.72  19.30  16.72  12.87
  8   37.90  23.97  16.79  16.43  15.46  13.02   9.30
 11   38.55  25.25  16.72  13.83  13.08  10.71   6.88
 14   47.61  36.66  22.87  14.02  13.44  11.20   6.46
 17   41.25  27.62  18.03  12.29  11.68   9.09   5.37

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–2015