[Jprogramming] Fwd: Axis specification in APL2
Rob Hodgkinson
rhodgkin at bigpond.net.au
Thu Jun 22 20:36:47 HKT 2006
In your example below of non-applicable shapes, the transpose is required by
the APL axis operator also as you point out, as in:
TX=. |:X
TX ; Y : TX+"1 Y
+--------+-----+-------+
| 0 300 | 0 1| 0 301|
|100 400 | 2 3| 2 303|
|200 500 | 4 5| 4 305|
| | 6 7| 6 307|
| | | |
| | 8 9|108 409|
| |10 11|110 411|
| |12 13|112 413|
| |14 15|114 415|
| | | |
| |16 17|216 517|
| |18 19|218 519|
| |20 21|220 521|
| |22 23|222 523|
+--------+-----+-------+
visually the data above is 'aligned' to add as we want - and now this is the
same model as the original example.
This is an example where I would stop and ask if X has been created with the
wrong shape and it might be better to set it up originally as shape 3 2,
then the transpose would never have been necessary.
I can't see how the axis operator could have done the above without the
transpose either, but better to review/revise the data model to avoid it in
both cases.
Note re your last example referring to this same data:
(X+"0 3 Y) -: (X+/Y)
1
and your more complicated examples in your message, such as:
$(i.5 4,3 6) +"1"2 3 i.5,3 2 6
5 4 3 2 6
... I don't believe are possible with the Axis Operator, but would likewise
be glad to be shown a solution, as also for an Axis example that can not be
reproduced using Rank with no transpose. I can't think of one.
Regards, Rob Hodgkinson
-----Original Message-----
From: programming-bounces at jsoftware.com
[mailto:programming-bounces at jsoftware.com] On Behalf Of Oleg Kobchenko
Sent: Thursday, 22 June 2006 6:45 PM
To: Programming forum
Subject: Re: [Jprogramming] Fwd: Axis specification in APL2
<...snip>
Here's an example of non-applicable shapes:
X=. 100*i.2 3
Y=. i.3 4 2
X ; Y ; (|:X) +"1 Y
+-----------+-----+-------+
| 0 100 200| 0 1| 0 301|
|300 400 500| 2 3| 2 303|
| | 4 5| 4 305|
| | 6 7| 6 307|
| | | |
| | 8 9|108 409|
| |10 11|110 411|
| |12 13|112 413|
| |14 15|114 415|
| | | |
| |16 17|216 517|
| |18 19|218 519|
| |20 21|220 521|
| |22 23|222 523|
+-----------+-----+-------+
it not possible to get the result above with
rank only without transpose,
although, it is possible to match + in a way
$X +"0 3 Y
2 3 3 4 2
Can either of the two examples above be done
with axis +[? ?] without transpose?
Can somebody provide an axis example,
that really cannot be done with rank alone?
<snip>
More information about the Programming
mailing list