From 41e459603dc7c1552194da7450ed2daeed6c0053 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 1 Jul 2021 21:37:46 -0400 Subject: Finish Select documentation --- docs/doc/select.html | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'docs/doc') diff --git a/docs/doc/select.html b/docs/doc/select.html index 13589621..48f2af19 100644 --- a/docs/doc/select.html +++ b/docs/doc/select.html @@ -161,3 +161,25 @@ ERROR ┘

Multi-axis selection

+

Select also allows 𝕨 to apply to multiple axes of 𝕩 simultaneously. For this case, 𝕨 must be a non-empty list (or unit array) where every element is an array of indices.

+↗️
    21, 300  34
+┌─                         
+╵ ⟨ 2 3 ⟩ ⟨ 2 0 ⟩ ⟨ 2 0 ⟩  
+  ⟨ 1 3 ⟩ ⟨ 1 0 ⟩ ⟨ 1 0 ⟩  
+                          ┘
+
+

Using a range for 𝕩 shows the structure of the selected elements more clearly, because each element is its own index. Each element of 𝕨 acts independently, giving a structure like the Table modifier.

+

While 𝕨 must have rank one or less, its elements can have any rank. When the elements are units, the corresponding axis of 𝕩 disappears from the result. We can select a 0-cell of 𝕩 in this way, although the more common case or selecting an element is handled by Pick.

+↗️
    <4,<5,<1  (310)⥊↕1e3
+┌·     
+· 451  
+      ┘
+     4, 5, 1  (310)⥊↕1e3
+451
+
+

However, the <¨ construct can select a cell of any rank from 𝕩, because 𝕨 can be smaller than =𝕩 (okay, not quite: an empty list is always interpreted as a list of indices, so it's impossible to select the full-rank cell 𝕩). Below, 𝕨 is missing one axis and the result is a 1-cell, or row, of 𝕩.

+↗️
    4,5 <¨ (310)⥊↕1e3
+⟨ 450 451 452 453 454 455 456 457 458 459 ⟩
+
+

If an element of 𝕨 has rank more than 1, it increases the rank of 𝕩 rather than decreasing it. The general rule is that in the result, one axis of 𝕩 is replaced by all the axes of the corresponding element of 𝕨 (trailing axes are unchanged). So the final shape 𝕨𝕩 is (∾≢¨𝕨)𝕨↓≢𝕩. But this shape doesn't affect the elements retrieved from 𝕩. In all cases, using ¨𝕨 for the left argument and then reshaping the result would yield the same value.

+

Selection only ever applies to leading axes of 𝕩. But you can skip some leading axes using ˘ or , to select on any contiguous set of axes. In particular, use the one-axis case 𝕨(-k) 𝕩 to select along axis k of 𝕩.

-- cgit v1.2.3