Index   <<   >>

Rank Operator: An Idea Worth Stealing Borrowing
Roger Hui
September, 2009


Abstract
1. Examples
2. Model
3. Applications
4. I.R.S.
5. History
References



Abstract

2. Examples

      x←2 3 4⍴⍳24
      (⍉rank 2) x
 0  4  8
 1  5  9
 2  6 10
 3  7 11
        
12 16 20
13 17 21
14 18 22
15 19 23

      ⍉[1]x
SYNTAX ERROR
      ⍉[1]x
     ∧

      (+/∘, rank 1) x
 6 22 38
54 70 86
      (+/∘, rank 2) x
66 210

      ⎕←a←↑ 'the' 'time' 'has' 'come' 'for' 'rank'
the 
time
has 
come
for 
rank
      ⍋ a
3 4 2 5 0 1
      (⍋ rank 1) a
3 2 1 0
3 1 2 0
3 1 0 2
0 3 2 1
3 0 1 2
1 3 2 0
      ({⍵[⍋⍵]} rank 1) a
 eht
eimt
 ahs
cemo
 for
aknr

2. Model

effrank ←{(0≤⍺)⊃(0⌈⍺+⍴⍴⍵)(⍺⌊⍴⍴⍵)}
cells   ←{⊂[(-⍺ effrank ⍵)↑⍳⍴⍴⍵] ⍵}
assemble←{↑ ((1⍴¨⍨r-⍨⌈/,r←⍴∘⍴¨⍵),¨⍴¨⍵)⍴¨⍵}

rank←{                               
     (m l r)←⌽3⍴⌽⍵⍵                   
     0=⎕NC'⍺' : assemble ⍺⍺¨ (m cells ⍵) 
     assemble (l cells ⍺) ⍺⍺¨ (r cells ⍵)
}

3. Applications



outer product
inner product
⍪⍵ ←→ , rank ¯1 ⍵ for non-scalar ⍵ commabar←{,rank ¯1⍣(2-×⍬⍴⍴⍴⍵){⍵}⍵}
 

4. I.R.S.

Integrated Rank Support (IRS) was

5. History

Iverson introduced function rank in section 6 of his seminal Operators and Functions research report [2] on 1978-04-26. The rank operator was invented by Arthur Whitney [3, 4] in July 1982 while on a train to the APL82 conference in Heidelberg. It was first published in Rationalized APL [5] on 1983-01-06, and the first implementation was released in SHARP APL on 1983-05-02 [6]. It is described in Sections 9.3.3, .4, and .5 of the ISO Standard on Extended APL [7].
 

References

[0]  Hui, Roger K.W., Rank and Uniformity, APL95, Volume 25, Number 4, 1995-06-04.
[1]  Bernecky, Robert, and Greg Bezoff, I.P. Sharp Associates, 1986.
[2]  Iverson, Kenneth E., Operators and Functions, Research Report #RC7091, IBM Corporation, 1978-04-26.
[3]  Whitney, Arthur, private e-mail, 2004-11-11.
[4]  Pesch, Roland, private e-mail, 2004-11-11.
[5]  Iverson, Kenneth E., Rationalized APL, I.P. Sharp Associates, 1983-01-06; revision 1, 1983-04-04.
[6]  Bernecky, Robert, Kenneth E. Iverson, Eugene McDonnell, Robert Metzger, and Henri Schueler, Language Extensions of May 1983, SATN 45, 1983-05-02.
[7]  ISO/IEC 13571:2001 (E), Programming Language APL, Extended, 2001-02-01.


The text requires the APL385 Unicode font, which can be downloaded from http://www.vector.org.uk/resource/apl385.ttf . To resolve (or at least explain) problems with displaying APL characters see http://www.vector.org.uk/archive/display.htm .

original writing: 2009-07-03 11:20; last updated: 2009-09-10 14:20