Thank you all for your help. I guess I got trapped with the selection on the left. It is obvious it should be as you point out.
On Sun, Oct 19, 2008 at 4:11 PM, Devon McCormick <[EMAIL PROTECTED]> wrote: > To answer your last question first, it looks like "1/2" means rank 1 or > rank > 2, e.g. > > (1 0 1 0,:1 0 0 1) <;.1 i. 4 4 > +---------+-----------+ > |0 1 2 3 | 8 9 10 11| > |4 5 6 7 |12 13 14 15| > +---------+-----------+ > |0 1 2 3|12 13 14 15| > |4 5 6 7| | > |8 9 10 11| | > +---------+-----------+ > > applies each rank 1 element of the boolean left argument. So, the "1 0 1 > 0" > returns the evenly divided first row of the result and the "1 0 0 1" > returns > the uneven division in the second result row. > > With integer rank 2 left arguments like this > > ((0 0,:2 2),:1 1,:3 3) <;.0 i. 4 4 > +---+--------+ > |0 1| 5 6 7| > |4 5| 9 10 11| > | |13 14 15| > +---+--------+ > > it applies each rank 2 of the numeric left argument, so you get a 2x2 > starting at position (0,0) for the first left-hand matrix and a 3x3 > starting > at position (1,1) for the second. > > As far as adding up rows within the partitions, here's a few ways. > > (1 0 1;1 0 0 1) <;.1 i. 3 4 > +------+--+ > |0 1 2 |3 | > |4 5 6 |7 | > +------+--+ > |8 9 10|11| > +------+--+ > > I changed the left argument from your example because it's more interesting > to have more than one row in some of the addends. > > So, you can sum after partitioning: > > +/&.>(1 0 1;1 0 0 1) <;.1 i. 3 4 > +------+--+ > |4 6 8 |10| > +------+--+ > |8 9 10|11| > +------+--+ > > Or without partitioning > > (1 0 1;1 0 0 1) +/;.1 i. 3 4 > 4 6 8 > 10 0 0 > > 8 9 10 > 11 0 0 > > But this gives you extraneous zeros because of the padding required to > equalize the rows of the unenclosed result. > > Lastly, you can enclose and sum at the same time: > > (0 1 1;1 0 0 1) ([:<+/);.1 i. 3 4 > +------+--+ > |4 5 6 |7 | > +------+--+ > |8 9 10|11| > +------+--+ > > Hope this helps. > > On Sun, Oct 19, 2008 at 8:57 AM, Don Guinn <[EMAIL PROTECTED]> wrote: > > > Playing with J for C and got to "Apply On Specified Partitions: Dyad u;.1 > > and u;.2". Replaced the < with +/ and it didn't sum the rows. After > looking > > at the result a little more closely I discovered that each cell contained > a > > table instead of a row. > > (0 1 1;1 0 0 1) <;.1 i. 3 4 > > +------+--+ > > |4 5 6 |7 | > > +------+--+ > > |8 9 10|11| > > +------+--+ > > (0 1 1;1 0 0 1) (<@$);.1 i. 3 4 > > +---+---+ > > |1 3|1 1| > > +---+---+ > > |1 3|1 1| > > +---+---+ > > > > I can't figure out why. > > > > Also, in the Dictionary for Cut it describes the rank as "_ 1/2 _". What > > does the "1/2" mean? Needless to say, I still have a long way go to fully > > understand Cut. > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > > > > -- > Devon McCormick, CFA > ^me^ at acm. > org is my > preferred e-mail > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
