From 4fd3566067b123ba53e0923520bdc8e19fad7d83 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 15 Feb 2021 19:57:36 -0500 Subject: Fix specification for Group Indices --- docs/spec/primitive.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/spec/primitive.html b/docs/spec/primitive.html index d0eb9b2f..eb51fd5f 100644 --- a/docs/spec/primitive.html +++ b/docs/spec/primitive.html @@ -123,12 +123,12 @@

Transpose () reorders axes of its argument to place the first axis last; if the argument has one or fewer axes then it's enclosed if it's an atom and otherwise returned unchanged. Reorder Axes () requires the left argument to be a list or unit of natural numbers, with length at most the rank of the right argument. This list is extended to match the right argument rank exactly by repeatedly appending the least unused natural number (for example, given 1300, 2 is appended). After extension, it specifies a result axis for each axis of the right argument. There must be no gaps in the list: that is, with the result rank equal to one plus the greatest value present, every result axis must appear at least once. Now each argument axis is "sent to" the specified result axis: in terms of indices, i𝕨𝕩 is (𝕨i)𝕩 if 𝕨 is complete. If multiple argument axes correspond to the same result axis, then a diagonal is taken, and it's as long as the shortest of those argument axes. Like Transpose, Reorder Axes encloses 𝕩 if it's an atom, so that its result is always an array.

Indices and selection

Each element in an array se is associated with an index, which is a list of natural numbers i such that ´i<s. The list of all indices, which corresponds to the element list e, contains all such lists i in lexicographic order. That is, index i comes before j exactly when the two indices are not the same, and i has the smaller value at the first position where they are unequal. The index of an element along a particular axis a is the value ai.

+

Range () 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 𝕩 should still result in an error). For a list 𝕩, the result is an array of shape 𝕩 in which the value at a given index is that index, as a list of natural numbers. That is, ii⊑↕𝕩 for any list of natural numbers i with ´i<𝕩.

Pick () is extended to array left arguments. In this case, it requires every depth-1 array in the nested structure of 𝕨 to be a valid index list for 𝕩, and every atom to be contained in one of these lists. The result is 𝕨 with each index list replaced by the element of 𝕩 at that index. In the simple case where 𝕨 itself is an index list, the result is the element of 𝕩 at index 𝕨.

First () simply takes the first element of its argument in index order, or the fill element if 𝕩 is empty.

For Select (), 𝕨 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 𝕩 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 𝕨 in order, followed by the trailing (unmatched) shape of 𝕩. This means that a single axis in 𝕩 can correspond to any number of axes in 𝕨𝕩, depending on the rank of that portion of 𝕨. More precisely, the value of the result at an index j is obtained by splitting j into one index into each array of 𝕨 followed by a partial index into 𝕩. An index i for 𝕩 comes from selecting from each array of 𝕨 and appending the results to the partial index from j, and the value i𝕩 is j𝕨𝕩.

First Cell () selects the initial major cell of 𝕩, giving an error if 𝕩 has rank 0 or length 0.

-

Group () performs an opposite operation to Select, so that 𝕨 specifies not the argument index that result values come from, but the result index that argument values go to. The general case is that 𝕨 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 𝕨, and each result element has rank (𝕨)+(=𝕩)-+´=¨𝕨, with the initial 𝕨 axes corresponding to elements of 𝕨 and the remainder to trailing axes of 𝕩. Each atom in 𝕨 can be either a natural number or ¯1 (which indicates the corresponding position in 𝕩 will be omitted). If ¯1 doesn't appear, the result has the property that each cell of 𝕩 appears in the corresponding element of 𝕨𝕨𝕩. More concretely, the length of the result along axis a is the maximum value in a𝕨 plus one, or zero if a𝕨 is empty. Axis a corresponds to =a𝕨 axes in 𝕩, and an element of the result at position i along this axis contains all positions in 𝕩 where i=a𝕨. There may be multiple such positions, and they're arranged along axis a of that result element according to their index order in 𝕩. The shapes of components of 𝕨 must match the corresponding axes of 𝕩, except for rank-1 components of 𝕨, which can match or have an extra element. This element, which like the others is either a natural number or ¯1, gives the minimum length of the result axis corresponding to the component of 𝕨 in question, but otherwise does not affect the result. Group Indices treats its argument 𝕩 as a left argument for Group and uses a right argument made up of indices, with the definition (↕≠1).

-

Range () 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 𝕩 should still result in an error). For a list 𝕩, the result is an array of shape 𝕩 in which the value at a given index is that index, as a list of natural numbers. That is, ii⊑↕𝕩 for any list of natural numbers i with ´i<𝕩.

+

Group () performs an opposite operation to Select, so that 𝕨 specifies not the argument index that result values come from, but the result index that argument values go to. The general case is that 𝕨 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 𝕨, and each result element has rank (𝕨)+(=𝕩)-+´=¨𝕨, with the initial 𝕨 axes corresponding to elements of 𝕨 and the remainder to trailing axes of 𝕩. Each atom in 𝕨 can be either a natural number or ¯1 (which indicates the corresponding position in 𝕩 will be omitted). If ¯1 doesn't appear, the result has the property that each cell of 𝕩 appears in the corresponding element of 𝕨𝕨𝕩. More concretely, the length of the result along axis a is the maximum value in a𝕨 plus one, or zero if a𝕨 is empty. Axis a corresponds to =a𝕨 axes in 𝕩, and an element of the result at position i along this axis contains all positions in 𝕩 where i=a𝕨. There may be multiple such positions, and they're arranged along axis a of that result element according to their index order in 𝕩. The shapes of components of 𝕨 must match the corresponding axes of 𝕩, except for rank-1 components of 𝕨, which can match or have an extra element. This element, which like the others is either a natural number or ¯1, gives the minimum length of the result axis corresponding to the component of 𝕨 in question, but otherwise does not affect the result. Group Indices treats its argument 𝕩 as a left argument for Group and uses a right argument made up of indices, which is ↕≠𝕩 if 𝕩 has depth 1 and ↕∾≢¨𝕩 if it has depth 2. Because the depth-1 case uses atomic indices, 𝕩 is required to be a list (and it can't be an atom). Much like Range, the result has depth one higher than the argument.

Indices (/) applies to a list of natural numbers, and returns a list of natural numbers. The result contains i𝕩 copies of each natural number index i for 𝕩, in increasing order.

Structural manipulation

Monadic structural functions work on the first axis of the argument, so they require it to have rank at least 1. Reverse () reverses the ordering of the major cells of 𝕩. Nudge (») shifts them forward, removing the last and placing a major cell made up of fill elements at the beginning, while Nudge Back («) does the same in the reverse direction, so it removes the first cell and places fills at the end. Prefixes () and Suffixes () each return lists with length one higher than 𝕩, whose elements are arrays with the same rank as 𝕩. For Prefixes, the element of the result at index i contains the first i major cells of 𝕩 in order, and for Suffixes, it contains all but these major cells.

-- cgit v1.2.3