[R] R matrices in memory

Douglas Bates bates at stat.wisc.edu
Fri Jul 18 01:15:29 CEST 2003


Francisco J Molina <fjmolina at lbl.gov> writes:

> Acording to the documentation in gsl 
> 
> "The physical row dimension tda, or trailing dimension, specifies the size
> of a row of the matrix as laid out in memory"

I think you may have problems here.  Arrays in R are stored in
column-major ordering, as in Fortran.  In other words, the elements of
a row of a matrix are not adjacent in memory so "the size of a row of
the matrix as laid out in memory" is not meaningful.  

For R matrices the elements of columns are adjacent in memory.

You may need to write conversion routines to copy the contents of the
R matrix into the form that GSL expects.

> I think that if I pass a matrix to C++ through .C as single ( or.double ),
> that is, 
> 
> .C ( as.single ( matrix ))
> 
> then the tda is simply the number of elements of that matrix.




More information about the R-help mailing list