[Rcpp-commits] r2185 - pkg/Rcpp/inst/examples/ConvolveBenchmarks

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Sep 26 01:15:15 CEST 2010


Author: edd
Date: 2010-09-26 01:15:14 +0200 (Sun, 26 Sep 2010)
New Revision: 2185

Modified:
   pkg/Rcpp/inst/examples/ConvolveBenchmarks/convolve7_c.c
Log:
again updated to section 5.10.1 of R 2.11.1


Modified: pkg/Rcpp/inst/examples/ConvolveBenchmarks/convolve7_c.c
===================================================================
--- pkg/Rcpp/inst/examples/ConvolveBenchmarks/convolve7_c.c	2010-09-25 23:11:33 UTC (rev 2184)
+++ pkg/Rcpp/inst/examples/ConvolveBenchmarks/convolve7_c.c	2010-09-25 23:15:14 UTC (rev 2185)
@@ -19,16 +19,16 @@
     /* UNPROTECT(3); */
     /* return(ab); */
 
-    R_len_t i, j, na, nb, nab;
+    int i, j, na, nb, nab;
     double *xa, *xb, *xab;
     SEXP ab;
-
-    PROTECT(a = coerceVector(a, REALSXP));
-    PROTECT(b = coerceVector(b, REALSXP));
-    na = length(a); nb = length(b); nab = na + nb - 1;
-    PROTECT(ab = allocVector(REALSXP, nab));
-    xa = REAL(a); xb = REAL(b);
-    xab = REAL(ab);
+    
+    PROTECT(a = AS_NUMERIC(a));
+    PROTECT(b = AS_NUMERIC(b));
+    na = LENGTH(a); nb = LENGTH(b); nab = na + nb - 1;
+    PROTECT(ab = NEW_NUMERIC(nab));
+    xa = NUMERIC_POINTER(a); xb = NUMERIC_POINTER(b);
+    xab = NUMERIC_POINTER(ab);
     for(i = 0; i < nab; i++) xab[i] = 0.0;
     for(i = 0; i < na; i++)
 	for(j = 0; j < nb; j++) xab[i + j] += xa[i] * xb[j];



More information about the Rcpp-commits mailing list