NAG C Library Function Document

nag_5d_shep_eval (e01tnc)

1
Purpose

nag_5d_shep_eval (e01tnc) evaluates the five-dimensional interpolating function generated by nag_5d_shep_interp (e01tmc) and its first partial derivatives.

2
Specification

#include <nag.h>
#include <nage01.h>
void  nag_5d_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_5d_shep_eval (e01tnc) takes as input the interpolant Q x , x5 of a set of scattered data points xr,fr , for r=1,2,,m, as computed by nag_5d_shep_interp (e01tmc), and evaluates the interpolant and its first partial derivatives at the set of points xi, for i=1,2,,n.
nag_5d_shep_eval (e01tnc) must only be called after a call to nag_5d_shep_interp (e01tmc).
nag_5d_shep_eval (e01tnc) is derived from the new implementation of QS3GRD described by Renka (1988). It uses the modification for five-dimensional interpolation described by Berry and Minser (1999).

4
References

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:     m IntegerInput
On entry: must be the same value supplied for argument m in the preceding call to nag_5d_shep_interp (e01tmc).
Constraint: m23.
2:     x[5×m] const doubleInput
Note: the i,jth element of the matrix X is stored in x[j-1×5+i-1].
On entry: must be the same array supplied as argument x in the preceding call to nag_5d_shep_interp (e01tmc). It must remain unchanged between calls.
3:     f[m] const doubleInput
On entry: must be the same array supplied as argument f in the preceding call to nag_5d_shep_interp (e01tmc). It must remain unchanged between calls.
4:     iq[2×m+1] const IntegerInput
On entry: must be the same array returned as argument iq in the preceding call to nag_5d_shep_interp (e01tmc). It must remain unchanged between calls.
5:     rq[21×m+11] const doubleInput
On entry: must be the same array returned as argument rq in the preceding call to nag_5d_shep_interp (e01tmc). It must remain unchanged between calls.
6:     n IntegerInput
On entry: n, the number of evaluation points.
Constraint: n1.
7:     xe[5×n] const doubleInput
Note: the i,jth element of the matrix is stored in xe[j-1×5+i-1].
On entry: xe[i-1×5] ,, xe[i-1×5+4]  must be set to the evaluation point xi, for i=1,2,,n.
8:     q[n] doubleOutput
On exit: q[i-1] contains the value of the interpolant, at xi, for i=1,2,,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_5d_shep_eval (e01tnc) returns with fail.code= NE_BAD_POINT.
9:     qx[5×n] doubleOutput
Note: the i,jth element of the matrix is stored in qx[j-1×5+i-1].
On exit: qx[i-1×5+j-1] contains the value of the partial derivatives with respect to xj of the interpolant Q x  at xi, for i=1,2,,n, and for each of the five partial derivatives j=1,2,3,4,5. 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_5d_shep_eval (e01tnc) returns with fail.code= NE_BAD_POINT.
10:   fail NagError *Input/Output
The NAG error argument (see Section 3.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 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 such points the corresponding values in q and qx contain extrapolated approximations. Points should be evaluated one by one to identify extrapolated values.
NE_INT
On entry, m=value.
Constraint: m23.
On entry, n=value.
Constraint: n1.
NE_INT_ARRAY
On entry, values in iq appear to be invalid. Check that iq has not been corrupted between calls to nag_5d_shep_interp (e01tmc) and nag_5d_shep_eval (e01tnc).
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.
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_5d_shep_interp (e01tmc) and nag_5d_shep_eval (e01tnc).

7
Accuracy

Computational errors should be negligible in most practical situations.

8
Parallelism and Performance

nag_5d_shep_eval (e01tnc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_5d_shep_eval (e01tnc) 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 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_5d_shep_eval (e01tnc) 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 On. At worst Omn time will be required.

10
Example

This program evaluates the function
f x = 1.25 + cos5.4x5 cos6x1 cos6x2 cos6x3 6 + 6 3 x4 - 1 2  
at a set of 30 randomly generated data points and calls nag_5d_shep_interp (e01tmc) to construct an interpolating function Q x . It then calls nag_5d_shep_eval (e01tnc) 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 to the suggested minimum of 4000 improves the interpolation accuracy at the expense of more time.
See also Section 10 in nag_5d_shep_interp (e01tmc).

10.1
Program Text

Program Text (e01tnce.c)

10.2
Program Data

Program Data (e01tnce.d)

10.3
Program Results

Program Results (e01tnce.r)