Very interesting result. I suspected there should
be more to it. What is used in +"1 is a combination
of explicit and implicit rank application. It works like this:
+ is rank 0, so frame shapes 2 3 and 2 4 3, they do
not match to have a prefix. By fixing + at "1 we chop off
one axis at the back (suffix) and have new frames
of shapes 2 and 2 4, where 2 is the common prefix and
4 is how left cell (of "1) is extended. It also can be seen with 

   X=. 100*i.2 3
   Y=. i.2 4 3
   X ; Y ; X +"1 Y
+-----------+--------+-----------+
|  0 100 200| 0  1  2|  0 101 202|
|300 400 500| 3  4  5|  3 104 205|
|           | 6  7  8|  6 107 208|
|           | 9 10 11|  9 110 211|
|           |        |           |
|           |12 13 14|312 413 514|
|           |15 16 17|315 416 517|
|           |18 19 20|318 419 520|
|           |21 22 23|321 422 523|
+-----------+--------+-----------+

I wonder if a rule can be obtained: a verb is applicable
with rank if shapes of arguments match by dropping 
any number of stretches of consecutive axes, provided 
that verb rank is not greater than length of their 
common suffix. Here's a few examples,
 
   $(i.5 4,3) +"1 2 i.5,3 2
5 4 3 2
   $(i.5 4,3   6) +"1"2 3 i.5,3 2   6
5 4 3 2 6
   $(i. 5 4,3  6) +"1 2"2 4 i. 5,3 2   6 7
5 4 3 2 6 7

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?
 

----- Original Message ----
From: Rob Hodgkinson <[EMAIL PROTECTED]>
To: Programming forum <[email protected]>
Sent: Wednesday, June 21, 2006 10:58:48 PM
Subject: RE: [Jprogramming] Fwd: Axis specification in APL2


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

Reply via email to