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)

## 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 $Q\left(x,y\right)$ of a set of scattered data points $\left({x}_{r},{y}_{r},{f}_{r}\right)$, for $\mathit{r}=1,2,\dots ,m$, as computed by nag_interp_2d_scat_shep (e01sg), and evaluates the interpolant and its first partial derivatives at the set of points $\left({u}_{i},{v}_{i}\right)$, for $\mathit{i}=1,2,\dots ,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:     $\mathrm{x}\left({\mathbf{m}}\right)$ – double array
2:     $\mathrm{y}\left({\mathbf{m}}\right)$ – double array
3:     $\mathrm{f}\left({\mathbf{m}}\right)$ – 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:     $\mathrm{iq}\left(\mathit{liq}\right)$int64int32nag_int array
liq, the dimension of the array, must satisfy the constraint $\mathit{liq}\ge 2×{\mathbf{m}}+1$.
Must be unchanged from the value returned from a previous call to nag_interp_2d_scat_shep (e01sg).
5:     $\mathrm{rq}\left(\mathit{lrq}\right)$ – double array
lrq, the dimension of the array, must satisfy the constraint $\mathit{lrq}\ge 6×{\mathbf{m}}+5$.
Must be unchanged from the value returned from a previous call to nag_interp_2d_scat_shep (e01sg).
6:     $\mathrm{u}\left({\mathbf{n}}\right)$ – double array
7:     $\mathrm{v}\left({\mathbf{n}}\right)$ – double array
The evaluation points $\left({u}_{\mathit{i}},{v}_{\mathit{i}}\right)$, for $\mathit{i}=1,2,\dots ,n$.

### Optional Input Parameters

1:     $\mathrm{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:     $\mathrm{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: ${\mathbf{n}}\ge 1$.

### Output Parameters

1:     $\mathrm{q}\left({\mathbf{n}}\right)$ – double array
The values of the interpolant at $\left({u}_{\mathit{i}},{v}_{\mathit{i}}\right)$, for $\mathit{i}=1,2,\dots ,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 ${\mathbf{ifail}}={\mathbf{3}}$.
2:     $\mathrm{qx}\left({\mathbf{n}}\right)$ – double array
3:     $\mathrm{qy}\left({\mathbf{n}}\right)$ – double array
The values of the partial derivatives of the interpolant $Q\left(x,y\right)$ at $\left({u}_{\mathit{i}},{v}_{\mathit{i}}\right)$, for $\mathit{i}=1,2,\dots ,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 ${\mathbf{ifail}}={\mathbf{3}}$.
4:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{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.

${\mathbf{ifail}}=1$
 On entry, ${\mathbf{m}}<6$, or $\mathit{liq}<2×{\mathbf{m}}+1$, or $\mathit{lrq}<6×{\mathbf{m}}+5$, or ${\mathbf{n}}<1$.
${\mathbf{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  ${\mathbf{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)).
${\mathbf{ifail}}=-99$
An unexpected error has been triggered by this routine. Please contact NAG.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{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 $\mathit{O}\left(n\right)$. At worst $\mathit{O}\left(mn\right)$ 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