Because most so-called scalar J verbs (arithmetic etc)
automatically scale over scalars (primitive atoms),
it doesn't make sense to use rank-0.

Rank-0 is useful when type, shape or boxedness
are affected as illustrated in two previous posts.

Operations that apply to items (rank _1 cells), such as 
Insert +/ may seem to add columns of the matrix,
but in reality they add rows--one at a time to
the total row. And the result is the final row,
whose elements are corresponding elements sums,
each for each (what happened to be) original column. 
That's one of the differences from APL, where 
(1) +/ always adds rows (ie rank-1 operation) and
(2) Axis notation is actually directly related transpose 
(being a shape or axes reverse).
But in J this illusion is coincidental,
where +/"1 means apply +/ to rows and collect
results in corresponding rank _1 shape.
It's not the same as rearrange axes and apply +/ .


--- On Tue, 7/1/08, Alex Rufon <[EMAIL PROTECTED]> wrote:

> Hmmm. When you say "atoms", did you mean
> individual elements of a an
> array?
> 
> Because I tried it out with a simple sum across:
>    i. 3 5
>  0  1  2  3  4
>  5  6  7  8  9
> 10 11 12 13 14
> 
> A normal sum across would give me the sum of the columns
>    +/ i. 3 5
> 15 18 21 24 27
> 
> Doing it with rank 0 would not compute. I assumed that the
> verb was
> applied on each element as you've explained
>    +/ "0 i. 3 5
>  0  1  2  3  4
>  5  6  7  8  9
> 10 11 12 13 14
> 
> Using rank 1 would actually give me a total of each rows
>    +/ "1 i. 3 5
> 10 35 60
> 
> This is consistent with your explanation.
> 
> Still, I am a bit bewildered on when to use rank 0. What
> clues or hints
> or a guideline should remind me that it's the time to
> use it? Rank 1 is
> very easy because I've easily associated it with the
> concept that it's
> like transposing. 
> Example:
>    +/ "1 i. 3 5
> 10 35 60
>    +/ |: i. 3 5
> 10 35 60
>    
> It never even occurred to me that my problem could use it.
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of
> Oleg Kobchenko
> Sent: Tuesday, July 01, 2008 4:47 PM
> To: Programming forum
> Subject: RE: [Jprogramming] Formatting then Boxing a vector
> 
> It's actually the other way around: rank-0 is atoms or
> columns of matrix, and rank-1 is vectors or rows of matrix.
> 
> The reason you might have thought of rank-1 as columns is
> because it makes verb seem to operate on cells collectively
> aligned
> into columns, as in  {."1 A  will return first column,
> whereas
> it actually returns list of first cell in each row--so it
> applies the verb to rows.
> 
> This confusion may have resulted from APL axes.
> 
> See J Forums for example,
> http://www.jsoftware.com/pipermail/programming/2006-June/002509.html
> 
> 
> --- On Tue, 7/1/08, Alex Rufon
> <[EMAIL PROTECTED]> wrote:
> 
> most likely I misunderstand it. I only use rank 1 when I
> try to apply a
> verb on the column level of a two dimension matrix. I
> assume (from what
> I've read so far) that rank zero is the rows of a two
> dimension matrix
> and is assumed that its there and is omitted.



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

Reply via email to