multidimensional arrays

Thomas M. Breuel breuel at harvard.ARPA
Mon Jan 7 06:02:47 AEST 1985


|[Doug Gwyn at Brl-Vld.ARPA writes:]
|I love C and use it for almost all applications programming.
|The single biggest deficiency I have found in the language
|is what Mr. Grady explained:  Formal array parameters are
|not permitted to have parametric dimensions.  That is,
|
|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 */
|	{
|
|is not a legal C procedure header.  It is clear that a C
|compiler COULD be made to handle this more general case,
|and that there is no practical way to code this procedure
|using the current language definition.  If one wants to
|displace Fortran from its dominating position in numerical
|software, this problem HAS to be solved.

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.

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.

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. (Flames to me -- I
love flames. Don't clutter the net with them).

						Thomas.
						breuel at harvard.



More information about the Comp.lang.c mailing list