Followed is the explaination in Randall Hyde's AoA book:

Column major ordering is the other function frequently used to compute the

address of an array element. FORTRAN and various dialects of BASIC (e.g.,

Microsoft) use this method to index arrays.

In row major ordering the rightmost index increased the fastest as you moved

through consecutive memory locations. In column major ordering the leftmost

index increases the fastest. Pictorially, a column major ordered array is

organized as shown in Figure 5.6.

The formulae for computing the address of an array element when using column

major ordering is very similar to that for row major ordering. You simply reverse

the indexes and sizes in the computation:

For a two-dimension column major array:

Element_Address = Base_Address + (rowindex * col_size + colindex) * Element_Size

I am wondering in overhead formulae whether the rowindex and the colindex should be exchanged each other as follow:

Element_Address=Base_Address +( colindex* col_size + rowindex) * Element_Size

Would you please tell me which one is correct!

Column major ordering is the other function frequently used to compute the

address of an array element. FORTRAN and various dialects of BASIC (e.g.,

Microsoft) use this method to index arrays.

In row major ordering the rightmost index increased the fastest as you moved

through consecutive memory locations. In column major ordering the leftmost

index increases the fastest. Pictorially, a column major ordered array is

organized as shown in Figure 5.6.

The formulae for computing the address of an array element when using column

major ordering is very similar to that for row major ordering. You simply reverse

the indexes and sizes in the computation:

For a two-dimension column major array:

Element_Address = Base_Address + (rowindex * col_size + colindex) * Element_Size

I am wondering in overhead formulae whether the rowindex and the colindex should be exchanged each other as follow:

Element_Address=Base_Address +( colindex* col_size + rowindex) * Element_Size

Would you please tell me which one is correct!

Let's start by replacing the term 'Column' with 'X', and 'Row' with 'Y'.

Here are the revised Column-Major formulae:

Address = Base + (Y * col_size + X) * Element_Size (Randy)

Address = Base + (X * col_size + Y) * Element_Size (Yours)

I think Randy is wrong, and you are right, in regards to Column Major Order.

Guys, its late, you may disagree, and you may have reason to, but before you shoot me down, do note that the 'conventional' array addressing scheme is Row Major, and for Row Major, Randy's Col-Maj formula would be correct, if we replaced col_size with row_size.

Here are the revised Column-Major formulae:

Address = Base + (Y * col_size + X) * Element_Size (Randy)

Address = Base + (X * col_size + Y) * Element_Size (Yours)

I think Randy is wrong, and you are right, in regards to Column Major Order.

Guys, its late, you may disagree, and you may have reason to, but before you shoot me down, do note that the 'conventional' array addressing scheme is Row Major, and for Row Major, Randy's Col-Maj formula would be correct, if we replaced col_size with row_size.

Got it, thanks for you detail explaination. i can proceed to next section confidently.

There's an ambiguity in the meaning of column size:

1) the column dimension of the matrix, which is the number of columns

2) the length of a matrix column, which is the number of rows

=====

Row-major order:

address = (row-index * columns-per-row + column-index) * element-size

C and C++ use row-major order.

=====

Randy is right about Fortran - it uses column-major order:

address = (column-index * rows-per-column + row-index) * element-size

1) the column dimension of the matrix, which is the number of columns

2) the length of a matrix column, which is the number of rows

=====

Row-major order:

address = (row-index * columns-per-row + column-index) * element-size

C and C++ use row-major order.

=====

Randy is right about Fortran - it uses column-major order:

address = (column-index * rows-per-column + row-index) * element-size