[Rcpp-devel] Returning Armadillo matrices with dimnames

Dirk Eddelbuettel edd at debian.org
Fri May 3 05:22:44 CEST 2013

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 good:
| Take your arma object, use wrap to turn it into a SEXP (or maybe an RObject)
| 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 via
    pointers as _both use the same allocation scheme_. So when Rcpp creates
    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 back,
    we are better off making a copy.

So once again the "No Free Lunch" theorem at work.  Sorry.


Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com

More information about the Rcpp-devel mailing list