Axis: Difference between revisions

Jump to navigation Jump to search
18 bytes added ,  09:06, 29 October 2019
m
Text replacement - "<code>" to "<source lang=apl inline>"
Miraheze>Marshall
(Created page with "In the APL array model, an axis is one dimension along which the elements of an array are organized. The rank of an array is the number of axes it has, and...")
 
Miraheze>Adám Brudzewsky
m (Text replacement - "<code>" to "<source lang=apl inline>")
Line 9: Line 9:
Use of the [[Rank operator]] allows a programmer to control which axes are used without referring to them explicitly (for example, by index). Rank, and more generally the [[leading axis theory]], uses the [[ravel order]] axis hierarchy directly without requiring another ordering to be imposed on axes. Despite this, the choice to make a positive operand to Rank specify a [[cell]] rank, while a negative operand specifies a [[frame]] length, weakly suggests an ordering that places trailing axes first and leading axes last—the opposite of the index ordering.
Use of the [[Rank operator]] allows a programmer to control which axes are used without referring to them explicitly (for example, by index). Rank, and more generally the [[leading axis theory]], uses the [[ravel order]] axis hierarchy directly without requiring another ordering to be imposed on axes. Despite this, the choice to make a positive operand to Rank specify a [[cell]] rank, while a negative operand specifies a [[frame]] length, weakly suggests an ordering that places trailing axes first and leading axes last—the opposite of the index ordering.


The choice to give leading axes lower indices and trailing axes higher indices is related to the choice to put lower-order places at higher indices in the base representation functions [[Decode]] and [[Encode]]. This is known in the wider programming world as a [https://en.wikipedia.org/wiki/Endianness big-endian] order. Because the base representation and axis ordering are in alignment, [[selection]] of an single element from an array satisfies the clean identity <code>i⌷A ←→ ((⍴A)⊥i)⌷,A</code>. If base representation used the opposite order, both of Decode's arguments would need to be reversed.
The choice to give leading axes lower indices and trailing axes higher indices is related to the choice to put lower-order places at higher indices in the base representation functions [[Decode]] and [[Encode]]. This is known in the wider programming world as a [https://en.wikipedia.org/wiki/Endianness big-endian] order. Because the base representation and axis ordering are in alignment, [[selection]] of an single element from an array satisfies the clean identity <source lang=apl inline>i⌷A ←→ ((⍴A)⊥i)⌷,A</code>. If base representation used the opposite order, both of Decode's arguments would need to be reversed.

Navigation menu