[Rcpp-devel] Returning Armadillo matrices with dimnames
krzysztof.sakrejda at gmail.com
Fri May 3 11:46:39 CEST 2013
On May 2, 2013 11:22 PM, "Dirk Eddelbuettel" <edd at debian.org> wrote:
> On 2 May 2013 at 17:24, Dirk Eddelbuettel wrote:
> | Sorry. It was just a quick guess.
> | On second thought, I think your earlier approach was actually pretty
> | Take your arma object, use wrap to turn it into a SEXP (or maybe an
> | and you should then be able to set attributes.
> And on third thought, I think we both overlooked one aspect:
> -- R and Rcpp can share objects, passing them back and forth efficiently
> pointers as _both use the same allocation scheme_. So when Rcpp
> an object, it is "as if" R created it. Which is why we can generally
> move them back and forth.
> -- That does not hold for Armadillo. So to bring an Armadillo object
> we are better off making a copy.
Depending on the context, you could pre-create both matrices in R and pass
them in to Rcpp/Armadillo as Dirk suggests. Manipulate them as necessary
and they are available back in R when you are done.
> So once again the "No Free Lunch" theorem at work. Sorry.
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Rcpp-devel