[Rcpp-devel] Access Rcpp::List element
Simon Zehnder
szehnder at uni-bonn.de
Sun May 26 15:20:46 CEST 2013
Dear Rcpp::Devels and Rcpp::Users,
I have maybe some trivial questions.
1. If I use
Rcpp::NumericVector A(someVector),
does it reuse memory from someVector for A? From http://cran.r-project.org/web/packages/Rcpp/vignettes/Rcpp-quickref.pdf I would say it does, whereas
Rcpp::NumerixVector A(clone(someVector))
does not.
2. Let us assume I am right in point 1, then my next question would arise towards reusing memory from R: Does it make a difference in C++ if I create a NumericVector with own memory and fill it in a loop or if I reuse memory from R and fill it in a loop? Again, I would say no, as if memory is reused, we usually pass a pointer to the memory tom the Rcpp Object, that has now direct access to this memory (of course this will be different when using parallel code, where memory allocation is essential).
3. Imagine I use now an S4 Object from R:
Rcpp::Export SEXP fName (SEXP& data_S4) {
Rcpp::S4 dataS4O (data_S4);
}
If data_S4 contains a list, has the command Rcpp::S4 dataS4(data_S4) already created an Rcpp::List Object from it? If not, how do I proceed to get such a Rcpp::List Object?
Best
Simon
More information about the Rcpp-devel
mailing list