From 14322d0923ee973f80121f1c26277a838da6198c Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 30 May 2022 22:24:30 -0400 Subject: Point out that one negative rank might correspond to two positive ones --- docs/doc/rank.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/doc') 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 @@
  • 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, +˝×¯11, 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, +˝×¯11, 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 10 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  >010,¯100,001
     ┌─        
     ╵  0 1 0  
    @@ -278,7 +278,7 @@
     ⟨ 3 2 9 ⟩
     
          (235) 1 (34)
    -Error: Mapping: Argument shape prefixes don't agree
    +Error: ⎉: Argument frames don't agree (2‿3‿5 ≡ ≢𝕨, 3‿4 ≡ ≢𝕩, common frame of 1 axes)
     

    On the other hand, Rank doesn't care about the argument cell shapes—it leaves that up to the function 𝔽. If 𝔽 is an arithmetic function, you'll get two layers of prefix agreement: one outer matching with , and an inner one with 𝔽.

    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 reorder axes).

    -- cgit v1.2.3