[comp.lang.misc] Row/Column Major Definition and History?

malcolm@Apple.COM (Malcolm Slaney) (09/03/88)

Can somebody tell me the history and definition of row major and column
major arrays?  I usually see this as part of a language definition stating
something like "The Fortran language stores arrays in row major order" (or
is Fortran column major????).

I've been wondering about this for a couple of years but I have never been
able to find a definition or an explanation.

Thanks.

							Malcolm Slaney
							malcolm@apple.com

pardo@june.cs.washington.edu (David Keppel) (09/03/88)

malcolm@Apple.COM (Malcolm Slaney) writes:
>[ Arrays: row- and column-major.  Whuzzat? ]

Reference: _The Theory and Practice of Compiler Writing_ by Jean-Paul
Tremblay and Paul G. Sorenson.  McGraw-Hill, 1985.  pg 574.

Idea: Memory is just a 1-dimensional array.  If we want a 2-d array,
we need to make a map from the 2-d "name" (e.g., A[2,3]) to the actual
1-d location.  Row- and column-major are just slighly different ways
of doing the mapping.

Consider:

	A[4..6,2..3] of two-byte

It can be laid out starting at addres 1010 as:

	1010 <4,2>
	1012 <4,3>
	1014 <5,2>
	1016 <5,3>
	1018 <6,2>
	1020 <6,3>

or as

	1010 <4,2>
	1012 <5,2>
	1014 <6,2>
	1016 <4,3>
	1018 <5,3>
	1020 <6,3>


    ;-D on  ( Help! my my commanding officer is row-major! )  Pardo
-- 
		    pardo@cs.washington.edu
    {rutgers,cornell,ucsd,ubc-cs,tektronix}!uw-beaver!june!pardo

malcolm@Apple.COM (Malcolm Slaney) (09/06/88)

pardo@uw-june.UUCP (David Keppel) writes:
>Idea: Memory is just a 1-dimensional array.  If we want a 2-d array,
>we need to make a map from the 2-d "name" (e.g., A[2,3]) to the actual
>1-d location.  Row- and column-major are just slighly different ways
>of doing the mapping.
>
Oops, I wasn't clear enough.  (Thanks to all the people who sent me long
detailed explanations about how 2d arrays are mapped into 1d memory.)

What I want to know is where the terminology row major and column major
came from.    I have heard rumors that it started back in the 19th
century in the linear algebra world.

I am asking this because a year or two ago I designed a array package for
signal processing (in Lisp) and I had to make two design decisions.  The
first was whether to describe two dimensional arrays using matrix notation 
(row, column) or graphics notation (x,y).  The second was to decide whether 
row major or column major made more sense.  I think the two decisions are 
independent and the choice isn't at all obvious.  Every time I describe the 
design I have to remember which is row major and which is column major.

Does anybody know where these terms came from?  I don't think the guy who
writes about language for the NY Times magazine section would be too 
interested in tracking this one down for me.

Thanks.

							Malcolm 
							malcolm@apple.com