diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-02-14 21:18:37 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-02-14 21:18:37 -0500 |
| commit | eac71d728f7a83c52deddcc766ae1ad3f8e3ef23 (patch) | |
| tree | 098fe0edc4e75d4584aaee242f33926c542b5776 /docs | |
| parent | b20aba3b36cfe161e762c85c98874c15d0b6985d (diff) | |
More detailed/correct description of Group
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/spec/primitive.html | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/docs/spec/primitive.html b/docs/spec/primitive.html index 8f0dba65..ab65ef6c 100644 --- a/docs/spec/primitive.html +++ b/docs/spec/primitive.html @@ -127,7 +127,7 @@ <p><strong>First</strong> (<code><span class='Function'>โ</span></code>) simply takes the first element of its argument in index order, or the fill element if <code><span class='Value'>๐ฉ</span></code> is empty.</p> <p>For <strong>Select</strong> (<code><span class='Function'>โ</span></code>), <code><span class='Value'>๐จ</span></code> is an array of natural numbers, or a list of such arrays; if it's an empty list, it's interpreted as the former. The given arrays are matched with leading axes of <code><span class='Value'>๐ฉ</span></code> and used to select from those axes. Their shape is retained, so that the final shape is the combined shapes of each array of natural numbers in <code><span class='Value'>๐จ</span></code> in order, followed by the trailing (unmatched) shape of <code><span class='Value'>๐ฉ</span></code>. This means that a single axis in <code><span class='Value'>๐ฉ</span></code> can correspond to any number of axes in <code><span class='Value'>๐จ</span><span class='Function'>โ</span><span class='Value'>๐ฉ</span></code>, depending on the rank of that portion of <code><span class='Value'>๐จ</span></code>. More precisely, the value of the result at an index <code><span class='Value'>j</span></code> is obtained by splitting <code><span class='Value'>j</span></code> into one index into each array of <code><span class='Value'>๐จ</span></code> followed by a partial index into <code><span class='Value'>๐ฉ</span></code>. An index <code><span class='Value'>i</span></code> for <code><span class='Value'>๐ฉ</span></code> comes from selecting from each array of <code><span class='Value'>๐จ</span></code> and appending the results to the partial index from <code><span class='Value'>j</span></code>, and the value <code><span class='Value'>i</span><span class='Function'>โ</span><span class='Value'>๐ฉ</span></code> is <code><span class='Value'>j</span><span class='Function'>โ</span><span class='Value'>๐จ</span><span class='Function'>โ</span><span class='Value'>๐ฉ</span></code>.</p> <p><strong>First Cell</strong> (<code><span class='Function'>โ</span></code>) selects the initial major cell of <code><span class='Value'>๐ฉ</span></code>, giving an error if <code><span class='Value'>๐ฉ</span></code> has rank 0 or length 0.</p> -<p><strong>Group</strong> (<code><span class='Function'>โ</span></code>) performs an opposite operation to Select, so that <code><span class='Value'>๐จ</span></code> specifies not the argument index that result values come from, but the result index that argument values go to. The result rank is <code><span class='Function'>โ </span><span class='Value'>๐จ</span></code>, and each result element has rank <code><span class='Number'>1</span><span class='Function'>+</span><span class='Paren'>(</span><span class='Function'>=</span><span class='Value'>๐ฉ</span><span class='Paren'>)</span><span class='Function'>-+</span><span class='Modifier'>ยด</span><span class='Function'>=</span><span class='Modifier'>ยจ</span><span class='Value'>๐จ</span></code>. The result element contains the minimal list of cells so that each cell of <code><span class='Value'>๐ฉ</span></code> appears in the corresponding element of <code><span class='Value'>๐จ</span><span class='Function'>โ</span><span class='Value'>๐จ</span><span class='Function'>โ</span><span class='Value'>๐ฉ</span></code>, in index order. <strong>Group Indices</strong> treats its argument <code><span class='Value'>๐ฉ</span></code> as a left argument for Group and uses a right argument made up of indices, with the definition <code><span class='Function'>โ</span><span class='Modifier2'>โ</span><span class='Paren'>(</span><span class='Function'>โโ </span><span class='Modifier2'>โ</span><span class='Number'>1</span><span class='Paren'>)</span></code>.</p> +<p><strong>Group</strong> (<code><span class='Function'>โ</span></code>) performs an opposite operation to Select, so that <code><span class='Value'>๐จ</span></code> specifies not the argument index that result values come from, but the result index that argument values go to. The general case is that <code><span class='Value'>๐จ</span></code> is a list of arrays of numbers; if it has depth less than 2 it's converted to this form by first enclosing it if it's an atom, then placing it in a length-1 list. After this transformation, the result rank is <code><span class='Function'>โ </span><span class='Value'>๐จ</span></code>, and each result element has rank <code><span class='Paren'>(</span><span class='Function'>โ </span><span class='Value'>๐จ</span><span class='Paren'>)</span><span class='Function'>+</span><span class='Paren'>(</span><span class='Function'>=</span><span class='Value'>๐ฉ</span><span class='Paren'>)</span><span class='Function'>-+</span><span class='Modifier'>ยด</span><span class='Function'>=</span><span class='Modifier'>ยจ</span><span class='Value'>๐จ</span></code>, with the initial <code><span class='Function'>โ </span><span class='Value'>๐จ</span></code> axes corresponding to elements of <code><span class='Value'>๐จ</span></code> and the remainder to trailing axes of <code><span class='Value'>๐ฉ</span></code>. Each atom in <code><span class='Value'>๐จ</span></code> can be either a natural number or <code><span class='Number'>ยฏ1</span></code> (which indicates the corresponding position in <code><span class='Value'>๐ฉ</span></code> will be omitted). If <code><span class='Number'>ยฏ1</span></code> doesn't appear, the result has the property that each cell of <code><span class='Value'>๐ฉ</span></code> appears in the corresponding element of <code><span class='Value'>๐จ</span><span class='Function'>โ</span><span class='Value'>๐จ</span><span class='Function'>โ</span><span class='Value'>๐ฉ</span></code>. More concretely, the length of the result along axis <code><span class='Value'>a</span></code> is the maximum value in <code><span class='Value'>a</span><span class='Function'>โ</span><span class='Value'>๐จ</span></code> plus one, or zero if <code><span class='Value'>a</span><span class='Function'>โ</span><span class='Value'>๐จ</span></code> is empty. Axis <code><span class='Value'>a</span></code> corresponds to <code><span class='Function'>=</span><span class='Value'>a</span><span class='Function'>โ</span><span class='Value'>๐จ</span></code> axes in <code><span class='Value'>๐ฉ</span></code>, and an element of the result at position <code><span class='Value'>i</span></code> along this axis contains all positions in <code><span class='Value'>๐ฉ</span></code> where <code><span class='Value'>i</span><span class='Function'>=</span><span class='Value'>a</span><span class='Function'>โ</span><span class='Value'>๐จ</span></code>. There may be multiple such positions, and they're arranged along axis <code><span class='Value'>a</span></code> of that result element according to their index order in <code><span class='Value'>๐ฉ</span></code>. <strong>Group Indices</strong> treats its argument <code><span class='Value'>๐ฉ</span></code> as a left argument for Group and uses a right argument made up of indices, with the definition <code><span class='Function'>โ</span><span class='Modifier2'>โ</span><span class='Paren'>(</span><span class='Function'>โโ </span><span class='Modifier2'>โ</span><span class='Number'>1</span><span class='Paren'>)</span></code>.</p> <p><strong>Range</strong> (<code><span class='Function'>โ</span></code>) is extended to apply to a list of natural numbers, in addition to the provided case of a single natural number (an enclosed natural number <code><span class='Value'>๐ฉ</span></code> should still result in an error). For a list <code><span class='Value'>๐ฉ</span></code>, the result is an array of shape <code><span class='Value'>๐ฉ</span></code> in which the value at a given index is that index, as a list of natural numbers. That is, <code><span class='Value'>i</span><span class='Function'>โก</span><span class='Value'>i</span><span class='Function'>โโ</span><span class='Value'>๐ฉ</span></code> for any list of natural numbers <code><span class='Value'>i</span></code> with <code><span class='Function'>โง</span><span class='Modifier'>ยด</span><span class='Value'>i</span><span class='Function'><</span><span class='Value'>๐ฉ</span></code>.</p> <p><strong>Indices</strong> (<code><span class='Function'>/</span></code>) applies to a list of natural numbers, and returns a list of natural numbers. The result contains <code><span class='Value'>i</span><span class='Function'>โ</span><span class='Value'>๐ฉ</span></code> copies of each natural number index <code><span class='Value'>i</span></code> for <code><span class='Value'>๐ฉ</span></code>, in increasing order.</p> <h3 id="structural-manipulation">Structural manipulation</h3> |
