[Rcpp-commits] r2744 - pkg/Rcpp/inst/examples/RcppInline
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Dec 8 14:01:43 CET 2010
Author: edd
Date: 2010-12-08 14:01:43 +0100 (Wed, 08 Dec 2010)
New Revision: 2744
Modified:
pkg/Rcpp/inst/examples/RcppInline/RObject.r
Log:
convert from RcppResultSet
Modified: pkg/Rcpp/inst/examples/RcppInline/RObject.r
===================================================================
--- pkg/Rcpp/inst/examples/RcppInline/RObject.r 2010-12-08 08:51:37 UTC (rev 2743)
+++ pkg/Rcpp/inst/examples/RcppInline/RObject.r 2010-12-08 13:01:43 UTC (rev 2744)
@@ -1,6 +1,6 @@
#!/usr/bin/r -t
#
-# Copyright (C) 2009 Dirk Eddelbuettel and Romain Francois
+# Copyright (C) 2009 - 2010 Dirk Eddelbuettel and Romain Francois
#
# This file is part of Rcpp.
#
@@ -17,6 +17,10 @@
# You should have received a copy of the GNU General Public License
# along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
+## NB This file is mostly historic and predates the unit tests.
+## Yet it still provides useful examples -- but the unitTests/
+## for vastly larger coverage
+
suppressMessages(library(Rcpp))
suppressMessages(library(inline))
@@ -88,16 +92,14 @@
### vectors
-cat("\n===Int Vector via RcppResultSet.getSEXP\n")
+cat("\n===Int Vector via wrap\n")
foo <- '
std::vector<int> iv = Rcpp::as< std::vector<int> >(x) ;
std::cout << "Returning twice the value of vector : ";
for (size_t i=0; i<iv.size(); i++) {
iv[i] = 2*iv[i];
}
- RcppResultSet rs;
- rs.add("", iv);
- return(rs.getSEXP());
+ return(Rcpp::wrap(iv));
'
funx <- cfunction(signature(x="numeric"), foo, Rcpp=TRUE, verbose=FALSE)
print(funx(x=2:5))
More information about the Rcpp-commits
mailing list