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_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(x,y)$Q\left(x,y\right)$ of a set of scattered data points (xr,yr,fr)$\left({x}_{r},{y}_{r},{f}_{r}\right)$, for r = 1,2,,m$\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 (ui,vi)$\left({u}_{i},{v}_{i}\right)$, for i = 1,2,,n$\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:     x(m) – double array
2:     y(m) – double array
3:     f(m) – 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:     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_2d_scat_shep (e01sg).
5:     rq(lrq) – double array
lrq, the dimension of the array, must satisfy the constraint lrq6 × m + 5$\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:     u(n) – double array
7:     v(n) – double array
n, the dimension of the array, must satisfy the constraint n1${\mathbf{n}}\ge 1$.
The evaluation points (ui,vi)$\left({u}_{\mathit{i}},{v}_{\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, 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$n$, the number of evaluation points.
Constraint: n1${\mathbf{n}}\ge 1$.

liq lrq

### Output Parameters

1:     q(n) – double array
The values of the interpolant at (ui,vi)$\left({u}_{\mathit{i}},{v}_{\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_2d_scat_shep_eval (e01sh) returns with ${\mathbf{ifail}}={\mathbf{3}}$.
2:     qx(n) – double array
3:     qy(n) – double array
The values of the partial derivatives of the interpolant Q(x,y)$Q\left(x,y\right)$ at (ui,vi)$\left({u}_{\mathit{i}},{v}_{\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 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:     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 < 6${\mathbf{m}}<6$, or liq < 2 × m + 1$\mathit{liq}<2×{\mathbf{m}}+1$, or lrq < 6 × m + 5$\mathit{lrq}<6×{\mathbf{m}}+5$, 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_2d_scat_shep (e01sg) and nag_interp_2d_scat_shep_eval (e01sh).
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 and qy 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_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 O(n)$\mathit{O}\left(n\right)$. At worst O(mn)$\mathit{O}\left(mn\right)$ time will be required.

## Example

```function nag_interp_2d_scat_shep_eval_example
nw = int64(0);
nq = int64(0);
x = [11.16;
12.85;
19.85;
19.72;
15.91;
0;
20.87;
3.45;
14.26;
17.43;
22.8;
7.58;
25;
0;
9.66;
5.22;
17.25;
25;
12.13;
22.23;
11.52;
15.2;
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;
20;
12.78;
17.87;
3.46;
12.39;
1.98;
11.87;
0;
20;
14.66;
19.57;
3.87;
10.79;
6.21;
8.53;
0;
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.3;
34.6;
5.74;
41.24;
10.74;
18.6;
5.47;
29.87;
4.4;
58.2;
4.73;
40.36;
6.43;
8.74;
13.71;
10.25;
15.74;
21.6;
19.31;
12.11;
53.1;
49.43;
3.25;
28.63;
5.52;
44.08];
u = [20;
6.41;
7.54;
9.91;
12.3];
v = [3.14;
15.44;
10.69;
18.27;
9.22];
[iq, rq, ifail] = nag_interp_2d_scat_shep(x, y, f, nw, nq);
[q, qx, qy, ifail] = nag_interp_2d_scat_shep_eval(x, y, f, iq, rq, u, v)
```
```

q =

15.8931
34.0528
19.3100
13.6778
14.5560

qx =

-1.2837
-3.6174
-2.8368
-1.5854
-0.6763

qy =

-0.6347
-3.5600
0.8061
-4.7103
-0.7753

ifail =

0

```
```function e01sh_example
nw = int64(0);
nq = int64(0);
x = [11.16;
12.85;
19.85;
19.72;
15.91;
0;
20.87;
3.45;
14.26;
17.43;
22.8;
7.58;
25;
0;
9.66;
5.22;
17.25;
25;
12.13;
22.23;
11.52;
15.2;
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;
20;
12.78;
17.87;
3.46;
12.39;
1.98;
11.87;
0;
20;
14.66;
19.57;
3.87;
10.79;
6.21;
8.53;
0;
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.3;
34.6;
5.74;
41.24;
10.74;
18.6;
5.47;
29.87;
4.4;
58.2;
4.73;
40.36;
6.43;
8.74;
13.71;
10.25;
15.74;
21.6;
19.31;
12.11;
53.1;
49.43;
3.25;
28.63;
5.52;
44.08];
u = [20;
6.41;
7.54;
9.91;
12.3];
v = [3.14;
15.44;
10.69;
18.27;
9.22];
[iq, rq, ifail] = e01sg(x, y, f, nw, nq);
[q, qx, qy, ifail] = e01sh(x, y, f, iq, rq, u, v)
```
```

q =

15.8931
34.0528
19.3100
13.6778
14.5560

qx =

-1.2837
-3.6174
-2.8368
-1.5854
-0.6763

qy =

-0.6347
-3.5600
0.8061
-4.7103
-0.7753

ifail =

0

```
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 29, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.966143786907196, "perplexity": 6990.251652428291}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2015-22/segments/1432207927388.78/warc/CC-MAIN-20150521113207-00145-ip-10-180-206-219.ec2.internal.warc.gz"}