ln63fhl@sdcc7.ucsd.EDU (David Cook) (10/13/86)
Has anyone figured out a way to get around the fact that open parameters will only work for 1-D arrays and not for matrices. I am beginining to realize that mod2 is not a good language for linear algebraic applications despite its wealth of structures and simplicity, but hoping someone can change my mind. Maybe my problem is that things have to be elegant; I can't stand being forced to use FORTRAN type solutions in mod2! ............................................Thanx, Dave Cook.
ken@ROCHESTER.ARPA (Comfy chair) (10/13/86)
I believe DEC's Modula-2 compiler has an extension to allow open matrices and higher order arrays. You could bypass the type checking by passing the address of the array. You'd still have to do your own indexing. This means passing the dimensions as well. Messy. Perhaps a neater way is to pass a descriptor (a record containing the address of the array, and the dimensions). I still don't see a way around either the inefficiency of an indexing function, or the verbosity of writing your own index computations. Note that C (until C++) has the same problems. Anybody have better ideas? Ken
broman%bugs@NOSC.ARPA (Vincent Broman) (10/14/86)
I don't see what is so abominably inefficient about a nice clean
indexing function on an array descriptor. That would be the Natural
Solution to this problem as well as more general ones, such as how to
store symmetric arrays in half the space, how to switch from dense
to sparse storage of a matrix, etc, etc.
The function call overhead is all the additional burden required,
since the arithmetic of index computation must be done in any case.
The only other inefficiency might be when a smart optimizing compiler
can simplify some sequential accesses to the array, but isn't smart enough
(or given opportunity) to expand an indexing function call inline
in order to optimize it.
Vincent Broman, code 632, Naval Ocean Systems Center, San Diego, CA 92152, USA
Phone: +1 619 225 2365 {seismo,caip,ihnp4,ucbvax}!\\\\\\\
Arpa: broman@bugs.nosc.mil Uucp: {floyd,moss,bang,hp-sdd,sdcsvax}!noscvax!bromanjoel@DECWRL.DEC.COM (Joel McCormack) (10/29/86)
The current Modula-2 compiler at DEC allows you to declare things like ARRAY
OF ARRAY OF REAL, and the HIGH function takes an optional parameter for the
dimension number. (Other extensions use HIGH(array) for the first dimension,
HIGH(array[0]) for the 2nd, etc.)
I would rather have something along the lines of Pascal's conformant arrays,
but ARRAY OF set a nasty precedent. (Several years ago I asked Niklaus Wirth
what he planned to do about making Modula-2 suitable for implementing math
libraries; he said he really didn't care about that kind of programming.)
Standard Modula-2 supports only one-dimensional open arrays, and I don't know
what the ISO group is contemplating.
- Joel McCormack {ihnp4 decvax ucbvax allegra}!decwrl!joel
joel@decwrl.dec.com