Inline videos. See also:Category: Articles with embedded Videos..

Row-major order

From Biocrawler, the free encyclopedia.

Row-major order describes a way to store a multidimensional array in linear memory. This is the approach used by the C programming language as well as many others, with the notable exception of Fortran. If an array is in row-major order, the memory offset from one row to the next is larger than that from one column to the next. For example, to store this 3×3 array:

 1  2  3
 4  5  6
 7  8  9

in C it would be laid out in memory as

 1  2  3  4  5  6  7  8  9

That is, the stride from one column to the next is 1 and the stride from one row to the next is 3.

To contrast, in a column-major language like Fortran, the same array would be represented as

 1  4  7  2  5  8  3  6  9

which is to say that the column step is 3 and the row step is 1.


Generalizing to higher dimensions, row-major order means that the stride along the "first" dimension (e.g., x) is smallest, increasing up to the "last" dimension (e.g., z). (For an arbitrary number of dimensions, n, one could have up to n! ordering schemes. (Any of the dimensions could be the major one, any of the remaining n−1 could be the secondary one, etc.) While there may be performance reasons to construct such a data structure, it is uncommon.

Treating a row-major array as a column-major array is the same as transposing it.

Wikipedia (http://en.wikipedia.org/wiki/Main_Page) Row-major_order (http://en.wikipedia.org/wiki/Row-major_order) version history (http://en.wikipedia.org/w/index.php?title=Row-major_order&action=history) GNU Free Documentation Lizenz (http://en.wikipedia.org/wiki/Wikipedia:Text_of_the_GNU_Free_Documentation_License) CC-by-sa (http://creativecommons.org/licenses/by-sa/2.5/)

Personal tools
Google Search
Google
Web
biocrawler.com