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.
The function may be called by the names: e01zac, nag_interp_dimn_grid or nag_nd_grid_interp.
3Description
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
Shepard D (1968) A two-dimensional interpolation function for irregularly spaced data Proc. 23rd Nat. Conf. ACM 517–523 Brandon/Systems Press Inc., Princeton
5Arguments
1: – IntegerInput
On entry: , the number of dimensions.
Constraint:
.
2: – const IntegerInput
On entry: the number of data ordinates in each dimension, with
, for .
Constraint:
.
3: – Nag_BooleanInput
On entry: states whether the data points are uniformly spaced.
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 doubleInput
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_InterpInput
On entry: the method to be used.
Weighted Average.
Linear Interpolation.
Cubic Interpolation.
Constraint:
, or .
9: – IntegerInput
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: – doubleInput
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).
6Error 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, 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.
7Accuracy
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.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
e01zac is not threaded in any implementation.
9Further Comments
None.
10Example
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.