TABLE OF CONTENTS


CsplineUtils/cevalCinteOld [ Functions ]

NAME

    cevalCinteOld --- old method for computing cevalCinte

FUNCTION

See evalCinte. This function works analogously to the R implementation, but was too slow, so it was replaced by cevalCinte2.

SYNOPSIS

199 void cevalCinteOld(double *cinte, double *x, int *nx, double *knots, int *ord, int *K, double *binte)

SOURCE

203 {
204     int nj = *K + *ord;
205     int nk = nj + *ord;
206     double * knots2 = (double *) malloc((nk +2) * sizeof(double));
207     knots2[0]=knots[0];
208     for(int j=0; j<nk; j++)
209         knots2[j+1]=knots[j];
210     knots2[nk+1]=knots[nk-1];
211 #ifdef DEBUGCINTE
212     Rprintf("knots2:\n ");
213     for(int j=0; j<nk+2; j++) Rprintf("%f ",knots2[j]);
214     Rprintf("\n");
215 #endif
216     int ord2 = *ord+1;
217     double * bs2 = (double *) malloc((nj+1)* *nx * sizeof(double));
218     csplinedesign(bs2,x,nx,knots2,&ord2,K);
219 #ifdef  DEBUGCINTE
220     Rprintf("bs2:\n");
221     for(int j=0; j<nj+1; j++) Rprintf("%f ",bs2[j * *nx]);
222     Rprintf("\n");
223     for(int j=0; j<nj+1; j++) Rprintf("%f ",bs2[1+ j * *nx]);
224     Rprintf("\n");
225 #endif
226     for(int i=0; i< *nx; i++){
227         for(int j=0; j<nj; j++){
228             cinte[i+j* *nx]=0;
229             if(x[i]>=knots[j+ *ord]) cinte[i + j* *nx] = binte[j];
230             if((x[i]<knots[j+ *ord]) & (x[i]>=knots[j]))
231             {
232                 for(int k=j+1;k<nj+1;k++) 
233                     cinte[i + j* *nx]+=binte[j]*bs2[i + k* *nx];
234             }
235         }
236     }
237     free(bs2);
238     free(knots2);
239 }