e01zaf 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 routine may be called by the names e01zaf or nagf_interp_dimn_grid.
e01zaf 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 e01zmf. 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
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 .
axis must be strictly increasing in each dimension.
5: – IntegerInput
On entry: the dimension of the array axis as declared in the (sub)program from which e01zaf is called.
if , ;
if , .
6: – Real (Kind=nag_wp) arrayInput
Note: the dimension 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: – Real (Kind=nag_wp) arrayInput
On entry: , the point at which the data value is to be interpolated.
the point must lie inside the limits of the data values in each dimension supplied in axis.
8: – IntegerInput
On entry: the method to be used.
, 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.
if , .
10: – Real (Kind=nag_wp)Input
On entry: the power used for the weighted average such that a high power will cause closer points to be more heavily weighted.
if , .
11: – Real (Kind=nag_wp)Output
On exit: holds the result of the interpolation.
12: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or is used it is essential to test the value of ifail on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
On entry, .
On entry, . Constraint: .
On entry, axis decreases in dimension . Constraint: axis definition must be strictly increasing.
On entry, and data range . Constraint: point must be within the data range.
On entry, . Constraint: , or .
On entry, and . Constraint: if , uniform must be .TRUE..
On entry, . Constraint: if , .
Cubic Interpolation method does not have enough data surrounding point; interpolation not possible.
Warning: the size of k has been reduced, due to too few data points around point.
An unexpected error has been triggered by this routine. Please
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
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.
e01zaf is not threaded in any implementation.
This program takes a set of uniform three-dimensional grid data points which come from the function
e01zaf then interpolates the data at the point using all three methods. The answers and the absolute errors are then printed.