From 6078db236e6c34788371576bb51410cf8298b583 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 31 May 2022 21:56:13 -0400 Subject: Define cells in the documentation --- docs/doc/array.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'docs/doc/array.html') diff --git a/docs/doc/array.html b/docs/doc/array.html index d941f90a..6ce906e3 100644 --- a/docs/doc/array.html +++ b/docs/doc/array.html @@ -117,6 +117,20 @@

The total number of elements in an array is its bound, and can be found using Deshape with , or by multiplying all the lengths in the shape. An array of rank 0, which always contains exactly one element, is called a unit, while an array of rank 1 is called a list and an array of rank 2 is called a table.

Elements

Any BQN value can be used as an array element, including another array (BQN, as a dynamically-typed language, doesn't restrict the types that can be used in one context without a good reason). However, BQN arrays are restricted relative to other array models. Frameworks like NumPy or Julia have mutable arrays, so that the value of an element can be changed after the array is created. This allows an array to be its own element, by creating an array and then inserting it into itself. This would be unnatural in BQN, where an array can only be formed from elements that already exist. In BQN only operations and namespaces are mutable.

+

Cells

+

The contents of an array are its elements, but it also makes sense to split up an array into subarrays of elements called cells. The most important kind of cell, a major cell consists of all the elements that have indices beginning with some particular index i. For this to make sense, i must be between 0 and the length l of the array's first axis, so that there are l major cells each identified by an index.

+↗️
    234 × 15811
+┌─            
+╵ 2 10 16 22  
+  3 15 24 33  
+  4 20 32 44  
+             ┘
+
+    1  234 × 15811  # Major cell 1
+⟨ 3 15 24 33 ⟩
+
+

A major cell still has an array structure: it retains all the axes of the original array other than the first. So it has its own major cells, identified by the index i of the original major cell and j within it. These are also cells of the original array. Generalizing, a cell with index list l is defined to be the array of all elements whose indices begin with l. In an array with rank n, the cell rank is n-≠l, and cells grouped using this rank. An n-cell mst have an empty cell index, so that it includes all elements—it's the entire array! An n-1 cell, also called a ¯1-cell, is a major cell. A 0-cell has an index of length n, and contains a single element.

+

Cells are the center of the leading axis model used to structure many array primitives.

Properties

Summarizing, the values needed to define an array are its rank (the number of axes), its shape (the number of positions along each axis), and the value of each element (that is, at each combination of positions). Two arrays match when all these values match.

If the rank is considered to be part of the shape, as it is when the shape is a BQN list, then the array is defined by its shape and element list—from deshape.

-- cgit v1.2.3