[Rcpp-devel] split the c++ code in several files

Romain Francois romain at r-enthusiasts.com
Thu Sep 16 20:34:18 CEST 2010

Le 16/09/10 20:25, baptiste auguie a écrit :
>>> Truth be told, I got lost in the recent discussions on the
>>> best way to pass a real (complex) matrix from R to Armadillo and I've
>>> been meaning to go back to this question.
>> Sorry for the confusion. I think Rcpp::as is fine. I need a bit more work in
>> RcppArmadillo for the interchangeability between ComplexVector and cx_mat.
> Part of the confusion is also on whether one particular technique can
> save making copies of the object.
> Thanks again,
> baptiste

If you want zero copies, you have to use the so-called "advanced 
constructors" in http://arma.sourceforge.net/docs.html#Mat
Both data structures then share the memory, good things as well as bad 
things can happen with this.

Rcpp::as I think makes two copies, which is one too many. I should 
probably check this. as returns an object, and then the copy constructor 
is used. Maybe not though. Perhaps someone else will know better how 
compilers, etc ... work.

When I will get around to fix the mat constructor that takes a 
NumericMatrix, only one copy should happen.


Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
|- http://bit.ly/cCmbgg : Rcpp 0.8.6
|- http://bit.ly/bzoWrs : Rcpp svn revision 2000
`- http://bit.ly/b8VNE2 : Rcpp at LondonR, oct 5th

More information about the Rcpp-devel mailing list