Major cell: Difference between revisions
Miraheze>Marshall (Created page with "In the APL array model and leading axis theory, a '''major cell''' is a cell of an array which has rank one smaller than the rank of the array, or equal to it...") |
Miraheze>Marshall mNo edit summary |
||
Line 19: | Line 19: | ||
└──────────┴─────────┴───────┘ | └──────────┴─────────┴───────┘ | ||
</source> | </source> | ||
Given another array <source lang=apl inline>B</source> we can search for cells of <source lang=apl inline>B</source> which [[match]] major cells of <source lang=apl inline>B</source>. [[High rank set functions|High-rank]] [[Index-of]] always searches for right argument cells whose rank matches the rank of a left argument major cell: if the right argument is a [[vector]] and not a [[matrix]] then it searches for the entire vector rather than its major cells (which are [[scalar]]s). | Given another array <source lang=apl inline>B</source> we can search for cells of <source lang=apl inline>B</source> which [[match]] major cells of <source lang=apl inline>B</source>. [[High-rank set functions|High-rank]] [[Index-of]] always searches for right argument cells whose rank matches the rank of a left argument major cell: if the right argument is a [[vector]] and not a [[matrix]] then it searches for the entire vector rather than its major cells (which are [[scalar]]s). | ||
<source lang=apl> | <source lang=apl> | ||
⊢B ← ↑ 4,/⍳6 | ⊢B ← ↑ 4,/⍳6 |
Revision as of 11:27, 15 November 2019
In the APL array model and leading axis theory, a major cell is a cell of an array which has rank one smaller than the rank of the array, or equal to it if the array is a scalar. The number of major cells in an array is its Tally, and a function can be called on the major cells of an array individually by applying it with rank ¯1
using the Rank operator. Functions designed to follow leading axis theory often manipulate the major cells of an array. For example, Reverse First (⊖
) is considered the primary form of Reverse in leading-axis languages because it can be interpreted as reversing the major cells of its argument; J removes last-axis Reverse entirely.
Examples
A
is an array with shape 3 4
. Using Tally we see that the number of major cells in A
is the first element of the shape, 3
:
⊢A ← 5 3 1 ∘.∧ 2 3 4 5 10 15 20 5 6 3 12 15 2 3 4 5 ≢A 3
We can separate A
's major cells using Enclose with rank ¯1
:
⊂⍤¯1 ⊢A ┌──────────┬─────────┬───────┐ │10 15 20 5│6 3 12 15│2 3 4 5│ └──────────┴─────────┴───────┘
Given another array B
we can search for cells of B
which match major cells of B
. High-rank Index-of always searches for right argument cells whose rank matches the rank of a left argument major cell: if the right argument is a vector and not a matrix then it searches for the entire vector rather than its major cells (which are scalars).
⊢B ← ↑ 4,/⍳6 1 2 3 4 2 3 4 5 3 4 5 6 A ⍳ B 4 3 4 A ⍳ 2 3 4 5 3