Some languages and at least one (old) version of
APL identify atoms with 1-element vectors.  This
treatment has consequences such as muddling the 
treatment of unit axes.  An example demonstrates what I mean:

If i is an array of integers and m is a matrix,
then i{m has shape ($i),(}.$m).

   m=: 3 4$'abcdefghijkl'
   m
abcd
efgh
ijkl
   i=: 2 1 2 2 0
   i{m
ijkl
efgh
ijkl
ijkl
   $ i{m
5 4
   ($i),}.$m
5 4

Now consider the case when the index array is
an atom vs. when it is a one element vector:

   $ 2{m
4
   $ (,2){m
1 4
   $ 2{"1 m
3
   $ (,2){"1 m
3 1

If you identify atoms with 1-element lists, you
would be forced to identify 1-row matrices,
1-column matrices, and vectors.  And on it goes.



----- Original Message -----
From: Terrence Brannon <[EMAIL PROTECTED]>
Date: Sunday, April 1, 2007 12:38 pm
Subject: [Jgeneral] "J for C Programmers" - atoms versus degenerate arrays

> On this page we see:
> 
> <quote href="http://www.jsoftware.com/help/jforc/declarations.htm";>
> An atom is defined to have rank 0; therefore, its shape is an 
> array with 0
> items, i. e. an empty array of rank 1.
> </quote>
> 
> My question about this quote is: why wouldn't an atom be a rank-1 
> array with
> 1 item of shape 1?
> 
> An array with 0 items would have no data. An atom has data. I 
> think an atom
> is more similar to a rank-1 array with shape 1 than a rank-1 array 
> of shape
> 0.
> 
> Continuing the the "Cells" section we see:
> 
> <quote href="http://www.jsoftware.com/help/jforc/declarations.htm";>
> A rank-3 array of shape 4 5, 6 such as the one defined in C by the
> declaration
> 
>      int q[4][5][6];
> 
> can be thought of as an array of 4 elements, each with rank 2 and 
> shape 5 6,
> or as a 4x5 array of elements, each with rank 1 and shape 6, or as 
> a 4x5x6
> array of rank-0 atoms.
> </quote>
> 
> And my question is: on the bolded part: why not a 4x5x6 of rank-1 
> atoms? But
> I think I know the answer to this. It is because a 4x5x6 array 
> already has
> "boxes" for data on each axis and we simply need to pop "boxless" 
> atoms in.
> 
> But understanding my second question does not make my first 
> question any
> clearer.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to