[Pomp-commits] r346 - pkg/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Sep 29 17:38:12 CEST 2010


Author: kingaa
Date: 2010-09-29 17:38:12 +0200 (Wed, 29 Sep 2010)
New Revision: 346

Modified:
   pkg/src/bspline.c
Log:

- use R_alloc instead of Calloc/Free


Modified: pkg/src/bspline.c
===================================================================
--- pkg/src/bspline.c	2010-09-29 15:36:58 UTC (rev 345)
+++ pkg/src/bspline.c	2010-09-29 15:38:12 UTC (rev 346)
@@ -74,12 +74,11 @@
   xrd = REAL(xr);
   PROTECT(y = allocMatrix(REALSXP,nx,nb)); nprotect++;
   ydata = REAL(y);
-  val = (double *) Calloc(nb,double);
+  val = (double *) R_alloc(nb,sizeof(double));
   for (j = 0; j < nx; j++) {
     periodic_bspline_basis_eval(xrd[j],pd,deg,nb,val);
     for (k = 0; k < nb; k++) ydata[j+nx*k] = val[k];
   }
-  Free(val);
   UNPROTECT(nprotect);
   return y;
 }
@@ -103,7 +102,7 @@
   x = fmod(x,period);
   if (x < 0.0) x += period;
   for (k = 0; k < nknots; k++) {
-    bspline_internal(&yy[k],&x,1,k,degree,&knots[0],nknots);
+    bspline_internal(&yy[k],&x,1,k,degree,knots,nknots);
   }
   for (k = 0; k < degree; k++) yy[k] += yy[nbasis+k];
   for (k = 0; k < nbasis; k++) {
@@ -121,7 +120,7 @@
 
   if (p == 0) {
     for (j = 0; j < nx; j++)
-      y[j] = ((knots[i] <= x[j]) && (x[j] < knots[i+1]));
+      y[j] = (double) ((knots[i] <= x[j]) && (x[j] < knots[i+1]));
   } else {
     i2 = i+1;
     p2 = p-1;



More information about the pomp-commits mailing list