The ‘Dual-View’ approach to array visualization

Previously, we found the J text representation revealed values of individual atoms, but could not distinguish singleton arrays of different shapes, or empty arrays. Ron Frank in his paper, “A New “Dual-View” Diagram of Array Structure” (Frank, 2003) describes “Dual-View”, applying combinatorics to enumerate the atoms, lists, planes and cubes and representing them with dots and edges.

For example, an array of shape 2 3 4 has 2 * 3 * 4 = 24 atoms (T00); (2*3)+(3*4)+(2*4)=26 edges (T01); 2 + 3 + 4 = 9 planes (T02); and 1 cube (T03).

Edges and dots indicate planes and cubes by sketching the array in three dimensions. Collinear segments count as only one edge, so the diagram above has 24 dots for atoms, 26 edges for lists (12 aligned vertically, eight horizontally, and six along the z axis), nine planes (two parallel to the x-z plane, four parallel to the x-y plane and three parallel to the y-z plane), in a three dimensional brick.

This monadic J verb produces these coefficients given the shape of the array by stitching 1 to items of the shape, then cross multiplying (2 1) ⊗ (3 1) ⊗ (4 1) to produce coefficients.

   arrayCoeff =: (+//.@(*/))/@,.&1 
   arrayCoeff 2 3 4
24 26 9 1

For single valued arrays the added edges create distinct representations.

   arrayCoeff 1
1 1

   arrayCoeff 1 1
1 2 1

   arrayCoeff 1 1 1
1 3 3 1

Empty arrays have at least one zero in their shape. The list with shape zero is represented by a single edge with no dot as predicted.

   arrayCoeff 0
0 1


For higher ranked arrays, edges indicate placement of planes and cubes.

   arrayCoeff 2 3 0
0 6 5 1

Above we see an array of shape 2 3 0 with two planes parallel to the z-x plane (two pairs of three edges) and three planes parallel to the z-y plane (three groups of two).This representation conveys the empty array of shape 2 3 0 distinctly. A previous post illustrated that distinct orientations can represent shape permutations.

When more than one item in the shape is zero, for example shape 0 2 0, difficulties with the “Dual-View” crop up.

   arrayCoeff 0 2 0
0 0 2 1

As before we have zero atoms, but we also have zero edges – an invisible representation, making it impossible to distinguish arrays with more than one zero in their shape. In the next blog post I’ll introduce augmentations to the “Dual-View”, and although this improves the representation of array shapes, I must say the J text representation remains best for showing values of atoms.

References:

Frank, Ronald I. (2003). A New ‘Dual View’ Diagram of Array Structure,
Proceedings of the ACM APL (SIGAPL), Federated Computer Research Conference (October 2003). ISBN 1 58113 668 4.

Advertisements

One thought on “The ‘Dual-View’ approach to array visualization

  1. Thanks for posting this I was unaware of Frank’s paper. As a long time J user I’m used to ignoring how an array “prints — particularly empty arrays. An accurate display that noted these invisible differences would be an advance.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s