multidimensional arrays

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Mon Jan 7 10:04:14 AEST 1985


> |void mat_mul( p, q, r, a, b, c )
> |	int	p, q, r;	/* dimensions */
> |	double	a[p][q], b[q][r], c[p][r];	/* arrays */
> |	{
> 
> I don't have any FORTRAN reference handy, but as far as I re-call, many
> (all?) FORTRANs do not permit functions of the above kind either.

You recall incorrectly.  Procedures like the above are legal in ANS `66
FORTRAN and Fortran `77, and are heavily used.

> If you need functions of the above kind, you can help yourself by using
> vectors as two-dimensional arrays and providing macros for creation and
> accessing them. Alternatively, you can rely on the compiler's
> representation of two-dimensional arrays in memory and only provide
> access functions.

If you have ever tried this you would know how gross it really is.
What is the point of a compiler if one has to resort to awkward
kludges to specify perfectly normal operations?

> BTW, who wants to displace FORTRAN from its dominating position in
> numerical computing? And why would you want to replace it with 'C'?
> 'C' is not very suited to numerical applications anyhow; the automatic
> promotion of float to double, and the lack of handling
> of over- and underflow are some of the problems.

FORTRAN is an atrocious language by modern standards.  C, while not
perfect, is much better for writing reliable production code.  It
would be better to use a single language for applications instead of
two (or worse, a combination of the two).

(My Fortran experience dates back to around 1960, but I wouldn't choose
to use it for any application now!)

ANSI standard C is expected to solve the problem of all arithmetic being
done in double precision, which I don't think was much of a problem.
FORTRAN does not handle overflow or underflow either, and any code that
has problems in this regard was not carefully written.  (Does anyone
remember scaled fixed point?  Worked just dandy..)



More information about the Comp.lang.c mailing list