Note that the expression you gave below simplifies further to:

   X1=. 1+i.2 3
   Y1=. 1+i.2 4 3
   X1 +"1 Y1     (even simpler than <X1+"1"1 2 Y1> shown below)
 2  4  6
 5  7  9
 8 10 12
11 13 15

17 19 21
20 22 24
23 25 27
26 28 30

This 'matching' of the frames is explained in the Primer (see Section on
Frame and Cell, and Agreement), where as quoted:

"The agreement rule is quite simple. If the left and right frames are the
same then there is no problem. Otherwise, one frame must be a prefix of the
other, and its cells are repeated into its trailing axes to provide the
required arguments."

Here the left frame shape is <2> and the right frame shape is <2 4>, so the
repetition takes place.  This can be easily seen for rank with:

   (X1;Y1;X1,"1 Y1)
------T--------T--------------┐
│1 2 3│ 1  2  3│1 2 3  1  2  3│
│4 5 6│ 4  5  6│1 2 3  4  5  6│
│     │ 7  8  9│1 2 3  7  8  9│
│     │10 11 12│1 2 3 10 11 12│
│     │        │              │
│     │13 14 15│4 5 6 13 14 15│
│     │16 17 18│4 5 6 16 17 18│
│     │19 20 21│4 5 6 19 20 21│
│     │22 23 24│4 5 6 22 23 24│
L-----+--------+---------------

(Not sure how the box chars will appear in text above, but execute to see).

Regards, Rob Hodgkinson

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Sunday, 18 June 2006 12:13 AM
To: Programming forum
Subject: [Jprogramming] Fwd: Axis specification in APL2

Interesting discussion at c.l.a

---------- Forwarded message ----------
From: [EMAIL PROTECTED]
Date: 17 Jun 2006 07:08:46 -0700
Subject: Re: Axis specification in APL2
To:

One need not rearrange the arguments with J ranks
(Sharp APL too, I suppose).

   X1 +"1"1 2 Y1
 2  4  6
 5  7  9
 8 10 12
11 13 15

17 19 21
20 22 24
23 25 27
26 28 30

Where
   X1=. 1+i.2 3
   Y1=. 1+i.2 4 3
   X1;Y1
+-----+--------+
|1 2 3| 1  2  3|
|4 5 6| 4  5  6|
|     | 7  8  9|
|     |10 11 12|
|     |        |
|     |13 14 15|
|     |16 17 18|
|     |19 20 21|
|     |22 23 24|
+-----+--------+


Martin Turner wrote:
> > "rbe" <[EMAIL PROTECTED]> wrote in news:1148844185.809977.57690
> > @i39g2000cwa.googlegroups.com:
> >
> >> With rank, there is NO need (or benefit) to have the bracket axis
> >> notation any more. Period. end of story.
> >
> > Okay, how do you do this with rank:
> >
> >      {rho}{rho}X
> > 2
> >      {rho}{rho}Y
> > 3
> >      X+[1 3]Y
> >
> >
> > A few comments:
> > 1. Randy: I don't have access to an APL2 system at the moment. Please
> > post simple data and result for same. I think a conjunction of rank
> > with the
> > transpose conjunction (whose name I forget) might do the trick for you.
> > I did say  that rank does about 99% of what the APL2 axis brackets do,
> > not 100%...
> >
> > --- Text cut here ---
>
> Randy's point is that the rank operator works on contiguous axes only.  To
> work on non-contiguous axes (eg 1 and 3) one must re-arrange one or other
of
> the arguments.
>
> His example was ...
>
> Given:
> #io {is} 1
> x {is} 2 3 {rho} {iota} 6
> y {is} 2 4 3 {rho} {iota} 24
>
> How to obtain:
>  2  4  6
>  5  7  9
>  8 10 12
> 11 13 15
>
> 17 19 21
> 20 22 24
> 23 25 27
> 26 28 30
>
>
> Brown:   x +[1 3] y
>
> Iverson: 2 1 3 {transpose} x (+{paw}2 2) 2 1 3 {transpose}y
>
>
> Bob's point is different.  He argues that knowing axis operation of x +[1
3]
> y, can one predict the behaviour of x function[1 3]y (eg x ,[1 3]y)?  The
> axis operator in APL2 seems to me to be erratic/complex, whereas the rank
> operator is simple, powerful and elegant.
>
> There is often a choice to be made between utility and beauty, but in this
> case the rank operator seems to win on both counts.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to