ocmath_2d_spline_grid
Description
This function computes a bicubic spline approximation to a set of data values, given on an equi-spaced rectangular grid in the x-y plane. The smoothness of fit can be controlled.
Syntax
int ocmath_2d_spline_grid( const uint nrSrc, const uint ncSrc, const double * pmatSrc, const uint nrDest, const uint ncDest, double * pmatDest, double dSmoothFactor = 0 )
Parameters
- nrSrc
- [input] The number of rows of source matrix.
- ncSrc
- [input] The number of cols of source matrix.
- pmatSrc
- [input] Source matrx.
- nrDest
- [input] The number of rows of output matrx.
- ncDest
- [input] The number of cols of output matrix.
- pmatDest
- [output] Output matrix.
- dSmoothFactor
- [input] The smoothing factor. Constraint: dSmoothFactor >= 0.
Return
Return 0 if succeed, or a non-zero Nag error codes:
NE_NULL_ARRAY = 82: pmatSrc and pmatDest must not be NULL.
NE_INT_ARG_LT = 11: nrSrc and ncSrc must not be less than 4, and nrDest, ncDest must not be less than 1.
NE_REAL_ARG_LT = 5: dSmoothFactor must be bigger than 0.
NE_SPLINE_COEFF_CONV = 263: The iterative process has failed to converge. Possibly dSmoothFactor is too small.
NE_ALLOC_FAIL = 73: Memory allocation failed.
Examples
EX1
//Before running, make sure a matrixlayer exists and is active in current project
void ocmath_2d_spline_grid_ex1(double smooth)
{
MatrixLayer ml = Project.ActiveLayer();
MatrixObject mo = ml.MatrixObjects(0);
if (!mo.IsValid())
printf("Error: MatrixObject is invalid!\n");
Matrix& mat = mo.GetDataObject();
int nRows = mo.GetNumRows();
int nCols = mo.GetNumRows();
int rows,cols;
rows = nRows;
cols = nCols;
matrix matDest(rows, cols);
int iRet;
iRet = ocmath_2d_spline_grid(nRows, nCols, mat, rows, cols, matDest, smooth);
if (iRet == 0)
mat = matDest;
else
printf("Error: Nag code is %d\n", iRet);
}
Remark
See Also
header to Include
origin.h
Reference
nag_2d_spline_fit_grid(e02dcc)nag_2d_spline_fit_grid(e02dcc), NAG Manual
|