
From:  Elias Mårtenson 
Subject:  Re: [Bugapl] Supporting negative ranks for ⍤ operator 
Date:  Wed, 27 Apr 2016 16:17:51 +0800 
You're reading section 9.3.4 "Rank operator deriving monadic
function". You also need to look at 9.3.5 "Rank operator deriving
dyadic function".
Given g ← f⍤P Q R:
P is the monadic rank
Q is the left rank
R is the right rank
So:
g Y applies g to the Pcells of Y
X g Y applies g to the Qcells of X and the Rcells of Y
The ⌽3⍴⌽y1 stuff is just a toocute way of saying that you can specify
fewer than 3 values in the right operand, and:
R is shorthand for R R R
Q R is shorthand for R Q R
Jay.
On 27 April 2016 at 08:28, Elias Mårtenson <address@hidden> wrote:
> About the ISO specification of ⍤
>
> In writing the above message, I was reading the ISO specification for the
> rank operator, and I find it incredibly confusing. I have quoted the
> description below, and based on my reading of this text, the rank parameter
> is not just a single value, but can be up to three values. However, no
> matter how I read it, I still can't see how any but the the very first value
> is actually every used.
>
> Also, the case where LENGTH ERROR is supposed to be raised does not happen
> in GNU APL.
>
> It seems as the specification for the rank operator is just broken on
> several levels in the spec. That seems to me to be reason enough to not pay
> attention to the spec in this case and just adapt the way Dyalog does it.
>
> Here's the spec for the rank operator from the ISO spec:
>
> Informal Description:
> The result of f⍤y is a function which, when applied to B, returns Z, the
> result of applying the function f to the ranky cells of B.
>
> Evaluation Sequence:
> If y is a scalar, set y1 to ,y. Otherwise set y1 to y.
> If y1 is not a vector, signal domainerror.
> If y1 has more than three elements, signal lengtherror.
> If any element of y1 is not a nearinteger, signal domainerror.
> Set y2 to ⌽3⍴⌽y1.
> Set y3 to the firstitem in y2.
> Set y4 to the integernearestto y3.
> If y4 exceeds the rank of B, set y5 to the rank of B, otherwise set y5 to
> y4.
> If y5 is negative, set y6 to 0⌈y5 plus the rank of B, otherwise set y6 to
> y5.
> Apply f to the ranky6 cells of B.
> Conform the individual result cells. Let their common shape after conforming
> be q, and let p be the frame of B with respect to f, that is, (rank of B)
> minus y6, and
> return the overall result with shape p,q.
[Prev in Thread]  Current Thread  [Next in Thread] 