|
From: | Juergen Sauermann |
Subject: | Re: [Bug-apl] Supporting negative ranks for ⍤ operator |
Date: | Fri, 06 May 2016 19:46:02 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
Hi Elias, the ISO standard (taking the monadic case for simplicity) says: Z ← f ⍣ y B ... If y is a scalar, set y1 to ,y. Otherwise set y1 to y. If y1 is not a vector, signal domain-error. If y1 has more than three elements, signal length-error. If any element of y1 is not a near-integer, signal domain-error. Set y2 to ⌽3⍴⌽y1. Set y3 to the first-item in y2. Set y4 to the integer-nearest-to 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. // () added by jsa Apply f to the rank-y6 cells of B. For y←¯1 that gives: y1 = ¯1 y2 - ¯1 ¯1 ¯1 y3 = ¯1 y4 = ¯1 y5 = ¯1 y6 = ¯1 + ⍴⍴B = ¯1 + 2 = +1 For y←+1 it gives: y1 = 1 y2 - 1 1 1 y3 = 1 y4 = 1 y5 = 1 y6 = +1 Both cases give the same y6 (and hence the same results) are the same. In Dyalog terms: for y←1 you take the rank-1-cells and for j←¯1 you take the rank-(2+¯1)-cells which are also the rank-1-cells when the rank of B is 2. The dyadic case is similar except that the computation above is performed independently for A and B. /// Jürgen On 05/06/2016 03:32 PM, Elias Mårtenson
wrote:
|
[Prev in Thread] | Current Thread | [Next in Thread] |