Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does MATLAB use column-major order? [closed]

I understand that the C language uses row-major order to store arrays, whereas MATLAB uses column-major order.

Is there any specific reason for MATLAB choosing column-major order? Does MATLAB gain significantly by opting to arrange multidimensional arrays by column in memory (i.e. columns are contiguous)?

like image 854
Karthik Balaguru Avatar asked Sep 30 '22 20:09

Karthik Balaguru


1 Answers

MATLAB uses column-major order for historical reasons.

Very early versions of MATLAB were implemented in FORTRAN and relied heavily on the LINPACK and EISPACK FORTRAN libraries which, unlike C, use column-major order. Even though it was (mostly) converted to a C implementation when it was initially commercialized, it retained the use of column-major order.

As far as I know there are no inherent advantages or disadvantages to column- or row-major arrays, it's just a choice that needs to be made one way or the other.

like image 143
Sam Roberts Avatar answered Oct 06 '22 18:10

Sam Roberts