Conformant Arrays in C

Peter da Silva peter at sugar.UUCP
Mon Mar 7 01:30:04 AEST 1988


In article <42529 at sun.uucp>, dgh%dgh at Sun.COM (David Hough) writes:
>         void matmul(double a[?ar][?ac], /* ar >= p, ac >= q */
>                     double b[?br][?bc], /* br >= q, bc >= r */
>                     double c[?cr][?cc], /* cr >= p, cc >= r */
>                     int p,              /* 0 <= p <= min(ar,cr) */
>                     int q,              /* 0 <= q <= min(ac,br) */
>                     int r)              /* 0 <= r <= min(bc,cc) */

WOw. I wouldn't have believed it... I prefer Fortran's syntax on this one.

	void matmul(double a[ar][ac], int ar, int ac,
	            double b[br][bc], int br, int bc,
	            double c[cr][cc], int cr, int cc,
		    int p,
		    int q,
		    int r)
	{
	}

Or:

	void matmul(a, ar, ac,
	            b, br, bc,
	            c, cr, cc,
		    p,
		    q,
		    r)
	int ar, ac, br, bc, cr, cc, p, q, r;
	double a[ar][ac];
	double b[br][bc];
	double c[cr][cc];
	{
	}

Doesn't require any new operators, doesn't require passing descriptors
around on the stack (yech), and allows you to allocate some space and
give it different dimensions in different places.
-- 
-- Peter da Silva  `-_-'  ...!hoptoad!academ!uhnix1!sugar!peter
-- Disclaimer: These U aren't mere opinions... these are *values*.



More information about the Comp.lang.c mailing list