Rank (operator)


 * This article is about the operator. See Rank for the number associated with every array. For numbers associated with a function specifying its argument rank, see function rank.

Rank is a primitive dyadic operator which applies its left operand function to cells of its arguments specified by its right operand array.

Rank specification
The right operand specifies the rank of subarrays to which the left operand function is applied as follows: For left argument  and right argument  ,

A non-negative right operand specifies the number of final axes to which the function applies. A negative right operand specifies complementary rank, i.e. the number of leading axes to be excluded. Negative rank can also be thought of as rank specification relative to the overall rank of the argument array.

Since a rank specification greater than the rank of the argument array means to apply the function to the whole array,,   or  , depending on the implementation, is "rank infinity" and always specifies the whole argument array.

Examples
Rotate rows in matrices of a 3D array:

Laminate scalars from arrays of differing ranks:

Flat outer product:

History
The rank operator was invented by Arthur Whitney in 1982 and first implemented in SHARP APL in 1983. It has been described as "a microcosm of APL history", its evolution a progression from scalar extension, which has been in APL since its inception, through leading axis theory to a construct which is a generalisation of scalar extension, inner (matrix) product, outer product, maplist in LISP, map in modern functional programming languages and the broadcast facility in NumPy.

Documentation

 * Dyalog
 * NARS2000

Publications

 * APLCart/Pub