aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2022-05-30 22:24:30 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2022-05-30 22:24:30 -0400
commit14322d0923ee973f80121f1c26277a838da6198c (patch)
tree126e85dfefe9bdd551d25b0ae055cc845ba2c3e9
parent85e689d146b57fda7231a21ad1c99771d267aa39 (diff)
Point out that one negative rank might correspond to two positive ones
-rw-r--r--doc/rank.md2
-rw-r--r--docs/doc/rank.html4
2 files changed, 3 insertions, 3 deletions
diff --git a/doc/rank.md b/doc/rank.md
index 949640fd..fa3e9b68 100644
--- a/doc/rank.md
+++ b/doc/rank.md
@@ -168,7 +168,7 @@ The Rank modifier also accepts a list of one to three numbers for `𝕘`, as wel
- A single number or one-element list indicates the ranks for all arguments.
- Two numbers indicate the ranks for `𝕨` and `𝕩`.
-As an example, we'll define the matrix-vector product. A matrix is a rank-2 array and a vector is a list, and their product is a list. It's made up of the elements `+´ row × vec` for each row `row` of the matrix. To define this using Rank, we'll change `+´` to `+˝` to get a unit out, and we need to map over the rows of the left argument but not of the right one. Following the rules above, there are several ways to do this, including `+˝∘×⎉1`, `+˝∘×⎉¯1‿1`, and `+˝∘×⎉¯1‿∞`. When correctly defined we can see that multiplication by the matrix `m` below negates the first element of a list, and also swaps it with the second.
+As an example, we'll define the matrix-vector product. A matrix is a rank-2 array and a vector is a list, and their product is a list. It's made up of the elements `+´ row × vec` for each row `row` of the matrix. To define this using Rank, we'll change `+´` to `+˝` to get a unit out, and we need to map over the rows of the left argument but not of the right one. Following the rules above, there are several ways to do this, including `+˝∘×⎉1`, `+˝∘×⎉¯1‿1`, and `+˝∘×⎉¯1‿∞`. Note that `⎉¯1` wouldn't work, because the ¯1 is interpreted separately for both arguments—it's equivalent to 1 matrix but 0 for the vector, or `⎉1‿0` overall. for the When correctly defined we can see that multiplication by the matrix `m` below negates the first element of a list, and also swaps it with the second.
⊢ m ← >⟨0‿1‿0,¯1‿0‿0,0‿0‿1⟩
diff --git a/docs/doc/rank.html b/docs/doc/rank.html
index aed77354..e96eacb1 100644
--- a/docs/doc/rank.html
+++ b/docs/doc/rank.html
@@ -243,7 +243,7 @@
<li>A single number or one-element list indicates the ranks for all arguments.</li>
<li>Two numbers indicate the ranks for <code><span class='Value'>𝕨</span></code> and <code><span class='Value'>𝕩</span></code>.</li>
</ul>
-<p>As an example, we'll define the matrix-vector product. A matrix is a rank-2 array and a vector is a list, and their product is a list. It's made up of the elements <code><span class='Function'>+</span><span class='Modifier'>´</span> <span class='Value'>row</span> <span class='Function'>×</span> <span class='Value'>vec</span></code> for each row <code><span class='Value'>row</span></code> of the matrix. To define this using Rank, we'll change <code><span class='Function'>+</span><span class='Modifier'>´</span></code> to <code><span class='Function'>+</span><span class='Modifier'>˝</span></code> to get a unit out, and we need to map over the rows of the left argument but not of the right one. Following the rules above, there are several ways to do this, including <code><span class='Function'>+</span><span class='Modifier'>˝</span><span class='Modifier2'>∘</span><span class='Function'>×</span><span class='Modifier2'>⎉</span><span class='Number'>1</span></code>, <code><span class='Function'>+</span><span class='Modifier'>˝</span><span class='Modifier2'>∘</span><span class='Function'>×</span><span class='Modifier2'>⎉</span><span class='Number'>¯1</span><span class='Ligature'>‿</span><span class='Number'>1</span></code>, and <code><span class='Function'>+</span><span class='Modifier'>˝</span><span class='Modifier2'>∘</span><span class='Function'>×</span><span class='Modifier2'>⎉</span><span class='Number'>¯1</span><span class='Ligature'>‿</span><span class='Number'>∞</span></code>. When correctly defined we can see that multiplication by the matrix <code><span class='Value'>m</span></code> below negates the first element of a list, and also swaps it with the second.</p>
+<p>As an example, we'll define the matrix-vector product. A matrix is a rank-2 array and a vector is a list, and their product is a list. It's made up of the elements <code><span class='Function'>+</span><span class='Modifier'>´</span> <span class='Value'>row</span> <span class='Function'>×</span> <span class='Value'>vec</span></code> for each row <code><span class='Value'>row</span></code> of the matrix. To define this using Rank, we'll change <code><span class='Function'>+</span><span class='Modifier'>´</span></code> to <code><span class='Function'>+</span><span class='Modifier'>˝</span></code> to get a unit out, and we need to map over the rows of the left argument but not of the right one. Following the rules above, there are several ways to do this, including <code><span class='Function'>+</span><span class='Modifier'>˝</span><span class='Modifier2'>∘</span><span class='Function'>×</span><span class='Modifier2'>⎉</span><span class='Number'>1</span></code>, <code><span class='Function'>+</span><span class='Modifier'>˝</span><span class='Modifier2'>∘</span><span class='Function'>×</span><span class='Modifier2'>⎉</span><span class='Number'>¯1</span><span class='Ligature'>‿</span><span class='Number'>1</span></code>, and <code><span class='Function'>+</span><span class='Modifier'>˝</span><span class='Modifier2'>∘</span><span class='Function'>×</span><span class='Modifier2'>⎉</span><span class='Number'>¯1</span><span class='Ligature'>‿</span><span class='Number'>∞</span></code>. Note that <code><span class='Modifier2'>⎉</span><span class='Number'>¯1</span></code> wouldn't work, because the ¯1 is interpreted separately for both arguments—it's equivalent to 1 matrix but 0 for the vector, or <code><span class='Modifier2'>⎉</span><span class='Number'>1</span><span class='Ligature'>‿</span><span class='Number'>0</span></code> overall. for the When correctly defined we can see that multiplication by the matrix <code><span class='Value'>m</span></code> below negates the first element of a list, and also swaps it with the second.</p>
<a class="replLink" title="Open in the REPL" target="_blank" href="https://mlochbaum.github.io/BQN/try.html#code=4oqiIG0g4oaQID7in6gw4oC/MeKAvzAswq8x4oC/MOKAvzAsMOKAvzDigL8x4p+pCgory50gMOKAvzHigL8wIMOXIDHigL8y4oC/MwoKbSAry53iiJjDl+KOiTHigL/iiJ4gMeKAvzLigL8z">↗️</a><pre> <span class='Function'>⊢</span> <span class='Value'>m</span> <span class='Gets'>←</span> <span class='Function'>&gt;</span><span class='Bracket'>⟨</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='Separator'>,</span><span class='Number'>¯1</span><span class='Ligature'>‿</span><span class='Number'>0</span><span class='Ligature'>‿</span><span class='Number'>0</span><span class='Separator'>,</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='Bracket'>⟩</span>
┌─
╵ 0 1 0
@@ -278,7 +278,7 @@
⟨ 3 2 9 ⟩
<span class='Function'>≢</span> <span class='Paren'>(</span><span class='Function'>↕</span><span class='Number'>2</span><span class='Ligature'>‿</span><span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>5</span><span class='Paren'>)</span> <span class='Function'>∾</span><span class='Modifier2'>⎉</span><span class='Number'>1</span> <span class='Paren'>(</span><span class='Function'>↕</span><span class='Number'>3</span><span class='Ligature'>‿</span><span class='Number'>4</span><span class='Paren'>)</span>
-<span class='Error'>Error: Mapping: Argument shape prefixes don't agree</span>
+<span class='Error'>Error: ⎉: Argument frames don't agree (2‿3‿5 ≡ ≢𝕨, 3‿4 ≡ ≢𝕩, common frame of 1 axes)</span>
</pre>
<p>On the other hand, Rank doesn't care about the argument cell shapes—it leaves that up to the function <code><span class='Function'>𝔽</span></code>. If <code><span class='Function'>𝔽</span></code> is an arithmetic function, you'll get <em>two</em> layers of prefix agreement: one outer matching with <code><span class='Modifier2'>⎉</span></code>, and an inner one with <code><span class='Function'>𝔽</span></code>.</p>
<p>It's also possible to apply multiple copies of Rank, which in general is powerful enough to match and not-match axes in any combination as long as the axes for each argument stay in order (of course, BQN also provides the tools to <a href="transpose.html#dyadic-transpose">reorder axes</a>).</p>