PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_interp_nd_scat_shep_eval (e01zn)
Purpose
nag_interp_nd_scat_shep_eval (e01zn) evaluates the multidimensional interpolating function generated by
nag_interp_nd_scat_shep (e01zm) and its first partial derivatives.
Syntax
[
q,
qx,
ifail] = e01zn(
x,
f,
iq,
rq,
xe, 'd',
d, 'm',
m, 'n',
n)
[
q,
qx,
ifail] = nag_interp_nd_scat_shep_eval(
x,
f,
iq,
rq,
xe, 'd',
d, 'm',
m, 'n',
n)
Description
nag_interp_nd_scat_shep_eval (e01zn) takes as input the interpolant
,
of a set of scattered data points
, for
, as computed by
nag_interp_nd_scat_shep (e01zm), and evaluates the interpolant and its first partial derivatives at the set of points
, for
.
nag_interp_nd_scat_shep_eval (e01zn) must only be called after a call to
nag_interp_nd_scat_shep (e01zm).
nag_interp_nd_scat_shep_eval (e01zn) 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).
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
Parameters
Compulsory Input Parameters
- 1:
– double array
-
Note: the th ordinate of the point is stored in .
must be the same array supplied as argument
x in the preceding call to
nag_interp_nd_scat_shep (e01zm). It
must remain unchanged between calls.
- 2:
– double array
-
must be the same array supplied as argument
f in the preceding call to
nag_interp_nd_scat_shep (e01zm). It
must remain unchanged between calls.
- 3:
– int64int32nag_int array
-
must be the same array returned as argument
iq in the preceding call to
nag_interp_nd_scat_shep (e01zm). It
must remain unchanged between calls.
- 4:
– double array
-
The dimension of the array
rq
must be at least
must be the same array returned as argument
rq in the preceding call to
nag_interp_nd_scat_shep (e01zm). It
must remain unchanged between calls.
- 5:
– double array
-
Note: the th ordinate of the point is stored in .
must be set to the evaluation point , for .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the arrays
xe,
x. (An error is raised if these dimensions are not equal.)
must be the same value supplied for argument
d in the preceding call to
nag_interp_nd_scat_shep (e01zm).
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the dimension of the array
f and the second dimension of the array
x. (An error is raised if these dimensions are not equal.)
must be the same value supplied for argument
m in the preceding call to
nag_interp_nd_scat_shep (e01zm).
Constraint:
.
- 3:
– int64int32nag_int scalar
-
Default:
the second dimension of the array
xe.
, the number of evaluation points.
Constraint:
.
Output Parameters
- 1:
– double array
-
contains the value of the interpolant, at
, for
. 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_nd_scat_shep_eval (e01zn) returns with
.
- 2:
– double array
-
contains the value of the partial derivatives with respect to the
th independent variable (dimension) of the interpolant
at
, for
, and for each of the partial derivatives
. 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_machine_real_largest (x02al)), and
nag_interp_nd_scat_shep_eval (e01zn) returns with
.
- 3:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
Constraint: .
Constraint: .
Constraint: .
On entry, exceeds the largest machine integer.
-
-
On entry, values in
iq appear to be invalid. Check that
iq has not been corrupted between calls to
nag_interp_nd_scat_shep (e01zm) and
nag_interp_nd_scat_shep_eval (e01zn).
On entry, values in
rq appear to be invalid. Check that
rq has not been corrupted between calls to
nag_interp_nd_scat_shep (e01zm) and
nag_interp_nd_scat_shep_eval (e01zn).
-
-
On entry, at least one evaluation point lies outside the region of
definition of the interpolant.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
Computational errors should be negligible in most practical situations.
Further Comments
The time taken for a call to nag_interp_nd_scat_shep_eval (e01zn) 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 . At worst time will be required.
Example
This program evaluates the function (in six variables)
at a set of randomly generated data points and calls
nag_interp_nd_scat_shep (e01zm) to construct an interpolating function
. It then calls
nag_interp_nd_scat_shep_eval (e01zn) to evaluate the interpolant at a set of points on the line
, for
. To reduce the time taken by this example, the number of data points is limited. Increasing this value to the suggested minimum of
improves the interpolation accuracy at the expense of more time.
See also
Example in
nag_interp_nd_scat_shep (e01zm).
Open in the MATLAB editor:
e01zn_example
function e01zn_example
fprintf('e01zn example results\n\n');
genid = int64(1);
subid = int64(1);
seed = [int64(1762543)];
m = 120;
n = 9;
d = 6;
[state, ifail] = g05kf(genid, subid, seed);
[state, x, ifail] = g05sa(int64(d*m), state);
x = reshape(x, d, m);
f = x(1, :).*x(2, :).*x(3, :)./(1+2.*x(4, :).*x(5, :).*x(6, :));
[iq, rq, ifail] = e01zm(x, f);
xe = zeros(d, n);
for i = 1:n
xe(:, i) = i/(n+1);
end
[q, qx, ifail] = e01zn(x, f, iq, rq, xe);
fprintf('\ni | f(i) q(i) | |f(i)-q(i)|\n');
fprintf('---|--------------------+--------------\n');
for i=1:n
fun = xe(1, i)*xe(2, i)*xe(3, i)/(1+2*xe(4, i)*xe(5, i)*xe(6, i));
fprintf('%d %10.4f%10.4f %10.4f\n', i, fun, q(i), abs(fun-q(i)));
end
e01zn example results
i | f(i) q(i) | |f(i)-q(i)|
---|--------------------+--------------
1 0.0010 0.0043 0.0033
2 0.0079 0.0040 0.0039
3 0.0256 0.0210 0.0046
4 0.0567 0.0536 0.0031
5 0.1000 0.0988 0.0012
6 0.1508 0.1526 0.0018
7 0.2034 0.2077 0.0043
8 0.2530 0.2570 0.0040
9 0.2966 0.2953 0.0013
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015