TABLE OF CONTENTS


CsplineUtils/cnBsmom [ Functions ]

NAME

    cnBsmom --- compute the N-h moment of a B-spline basis function

FUNCTION

Computes the N-th moment of the j-th B-spline basis function of order ord defined on the given set of knots. See also nBsmom.

SYNOPSIS

38 double cnBsmom(const int N, const int ord, const int j, const double *knots, const int knotord)

INPUTS

    N       moment to compute
    ord     order of the spline
    j       which basis function to compute the moment for
    knots   set of knots to use
    knotord order for which the knots were constructed

OUTPUTS

SOURCE

42 {
43     double lknot=knots[j-ord+knotord];
44     double rknot=knots[j+knotord];
45     if(lknot==rknot){
46         return pow(rknot,N);
47     }
48     double out;
49     // magic recursive formula
50     out = ord/(rknot-lknot)/(N+1);
51     out = out*(-cnBsmom(N+1,ord-1,j-1,knots,knotord)+cnBsmom(N+1,ord-1,j,knots,knotord));
52     return out;
53 }