From 2afb23928e1984d475cc460e1672e8f6fa0e4dbe Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 11 Aug 2021 17:21:31 -0400 Subject: Allow clicking on header to get fragment link --- docs/doc/transpose.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'docs/doc/transpose.html') diff --git a/docs/doc/transpose.html b/docs/doc/transpose.html index 42d3dd71..b2319106 100644 --- a/docs/doc/transpose.html +++ b/docs/doc/transpose.html @@ -4,9 +4,9 @@ BQN: Transpose -

Transpose

+

Transpose

Transpose () is a tool for rearranging the axes of an array. BQN's version is tweaked relative to APL to align better with the leading axis model and make common operations easier.

-

Transpose basics

+

Transpose basics

The name for the primitive comes from the Transpose operation on matrices. Given a matrix as an array of rank 2, will transpose it:

↗️
     mat  23  6
 ┌─       
@@ -27,7 +27,7 @@
 3
 

With two axes the only interesting operation of this sort is to swap them (and with one or zero axes there's nothing interesting to do, and just returns the argument array). But a BQN programmer may well want to work with higher-rank arrays—although such a programmer might call them "tensors"—and this means there are many more ways to rearrange the axes. Transpose extends to high-rank arrays to allow some useful special cases as well as completely general axis rearrangement, as described below.

-

Monadic Transpose

+

Monadic Transpose

APL extends matrix transposition to any rank by reversing all axes for its monadic , but this generalization isn't very natural and is almost never used. The main reason for it is to maintain the equivalence a MP b ←→ b MP a, where MP +˝×1 is the generalized matrix product. But even here APL's Transpose is suspect. It does much more work than it needs to, as we'll see.

BQN's transpose takes the first axis of 𝕩 and moves it to the end.

↗️
     a23456  23456
@@ -88,7 +88,7 @@
 ⟨ 3 4 2 5 6 ⟩
 

In a case like this BQN's Dyadic transpose is much easier.

-

Dyadic Transpose

+

Dyadic Transpose

Transpose also allows a left argument that specifies a permutation of 𝕩's axes. For each index pi𝕨 in the left argument, axis i of 𝕩 is used for axis p of the result. Multiple argument axes can be sent to the same result axis, in which case that axis goes along a diagonal of 𝕩, and the result will have a lower rank than 𝕩.

↗️
     13204  a23456
 ⟨ 5 2 4 3 6 ⟩
@@ -109,7 +109,7 @@
 ⟨ 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˙).

-

Definitions

+

Definitions

Here we define the two valences of Transpose more precisely.

An atom right argument to either valence of Transpose is always enclosed to get an array before doing anything else.

Monadic transpose is identical to (=-1˙), except that if 𝕩 is a unit it is returned unchanged (after enclosing, if it's an atom) rather than giving an error.

-- cgit v1.2.3