J: how do I discard leading axes?
Author Message
J: how do I discard leading axes?

I have learned to use the verb (,/) to discard the leading axis from an
array, converting something of shape 2 2 x to shape 4 x, for example.

Now I want to discard all but the last axis from an array, converting
shape 2 2 2 x to shape 8 x, but where the rank of the input is unknown.

Any better ideas?  This seems like a very clumsy way to do something basic.

Henry Rich

Wed, 30 Jul 1997 06:36:10 GMT
J: how do I discard leading axes?
Here's one way to discard all but the last axis:

Alternatively:
,.&.|:

--
Raul D. Miller

Wed, 30 Jul 1997 07:03:15 GMT
J: how do I discard leading axes?
Raul Miller wrote on Friday, February 10:

Quote:
> Here's one way to discard all but the last axis:

> Alternatively:
>    ,.&.|:

A variation on the first expression:  ,&.(<"1"_) .
The second expression ,.&.|: is rather neat.

Wed, 30 Jul 1997 16:29:49 GMT
J: how do I discard leading axes?
,.&.|:

Er... on second thought, don't do this.  It does a bit more than just
ravelling...

--
Raul D. Miller

Thu, 31 Jul 1997 08:02:27 GMT
J: how do I discard leading axes?

Quote:
Raul Miller writes:
>Here's one way to discard all but the last axis:

Here's another way:

(;\$) a i.1 2 3 4
+-----------+---+
| 0  1  2  3|6 4|
| 4  5  6  7|   |
| 8  9 10 11|   |
|12 13 14 15|   |
|16 17 18 19|   |
|20 21 22 23|   |
+-----------+---+

Sat, 02 Aug 1997 03:44:49 GMT
J: how do I discard leading axes?
: I have learned to use the verb (,/) to discard the leading axis from an
: array, converting something of shape 2 2 x to shape 4 x, for example.

: Now I want to discard all but the last axis from an array, converting
: shape 2 2 2 x to shape 8 x, but where the rank of the input is unknown.

: Any better ideas?  This seems like a very clumsy way to do something basic.

: Henry Rich

Henry, the first thing that comes to mind is ,.&.|:.
Cliff

\$i.2 3 4 5
2 3 4 5
\$,/i.2 3 4 5
6 4 5
\$,.&.|:i.2 3 4 5
24 5
\$i.2 3 4 5
2 3 4 5
\$,/i.2 3 4 5
6 4 5
\$,.i.2 3 4 5
2 60
\$,.&.|:i.2 3 4 5
24 5

--
Clifford A. Reiter
Mathematics Department, Lafayette College
Easton, PA 18042 USA,   610-250-5277

Mon, 04 Aug 1997 09:10:30 GMT

 Page 1 of 1 [ 6 post ]

Relevant Pages

Powered by phpBB® Forum Software