From f910f64594053011efd57a97100ad19ee1e39fb4 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sun, 20 Sep 2020 13:50:30 -0400 Subject: Use "unit" or "rank-0" instead of "scalar" --- docs/doc/leading.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'docs/doc/leading.html') diff --git a/docs/doc/leading.html b/docs/doc/leading.html index de9ea039..b2f2cda6 100644 --- a/docs/doc/leading.html +++ b/docs/doc/leading.html @@ -109,7 +109,7 @@

Other monadic functions

Not all functions work on the first axis in a straightforward manner. Transpose moves the first axis to the end, so while it focuses on the first one, it shifts every axis of the argument. Join also works on every axis of its argument, and applies to the leading axes of the argument's elements instead: these leading inner axes are matched up with the outer axes, and trailing inner axes are allowed but the elements must have rank at least as high as the argument array.

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.

+

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

Multiple axes

@@ -146,7 +146,7 @@

Functions with single-axis depth 1 tend to be more complicated; see for example Group.

Leading axis agreement

-

Scalar functions, and the Each (¨) and Depth () modifiers, use leading axis agreement to match their arguments together. All axes of the lower-rank argument are matched with the leading axes of the higher-rank one, and axes matched together must have the same length. After pairing axes in this way, a single element of the lower-rank argument might correspond to any number of elements of the higher-rank one. It's reused for each of those corresponding elements.

+

Arithmetic functions, and the Each (¨) and Depth () modifiers, use leading axis agreement to match their arguments together. All axes of the lower-rank argument are matched with the leading axes of the higher-rank one, and axes matched together must have the same length. After pairing axes in this way, a single element of the lower-rank argument might correspond to any number of elements of the higher-rank one. It's reused for each of those corresponding elements.

↗️
     x  324  60     # A rank-3 array
 ┌─             
 ╎  0  1  2  3  
@@ -198,7 +198,7 @@
   40 42 44 46  
               ┘
 
-

If one argument is a scalar, that is, it has no axes, then leading axis agreement reduces to "scalar extension", where a single scalar is matched with an entire array by repeating it at every application. A scalar always agrees with any other array under leading axis agreement because it has no axes whose lengths would need to be checked.

+

If one argument is a unit, that is, it has no axes, then leading axis agreement reduces to APL's "scalar extension" (where "scalar" is equivalent to BQN's "unit"), where a single unit is matched with an entire array by repeating it at every application. A unit always agrees with any other array under leading axis agreement because it has no axes whose lengths would need to be checked.

With leading axis agreement, there are k+1 shapes for arrays that can be added (or any other function with Each) to a given array x without changing its rank. These are precisely the prefixes of x, with ranks from 0 to k inclusive. Arrays with larger rank can also be used as the other argument, but then the result shape will match that argument and not x.

Search functions

The search functions Bins (⍋⍒), Index of (), Progressive Index of (), and Member of () look through cells of one argument to find cells of the other. Find () also does a search, but a slightly different one: it tries to find slices of cells of its right argument that match the left argument.

-- cgit v1.2.3