[Rcpp-devel] integer and numeric vector
Romain François
francoisromain at free.fr
Wed Jan 6 09:17:32 CET 2010
And now we can use the initializer lists in conjunction with these classes:
Rcpp::wrap( {1,2,3} )
Rcpp::wrap( {1.0,2.0,3.0} )
Rcpp::wrap( {false, true} )
Rcpp::wrap( {(Rbyte)0, (Rbyte)1 } )
I'll tackle CharacterVector and ExpressionVector tonight.
Romain
On 01/05/2010 06:46 PM, Romain François wrote:
>
> I've added logical and raw vectors into the mix, and a draft for generic
> vectors (lists).
>
> Romain
>
> On 01/05/2010 04:28 PM, Romain François wrote:
>> Hello,
>>
>> I've commited Rcpp::IntegerVector and Rcpp::NumericVector. see the unit
>> tests for more examples, but here's an example:
>>
>> NumericVector x = {0.0,1.0,2.0,3.0} ; // this needs GCC>= 4.4
>> for( int i=0; i<x.size(); i++) x[i] = x[i]*2 ;
>> return x ;',
>>
>> other constructors are available so that the class is usable before 4.4:
>>
>> NumericVector x(10) ; // allocate an numeric vector of 10 elements (uses
>> Rf_allocVector( REALSXP, 10 )
>>
>> or the NumericVector(SEXP) which simply wraps up the SEXP into an object.
>>
>> Romain
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/IW9B : C++ exceptions at the R level
|- http://tr.im/IlMh : CPP package: exposing C++ objects
`- http://tr.im/HlX9 : new package : bibtex
More information about the Rcpp-devel
mailing list