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(x,y,z)$Q\left(x,y,z\right)$ of a set of scattered data points (xr,yr,zr,fr)$\left({x}_{r},{y}_{r},{z}_{r},{f}_{r}\right)$, for r = 1,2,,m$\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 (ui,vi,wi)$\left({u}_{i},{v}_{i},{w}_{i}\right)$, for i = 1,2,,n$\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:     x(m) – double array
2:     y(m) – double array
3:     z(m) – double array
4:     f(m) – 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:     iq(liq) – int64int32nag_int array
liq, the dimension of the array, must satisfy the constraint liq2 × m + 1$\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:     rq(lrq) – double array
lrq, the dimension of the array, must satisfy the constraint lrq10 × m + 7$\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:     u(n) – double array
8:     v(n) – double array
9:     w(n) – double array
n, the dimension of the array, must satisfy the constraint n1${\mathbf{n}}\ge 1$.
u(i)${\mathbf{u}}\left(\mathit{i}\right)$, v(i)${\mathbf{v}}\left(\mathit{i}\right)$, w(i)${\mathbf{w}}\left(\mathit{i}\right)$ must be set to the evaluation point (ui,vi,wi)$\left({u}_{\mathit{i}},{v}_{\mathit{i}},{w}_{\mathit{i}}\right)$, for i = 1,2,,n$\mathit{i}=1,2,\dots ,n$.

### Optional Input Parameters

1:     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:     n – int64int32nag_int scalar
Default: The dimension of the arrays u, v, w. (An error is raised if these dimensions are not equal.)
n$n$, the number of evaluation points.
Constraint: n1${\mathbf{n}}\ge 1$.

liq lrq

### Output Parameters

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

ifail = 1${\mathbf{ifail}}=1$
 On entry, m < 10${\mathbf{m}}<10$, or liq < 2 × m + 1$\mathit{liq}<2×{\mathbf{m}}+1$, or lrq < 10 × m + 7$\mathit{lrq}<10×{\mathbf{m}}+7$, or n < 1${\mathbf{n}}<1$.
ifail = 2${\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 ifail = 3${\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)).

## 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 O(n)$\mathit{O}\left({\mathbf{n}}\right)$. At worst O(mn)$\mathit{O}\left({\mathbf{m}}{\mathbf{n}}\right)$ time will be required.

## Example

```function nag_interp_3d_scat_shep_eval_example
nw = int64(0);
nq = int64(0);
x = [0.8;
0.23;
0.18;
0.58;
0.64;
0.88;
0.3;
0.87;
0.04;
0.62;
0.87;
0.62;
0.86;
0.87;
0.49;
0.12;
0.02;
0.62;
0.49;
0.36;
0.62;
0.01;
0.41;
0.17;
0.51;
0.85;
0.2;
0.04;
0.31;
0.88];
y = [0.23;
0.88;
0.43;
0.95;
0.69;
0.35;
0.1;
0.09;
0.02;
0.9;
0.96;
0.64;
0.13;
0.6;
0.43;
0.61;
0.71;
0.93;
0.54;
0.56;
0.42;
0.72;
0.36;
0.99;
0.29;
0.05;
0.2;
0.67;
0.63;
0.27];
z = [0.37;
0.05;
0.04;
0.62;
0.2;
0.49;
0.78;
0.05;
0.4;
0.43;
0.24;
0.45;
0.47;
0.46;
0.13;
0;
0.82;
0.44;
0.04;
0.39;
0.97;
0.45;
0.52;
0.65;
0.59;
0.04;
0.87;
0.04;
0.18;
0.07];
f = [0.51;
1.8;
0.11;
2.65;
0.93;
0.72;
-0.11;
0.67;
0;
2.2;
3.17;
0.74;
0.64;
1.07;
0.22;
0.41;
0.58;
2.48;
0.37;
0.35;
-0.2;
0.78;
0.11;
2.82;
0.14;
0.61;
-0.25;
0.59;
0.5;
0.71];
u = [0.1;
0.2;
0.3;
0.4;
0.5;
0.6];
v = [0.1;
0.2;
0.3;
0.4;
0.5;
0.6];
w = [0.1;
0.2;
0.3;
0.4;
0.5;
0.6];
[iq, rq, ifail] = nag_interp_3d_scat_shep(x, y, z, f, nw, nq);
[q, qx, qy, qz, ifail] = nag_interp_3d_scat_shep_eval(x, y, z, f, iq, rq, u, v, w)
```
```

q =

0.2630
0.1182
0.0811
0.1552
0.3019
0.5712

qx =

0.6461
0.5704
0.4660
0.6000
0.5951
1.1069

qy =

-0.8302
-0.7920
-0.0879
0.6071
1.2569
2.9164

qz =

-1.7062
-0.7648
-0.1490
0.0258
-0.1253
-0.2232

ifail =

0

```
```function e01th_example
nw = int64(0);
nq = int64(0);
x = [0.8;
0.23;
0.18;
0.58;
0.64;
0.88;
0.3;
0.87;
0.04;
0.62;
0.87;
0.62;
0.86;
0.87;
0.49;
0.12;
0.02;
0.62;
0.49;
0.36;
0.62;
0.01;
0.41;
0.17;
0.51;
0.85;
0.2;
0.04;
0.31;
0.88];
y = [0.23;
0.88;
0.43;
0.95;
0.69;
0.35;
0.1;
0.09;
0.02;
0.9;
0.96;
0.64;
0.13;
0.6;
0.43;
0.61;
0.71;
0.93;
0.54;
0.56;
0.42;
0.72;
0.36;
0.99;
0.29;
0.05;
0.2;
0.67;
0.63;
0.27];
z = [0.37;
0.05;
0.04;
0.62;
0.2;
0.49;
0.78;
0.05;
0.4;
0.43;
0.24;
0.45;
0.47;
0.46;
0.13;
0;
0.82;
0.44;
0.04;
0.39;
0.97;
0.45;
0.52;
0.65;
0.59;
0.04;
0.87;
0.04;
0.18;
0.07];
f = [0.51;
1.8;
0.11;
2.65;
0.93;
0.72;
-0.11;
0.67;
0;
2.2;
3.17;
0.74;
0.64;
1.07;
0.22;
0.41;
0.58;
2.48;
0.37;
0.35;
-0.2;
0.78;
0.11;
2.82;
0.14;
0.61;
-0.25;
0.59;
0.5;
0.71];
u = [0.1;
0.2;
0.3;
0.4;
0.5;
0.6];
v = [0.1;
0.2;
0.3;
0.4;
0.5;
0.6];
w = [0.1;
0.2;
0.3;
0.4;
0.5;
0.6];
[iq, rq, ifail] = e01tg(x, y, z, f, nw, nq);
[q, qx, qy, qz, ifail] = e01th(x, y, z, f, iq, rq, u, v, w)
```
```

q =

0.2630
0.1182
0.0811
0.1552
0.3019
0.5712

qx =

0.6461
0.5704
0.4660
0.6000
0.5951
1.1069

qy =

-0.8302
-0.7920
-0.0879
0.6071
1.2569
2.9164

qz =

-1.7062
-0.7648
-0.1490
0.0258
-0.1253
-0.2232

ifail =

0

```