Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_interp_3d_scat_shep_eval (e01th)

## Purpose

nag_interp_3d_scat_shep_eval (e01th) evaluates the three-dimensional interpolating function generated by nag_interp_3d_scat_shep (e01tg) and its first partial derivatives.

## Syntax

[q, qx, qy, qz, ifail] = e01th(x, y, z, f, iq, rq, u, v, w, 'm', m, 'n', n)
[q, qx, qy, qz, ifail] = nag_interp_3d_scat_shep_eval(x, y, z, f, iq, rq, u, v, w, 'm', m, 'n', n)

## Description

nag_interp_3d_scat_shep_eval (e01th) takes as input the interpolant $Q\left(x,y,z\right)$ of a set of scattered data points $\left({x}_{r},{y}_{r},{z}_{r},{f}_{r}\right)$, for $\mathit{r}=1,2,\dots ,m$, as computed by nag_interp_3d_scat_shep (e01tg), and evaluates the interpolant and its first partial derivatives at the set of points $\left({u}_{i},{v}_{i},{w}_{i}\right)$, for $\mathit{i}=1,2,\dots ,n$.
nag_interp_3d_scat_shep_eval (e01th) must only be called after a call to nag_interp_3d_scat_shep (e01tg).
This function is derived from the function QS3GRD described by Renka (1988).

## References

Renka R J (1988) Algorithm 661: QSHEP3D: Quadratic Shepard method for trivariate interpolation of scattered data ACM Trans. Math. Software 14 151–152

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{x}\left({\mathbf{m}}\right)$ – double array
2:     $\mathrm{y}\left({\mathbf{m}}\right)$ – double array
3:     $\mathrm{z}\left({\mathbf{m}}\right)$ – double array
4:     $\mathrm{f}\left({\mathbf{m}}\right)$ – double array
m, x, y, z and f must be the same values as were supplied in the preceding call to nag_interp_3d_scat_shep (e01tg).
5:     $\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_3d_scat_shep (e01tg).
6:     $\mathrm{rq}\left(\mathit{lrq}\right)$ – double array
lrq, the dimension of the array, must satisfy the constraint $\mathit{lrq}\ge 10×{\mathbf{m}}+7$.
Must be unchanged from the value returned from a previous call to nag_interp_3d_scat_shep (e01tg).
7:     $\mathrm{u}\left({\mathbf{n}}\right)$ – double array
8:     $\mathrm{v}\left({\mathbf{n}}\right)$ – double array
9:     $\mathrm{w}\left({\mathbf{n}}\right)$ – double array
${\mathbf{u}}\left(\mathit{i}\right)$, ${\mathbf{v}}\left(\mathit{i}\right)$, ${\mathbf{w}}\left(\mathit{i}\right)$ must be set to the evaluation point $\left({u}_{\mathit{i}},{v}_{\mathit{i}},{w}_{\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, z, f. (An error is raised if these dimensions are not equal.)
m, x, y, z and f must be the same values as were supplied in the preceding call to nag_interp_3d_scat_shep (e01tg).
2:     $\mathrm{n}$int64int32nag_int scalar
Default: the dimension of the arrays u, v, w. (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
${\mathbf{q}}\left(\mathit{i}\right)$ contains the value of the interpolant, at $\left({u}_{\mathit{i}},{v}_{\mathit{i}},{w}_{\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_3d_scat_shep_eval (e01th) returns with ${\mathbf{ifail}}={\mathbf{3}}$.
2:     $\mathrm{qx}\left({\mathbf{n}}\right)$ – double array
3:     $\mathrm{qy}\left({\mathbf{n}}\right)$ – double array
4:     $\mathrm{qz}\left({\mathbf{n}}\right)$ – double array
${\mathbf{qx}}\left(\mathit{i}\right)$, ${\mathbf{qy}}\left(\mathit{i}\right)$, ${\mathbf{qz}}\left(\mathit{i}\right)$ contains the value of the partial derivatives of the interpolant $Q\left(x,y,z\right)$ at $\left({u}_{\mathit{i}},{v}_{\mathit{i}},{w}_{\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, qy and qz are set to the largest machine representable number (see nag_machine_real_largest (x02al)), and nag_interp_3d_scat_shep_eval (e01th) returns with ${\mathbf{ifail}}={\mathbf{3}}$.
5:     $\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}}<10$, or $\mathit{liq}<2×{\mathbf{m}}+1$, or $\mathit{lrq}<10×{\mathbf{m}}+7$, 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_3d_scat_shep (e01tg) and nag_interp_3d_scat_shep_eval (e01th).
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, qy and qz have been set to the largest machine representable number (see nag_machine_real_largest (x02al)).
${\mathbf{ifail}}=-99$
${\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.

The time taken for a call to nag_interp_3d_scat_shep_eval (e01th) will depend in general on the distribution of the data points. If x, y and z are approximately uniformly distributed, then the time taken should be only $\mathit{O}\left({\mathbf{n}}\right)$. At worst $\mathit{O}\left({\mathbf{m}}{\mathbf{n}}\right)$ time will be required.

## Example

See Example in nag_interp_3d_scat_shep (e01tg).
```function e01th_example

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

data = [ 0.80  0.23  0.37  0.51;
0.23  0.88  0.05  1.80;
0.18  0.43  0.04  0.11;
0.58  0.95  0.62  2.65;
0.64  0.69  0.20  0.93;
0.88  0.35  0.49  0.72;
0.30  0.10  0.78 -0.11;
0.87  0.09  0.05  0.67;
0.04  0.02  0.40  0.00;
0.62  0.90  0.43  2.20;
0.87  0.96  0.24  3.17;
0.62  0.64  0.45  0.74;
0.86  0.13  0.47  0.64;
0.87  0.60  0.46  1.07;
0.49  0.43  0.13  0.22;
0.12  0.61  0.00  0.41;
0.02  0.71  0.82  0.58;
0.62  0.93  0.44  2.48;
0.49  0.54  0.04  0.37;
0.36  0.56  0.39  0.35;
0.62  0.42  0.97 -0.20;
0.01  0.72  0.45  0.78;
0.41  0.36  0.52  0.11;
0.17  0.99  0.65  2.82;
0.51  0.29  0.59  0.14;
0.85  0.05  0.04  0.61;
0.20  0.20  0.87 -0.25;
0.04  0.67  0.04  0.59;
0.31  0.63  0.18  0.50;
0.88  0.27  0.07  0.71];

x = data(:,1); y = data(:,2); z = data(:,3); f = data(:,4);
nw = int64(0);
nq = nw;
[iq, rq, ifail] = e01tg( ...
x, y, z, f, nw, nq);

% Evaluate at equispaced points on diagonal line
px = [0.1:0.1:0.6]'; py = px; pz = px;

[q, qx, qy, qz, ifail] = e01th( ...
x, y, z, f, iq, rq, px, py, pz);

fprintf('  Evaluation point       Q(x,y,z)\n');
fprintf(' (%4.1f, %4.1f, %4.1f)    %8.4f\n',[px py pz q]');

```
```e01th example results

Evaluation point       Q(x,y,z)
( 0.1,  0.1,  0.1)      0.2630
( 0.2,  0.2,  0.2)      0.1182
( 0.3,  0.3,  0.3)      0.0811
( 0.4,  0.4,  0.4)      0.1552
( 0.5,  0.5,  0.5)      0.3019
( 0.6,  0.6,  0.6)      0.5712
```