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)?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With