Two Dimensional Arrays.
Doug Gwyn
gwyn at smoke.BRL.MIL
Tue Feb 28 02:22:04 AEST 1989
In article <1474 at etive.ed.ac.uk> sam at lfcs.ed.ac.uk (S. Manoharan) writes:
>Passing a 2-D array around different functions does not seem
>nice, for one needs to declare the dimensions of the array in
>each and every function. The only way to overcome this problem
>is to use pointers instead of arrays.
You can also pass around descriptors by value, not just by reference.
>Now, coming to the query, is there a better/elegant way of coding
>an array sothat one can use his matrix functions ( say, transpose,
>inverse, read, write, ... ) for all array types ( double, long, .. )
>and sizes?
Unless you use self-describing structures, you cannot possibly cover
ALL array types. And I would be hard put to say what some of the
operations mean for some types of array. To take a simple example,
what is the "inverse" of an integer array? (Probably not an integer
array.) In some cases more than one definition is possible, depending
on context. For Boolean matrices, the transitive closure is an
important operation that has no counterpart for real-number matrices.
And so on. The point of all this is, one should implement the most
commonly useful operations for the most common data types, and not
worry too much about excessive generality.
More information about the Comp.lang.c
mailing list