[R] matlab style of storing arrays compared to R
Rainer M Krug
r.m.krug at gmail.com
Fri Nov 21 18:05:39 CET 2008
On Fri, Nov 21, 2008 at 6:12 PM, Douglas Bates <bates at stat.wisc.edu> wrote:
> R uses column-major ordering of multidimensional arrays, as in
> Fortran, unlike the row-major ordering of C multidimensional arrays.
> This is because the numerical linear algebra code used in R is from
> the Eispack, Linpack, BLAS, Lapack family of Fortran subroutine
> packages. Even when implementation languages other than Fortran are
> used, the Fortran storage conventions prevail because they affect the
> design of algorithms.
> Matlab is based on the same code (Matlab began as an interactive
> wrapper around Eispack and Linpack) and uses the same representation
> of arrays.
Thanks a lot for your detailed explanation. This will make my life much easier.
> On Fri, Nov 21, 2008 at 2:41 AM, Rainer M Krug <r.m.krug at gmail.com> wrote:
>> I am trying to figure out, if the matlab style of linear indexing of
>> an array is the same as in R. i.e.
>> x <- array( 1:24, dim=c(2,3,4) )
>> and if the same is true in matlab, assuming that
>> x[n1,n2,n3] in R returns the same as y(n1,n2,n3) when y is a matrix in matlab
>> I found the following reference
>> And it seems to be the same, but another source says it is different.
>> Could somebody confirm, if it is the same?
>> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
>> Biology, UCT), Dipl. Phys. (Germany)
>> Centre of Excellence for Invasion Biology
>> Faculty of Science
>> Natural Sciences Building
>> Private Bag X1
>> University of Stellenbosch
>> Matieland 7602
>> South Africa
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)
Centre of Excellence for Invasion Biology
Faculty of Science
Natural Sciences Building
Private Bag X1
University of Stellenbosch
More information about the R-help