diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-12-27 17:30:15 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-12-27 17:30:15 -0500 |
| commit | 6a1ccd4bd4b053d494cb9acfc8116550e3de8bec (patch) | |
| tree | bb7007006a8936228758dbb6673b03beff161fef /spec | |
| parent | 83427eaba663a68f5ed4fba55d0fdd328b47c6fc (diff) | |
Commentary on arithmetic primitives from layer 1
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/primitive.md | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/primitive.md b/spec/primitive.md index f888c0b9..d0df9318 100644 --- a/spec/primitive.md +++ b/spec/primitive.md @@ -104,3 +104,17 @@ The reference implementations extend Shape (`≢`) to atoms as well as arrays, i - **Rank** (`=`) gives the length of the shape. - **Length** (`≠`) gives the number of major cells, or `1` for an argument of rank `0`. - **Depth** (`≡`) gives the nesting depth. It ignores the shapes of arrays, and considering only the depths of their elements. + +### Arithmetic + +Arithmetic functions not already provided are defined in layer 1. These definitions, like the provided functions, apply to atoms only; they should be extended to arrays using the `_perv` modifier from layer 2. + +- **Sign** (`×`) +- **Square Root** and **Root** (`√`) are defined in terms of Power. If a dedicated implementation is used for square roots, then Power should check for a right argument of `0.5` and use this implementation in order to maintain consistency. +- **Ceiling** (`⌈`) is like Floor, but rounds up instead of down. +- **Not** (`¬`) is a linear extension of logical negation, and **Span** (`¬`) adds the left argument. +- **And** (`∧`) and **Or** (`∨`) are bilinear extensions of the boolean functions. +- **Minimum** (`⌊`) and **Maximum** (`⌈`) return the smaller or larger of the arguments, respectively. They are *not required* to be implemented for character arguments, and may give an error if either argument is a character. +- **Absolute Value** (`|`) +- **Modulus** (`|`) is an extension of modular division to real numbers. As it uses floor instead of truncation, it's not the same as the `%` operator from C or other languages when `𝕨<0`. +- Comparisons **Less Than** (`<`), **Greater Than** (`>`), **Greater Than or Equal to** (`≥`), and **Not Equals** (`≠`) are defined in terms of the two provided comparisons. |
