4,577
edits
m (Text replacement - " ⊢( *[^∘])" to " ⎕←$1") Tags: Mobile edit Mobile web edit |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
Line 5: | Line 5: | ||
== Rectangular indexing == | == Rectangular indexing == | ||
'''Rectangular indexing''' selects indices along each [[axis]] of a given array. This indexing mode is usually implemented as [[Bracket indexing]] <source lang=apl inline>X[Y]</ | '''Rectangular indexing''' selects indices along each [[axis]] of a given array. This indexing mode is usually implemented as [[Bracket indexing]] <source lang=apl inline>X[Y]</syntaxhighlight> and [[Index (function)|Squad indexing]] <source lang=apl inline>Y⌷X</syntaxhighlight>. Rectangular indexing has an important property: If rectangular indexing is applied to a [[matrix]], the elements at four corners of a rectangle still form a rectangle in the result. This property generalizes to four elements of a higher-[[rank]] array for that share an index over all but two axes. | ||
<source lang=apl> | <source lang=apl> | ||
Line 19: | Line 19: | ||
21 24 | 21 24 | ||
31 34 | 31 34 | ||
</ | </syntaxhighlight> | ||
=== Relationship to leading axis theory === | === Relationship to leading axis theory === | ||
Line 30: | Line 30: | ||
11 12 13 14 | 11 12 13 14 | ||
21 22 23 24 | 21 22 23 24 | ||
</ | </syntaxhighlight> | ||
=== Replicate as a special case === | === Replicate as a special case === | ||
Various forms of [[Replicate]] can be used to select one or more indices over a single axis. <source lang=apl inline>X/Y</ | Various forms of [[Replicate]] can be used to select one or more indices over a single axis. <source lang=apl inline>X/Y</syntaxhighlight> applies to the last axis, <source lang=apl inline>X⌿Y</syntaxhighlight> to the first, and <source lang=apl inline>X/[K]Y</syntaxhighlight> applies to the K-th axis. All the other axes are kept intact. The main difference from other indexing primitives is that X does not specify the indices; instead, it specifies how many copies of the corresponding indices to include in the result. | ||
<source lang=apl> | <source lang=apl> | ||
Line 41: | Line 41: | ||
11 12 13 14 | 11 12 13 14 | ||
21 22 23 24 | 21 22 23 24 | ||
</ | </syntaxhighlight> | ||
== Non-rectangular indexing == | == Non-rectangular indexing == | ||
Line 51: | Line 51: | ||
11 22 | 11 22 | ||
13 24 | 13 24 | ||
</ | </syntaxhighlight> | ||
== Deep indexing == | == Deep indexing == | ||
Line 72: | Line 72: | ||
((2 1)1 2)⊃G | ((2 1)1 2)⊃G | ||
K | K | ||
</ | </syntaxhighlight> | ||
{{APL features}}[[Category:Arrays]] | {{APL features}}[[Category:Arrays]] |