evan@u1100s.UUCP (Evan J. Bigall) (09/06/88)
In: <16512@apple.Apple.COM> Malcolm Slaney says: > 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????). What this refers to is the way in which arrays are laid out in memory. Fortran is column major meaning the arrays are laid out taking from the columns first. For example, the array: - - | 1 2 3 | | 4 5 6 | | 7 8 9 | - - Gets laid out in memory by Fortran as: 1 4 7 2 5 8 3 6 9 Almost everybody else does row major which results in a lay out of: 1 2 3 4 5 6 7 8 9 Why Fortran does it this way I do not know, its way before my time. You might ask why do I care? It seems like the sort of thing you dont really want to know about. The reason you care, is to make comparisons. They only reason I ever use fortran, is to run timings so I can show Fortran bigots that the things runs faster in APL, C, etc... Well, if you write a (good) Fortran program that takes the dot product of two 10,000 by 10,000 matrixs, and then write a C program that "literally" corresponds, you will find the c program runs about 1000 times slower. This is because the C program is page faulting on every fetch of a number out of the matrix. Of course you can do it the other way to make Fortran look bad, but thats another tale. . . Hope this satisfy's your curiosity. Evan Obligatory Fortran jokes: FORTRAN, "the infantile disorder", by now nearly 20 years old, is hopelessly inadequate for whatever computer application you have in mind today: it is now too clumsy, too risky, and too expensive to use. - Edsger Dijkstra You can tell how far we have to go, when FORTRAN is the language of supercomputers. -- Steven Feiner Multiple choice test: WHAT IS FORTRAN? [a] between thre and fiv tran. [b] what two computers engage in before interface. [c] ridiculous. Real Programmers don't write in FORTRAN: FORTRAN is for pipe stress freaks and crystallography weenies. Real programmers don't write in FORTRAN: FORTRAN is for wimp engineers who wear white socks. The determined Real Programmer can write FORTRAN programs in any language. -- I barely have the authority to speak for myself, certainly not anybody else evan@ctt.bellcore.com {ucbvax, rutgers, decwrl, attunix}!bellcore!ctt!evan