# Dsgrid Introduction

Dsgrid is a package in the ngmath library that implements a simple inverse distance weighted interpolation algorithm. The input for the interpolation is a set of randomly-spaced three-dimensional coordinates with functional values at those coordinates; the output is a set of interpolated function values at coordinates in a user-specified grid. The coordinates in the output grid must be monotone increasing in each coordinate direction, but need not be uniformly spaced. See the comparative analysis of the ngmath packages for details on which ngmath package is most appropriate for your problem.

## General background on interpolation methods

Computational interpolation methods can be divided into two basic classes: fitted function methods and weighted average methods.

The fitted function, or fitted surface, methods fit an algebraic surface to the known data and then pick the interpolated values from the fitted surface. The weighted average methods calculate interpolated values as weighted averages of known values.

Among the weighted average methods, the simplest are known as the inverse distance weighted average methods. Dsgrid uses one of these methods.

## The interpolation method used in Dsgrid

Dsgrid uses a simple weighted average method to do its interpolation. For interpolation at a coordinate, weights are computed for input coordinates, the values of such weights being inversely proportional to the distance an input coordinate is from the point where an interpolated value is desired. In the default situation in the Dsgrid package, the influence of an input datum on a calculated value at an interpolation point varies as the inverse cube of the distance between the interpolated point and the input datum. The sum of the weights is normalized to unity and an interpolated value is the sum of the products of the known functional values and the calculated weights.

The capability exists in Dsgrid to vary the power of the distances used to compute the weights. For powers of the distances greater than one, the interpolated surface is flat at the input data; the size of the flat spot increases with increasing values of the power. If the power of the distances is one, then the weights are computed simply as linear inverse distances and the areas around input data are cone shaped. If the power is less than one, then the areas around input data form a cusp at the data points. Example 2 illustrates the effects of modifying the exponent of the distances used in computing the weights. For full details on interpolation methods, consult Dave Watson's book Contouring.

## Dsgrid functional overview

• Functionally equivalent Fortran and C interfaces are provided in both single and double precision versions.
• Interfaces exist for two-dimensional interpolation as well as 3D.
• Interfaces exist for interpolation at individual points.
• The capability exists to specify that only input data points within a specified distance from an interpolated point be considered in the calculation of weights. In the default case, all input data are used in the calculation of the weights.
• The package has a shadowing option which, when in effect, reduces the effect that a cluster of points might have in skewing interpolated values. This shadowing feature is based on original work of Bob Lackman. Example 4 illustrates the shadowing feature.

## Learning how to use Dsgrid

You should now proceed to the module on learning how to use Dsgrid.
home | contents | defs | params | procedures | exmpls | index