NAG Library Routine Document
e01tlf (dim4_scat_shep_eval)
1
Purpose
e01tlf evaluates the fourdimensional interpolating function generated by
e01tkf and its first partial derivatives.
2
Specification
Fortran Interface
Integer, Intent (In)  ::  m, iq(2*m+1), n  Integer, Intent (Inout)  ::  ifail  Real (Kind=nag_wp), Intent (In)  ::  x(4,m), f(m), rq(15*m+9), xe(4,n)  Real (Kind=nag_wp), Intent (Out)  ::  q(n), qx(4,n) 

C Header Interface
#include <nagmk26.h>
void 
e01tlf_ (const Integer *m, const double x[], const double f[], const Integer iq[], const double rq[], const Integer *n, const double xe[], double q[], double qx[], Integer *ifail) 

3
Description
e01tlf takes as input the interpolant
$Q\left(\mathbf{x}\right)$,
$x\in {\mathbb{R}}^{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
e01tkf, and evaluates the interpolant and its first partial derivatives at the set of points
${\mathbf{x}}_{i}$, for
$\mathit{i}=1,2,\dots ,n$.
e01tlf must only be called after a call to
e01tkf.
e01tlf is derived from the new implementation of QS3GRD described by
Renka (1988). It uses the modification for highdimensional interpolation described by
Berry and Minser (1999).
4
References
Berry M W, Minser K S (1999) Algorithm 798: highdimensional 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
e01tkf.
Constraint:
${\mathbf{m}}\ge 16$.
 2: $\mathbf{x}\left(4,{\mathbf{m}}\right)$ – Real (Kind=nag_wp) arrayInput

Note: the coordinates of ${x}_{r}$ are stored in ${\mathbf{x}}\left(1,r\right)\dots {\mathbf{x}}\left(4,r\right)$.
On entry:
must be the same array supplied as argument
x in the preceding call to
e01tkf. It
must remain unchanged between calls.
 3: $\mathbf{f}\left({\mathbf{m}}\right)$ – Real (Kind=nag_wp) arrayInput

On entry:
must be the same array supplied as argument
f in the preceding call to
e01tkf. It
must remain unchanged between calls.
 4: $\mathbf{iq}\left(2\times {\mathbf{m}}+1\right)$ – Integer arrayInput

On entry:
must be the same array returned as argument
iq in the preceding call to
e01tkf. It
must remain unchanged between calls.
 5: $\mathbf{rq}\left(15\times {\mathbf{m}}+9\right)$ – Real (Kind=nag_wp) arrayInput

On entry:
must be the same array returned as argument
rq in the preceding call to
e01tkf. 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)$ – Real (Kind=nag_wp) arrayInput

On entry: ${\mathbf{xe}}\left(1:4,\mathit{i}\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)$ – Real (Kind=nag_wp) arrayOutput

On exit:
${\mathbf{q}}\left(\mathit{i}\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
x02alf), and
e01tlf returns with
${\mathbf{ifail}}={\mathbf{3}}$.
 9: $\mathbf{qx}\left(4,{\mathbf{n}}\right)$ – Real (Kind=nag_wp) arrayOutput

On exit:
${\mathbf{qx}}\left(j,i\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
x02alf), and
e01tlf returns with
${\mathbf{ifail}}={\mathbf{3}}$.
 10: $\mathbf{ifail}$ – IntegerInput/Output

On entry:
ifail must be set to
$0$,
$1\text{or}1$. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
$1\text{or}1$ is recommended. If the output of error messages is undesirable, then the value
$1$ is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
$0$.
When the value $\mathbf{1}\text{or}\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit:
${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
${\mathbf{ifail}}=0$ or
$1$, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
 ${\mathbf{ifail}}=1$

On entry, ${\mathbf{m}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{m}}\ge 16$.
On entry, ${\mathbf{n}}=\u2329\mathit{\text{value}}\u232a$.
Constraint: ${\mathbf{n}}\ge 1$.
 ${\mathbf{ifail}}=2$

On entry, values in
iq appear to be invalid. Check that
iq has not been corrupted between calls to
e01tkf and
e01tlf.
On entry, values in
rq appear to be invalid. Check that
rq has not been corrupted between calls to
e01tkf and
e01tlf.
 ${\mathbf{ifail}}=3$

On entry, at least one evaluation point lies outside the region of
definition of the interpolant. At such points the corresponding
values in
q and
qx contain extrapolated approximations. Points
should be evaluated one by one to identify extrapolated values.
 ${\mathbf{ifail}}=99$
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
 ${\mathbf{ifail}}=399$
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
 ${\mathbf{ifail}}=999$
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
Computational errors should be negligible in most practical situations.
8
Parallelism and Performance
e01tlf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
e01tlf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementationspecific information.
The time taken for a call to e01tlf 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.
9.1
Internal Changes
Internal changes have been made to this routine as follows:
 At Mark 26.0: The algorithm used by this routine, based on a Modified Shepard method, has been changed to produce more reliable results for some data sets which were previously not well handled. In addition, handling of evaluation points which are far away from the original data points has been improved by use of an extrapolation method which returns useful results rather than just an error message as was done at earlier Marks.
 At Mark 26.1: The algorithm has undergone further changes which enable it to work better on certain data sets, for example data presented on a regular grid. The results returned when evaluating the function at points which are not in the original data set used to construct the interpolating function are now likely to be slightly different from those returned at previous Marks of the Library, but the function still interpolates the original data.
For details of all known issues which have been reported for the NAG Library please refer to the
Known Issues list.
10
Example
This program evaluates the function
at a set of
$30$ randomly generated data points and calls
e01tkf to construct an interpolating function
$Q\left(\mathbf{x}\right)$. It then calls
e01tlf 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
e01tkf.
10.1
Program Text
Program Text (e01tlfe.f90)
10.2
Program Data
Program Data (e01tlfe.d)
10.3
Program Results
Program Results (e01tlfe.r)