From 4cfeb0f2a9c040e85f67a8d78e8a40de68530e46 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 1 Jun 2022 16:06:28 -0400 Subject: Consistently use the name Reorder Axes, not dyadic Transpose --- docs/doc/indices.html | 2 +- docs/doc/primitive.html | 2 +- docs/doc/rank.html | 2 +- docs/doc/transpose.html | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'docs') diff --git a/docs/doc/indices.html b/docs/doc/indices.html index 8ed4317e..36bf279c 100644 --- a/docs/doc/indices.html +++ b/docs/doc/indices.html @@ -85,7 +85,7 @@ -

In Dyadic Transpose (⍉), 𝕨 is made up of indices into axes of 𝕩. Since array shape is 1-dimensional, there is only one sensible choice for these elements, a single number each.

+

In Reorder Axes (⍉), 𝕨 is made up of indices into axes of 𝕩. Since array shape is 1-dimensional, there is only one sensible choice for these elements, a single number each.

Element indices

In general, the index of an element of an array is a list whose length matches the array rank. It is also possible to use a number for an index into a list, as the list index is a singleton, but this must be kept consistent with the rest of the language. NARS-family APLs make the Index Generator (↕ in BQN) return a numeric list when the argument has length 1 but a nested array otherwise. This means that the depth of the result depends on the shape of the argument, inverting the typical hierarchy. BQN shouldn't have such an inconsistency.

Functions Range (↕), Indices (/), Group (βŠ”), and Pick (βŠ‘) naturally deal with element indices. Each of these can be defined to use list indices. However, this usually rules out the possibility of using atomic indices, which makes these functions harder to use both with generic array manipulation and with the major cell indices discussed in the next section. For this reason BQN restricts βŠ” and / to use atomic indices, which comes with the requirement that the arguments to Group and Indices, and the result of Group Indices, must be lists. For dyadic Group the depth-1 elements of 𝕨 are arrays of indices along axes of the result (multi-axis documentation). This means each axis of 𝕩 can only be related to one axis of the result.

diff --git a/docs/doc/primitive.html b/docs/doc/primitive.html index 7e32c91e..3da3019b 100644 --- a/docs/doc/primitive.html +++ b/docs/doc/primitive.html @@ -182,7 +182,7 @@ ⍉ Transpose -Reorder axes +Reorder Axes / diff --git a/docs/doc/rank.html b/docs/doc/rank.html index d030055d..23a5630e 100644 --- a/docs/doc/rank.html +++ b/docs/doc/rank.html @@ -281,7 +281,7 @@ 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).

+

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

One of the relatively more common instance of this pattern is a variation on the Table modifier, to work with cells instead of elements. Here we'll make a table of all combinations of one row (1-cell) from 𝕨 and one from 𝕩. To do this, we want to first line up each row of 𝕨 with the whole of 𝕩. As in a matrix product, that's βŽ‰1β€Ώβˆž. But then we'd like to pair that row with the rows of 𝕩 individually, which could be written βŽ‰βˆžβ€Ώ1. But since we know the left argument has been reduced to lists, βŽ‰1 also works. We then arrange the two layers of mapping with βŽ‰1 on the inside, giving (βˆΎβŽ‰1)βŽ‰1β€Ώβˆž.

↗️
    ("abc"≍"def") βˆΎβŽ‰1βŽ‰1β€Ώβˆž >"QR"β€Ώ"ST"β€Ώ"UV"
 β”Œβ”€       
diff --git a/docs/doc/transpose.html b/docs/doc/transpose.html
index fca1d637..952abc2c 100644
--- a/docs/doc/transpose.html
+++ b/docs/doc/transpose.html
@@ -87,8 +87,8 @@
 ↗️
    β‰’ β‰βΌβŽ‰Β―2 ⍉ a23456  # Restrict Transpose to the first three axes
 ⟨ 3 4 2 5 6 ⟩
 
-

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

-

Dyadic Transpose

+

In a case like this the dyadic version of ⍉, called Reorder Axes, is much easier.

+

Reorder Axes

Transpose also allows a left argument that specifies a permutation of 𝕩's axes. For each index p←iβŠ‘π•¨ 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 𝕩.

↗️
    β‰’ 1β€Ώ3β€Ώ2β€Ώ0β€Ώ4 ⍉ a23456
 ⟨ 5 2 4 3 6 ⟩
@@ -108,9 +108,9 @@
 ↗️
    β‰’ 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 Reorder Axes with a "default" left argument: (=-1Λ™)βŠΈβ‰.

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.

-

In dyadic Transpose, 𝕨 is a number or numeric array of rank 1 or less, and 𝕨≀○≠≒𝕩. Define the result rank r←(=𝕩)-+Β΄Β¬βˆŠπ•¨ to be the right 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.

+

In Reorder Axes, 𝕨 is a number or numeric array of rank 1 or less, and 𝕨≀○≠≒𝕩. Define the result rank r←(=𝕩)-+Β΄Β¬βˆŠπ•¨ to be the right 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.

-- cgit v1.2.3