QUERY ON +.x ON NESTED ARRAYS IN APL2
Author Message
QUERY ON +.x ON NESTED ARRAYS IN APL2

Consider this nested vector in APL2

.--------------.
|  .---. .---. |
V  =   |  | 1 | | 2 | |
|  '~--' '~--' |
'--------------'

which could be built by       c"  ,"  1 2

The depth of         V              is  2
The depth of         +/ V x V       is  2
But the depth of     V +.x V        is  3

Why ??

Bill Knight  /  University of New Brunswick  /  Canada

Tue, 09 Jan 1996 05:26:37 GMT
QUERY ON +.x ON NESTED ARRAYS IN APL2

Quote:

> Consider this nested vector in APL2

>              .--------------.
>              |  .---. .---. |
>       V  =   |  | 1 | | 2 | |
>              |  '~--' '~--' |
>              '--------------'

> which could be built by       c"  ,"  1 2

> The depth of         V              is  2
> The depth of         +/ V x V       is  2
> But the depth of     V +.x V        is  3

> Why ??

Many common cases of inner product do end up with what appears to be
an extra level of nesting. However, generality requires that the level
be there so that information is not lost in the general case.
In words, the definition of inner product says to take rows of the
left against columns of the right in all combinations and then reduce
each result by F. I'll use the following notation:

" stands for dieresis  (each)
c            left shoe (enclose)
jot          jot       (outer product)
rho          rho       (reshape)

For L and R rank 2 the definition may be written in zero origin
as follows:

L F.G R
F/" (c[1] jot.G c[0]R

The documentation contains a more general definition for any rank.

In many useful cases, the result of the outer product is an array of
vectors. Applying F reduction to each of these vectors gives scalars
and, in these examples, these scalars look like an extra level of
nesting. This level of nesting is needed whenever G produces an array
of rank N greater than 1. Then the reduction produces a result of rank
N-1 (rank is what reduction reduces) and the level of nesting is
required. Here's an example:

(2 2 rho 2 3 1 2) ,.rho 2 2 rho 1 2 10 20

Jim

Fri, 12 Jan 1996 23:48:26 GMT

 Page 1 of 1 [ 2 post ]

Relevant Pages