[comp.lang.apl] Visualizing multi-dimensional arrays

DMLAUR@pucc.Princeton.EDU (David M. Laur) (02/17/89)

I'm forwarding the following note from Ron Frank at the IBM TJ Watson
Research Center.  For many years he was the manager of "Low-End APL
Development", he is currently Manager for Parallel Computing Environments.
His e-mail address is:

  Ron Frank,   rifrank@yktvmh.bitnet

-------------------- Original Message -----------------------

In re query from Udo Hafermann, please forward.

Ron
__________________________________________-
I gave a paper on the visualization of multidimensional arrays at
the APL meeting in NYC a few years ago.  A summary appears below.

First a few comments.

1) An old paper by Zvi Weiss and Harry Saal showed, by sampling actual
code, that few people used 3D arrays and practically no-one used
4 or more D arrays.

2) Other work in psychology has recently shown (last 5 or so years)
that humans naturally take hard to grasp problems and reduce them
to hierarchically organized subproblems.  E.g. memorizing very long
strings of random digits.

The hierarchical breakdown usually is in the form of a tree with
a max of 7-9 sub nodes of any given node - and usually 5 or fewer.

This relates to my visualization algorithm below, in that I break down
the visualization problem into a hierarchy of sub problems, all of
which can be visualized.  This is a very general technique.
The theorem can be extended by considering the tables arrayed in
rows and columns in a room(5).  The rooms in rows and columns on the floo
of a building(7).  The floors(8).  The buildings on a block(9). The block
a 2D array in the city (east-west streets have buildings, not north south
streets)(11).  Etc. for cities(13), counties(15), states(17), countries(1
continents(21), planets(22) and moons(23).

3)  Array visualizations are relative to the problem being solved.
Visualizing the faces of a 4D cube to see that they are 3D cubes
is easy - see below.  Visualizing topological relationships
in 4 or more D is harder.  E.g., inside and outside of 4 D surfaces,
or abutting of 4D cube faces.

4)  Visualizing continuous arrays (real number indicies), is
harder.

---------------------------------------
THEOREM

THE BASE OF A 4-D HYPERCUBE IS A CUBE

1   CUBIC EGG CRATE ON A ROW OF TABLES
    (same number of tables as rows, cols, shelves of crates)

2   ANY EGG IS NAMED BY 4 INDICES

    2a  TABLE (1st)
    2b  CRATE SHELF (2nd top to bottom)
    2c  ROW & COLUMN ON CRATE SHELF (3rd, 4th)
        (rows across - front to back - in direction of tables - a row
         is orthogonal to table axis parallel to table top)
        (cols front to back - left to right - a col is parallel
         to table axis)

3   SET OF CRATES IS A 4-D ARRAY

4   BASE ALONG TABLE AXIS IS A CRATE
    (The crate on the first table is the base - a 3D object)
    (The crate on the last table is the top - a 3D object)

5   BASE ALONG SHELF AXIS IS A SET OF BOTTOM SHELVES
    (The bottom shelf from ALL crates is the base - a 3D object)
    (The shelf is 2D and the table index is the third D)
    (The Top shelf from ALL crates is the TOP along the shelf axis
     - a 3D object)

    5a  WHICH MAKE 3 INDEX THINGYS
     5a1  ROW, COL, TABLE
     5a2  ROW, COL, TABLE
    5b  A 3 INDEX THINGY IS A CUBE IF ALL MAXINDEX ARE EQUAL

6   Call the table axis T, the row axis X, the shelf axis Y, and
    the column axis Z (parallel to T).  Being discrete, we count
    out from the origin, the upper left corner of the bottom, or
    first crate.  The Y axis points down just so we get a right handed
    coordinate system.

7   BASE ALONG ROW AXIS IS not LEFT AS A STUDENT PROBLEM
    It is the set of all crate left sides (facing in the direction of the
    T axis.  Each side is 2D, with a 3rd index for tables.

8   BASE ALONG COL AXIS IS not LEFT AS A STUDENT PROBLEM
    It is the set of all crate front faces - observer
    facing in the direction of the T axis.  Each face is 2D,
    with a 3rd index for tables.

9   We have just shown all bounding faces of a 4D cube are
    3D cubes.

.********************************************
BIBLIOGRAPHY

(1) Ornstein, Robert E.
The Psychology of Consciousness
W. H. Freeman Pub., San Francisco.  Various editions.

(2) Saal, H. J., and Weiss, Z.
Some Properties of APL Programs
Proc. of APL 75, Assoc. of Comp. Mach. NY, 1975 p.294.
.********************************************
---------------------------------------
Transposing axes:

Table, Shelf, Row, Column
(1,2,3,4)
to

(1,3,2,4)

Table, Row, Shelf, Column

Mirror reflect each crate about a mirror through its upper left and
lower right edges.  Or, just interchange rows and shelves. The
observer is facing in the direction of the T axis.

I think of boxes lined up on school-room tables with the column axis
accidently (fact not to be used) parallel to the line of chairs.

Sit in a chair.  The shelves are stacked from top to bottom.
The rows go from left to right, the columns from near to far.
---------------------------------------
Transposing axes:

Table, Shelf, Row, Column
(1,2,3,4)
to

(3,2,1,4)

Row, Shelf, Table, Column

Slice all the carton boxes vertically so each row is a slice.
The knife is orthogonal to the table axis, parallel to the ground,
and moves downward.

Take all the first row slices, in order from all of the tables
and make a new carton on table one.  Take all of the second row slices
and make a new carton on table 2, etc.  Notice, columns and shelf heights
stay the same.
---------------------------------------
This shows that transpositions are higly discontinuous, topologically,
in the dimensions of the transposition.
---------------------------------------

+-----------------+   David Laur
|"You can tell an |   Princeton University
| APL programmer, |   Interactive Computer Graphics Lab
| but not much."  |   Bitnet: dmlaur@pucc
+-----------------+   UUCP: allegra!psuvax1!pucc.BITNET!DMLAUR