nag_4d_shep_eval (e01tlc) (PDF version)
e01 Chapter Contents
e01 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_4d_shep_eval (e01tlc)

## 1  Purpose

nag_4d_shep_eval (e01tlc) evaluates the four-dimensional interpolating function generated by nag_4d_shep_interp (e01tkc) and its first partial derivatives.

## 2  Specification

 #include #include
 void nag_4d_shep_eval (Integer m, const double x[], const double f[], const Integer iq[], const double rq[], Integer n, const double xe[], double q[], double qx[], NagError *fail)

## 3  Description

nag_4d_shep_eval (e01tlc) takes as input the interpolant $Q\left(\mathbf{x}\right)$, $x\in {ℝ}^{4}$ of a set of scattered data points $\left({\mathbf{x}}_{\mathit{r}},{f}_{\mathit{r}}\right)$, for $\mathit{r}=1,2,\dots ,m$, as computed by nag_4d_shep_interp (e01tkc), and evaluates the interpolant and its first partial derivatives at the set of points ${\mathbf{x}}_{i}$, for $\mathit{i}=1,2,\dots ,n$.
nag_4d_shep_eval (e01tlc) must only be called after a call to nag_4d_shep_interp (e01tkc).
nag_4d_shep_eval (e01tlc) is derived from the new implementation of QS3GRD described by Renka (1988). It uses the modification for high-dimensional interpolation described by Berry and Minser (1999).
Berry M W, Minser K S (1999) Algorithm 798: high-dimensional interpolation using the modified Shepard method ACM Trans. Math. Software 25 353–366
Renka R J (1988) Algorithm 661: QSHEP3D: Quadratic Shepard method for trivariate interpolation of scattered data ACM Trans. Math. Software 14 151–152

## 5  Arguments

1:    $\mathbf{m}$IntegerInput
On entry: must be the same value supplied for argument m in the preceding call to nag_4d_shep_interp (e01tkc).
Constraint: ${\mathbf{m}}\ge 16$.
2:    $\mathbf{x}\left[4×{\mathbf{m}}\right]$const doubleInput
Note: the coordinates of ${x}_{r}$ are stored in ${\mathbf{x}}\left[\left(r-1\right)×4\right]\dots {\mathbf{x}}\left[\left(r-1\right)×4+3\right]$.
On entry: must be the same array supplied as argument x in the preceding call to nag_4d_shep_interp (e01tkc). It must remain unchanged between calls.
3:    $\mathbf{f}\left[{\mathbf{m}}\right]$const doubleInput
On entry: must be the same array supplied as argument f in the preceding call to nag_4d_shep_interp (e01tkc). It must remain unchanged between calls.
4:    $\mathbf{iq}\left[2×{\mathbf{m}}+1\right]$const IntegerInput
On entry: must be the same array returned as argument iq in the preceding call to nag_4d_shep_interp (e01tkc). It must remain unchanged between calls.
5:    $\mathbf{rq}\left[15×{\mathbf{m}}+9\right]$const doubleInput
On entry: must be the same array returned as argument rq in the preceding call to nag_4d_shep_interp (e01tkc). It must remain unchanged between calls.
6:    $\mathbf{n}$IntegerInput
On entry: $n$, the number of evaluation points.
Constraint: ${\mathbf{n}}\ge 1$.
7:    $\mathbf{xe}\left[4×{\mathbf{n}}\right]$const doubleInput
Note: the $\left(i,j\right)$th element of the matrix is stored in ${\mathbf{xe}}\left[\left(j-1\right)×4+i-1\right]$.
On entry: ${\mathbf{xe}}\left[\left(\mathit{r}-1\right)×4\right],\dots ,{\mathbf{xe}}\left[\left(\mathit{r}-1\right)×4+3\right]$ must be set to the evaluation point ${\mathbf{x}}_{\mathit{i}}$ , for $\mathit{i}=1,2,\dots ,n$.
8:    $\mathbf{q}\left[{\mathbf{n}}\right]$doubleOutput
On exit: ${\mathbf{q}}\left[\mathit{i}-1\right]$ contains the value of the interpolant, at ${\mathbf{x}}_{\mathit{i}}$, 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_real_largest_number (X02ALC)), and nag_4d_shep_eval (e01tlc) returns with ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_BAD_POINT.
9:    $\mathbf{qx}\left[4×{\mathbf{n}}\right]$doubleOutput
Note: the $\left(i,j\right)$th element of the matrix is stored in ${\mathbf{qx}}\left[\left(j-1\right)×4+i-1\right]$.
On exit: ${\mathbf{qx}}\left[\left(i-1\right)×4+j-1\right]$ contains the value of the partial derivatives with respect to ${\mathbf{x}}_{j}$ of the interpolant $Q\left(\mathbf{x}\right)$ at ${\mathbf{x}}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$, and for each of the four partial derivatives $j=1,2,3,4$. If any of these evaluation points lie outside the region of definition of the interpolant, the corresponding entries in qx are set to the largest machine representable number (see nag_real_largest_number (X02ALC)), and nag_4d_shep_eval (e01tlc) returns with ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_BAD_POINT.
10:  $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 2.7 in How to Use the NAG Library and its Documentation).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
NE_BAD_PARAM
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_BAD_POINT
On entry, at least one evaluation point lies outside the region of definition of the interpolant. At all such points the corresponding values in q and qx have been set to ${\mathbf{nag_real_largest_number}}$: ${\mathbf{nag_real_largest_number}}=〈\mathit{\text{value}}〉$.
NE_INT
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{m}}\ge 16$.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 1$.
NE_INT_ARRAY
On entry, values in iq appear to be invalid. Check that iq has not been corrupted between calls to nag_4d_shep_interp (e01tkc) and nag_4d_shep_eval (e01tlc).
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
NE_REAL_ARRAY
On entry, values in rq appear to be invalid. Check that rq has not been corrupted between calls to nag_4d_shep_interp (e01tkc) and nag_4d_shep_eval (e01tlc).

## 7  Accuracy

Computational errors should be negligible in most practical situations.

## 8  Parallelism and Performance

nag_4d_shep_eval (e01tlc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the x06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

## 9  Further Comments

The time taken for a call to nag_4d_shep_eval (e01tlc) will depend in general on the distribution of the data points. If the data points 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.

## 10  Example

This program evaluates the function
 $f x = 1.25 + cos5.4x4 cos6x1 cos6x2 6 + 6 3 x3 - 1 2$
at a set of $30$ randomly generated data points and calls nag_4d_shep_interp (e01tkc) to construct an interpolating function $Q\left(\mathbf{x}\right)$. It then calls nag_4d_shep_eval (e01tlc) to evaluate the interpolant at a set of random points.
To reduce the time taken by this example, the number of data points is limited to $30$. Increasing this value improves the interpolation accuracy at the expense of more time.
See also Section 10 in nag_4d_shep_interp (e01tkc).

### 10.1  Program Text

Program Text (e01tlce.c)

### 10.2  Program Data

Program Data (e01tlce.d)

### 10.3  Program Results

Program Results (e01tlce.r)

nag_4d_shep_eval (e01tlc) (PDF version)
e01 Chapter Contents
e01 Chapter Introduction
NAG Library Manual