[Rcpp-devel] Matrix: column-major storage?
rdiaz02 at gmail.com
Wed Nov 7 21:27:35 CET 2012
Dear Dirk, Doug, and Romain,
Thanks a lot for your (very fast ---didn't even have time to have dinner
;-) responses. I was aware of the column-major order in R, but for no
reason I was expecting row-major in C++ (but then, I was expecting nrow
and ncol to work as they did).
I'll play around with RcppArmadillo and RcppEigen, and also see if I can
easily adapt my algorithms to use column-major order efficiently.
On Wed, 7 Nov 2012 13:43:52 -0600,Dirk Eddelbuettel <edd at debian.org> wrote:
> Hi Ramon,
> And welcome!
> On 7 November 2012 at 20:25, Ramon Diaz-Uriarte wrote:
> | I understand it is not possible to store things in row-major order with
> | Rcpp Matrix types?
> In short: No.
> In more detail, and allow me to quote from Section "5.11.2 Calculating
> numerical derivatives" in "Writing R Extensions":
> Now, we compute the `i''th column of the gradient matrix. Note how it
> is accessed: R stores matrices by column (like FORTRAN).
> (which was the first suitable hit I found in the manual).
> A *lot* of the power and convenience in Rcpp comes from the fact that we do
> provide so-called 'proxy objects' that are fairly thing wrappers (with added
> C++ magic) on top of the original R types.
> So whatever it is in R, it is in Rcpp (holds as a general rule, void where
> prohibited and you have a money-back guarantee).
> If you want different matrix representations, the excellent package
> RcppArmadillo and RcppEigen are willing and able to help. Getting data to
> and from them is easy too.
> Hope this helps, Dirk
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
Department of Biochemistry, Lab B-25
Facultad de Medicina
Universidad Autónoma de Madrid
Arzobispo Morcillo, 4
Email: rdiaz02 at gmail.com
ramon.diaz at iib.uam.es
More information about the Rcpp-devel