Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!umcp-cs!chris
From: chris@umcp-cs.UUCP (Chris Torek)
Newsgroups: net.lang.c
Subject: Re: multidimensional arrays in C
Message-ID: <2301@umcp-cs.UUCP>
Date: Sun, 6-Jan-85 13:55:45 EST
Article-I.D.: umcp-cs.2301
Posted: Sun Jan  6 13:55:45 1985
Date-Received: Tue, 8-Jan-85 02:41:20 EST
References: <458@ecsvax.UUCP>
Organization: U of Maryland, Computer Science Dept., College Park, MD
Lines: 34

I would like to point out (or perhaps belabour the obvious) that
FORTRAN can't access multidimensional arrays without knowing the
dimensions either.  If you write

	SUBROUTINE FOO (A, N)
	INTEGER N
	REAL A(N,N)

	INTEGER I, J
	REAL V
	...
	V = A(I,J)
	END

then the compiler computes the array as (pseudo C)

	v = *(a + (j-1)*n + i-1);	/* N.B.: this is NOT optimized */

(assuming I haven't screwed up my row & column order, as usual).

It takes JUST AS MUCH MACHINE TIME (though more programmer time*) to
access "ordinary" multi-dimensional arrays in C as it does in FORTRAN.
(And don't talk to me about your fancy optimizing compiler which
generates pointers to vectors; I can do that in C too. :-))

----------------
*This IS a consideration---but how much programmer time is wasted
finding bugs like DO 10 I = 1.20?
-- 
(This line accidently left nonblank.)

In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (301) 454-7690
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland