ocmath_2d_spline_eval

 

Description

Calculates values of a bicubic spline from its B-spline representation.

Syntax

int ocmath_2d_spline_eval( int nEvalPoints, const double * pX, const double * pY, double * pZ, ocmath_2dSpline * spline )

Parameters

nEvalPoints
[input] total number of points to be evaluated
pX
[input] pointer to X coordinate of evaluation points.
pY
[input] pointer to Y coordinate of evaluation points.
pZ
[output] pointer to the values at evaluation points.
spline
[input] pointer to structure ocmath_2dSpline, which is usually returned by ocmath_2d_spline_interpolant

Return

NE_NOERROR (code 0) --- success

NE_INT_ARG_LT (error code 11) --- nEvalPoints < 1 or spline->nx < 8 or spline->ny < 8

NE_END_KNOTS_CONS (error code 264) --- the end knots should satisfy: spline->lamda[0] = spline->lamda[1] = spline->lamda[2] = spline->lamda[3], spline->lamda[spline->nx - 4] = spline->lamda[spline->nx - 3] = spline->lamda[spline->nx - 2] = spline->lamda[spline->nx - 1], spline->mu[0] = spline->mu[1] = spline->mu[2] = spline->mu[3], spline->mu[spline->ny - 4] = spline->mu[spline->ny - 3] = spline->mu[spline->ny - 2] = spline->mu[spline->ny - 1]

NE_NOT_INCREASING (error code 62) --- spline->lamda[i] or spline->mu[i] not increasing

NE_POINT_OUTSIDE_RECT (error code 266) --- pX or pY not satisfy: spline->lamda[3] <= pX[ii] <= spline->lamda[spline->nx - 4] and spline->mu[3] <= pY[ii] <= spline->mu[spline->ny - 4]

NE_ALLOC_FAIL (error code 73) --- memory allocation failed

Examples

EX1

//This program reads in knot sets spline.lamda[0],. . . ,spline.lamda[spline.nx-1]
//and spline.mu[0],. . . ,spline.mu[spline.ny and a set of bicubic spline coefficients cij.
//Following these are a value for m and the co-ordinates (xr, yr), for r = 1, 2, . . .,m,
//at which the spline is to be evaluated.
void ocmath_2d_spline_eval_ex1()
{
    int i, m = 7;
    double x[20] = {1.0, 1.1, 1.5, 1.6, 1.9, 1.9, 2.0};
    double y[20] = {0.0, 0.1, 0.7, 0.4, 0.3, 0.8, 1.0};
    double ff[20];
    ocmath_2dSpline spline;
    double lamda[] = {1.0,1.0,1.0,1.0,1.3,1.5,1.6,2.0,2.0,2.0,2.0};
    double mu[] = {0.0,0.0, 0.0, 0.0, 0.4, 0.7, 1.0, 1.0, 1.0, 1.0};
    double c[] ={1.0000, 1.1333, 1.3667, 1.7000, 1.9000, 2.0000,
        1.2000, 1.3333, 1.5667, 1.9000, 2.1000, 2.2000,
        1.5833, 1.7167, 1.9500, 2.2833, 2.4833, 2.5833,
        2.1433, 2.2767, 2.5100, 2.8433, 3.0433, 3.1433,
        2.8667, 3.0000, 3.2333, 3.5667, 3.7667, 3.8667,
        3.4667, 3.6000, 3.8333, 4.1667, 4.3667, 4.4667,
        4.0000, 4.1333, 4.3667, 4.7000, 4.9000, 5.0000};

    spline.nx = 11;
    spline.ny = 10;
    spline.c = c;
    spline.lamda =lamda;
    spline.mu = mu;

    ocmath_2d_spline_eval(m, x, y, ff, &spline);

    printf(" i x[i] y[i] ff[i]\n");
    for (i=0; i<m; i++)
        printf("%7ld %11.3f%11.3f%11.3f\n",i,x[i],y[i],ff[i]);
}

Remark

See Also

ocmath_1d_spline_evaluate

header to Include

origin.h

Reference

nag_2d_spline_eval(e02dec)nag_2d_spline_eval(e02dec), NAG Manual