Array elements are usually considered as being arranged with the first subscript as the row number and the second subscript as the column number. This corresponds to traditional mathematical nxm matrix notation:
a1,1 |
a1,2 |
a1,3 |
... |
a1,m |
a2,1 |
a2,2 |
... |
|
a2,m |
... |
... |
ai,j |
... |
ai,m |
an,1 |
an,2 |
... |
|
an,m |
Element ai,j is located in row i, column j.
INTEGER*4 A(3,2)
The elements of A are conceptually arranged in 3 rows and 2 columns:
A(1,1) | A(1,2) |
A(2,1) | A(2,2) |
A(3,1) | A(3,2) |
Array elements are stored in column-major order.
Example: For the array A, they are located in memory as follows:
A(1,1) | A(2,1) | A(3,1) | A(1,2) | A(2,2) | A(3,2) |
The inner (leftmost) subscript changes more rapidly.