TABLE OF CONTENTS


CsplineUtils/cSplineDerivInt [ Functions ]

NAME

    cSplineDerivInt --- compute the convolution of the derivatives of two spline basis functions

FUNCTION

Used to compute the penalty matrix for the integrated squared second derivative. This routine computes the integral from 0 to infinity of the l1 derivative and the l2 derivative of the j1 and j2-th splines of order n1 and n2 defined on a set of knots.

See also splinederivint for the R implementation.

SYNOPSIS

397 double cSplineDerivInt(int l1, int n1, int j1, int l2, int n2, int j2, double *knots, int splord)

INPUTS

    l1     derivative of the first spline
    n1     order of the first spline
    j1     index of the first spline
    l2     derivative of the second spline
    n2     order of the second spline
    j2     index of the second spline
    knots  set of knots on which the splines are defined
    splord order of the splines

OUTPUTS

SOURCE

401 {
402     if((j1-n1>=j2) | (j2-n2>=j1)) return 0;
403     if((l1==0) & (l2==0)) return cSplineConvolution(0,n2,j1,n2,j2,knots,splord);
404     if(l2>l1){
405         int l3=l1; l1=l2; l2=l3;
406         int n3=n1; n1=n2; n2=n3;
407         int j3=j1; j1=j2; j2=j3;
408     }
409     double out=0;
410     double denom1 = knots[j1-1+splord]-knots[j1-n1+splord];
411     double denom2 = knots[j1+splord] - knots[j1-n1+1+splord];
412     if(denom1>0)
413         out += (n1-1.0)/denom1 * cSplineDerivInt(l1-1,n1-1,j1-1,l2,n2,j2,knots,splord);
414     if(denom2>0)
415         out -= (n1-1.0)/denom2 * cSplineDerivInt(l1-1,n1-1,j1,l2,n2,j2,knots,splord);
416     return out;
417 }