: >|> Concerning storage of arrays in various languages, it should be clear to

: >|> anyone with half a brain (or with a linear algebra course 101 in their

: >|> transcript, whichever ;-) that Fortran did it the right way.

: >I don't understand this comment. In my experience, when a

: >mathematician writes

: >

: > A

: > ij

: >

: >he means the element of A at row i, column j,

: >which seems quite a lot like row-major ordering

: >to me.

: I think that the deal is that in memory the stuff is stored linearly.

: This means that multi-dimensional arrays are actually linear arrays

: of pointers (or equivelent links). For example:

Nope. Most Fortan and Pascal-like languages use a single block

of contiguous storage. The difference is how they are indexed.

The difference between Pascal-like languages ( Pascal/Modula/Oberon )

and FORTRAN matrix notation is that pascal-like languages follows from

the design of the recursive data types whereas Fortran follows common

mathematical notation.

In Pascal-like languages array ("[","]" ), record field (".")

and pointer selectors ("^" ) follow a simple left to right ordering

that mirrors the type definition regardless whether or not

Eg.

a : ARRAY N OF BaseType;

used as

a[4]

If the base type is a record then

a : ARRAY N OF

RECORD

x : FieldType

END;

used as

a[2].x

If the field of a record is an array then array selectors follows the

record selector as expected.

a : ARRAY N OF

RECORD

x : ARRAY M OF REAL;

END;

a[2].x[3] := 6.0;

Of course this leads to the problem that Pascal-like languages

do not follow the usual mathematical notation.

a : ARRAY N OF ARRAY M OF REAL;

or a : ARRAY N,M OF REAL; (* MxN array *)

a[j][i] := 5.0;

or a[j,i] := 5.0;

Older FORTRAN's did not have records and pointers. ( This meant of

course that there was no convienent way to build trees and other

common computer/numerics data structures. But that is another storey.

Perhaps some old FORTRAN programmer will be happy to tell you how they

mapped out the nodes of a tree from a single block of memory on

a IBM/360, 486DX266 or some similar relic iron of days gone by :-) ).

What fortran had was arrays and simple data types. Arrays were defined

and indexed a notation that closely follows common the matrix notation

of most math texts. The compiler writer was leveled with the

responsibility of the less systematic notation.

DEFINE a[M,N]

a[i,j] = 5.0

Note : although the Pascal and FORTRAN notations appear different

they are in fact indexing the same memory cells.

In either case programmers walk/index softly along the so-called

cache-lines and vary the index that follows the cache line more

frequently than the one that is perpendicular to the cache line.

Whitney