Csagrid Introduction


About Csagrid

Csagrid (Cubic Spline Approximation GRIDder) is a software package in the ngmath library that implements a cubic spline approximation algorithm to fit a function to input data. The input for the approximation is a set of randomly-spaced data. These data may be one-dimensional, two-dimensional, or three-dimensional. See the comparative analysis of the ngmath packages for details on which ngmath package is most appropriate for your problem.

Csagrid is the only package in the ngmath library that offers a fitted surface approximation for three-dimensional data. The results obtained from Csagrid will, in general, be more visually appealing than the results obtained from the weighted average algorithm used in Dsgrid. For an example of this, compare the plot for Csagrid example 5 to the plot for Dsgrid example 1.

The output is a set of values at coordinates on a user-specified grid, or at a set of user-specified points (including at a single point).

Functionally equivalent Fortran, C, and NCL interfaces are provided.

Csagrid is based on the work of David Fulker and his package Splpack.

For a proper understanding of the package, read the remainder of this module. If you are an impatient sort, you may go to the Overview of Csagrid procedures module and proceed at your own risk.

General background on interpolation and approximation methods

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

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

The approximation method used in Csagrid

Csagrid uses a fitted-function algorithm. Given n-dimensional input data, Csagrid finds an n-dimensional cubic spline surface that is a least-squares fit to the input data. This surface will not necessarily pass through the original data.

The algorithm used in Csagrid to find an approximating cubic spline is different from cubic spline interpolation. In cubic spline interpolation, the knots occur at the input data values and the interpolated curve or surface passes through the input data. In Csagrid, the approximating curve or surface is calculated as a linear combination of spline basis functions, the number of which is equal to the user-specified value for the number of knots. The more basis functions there are, the closer the fit is to the original data. However, the more basis functions there are, the greater the cost in compute time. The plot for Example 1 illustrates the relationship between the number of basis functions and the appearance of the approximated surface. The timing table gives an indication of compute time requirements.

Options exist for weighting the input data values, for extrapolation into data sparse regions, and for taking first and second order partial derivatives in each coordinate direction.

Learning how to use Csagrid

To learn the details on using the Csagrid package, proceed to the module on learning how to use Csagrid.
home | contents | defs | procedures | examples | errors