From b3ecbb5695a5a0a0637c924da0022abca940ffee Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 21 Jul 2020 19:13:22 -0400 Subject: Add Rank function as monadic = --- docs/doc/depth.html | 2 +- docs/doc/transpose.html | 8 ++++---- docs/index.html | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/docs/doc/depth.html b/docs/doc/depth.html index e141585c..cd025527 100644 --- a/docs/doc/depth.html +++ b/docs/doc/depth.html @@ -9,7 +9,7 @@ โ‰ก "a string is a list of characters" 1 -

Depth is somewhat analogous to an array's rank โ‰ โ‰ข๐•ฉ, and in fact rank can be "converted" to depth by splitting rows with <โމ1, reducing the rank by 1 and increasing the depth. Unlike rank, Depth doesn't care at all about its argument's shape:

+

Depth is somewhat analogous to an array's rank =๐•ฉ, and in fact rank can be "converted" to depth by splitting rows with <โމ1, reducing the rank by 1 and increasing the depth. Unlike rank, Depth doesn't care at all about its argument's shape:

    โ‰ก 3โ€ฟ4โฅŠ"characters"
 1
     โ‰ก (1+โ†•10)โฅŠ"characters"
diff --git a/docs/doc/transpose.html b/docs/doc/transpose.html
index 2020a520..3b5af23b 100644
--- a/docs/doc/transpose.html
+++ b/docs/doc/transpose.html
@@ -53,7 +53,7 @@
 โŸจ 2 6 3 4 5 โŸฉ
 

Using these forms, we can state BQN's generalized matrix product swapping rule:

-
a MP b  โ†โ†’  โ‰โŸ(โ‰ โ‰ขa) a โ‰โผโŠธMPโŸœโ‰ b
+
a MP b  โ†โ†’  โ‰โŸ(=a) a โ‰โผโŠธMPโŸœโ‰ b
 

Certainly not as concise as APL's version, but not a horror either. BQN's rule is actually more parsimonious in that it only performs the axis exchanges necessary for the computation: it moves the two axes that will be paired with the matrix product into place before the product, and directly exchanges all axes afterwards. Each of these steps is equivalent in terms of data movement to a matrix transpose, the simplest nontrivial transpose to perform. Also remember that for two-dimensional matrices both kinds of transposition are the same, and APL's rule holds in BQN.

Axis permutations of the types we've shown generate the complete permutation group on any number of axes, so you could produce any transposition you want with the right sequence of monadic transpositions with Rank. However, this can be unintuitive and tedious. What if you want to transpose the first three axes, leaving the rest alone? With monadic Transpose you have to send some axes to the end, then bring them back to the beginning. For example [following four or five failed tries]:

@@ -80,10 +80,10 @@
    โ‰ข 2 โ‰ a23456  # Restrict Transpose to the first three axes
 โŸจ 3 4 2 5 6 โŸฉ
 
-

Finally, it's worth noting that, as monadic Transpose moves the first axis to the end, it's equivalent to dyadic Transpose with a "default" left argument: (โ‰ โˆ˜โ‰ข-1หœ)โŠธโ‰.

+

Finally, it's worth noting that, as monadic Transpose moves the first axis to the end, it's equivalent to dyadic Transpose with a "default" left argument: (=-1หœ)โŠธโ‰.

Definitions

Here we define the two valences of Transpose more precisely.

A non-array right argument to Transpose is always enclosed to get a scalar array before doing anything else.

-

Monadic transpose is identical to (โ‰ โˆ˜โ‰ข-1หœ)โŠธโ‰, except that for scalar arguments it returns the array unchanged rather than giving an error.

-

In Dyadic transpose, the left argument is a number or numeric array of rank 1 or less, and ๐•จโ‰คโ—‹โ‰ โ‰ข๐•ฉ. Define the result rank rโ†(โ‰ โ‰ข๐•ฉ)-+ยดยฌโˆŠ๐•จ to be the argument rank minus the number of duplicate entries in the left argument. We require โˆงยด๐•จ<r. Bring ๐•จ to full length by appending the missing indices: ๐•จโˆพโ†ฉ๐•จ(ยฌโˆ˜โˆŠหœ/โŠข)โ†•r. Now the result shape is defined to be โŒŠยดยจ๐•จโŠ”โ‰ข๐•ฉ. Element iโŠ‘z of the result z is element (๐•จโŠi)โŠ‘๐•ฉ of the argument.

+

Monadic transpose is identical to (=-1หœ)โŠธโ‰, except that for scalar arguments it returns the array unchanged rather than giving an error.

+

In Dyadic transpose, the left argument is a number or numeric array of rank 1 or less, and ๐•จโ‰คโ—‹โ‰ โ‰ข๐•ฉ. Define the result rank rโ†(=๐•ฉ)-+ยดยฌโˆŠ๐•จ to be the argument rank minus the number of duplicate entries in the left argument. We require โˆงยด๐•จ<r. Bring ๐•จ to full length by appending the missing indices: ๐•จโˆพโ†ฉ๐•จ(ยฌโˆ˜โˆŠหœ/โŠข)โ†•r. Now the result shape is defined to be โŒŠยดยจ๐•จโŠ”โ‰ข๐•ฉ. Element iโŠ‘z of the result z is element (๐•จโŠi)โŠ‘๐•ฉ of the argument.

diff --git a/docs/index.html b/docs/index.html index f57273e5..57e708ba 100644 --- a/docs/index.html +++ b/docs/index.html @@ -209,7 +209,7 @@ = - +Rank Equals -- cgit v1.2.3