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_shep_eval (e01sh)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_interp_2d_scat_shep_eval (e01sh) evaluates the two-dimensional interpolating function generated by nag_interp_2d_scat_shep (e01sg) and its first partial derivatives.

Syntax

[q, qx, qy, ifail] = e01sh(x, y, f, iq, rq, u, v, 'm', m, 'n', n)
[q, qx, qy, ifail] = nag_interp_2d_scat_shep_eval(x, y, f, iq, rq, u, v, 'm', m, 'n', n)

Description

nag_interp_2d_scat_shep_eval (e01sh) takes as input the interpolant Qx,y of a set of scattered data points xr,yr,fr, for r=1,2,,m, as computed by nag_interp_2d_scat_shep (e01sg), and evaluates the interpolant and its first partial derivatives at the set of points ui,vi, for i=1,2,,n.
nag_interp_2d_scat_shep_eval (e01sh) must only be called after a call to nag_interp_2d_scat_shep (e01sg).
This function is derived from the function QS2GRD described by Renka (1988).

References

Renka R J (1988) Algorithm 660: QSHEP2D: Quadratic Shepard method for bivariate interpolation of scattered data ACM Trans. Math. Software 14 149–150

Parameters

Compulsory Input Parameters

1:     xm – double array
2:     ym – double array
3:     fm – double array
m, x, y and f must be the same values as were supplied in the preceding call to nag_interp_2d_scat_shep (e01sg).
4:     iqliq int64int32nag_int array
liq, the dimension of the array, must satisfy the constraint liq2×m+1.
Must be unchanged from the value returned from a previous call to nag_interp_2d_scat_shep (e01sg).
5:     rqlrq – double array
lrq, the dimension of the array, must satisfy the constraint lrq6×m+5.
Must be unchanged from the value returned from a previous call to nag_interp_2d_scat_shep (e01sg).
6:     un – double array
7:     vn – double array
The evaluation points ui,vi, for i=1,2,,n.

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.)
m, x, y and f must be the same values as were supplied in the preceding call to nag_interp_2d_scat_shep (e01sg).
2:     n int64int32nag_int scalar
Default: the dimension of the arrays u, v. (An error is raised if these dimensions are not equal.)
n, the number of evaluation points.
Constraint: n1.

Output Parameters

1:     qn – double array
The values of the interpolant at ui,vi, for i=1,2,,n. If any of these evaluation points lie outside the region of definition of the interpolant the corresponding entries in q are set to the largest machine representable number (see nag_machine_real_largest (x02al)), and nag_interp_2d_scat_shep_eval (e01sh) returns with ifail=3.
2:     qxn – double array
3:     qyn – double array
The values of the partial derivatives of the interpolant Qx,y at ui,vi, for i=1,2,,n. If any of these evaluation points lie outside the region of definition of the interpolant, the corresponding entries in qx and qy are set to the largest machine representable number (see nag_machine_real_largest (x02al)), and nag_interp_2d_scat_shep_eval (e01sh) returns with ifail=3.
4:     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<6,
orliq<2×m+1,
orlrq<6×m+5,
orn<1.
   ifail=2
Values supplied in iq or rq appear to be invalid. Check that these arrays have not been corrupted between the calls to nag_interp_2d_scat_shep (e01sg) and nag_interp_2d_scat_shep_eval (e01sh).
W  ifail=3
At least one evaluation point lies outside the region of definition of the interpolant. At all such points the corresponding values in q, qx and qy have been set to the largest machine representable number (see nag_machine_real_largest (x02al)).
   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 to nag_interp_2d_scat_shep_eval (e01sh) will depend in general on the distribution of the data points. If x and y are approximately uniformly distributed, then the time taken should be only On. At worst Omn time will be required.

Example

See Example in nag_interp_2d_scat_shep (e01sg).
function e01sh_example


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

% Scattered Grid Data
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];

% Generate interpolant
nw = int64(0);
nq = int64(0);
[iq, rq, ifail] = e01sg(x, y, f, nw, nq);

% Interpolation points
u = [20.00;  6.41;  7.54;  9.91; 12.30];
v = [ 3.14; 15.44; 10.69; 18.27;  9.22];

% Interpolate at interpolation points 
[q, qx, qy, ifail] = e01sh(x, y, f, iq, rq, u, v);

fprintf('Interpolated values Q and its derivatives at (u,v)\n'); 
fprintf('     u      v      q      qx     qy\n');
for i = 1:size(u,1)
  fprintf('%7.2f%7.2f%7.2f%7.2f%7.2f\n', u(i), v(i), q(i), qx(i), qy(i));
end


e01sh example results

Interpolated values Q and its derivatives at (u,v)
     u      v      q      qx     qy
  20.00   3.14  15.89  -1.28  -0.63
   6.41  15.44  34.05  -3.62  -3.56
   7.54  10.69  19.31  -2.84   0.81
   9.91  18.27  13.68  -1.59  -4.71
  12.30   9.22  14.56  -0.68  -0.78

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