From bda30287098ab9002bc4d3e8290ed06c21abec28 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sun, 16 Aug 2020 22:14:53 -0400 Subject: Add document on Solo, Couple, and Merge --- docs/doc/leading.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs/doc/leading.html') diff --git a/docs/doc/leading.html b/docs/doc/leading.html index 0301ddd4..e86c57f7 100644 --- a/docs/doc/leading.html +++ b/docs/doc/leading.html @@ -66,7 +66,7 @@ ef" ┘ -

Solo (), something of a maverick, manages to act on zero leading axes of its argument by creating the first axis of the result instead. Because it doesn't need any axis to work, it can go in front of either axis but also past the last one by working with rank 0, a case where most array functions would give an error.

+

Solo (), something of a maverick, manages to act on zero leading axes of its argument by creating the first axis of the result instead. Because it doesn't need any axis to work, it can go in front of either axis but also past the last one by working with rank 0, a case where most array functions would give an error.

      a                 # Solo adds a length-1 axis
 ⟨ 1 3 2 ⟩
     a    a             # First Cell undoes this
@@ -107,7 +107,7 @@
 

The other two monadic functions that work on high-rank arguments are Deshape () and First (). These treat the argument as one long list, ordered by its element indices. This ordering privileges leading axes (in fact, it is the reason for the choice of leading axes in the leading axis convention), but these functions can't really be said to work on leading axes: they apply to all axes.

The Each (¨) and Table () modifiers return functions which are the same in the monadic case. These functions simply go through all elements of the argument array without regard for its multi-dimensional structure (the operand is applied to elements in index order, matching Deshape; this matters if it has side effects). Similarly, monadic scalar functions do not have any sort of leading axis dependence.

Dyadic functions

-

For dyadic functions the pattern of working on only one argument axis is not so common. Only two functions can be said to follow it roughly: Join to () combines two arrays along one axis, using the first axis of both arguments if they have the same rank and of the higher-rank argument if they differ by one. Couple (), like Solo, does not manipulate the argument axes but adds a result axis. There are also some functions that can't be limited to leading axes: Reshape () treats the argument as one long list, and Pick () requires each index to be as long as the right argument's rank, because it selects elements and not cells from the right argument.

+

For dyadic functions the pattern of working on only one argument axis is not so common. Only two functions can be said to follow it roughly: Join to () combines two arrays along one axis, using the first axis of both arguments if they have the same rank and of the higher-rank argument if they differ by one. Couple (), like Solo, does not manipulate the argument axes but adds a result axis. There are also some functions that can't be limited to leading axes: Reshape () treats the argument as one long list, and Pick () requires each index to be as long as the right argument's rank, because it selects elements and not cells from the right argument.

Multiple axes

Instead of always working on a single axis, many dyadic functions work on one axis by default, but also allow a left argument with multiple elements corresponding to leading axes of the right argument. To decide which of the two possibilities applies, these functions test the left argument depth, a convention that is discussed in the depth documentation. A left argument that applies to one axis has a particular depth; the argument can also be a list of such arguments.

-- cgit v1.2.3