[Rcpp-commits] r3181 - in pkg/Rcpp: . inst/examples/OpenMP

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Aug 26 21:29:13 CEST 2011


Author: dmbates
Date: 2011-08-26 21:29:12 +0200 (Fri, 26 Aug 2011)
New Revision: 3181

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/examples/OpenMP/OpenMPandInline.r
Log:
Added a variant using the import_transform class method for the Rcpp Vector class.


Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2011-08-26 16:48:34 UTC (rev 3180)
+++ pkg/Rcpp/ChangeLog	2011-08-26 19:29:12 UTC (rev 3181)
@@ -1,3 +1,8 @@
+2011-08-26  Douglas Bates  <bates at stat.wisc.edu>
+
+	* inst/examples/OpenMP/OpenMPandInline.r: Added another variant
+	using import_transform for the Rcpp Vector class.
+
 2011-08-26  Dirk Eddelbuettel  <edd at debian.org>
 
 	* inst/examples/OpenMP/OpenMPandInline.r: Added two std::transform()

Modified: pkg/Rcpp/inst/examples/OpenMP/OpenMPandInline.r
===================================================================
--- pkg/Rcpp/inst/examples/OpenMP/OpenMPandInline.r	2011-08-26 16:48:34 UTC (rev 3180)
+++ pkg/Rcpp/inst/examples/OpenMP/OpenMPandInline.r	2011-08-26 19:29:12 UTC (rev 3181)
@@ -40,6 +40,12 @@
 '
 funSerialStdAlgRcpp <- cxxfunction(signature(xs="numeric"), body=serialStdAlgRcppCode, plugin="Rcpp")
 
+serialImportTransRcppCode <- '
+   Rcpp::NumericVector x(xs);
+   return Rcpp::NumericVector::import_transform(x.begin(), x.end(), ::log);
+'
+funSerialImportTransRcpp <- cxxfunction(signature(xs="numeric"), body=serialImportTransRcppCode, plugin="Rcpp")
+
 ## now with a sugar expression with internalizes the loop
 sugarRcppCode <- '
    // assign to C++ vector
@@ -71,6 +77,7 @@
 z <- seq(1, 2e6)
 res <- benchmark(funSerial(z), funSerialStdAlg(z),
                  funSerialRcpp(z), funSerialStdAlgRcpp(z),
+                 funSerialImportTransRcpp(z),
                  funOpenMP(z), funSugarRcpp(z),
                  columns=c("test", "replications", "elapsed",
                            "relative", "user.self", "sys.self"),



More information about the Rcpp-commits mailing list