[comp.lang.apl] Visualization of arrays

hafer@infbs (Udo Hafermann) (02/03/89)

As I am working on visualiyation of APL concepts, I would like to know:
How do you "normally" visualize APL arrays?  I suspect that up to rank
3, arrays are thought of as "concrete" objects, i.e. arranged in three-
dimensional space in the natural way (unless the application implies
thinking of "vectors of tables").

Arrays of higher rank do not have any natural arrangement in space; 
does anyone nevertheless use some kind of embedding to envision the
concept of axis?  How do you try to envision the transpose operation on
arrays of rank 4 and higher?  (As an aside, does anyone *use*
4-dimensional arrays at all?

Thanks for any contributions to this mini-poll.

zeke@fornax.UUCP (Zeke Hoskin) (02/07/89)

In article <121@infbsgr.infbs>, hafer@infbs (Udo Hafermann) writes:
> Arrays of higher rank do not have any natural arrangement in space; 
> (As an aside, does anyone *use* 4-dimensional arrays at all?
   How do we use them? Let me count the ways....
(1) as intermediates in operations involving lower-rank arrays.
(2) as a natural way of representing data with more than three
   "coordinates", for instance a table of profit vs time, place,
    material, personnel cost, and tax classification.
(3) In modelling real-world physics problems where there are indeed
    more than three space-like dimensions. (This is over and above
    lots of trad scientific treatments of things like the slope of
    the temperature-pressure plane w.r.t five or six concentrations
    all treated as (admittedly not independent) cooordinates)

   As for how to visualize higher-rank arrays: I wish I could help
you here.  If you played a lot of 4-dimensional chess, or even
4-D tictactoe, eventually some of the painstaking gruntwork that
is associated with the "left brain" would create some kind of
association in the "right brain" where people make stupid mistakes,
know things that aren't so, and have dazzling insights.  

    Other things that might help: learn tensor theory (after, not
as I stupidly did before, the appropriate matrix algebra); fool
around with quaternions; do some topology; figure out the 
the properties of a space where one of the dimensions has negative
squares, so Pythagoras' Theorem becomes (H*2) = (A*2)-B*2, and then
wander around trying to deduce Special Relativity from them. Tradition
has it that it is useful to have a friend follow you around while you
are doing this, to stop you from walking into open manholes.
-- 
What makes one step a giant leap|Zeke Hoskin/SFU VLSI group,Burnaby,BC,Canada
Is all the steps before         | ...!ubc-cs!sfu_fornax!zeke

jaxon@uicsrd.csrd.uiuc.edu (02/09/89)

The default display of rank 4 arrays isn't particularly good.  I prefer
enclosing them along the last two dimensions before they are displayed.
I find the resulting display (a 2D array of 2D arrays) lets me compute
the index of an element visually, and lets me notice adjacency along the
leading axes more easily.

In expressions I seldom 'use' more than 3 axes, the rest are just carried
along through the pervasive functions or others derived from the Each
operator.  To visualize those expressions, I generally enclose either
the axes I'm working on, or the complementary set.

In every APL I've known, arrays are stored in row-major order.  On most
high performance equipment,  the innermost loops should access items
along the trailing dimensions, so I also try to keep data that are used
together adjacent along some trailing axis.   If you are doing  Reductions
or Scans, however, you might want to test the relative performance of
different reduction axes.   This storage order is the "opposite" of
Fortran, so where you might prefer pre-multiplication inner products
in F77, you will want to convert to post-multiplication for APL.  

regards
Greg Jaxon  (jaxon@uicsrd.uiuc.edu)