Skip to content

Commit 9d68004

Browse files
committed
Added a variant using the import_transform class method for the Rcpp Vector class.
1 parent 9757d72 commit 9d68004

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2011-08-26 Douglas Bates <bates@stat.wisc.edu>
2+
3+
* inst/examples/OpenMP/OpenMPandInline.r: Added another variant
4+
using import_transform for the Rcpp Vector class.
5+
16
2011-08-26 Dirk Eddelbuettel <edd@debian.org>
27

38
* inst/examples/OpenMP/OpenMPandInline.r: Added two std::transform()

inst/examples/OpenMP/OpenMPandInline.r

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ serialStdAlgRcppCode <- '
4040
'
4141
funSerialStdAlgRcpp <- cxxfunction(signature(xs="numeric"), body=serialStdAlgRcppCode, plugin="Rcpp")
4242

43+
serialImportTransRcppCode <- '
44+
Rcpp::NumericVector x(xs);
45+
return Rcpp::NumericVector::import_transform(x.begin(), x.end(), ::log);
46+
'
47+
funSerialImportTransRcpp <- cxxfunction(signature(xs="numeric"), body=serialImportTransRcppCode, plugin="Rcpp")
48+
4349
## now with a sugar expression with internalizes the loop
4450
sugarRcppCode <- '
4551
// assign to C++ vector
@@ -71,6 +77,7 @@ funOpenMP <- cxxfunction(signature(xs="numeric"), body=openMPCode, plugin="Rcpp"
7177
z <- seq(1, 2e6)
7278
res <- benchmark(funSerial(z), funSerialStdAlg(z),
7379
funSerialRcpp(z), funSerialStdAlgRcpp(z),
80+
funSerialImportTransRcpp(z),
7481
funOpenMP(z), funSugarRcpp(z),
7582
columns=c("test", "replications", "elapsed",
7683
"relative", "user.self", "sys.self"),

0 commit comments

Comments
 (0)