From e2b07a5fd0bbaad232c717fb90a31d6c61d72bd4 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 14 Jul 2022 20:06:50 -0400 Subject: Try to include previous variable definitions in REPL links --- docs/doc/rank.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'docs/doc/rank.html') diff --git a/docs/doc/rank.html b/docs/doc/rank.html index 631693cf..409fee4b 100644 --- a/docs/doc/rank.html +++ b/docs/doc/rank.html @@ -104,7 +104,7 @@

What's it mean for Nudge to shift the "entire table"? The block above shows that it shifts downward, but what's really happening is that Nudge treats 𝕩 as a collection of major cells—its rows—and shifts these. So it adds an entire row and moves the rest of the rows downwards. Nudge Cells appears similar, but it's acting independently on each row, and the values that it moves around are major cells of the row, that is, rank-0 units.

Here's an example showing how Cells can be used to shift each row independently, even though it's not possible to shift columns like this (in fact the best way to do that would be to transpose in order to work on rows). It uses the not-yet-introduced dyadic form of Cells, so you might want to come back to it after reading the next section.

-↗️
    ("∘∘") »˘ a
+↗️
    ("∘∘") »˘ a
 ┌─          
 ╵"abcdefgh  
   ∘ijklmno  
@@ -112,7 +112,7 @@
            ┘
 

You can also see how Cells splits its argument into rows using a less array-oriented primitive: Enclose just wraps each row up so that it appears as a separate element in the final result.

-↗️
    <˘ a
+↗️
    <˘ a
 ⟨ "abcdefgh" "ijklmnop" "qrstuvwx" ⟩
 

Enclose also comes in handy for the following task: join the rows in an array of lists, resulting in an array where each element is a joined row. The obvious guess would be "join cells", ˘, but it doesn't work, because each can return a result with a different length. Cells tries to make each result of into a cell, when the problem was to use it as an element. But a 0-cell is an enclosed element, so we can close the gap by applying < to a joined list: <.

@@ -131,7 +131,7 @@

This approach can apply to more complicated functions as well. And because the result of < always has the same shape, ⟨⟩, the function <𝔽˘ can never have a shape agreement error. So if 𝔽˘ fails, it can't hurt to check <𝔽˘ and see what results 𝔽 is returning.

Two arguments

When given two arguments, Cells tries to pair their cells together. Starting simple, a unit (whether array or atom) on either side will be paired with every cell of the other argument.

-↗️
    '∘' »˘ a
+↗️
    '∘' »˘ a
 ┌─          
 ╵"∘abcdefg  
   ∘ijklmno  
@@ -139,7 +139,7 @@
            ┘
 

If you want to use this one-to-many behavior with an array, it'll take more work: since you're really only mapping over one argument, bind the other inside Cells.

-↗️
    "∘∘" »˘ a
+↗️
    "∘∘" »˘ a
 Error: ˘: Leading axis of arguments not equal (⟨2⟩ ≡ ≢𝕨, 3‿8 ≡ ≢𝕩)
 
     "∘∘"»˘ a
@@ -150,7 +150,7 @@
            ┘
 

This is because the general case of Cells does one-to-one matching, pairing the first axis of one argument with the other. For this to work, the two arguments need to have the same length.

-↗️
     "012" »˘ a,  (3"UVWXYZ") »˘ a 
+↗️
     "012" »˘ a,  (3"UVWXYZ") »˘ a 
 ┌─                           
 · ┌─           ┌─            
   ╵"0abcdefg   ╵"UVabcdef    
@@ -160,7 +160,7 @@
                             ┘
 

The arguments might have different ranks: for example, "012" has rank 1 and a has rank 2 above. That's fine: it just means Cells will pass arguments of rank 0 and 1 to its operand. You can see these arguments using Pair Cells, ˘, so that each cell of the result is just a list of the two arguments used for that call.

-↗️
    "012" ˘ a
+↗️
    "012" ˘ a
 ┌─                  
 ╵ ┌·    "abcdefgh"  
   ·'0'              
@@ -196,7 +196,7 @@
 ⟨ "abc" "def" ⟩
 

The function 𝔽k, for k0, operates on the k-cells of its arguments—that is, it maps over all but the last k axes. For any given argument a, ranks k and k-=a are the same, as long as k0 and (k-=a)¯1. So rank 2 is rank ¯3 for a rank-5 array. The reason this option is useful is that the same rank might be applied to multiple arguments, either with multiple function calls or one call on two arguments. Let's revisit an example with Cells from before, shifting the same string into each row of a table. The function » should be called on rank-1 strings, but because the argument ranks are different, a negative rank can't get down to rank 1 on both sides. Positive rank 1 does the job, allowing us to unbundle the string "∘∘" so that »1 is a standalone function.

-↗️
    "∘∘"»˘ a
+↗️
    "∘∘"»˘ a
 ┌─          
 ╵"∘∘abcdef  
   ∘∘ijklmn  
@@ -260,7 +260,7 @@
 ⟨ 2 ¯1 3 ⟩
 

But a rank of 1 works the best because it also defines a matrix-matrix product. Which as shown below does the same transformation to the cells of the right-hand-side matrix, instead of the elements of a vector. This works because × and +˝ work on the leading axes of their arguments. When 1 is applied, these axes are the last axis of 𝕨 and the first axis of 𝕩. Which… is kind of weird, but it's what a matrix product is.

-↗️
    +˝ 010 × 123×110
+↗️
    +˝ 010 × 123×110
 ⟨ 2 20 ⟩
 
     m +˝×1 123×110
-- 
cgit v1.2.3