2.1.17.5.16 ocmath_parametric_interpolate_eval


Description

Get interpolated data using parametric interpolation. For every dimension of pData call the function ocmath_interpolate to interpolate.

Syntax

int ocmath_parametric_interpolate_eval( const double * pEvalT, double * pEvalData, UINT nEvalSize, const double * pT, const double * pData, UINT nDataSize, UINT nDimension = 2, int nMode = INTERP_TYPE_SPLINE, double dSmoothingFactor = 0, const double * pWeights = NULL, int iOption = OPTION_EXTRAPOLATE )

Parameters

pEvalT
[input]parameter points to be evaluated, if one element is outside of valid range, relative interpolated data will be NANUM
pEvalData
[output]interpolated data, with size nDimension by nEvalSize
nEvalSize
[input] point number to be evaluated, size of pEvalT
pT
[input]parameter data, size of nDataSize
pData
[input]source data, with size nDimension by nDataSize
nDataSize
[input] size of each dimension
nDimension
[input] dimension of source data, nDimension >= 2
nMode
interpolation method. Must be one of the three modes:
INTERP_TYPE_LINEAR(linear interpolation),
INTERP_TYPE_SPLINE(cubic spline interpolation with natural boundary condition),
INTERP_TYPE_BSPLINE(B-Spline curve fitting using method by Dierckx.P)
dSmoothingFactor
[input] This argument specifies the closeness to the original data. It is only useful when nMode = INTERP_TYPE_BSPLINE. dSmoothingFactor >= 0.
By means of this parameter, the user can control the tradeoff between closeness of fit and smoothness of fit of the approximation.
If dSmoothingFactor is too large, the spline will be too smooth and signal will be lost ; if it is too small the spline will pick up too much noise.
In the extreme cases the program will return an interpolating spline if dSmoothingFactor=0 and the weighted least-squares polynomial of degree 3 if s is very large.
pWeights
[input]pointer to weights, which is only used in method INTERP_TYPE_BSPLINE, by default(pWeights = NULL) all weights are 1. size is nDataSize
iOption
[input] specify how to extrapolate Y values in extrapolated range. Must be one of the three values:
OPTION_EXTRAPOLATE(extrapolate Y using the last two points),
OPTION_SET_MISSING(set all Y values in the extrapolated range to be missing values),
OPTION_REPEAT_LAST(use the Y value of the closest input X value for all values in the extrapolated range)

Return

Returns 0 on success, otherwise returns error code in enum Err_Spline.

Examples

EX1

void    ocmath_parametric_interpolate_eval_ex1()
{
    const int nDataSize = 5;
    vector vT(nDataSize);
    matrix mData = {{0, 1, -1, 0, 3},{0, 2, 3, 1, 0}};
    if(OE_NOERROR != ocmath_parametric_interpolate_range(vT, mData, nDataSize))
    {
        out_str("error in calculating range");
        return;
    }
    vector vEvalT;
    vEvalT.Data(vT[0], vT[nDataSize - 1], (vT[nDataSize - 1] - vT[0])/20);
    int nEvalPoints = vEvalT.GetSize();
    matrix mEvalData(2, nEvalPoints);
    if(0 != ocmath_parametric_interpolate_eval(vEvalT, mEvalData, nEvalPoints, vT, mData, nDataSize))
    {
        out_str("error in evaluation");
        return;
    }
    for(int ii = 0; ii < nEvalPoints; ii++)
    {
        printf("%f\t%f\t%f\n", vEvalT[ii], mEvalData[0][ii], mEvalData[1][ii]);
    }
}

Remark

See Also

ocmath_parametric_interpolate_range

Header to Include

origin.h

Reference