NAG CL Interface
e01zac (dimn_grid)
1
Purpose
e01zac interpolates data at a point in -dimensional space, that is defined by a set of gridded data points. It offers three methods to interpolate the data: Linear Interpolation, Cubic Interpolation and Weighted Average.
2
Specification
void |
e01zac (Integer d,
const Integer narr[],
Nag_Boolean uniform,
const double axis[],
Integer lx,
const double v[],
const double point[],
Nag_Interp method,
Integer k,
double wf,
double *ans,
NagError *fail) |
|
The function may be called by the names: e01zac, nag_interp_dimn_grid or nag_nd_grid_interp.
3
Description
e01zac interpolates an -dimensional point within a set of gridded data points, , with corresponding data values where, for the th dimension, and is the number of ordinates in the th dimension.
A hypercube of
data points
, where
and the corresponding data values are
, around the given point,
, is found and then used to interpolate using one of the following three methods.
-
(i)Weighted Average, that is a modification of Shepard's method (Shepard (1968)) as used for scattered data in e01zmc. This method interpolates the data with the weighted mean
where , and , for a given value of .
-
(ii)Linear Interpolation, which takes surrounding data points () and performs two one-dimensional linear interpolations in each dimension on data points and , reducing the dimension every iteration until it has reached an answer. The formula for linear interpolation in dimension is simply
where and .
-
(iii)Cubic Interpolation, based on cubic convolution (Keys (1981)). In a similar way to the Linear Interpolation method, it performs the interpolations in one dimension reducing it each time, however it requires four surrounding data points in each dimension (), two in each direction . The following is used to calculate the one-dimensional interpolant in dimension
where and
.
4
References
Keys R (1981) Cubic Convolution Interpolation for Digital Image Processing
IEEE Transactions on Acoutstics, Speech, and Signal Processing Vol ASSP-29 No. 6 1153–1160
http://hmi.stanford.edu/doc/Tech_Notes/HMI-TN-2004-004-Interpolation/Keys_cubic_interp.pdf
Shepard D (1968) A two-dimensional interpolation function for irregularly spaced data Proc. 23rd Nat. Conf. ACM 517–523 Brandon/Systems Press Inc., Princeton
5
Arguments
-
1:
– Integer
Input
-
On entry: , the number of dimensions.
Constraint:
.
-
2:
– const Integer
Input
-
On entry: the number of data ordinates in each dimension, with
, for .
Constraint:
.
-
3:
– Nag_Boolean
Input
-
On entry: states whether the data points are uniformly spaced.
- The data points are uniformly spaced.
- The data points are not uniformly spaced.
Constraint:
if
,
uniform must be Nag_TRUE.
-
4:
– const double
Input
-
On entry: defines the axis. If the data points are uniformly spaced (see argument
uniform)
axis should contain the start and end of each dimension
.
If the data points are not uniformly spaced,
axis should contain all the data ordinates for each dimension
.
Constraint:
axis must be strictly increasing in each dimension.
-
5:
– Integer
Input
-
On entry: the dimension of the array
axis.
Constraints:
- if , ;
- if , .
-
6:
– const double
Input
-
Note: the dimension,
dim, of the array
v
must be at least
.
On entry: holds the values of the data points in such an order that the index of a data value with coordinates
is
where
e.g.,
.
-
7:
– const double
Input
-
On entry: , the point at which the data value is to be interpolated.
Constraint:
the point must lie inside the limits of the data values in each dimension supplied in
axis.
-
8:
– Nag_Interp
Input
-
On entry: the method to be used.
- Weighted Average.
- Linear Interpolation.
- Cubic Interpolation.
Constraint:
, or .
-
9:
– Integer
Input
-
On entry: if
,
k controls the number of data points used in the Weighted Average method, with
k points used in each dimension, either side of the interpolation point. The total number of data points used for the interpolation will therefore be
.
If
, then
k is not referenced and need not be set.
Constraint:
if , .
-
10:
– double
Input
-
On entry: the power used for the weighted average such that a high power will cause closer points to be more heavily weighted.
Constraint:
if , .
-
11:
– double *
Output
-
On exit: holds the result of the interpolation.
-
12:
– NagError *
Input/Output
-
The NAG error argument (see
Section 7 in the Introduction to the NAG Library CL Interface).
6
Error Indicators and Warnings
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
See
Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
- NE_BAD_PARAM
-
On entry, argument had an illegal value.
- NE_INT
-
Cubic Interpolation method does not have enough data surrounding
point; interpolation not possible.
On entry, .
Constraint: .
On entry, .
Constraint: if , .
On entry, , .
Constraint: if , .
On entry,
,
narr.
Constraint: if
,
.
On entry,
and
.
Constraint: if
,
uniform must be Nag_TRUE.
- NE_INT_2
-
On entry, .
Constraint: .
- 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 7.5 in the Introduction to the NAG Library CL Interface for further information.
- NE_NO_LICENCE
-
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library CL Interface for further information.
- NE_NOT_INCREASING
-
On entry,
axis decreases in dimension
.
Constraint:
axis definition must be strictly increasing.
- NE_REAL
-
On entry,
and data range
.
Constraint:
point must be within the data range.
On entry, .
Constraint: if , .
- NW_INT
-
Warning: the size of
k has been reduced, due to too few data points around
point.
7
Accuracy
For most data the Cubic Interpolation method will provide the best interpolation but it is data dependent. If the data is linear, the Linear Interpolation method will be best. For noisy data the Weighted Average method is advised with and . This will include more data points and give them a greater influence to the answer.
8
Parallelism and Performance
e01zac is not threaded in any implementation.
None.
10
Example
This program takes a set of uniform three-dimensional grid data points which come from the function
e01zac then interpolates the data at the point using all three methods. The answers and the absolute errors are then printed.
10.1
Program Text
10.2
Program Data
10.3
Program Results