Skip to content

Commit

Permalink
Show argument first for multidimensional Group example
Browse files Browse the repository at this point in the history
  • Loading branch information
mlochbaum committed Apr 15, 2024
1 parent fb40252 commit 78ca5c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doc/group.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ If there are non-list arrays in `𝕨`, these correspond to multiple axes in `

Here we split up a rank-2 array into a rank-2 array of rank-2 arrays. Along the first axis we simply separate the first pair and second pair of rowsβ€”a partition. Along the second axis we separate odd from even indices.

(10×↕4)+βŒœβ†•7

⟨0β€Ώ0β€Ώ1β€Ώ1,0β€Ώ1β€Ώ0β€Ώ1β€Ώ0β€Ώ1β€Ώ0⟩ βŠ” (10×↕4)+βŒœβ†•7

Each group `iβŠ‘π•¨βŠ”π•©` is composed of the cells `j<Β¨βŠΈβŠπ•©` such that `iβ‰’jβŠ‘Β¨π•¨`. The groups retain their array structure and ordering along each argument axis. Using multidimensional [Replicate](replicate.md) we can say that `iβŠ‘π•¨βŠ”π•©` is `(i=𝕨)/𝕩`.
Expand Down
10 changes: 9 additions & 1 deletion docs/doc/group.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,15 @@ <h3 id="multidimensional-grouping"><a class="header" href="#multidimensional-gro
<p>Dyadic Group allows the right argument to be grouped along multiple axes by using a nested left argument. In this case, <code><span class='Value'>𝕨</span></code> must be a list of numeric arrays, and the result has rank <code><span class='Function'>β‰ </span><span class='Value'>𝕨</span></code>. Assuming for now that all elements of <code><span class='Value'>𝕨</span></code> are lists, each result element has the same rank as <code><span class='Value'>𝕩</span></code>. The result shape is <code><span class='Number'>1</span><span class='Function'>+⌈</span><span class='Modifier'>´¨</span><span class='Value'>𝕨</span></code>, while the shape of element <code><span class='Value'>i</span><span class='Function'>βŠ‘</span><span class='Value'>𝕨</span><span class='Function'>βŠ”</span><span class='Value'>𝕩</span></code> is <code><span class='Value'>i</span><span class='Function'>+</span><span class='Modifier'>Β΄</span><span class='Modifier2'>∘</span><span class='Function'>=</span><span class='Modifier'>Β¨</span><span class='Value'>𝕨</span></code>. If every element of <code><span class='Value'>𝕨</span></code> is a list in ascending order with no Β―1s, we have <code><span class='Value'>𝕩</span><span class='Function'>β‰‘βˆΎ</span><span class='Value'>𝕨</span><span class='Function'>βŠ”</span><span class='Value'>𝕩</span></code>, that is, <a href="join.html#join">Join</a> is the inverse of partitioning.</p>
<p>If there are non-list arrays in <code><span class='Value'>𝕨</span></code>, these correspond to multiple axes in <code><span class='Value'>𝕩</span></code> but only one axis of the result. Each of these groups of axes is treated as a single axis in index order, as though <code><span class='Value'>𝕩</span></code> were reshaped to convert each into exactly one axis, and <code><span class='Function'>β₯Š</span><span class='Modifier'>Β¨</span></code> were applied to <code><span class='Value'>𝕨</span></code>.</p>
<p>Here we split up a rank-2 array into a rank-2 array of rank-2 arrays. Along the first axis we simply separate the first pair and second pair of rowsβ€”a partition. Along the second axis we separate odd from even indices.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4p+oMOKAvzDigL8x4oC/MSww4oC/MeKAvzDigL8x4oC/MOKAvzHigL8w4p+pIOKKlCAoMTDDl+KGlTQpK+KMnOKGlTc=">↗️</a><pre> <span class='Bracket'>⟨</span><span class='Number'>0</span><span class='Ligature'>β€Ώ</span><span class='Number'>0</span><span class='Ligature'>β€Ώ</span><span class='Number'>1</span><span class='Ligature'>β€Ώ</span><span class='Number'>1</span><span class='Separator'>,</span><span class='Number'>0</span><span class='Ligature'>β€Ώ</span><span class='Number'>1</span><span class='Ligature'>β€Ώ</span><span class='Number'>0</span><span class='Ligature'>β€Ώ</span><span class='Number'>1</span><span class='Ligature'>β€Ώ</span><span class='Number'>0</span><span class='Ligature'>β€Ώ</span><span class='Number'>1</span><span class='Ligature'>β€Ώ</span><span class='Number'>0</span><span class='Bracket'>⟩</span> <span class='Function'>βŠ”</span> <span class='Paren'>(</span><span class='Number'>10</span><span class='Function'>×↕</span><span class='Number'>4</span><span class='Paren'>)</span><span class='Function'>+</span><span class='Modifier'>⌜</span><span class='Function'>↕</span><span class='Number'>7</span>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=KDEww5fihpU0KSvijJzihpU3Cgrin6gw4oC/MOKAvzHigL8xLDDigL8x4oC/MOKAvzHigL8w4oC/MeKAvzDin6kg4oqUICgxMMOX4oaVNCkr4oyc4oaVNw==">↗️</a><pre> <span class='Paren'>(</span><span class='Number'>10</span><span class='Function'>×↕</span><span class='Number'>4</span><span class='Paren'>)</span><span class='Function'>+</span><span class='Modifier'>⌜</span><span class='Function'>↕</span><span class='Number'>7</span>
β”Œβ”€
β•΅ 0 1 2 3 4 5 6
10 11 12 13 14 15 16
20 21 22 23 24 25 26
30 31 32 33 34 35 36
β”˜

<span class='Bracket'>⟨</span><span class='Number'>0</span><span class='Ligature'>β€Ώ</span><span class='Number'>0</span><span class='Ligature'>β€Ώ</span><span class='Number'>1</span><span class='Ligature'>β€Ώ</span><span class='Number'>1</span><span class='Separator'>,</span><span class='Number'>0</span><span class='Ligature'>β€Ώ</span><span class='Number'>1</span><span class='Ligature'>β€Ώ</span><span class='Number'>0</span><span class='Ligature'>β€Ώ</span><span class='Number'>1</span><span class='Ligature'>β€Ώ</span><span class='Number'>0</span><span class='Ligature'>β€Ώ</span><span class='Number'>1</span><span class='Ligature'>β€Ώ</span><span class='Number'>0</span><span class='Bracket'>⟩</span> <span class='Function'>βŠ”</span> <span class='Paren'>(</span><span class='Number'>10</span><span class='Function'>×↕</span><span class='Number'>4</span><span class='Paren'>)</span><span class='Function'>+</span><span class='Modifier'>⌜</span><span class='Function'>↕</span><span class='Number'>7</span>
β”Œβ”€
β•΅ β”Œβ”€ β”Œβ”€
β•΅ 0 2 4 6 β•΅ 1 3 5
Expand Down

0 comments on commit 78ca5c3

Please sign in to comment.