[Rcpp-commits] r850 - in pkg: Rcpp RcppExamples RcppExamples/inst RcppExamples/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Mar 7 14:27:35 CET 2010
Author: romain
Date: 2010-03-07 14:27:34 +0100 (Sun, 07 Mar 2010)
New Revision: 850
Modified:
pkg/Rcpp/DESCRIPTION
pkg/RcppExamples/DESCRIPTION
pkg/RcppExamples/inst/ChangeLog
pkg/RcppExamples/src/RcppStringVectorExample.cpp
pkg/RcppExamples/src/RcppVectorExample.cpp
Log:
use string transformer in examples
Modified: pkg/Rcpp/DESCRIPTION
===================================================================
--- pkg/Rcpp/DESCRIPTION 2010-03-07 13:18:38 UTC (rev 849)
+++ pkg/Rcpp/DESCRIPTION 2010-03-07 13:27:34 UTC (rev 850)
@@ -1,6 +1,6 @@
Package: Rcpp
Title: Rcpp R/C++ interface package
-Version: 0.7.7.14
+Version: 0.7.7.15
Date: $Date$
Author: Dirk Eddelbuettel and Romain Francois, with contributions
by Simon Urbanek and David Reiss; based on code written during
Modified: pkg/RcppExamples/DESCRIPTION
===================================================================
--- pkg/RcppExamples/DESCRIPTION 2010-03-07 13:18:38 UTC (rev 849)
+++ pkg/RcppExamples/DESCRIPTION 2010-03-07 13:27:34 UTC (rev 850)
@@ -8,7 +8,7 @@
Description: Examples for Seamless R and C++ integration
The Rcpp package contains a C++ library that facilitates the integration of
R and C++ in various ways. This package provides examples.
-Depends: R (>= 2.10.0), Rcpp (>= 0.7.7.14)
+Depends: R (>= 2.10.0), Rcpp (>= 0.7.7.15)
Suggests: inline (>= 0.3.4), RUnit
SystemRequirements: None
URL: http://dirk.eddelbuettel.com/code/rcpp.html, http://romainfrancois.blog.free.fr/index.php?category/R-package/Rcpp
Modified: pkg/RcppExamples/inst/ChangeLog
===================================================================
--- pkg/RcppExamples/inst/ChangeLog 2010-03-07 13:18:38 UTC (rev 849)
+++ pkg/RcppExamples/inst/ChangeLog 2010-03-07 13:27:34 UTC (rev 850)
@@ -1,3 +1,9 @@
+2010-03-07 Romain Francois <romain at r-enthusiasts.com
+
+ * src/RcppVectorExample.cpp: use a new vector for the output
+ * src/RcppStringVectorExample.cpp: rework the new api version
+ using the StringTransformer class (depends on Rcpp >= 0.7.7.15)
+
2010-03-04 Dirk Eddelbuettel <edd at dexter>
* src/RcppMatrixExample.cpp: Added 'classic' + 'new' API examples
Modified: pkg/RcppExamples/src/RcppStringVectorExample.cpp
===================================================================
--- pkg/RcppExamples/src/RcppStringVectorExample.cpp 2010-03-07 13:18:38 UTC (rev 849)
+++ pkg/RcppExamples/src/RcppStringVectorExample.cpp 2010-03-07 13:27:34 UTC (rev 850)
@@ -23,27 +23,13 @@
#include <Rcpp.h>
-// local helper class to transform all characters of a given string
-class StringToLower{
-public:
- StringToLower() : buffer() {}
- ~StringToLower(){}
-
- std::string operator()( const char* input){
- buffer = input ;
- std::transform( buffer.begin(), buffer.end(), buffer.begin(), ::tolower);
- return buffer ;
- }
-private:
- std::string buffer ;
-} ;
-
RcppExport SEXP newRcppStringVectorExample(SEXP strvec) {
Rcpp::StringVector orig(strvec); // creates Rcpp string vector from SEXP
Rcpp::StringVector vec(orig.size());
- std::transform( orig.begin(), orig.end(), vec.begin(), StringToLower() ) ;
+ std::transform( orig.begin(), orig.end(), vec.begin(),
+ Rcpp::make_string_transformer(tolower) ) ;
Rcpp::Pairlist res(
Rcpp::Named( "result" ) = vec,
Modified: pkg/RcppExamples/src/RcppVectorExample.cpp
===================================================================
--- pkg/RcppExamples/src/RcppVectorExample.cpp 2010-03-07 13:18:38 UTC (rev 849)
+++ pkg/RcppExamples/src/RcppVectorExample.cpp 2010-03-07 13:27:34 UTC (rev 850)
@@ -25,9 +25,9 @@
RcppExport SEXP newRcppVectorExample(SEXP vector) {
- Rcpp::NumericVector vec(vector); // creates Rcpp vector from SEXP
- Rcpp::NumericVector orig(vector); // keep a copy (as the classic version does)
-
+ Rcpp::NumericVector orig(vector); // keep a copy (as the classic version does)
+ Rcpp::NumericVector vec(orig.size()); // create a target vector of the same size
+
// we could query size via
// int n = vec.size();
// and loop over the vector, but using the STL is so much nicer
More information about the Rcpp-commits
mailing list