TABLE OF CONTENTS


CcurveUpdate/RemakeSplineBasis [ Functions ]

NAME

    RemakeSplineBasis --- update spline basis after a birth-death-move operation

FUNCTION

This function is called by MH_BDM, to update the spline basis after adding, moving or deleting a knot. It's a more efficient version of MakeSplineBasis that only updates the basis functions required by the operation.

For move steps, this means simply updating a subset of basis functions. For birth and move steps, existing basis functions are moved, and the intermediate ones updated.

SYNOPSIS

1161 void RemakeSplineBasis(curveP theCurve, char oper, int j)

INPUTS

    theCurve      a CCurve structure
    oper          character, either 'm' for move, 'b' for birth or 'd' for death.
    j             index of the knot that was moved, added or deleted.

OUTPUTS

    theCurve, with SplineBasis, SplineBasisCum, SplineBasisInt and SplineBasisExp updated

SOURCE

1165 {
1166     if(!theCurve->hasSpline) return;
1167     double * knots = theCurve->SplineKnots;
1168     int ord = theCurve->SplineOrd;
1169     int nknots = theCurve->SplineNknots;
1170     int nj = theCurve->nj;
1171     int nx = theCurve->nx;
1172     double * x = theCurve->X;
1173     int c1 = 1;
1174 
1175     // compute integrals over each basis spline
1176     cevalBinte(theCurve->SplineBasisInt, knots, &ord, &nknots);
1177 
1178     // For frailty, compute the expectations
1179     if(!theCurve->isHazard) 
1180         cevalEinte(theCurve->SplineBasisExp, knots, &ord, &nknots, &c1);
1181         
1182     if(oper=='m'){
1183         // Update basis from j to j+ord (j here is the moveind, in internal knot numbering)
1184         UpdateSplineBasis(theCurve,-1,j,imin(nj,j+ord+1)); 
1185     }
1186     if(oper=='d'){
1187         //move basis j+1 through nj into j through nj-1
1188         int nmv = ((nj) - (j+1))*nx;
1189         nmv = nmv>0 ? nmv : 0;
1190         if(nmv>0){
1191             F77_CALL(dcopy)(&nmv, theCurve->SplineBasis + (j+1)*nx, &c1,
1192                     theCurve->SplineBasis + j*nx, &c1);
1193             if(theCurve->isHazard)
1194                 F77_CALL(dcopy)(&nmv, theCurve->SplineBasisCum + (j+1)*nx,
1195                     &c1, theCurve->SplineBasisCum + j*nx, &c1);
1196         }
1197         // update basis functions j-ord through j
1198         UpdateSplineBasis(theCurve,-1,imax(0,j-ord),j);
1199     }
1200     if(oper=='b'){
1201         // //move basis j+1 : nj to j+2 : nj+1
1202         for(int k=nj-2;k>j;k--) F77_CALL(dcopy)(&nx, theCurve->SplineBasis + k*nx, &c1,
1203                 theCurve->SplineBasis + (k+1)*nx, &c1);
1204         if(theCurve->isHazard) for(int k=nj-2;k>j;k--) F77_CALL(dcopy)(&nx,
1205                 theCurve->SplineBasisCum + k*nx, &c1, theCurve->SplineBasisCum + (k+1)*nx, &c1);
1206         // update basis from j-ord to j+2
1207         UpdateSplineBasis(theCurve,-1,imax(0,j-ord),imin(nj,j+2));
1208     }
1209 }