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

可紊 提交于 2020-12-05 10:33:05

问题


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)?


回答1:


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.



来源:https://stackoverflow.com/questions/25907998/why-does-matlab-use-column-major-order

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!