[Rcpp-devel] Returning Armadillo matrices with dimnames

Dirk Eddelbuettel edd at debian.org
Fri May 3 00:24:43 CEST 2013

On 2 May 2013 at 16:37, Sameer D'Costa wrote:
| > From a quick look at the header file Matrix.h it seems that
| >
| >     template <typename Iterator>
| >     Matrix( const int& nrows_, const int& ncols, Iterator start ) ;
| >
| > should be what you are after.  (The various types are just typedefs to the
| > templated variants of Matrix for int, double, char, ...)
| >
| > But do check the source file to be sure and maybe do a quick performance for
| > both 'small' and 'large' matrices -- run-time should be constant if there are
| > only pointer copies.
| I tried this constructor and it looks like it does make a copy.  (line
| 119 of Rcpp/inst/include/Rcpp/api/meat/Vector.h if I am reading it
| correctly). Also looks like the run time does increase significantly
| as the dimension increases. Oh well. never mind. Thanks.

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.


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

More information about the Rcpp-devel mailing list