Skip to content
Snippets Groups Projects
Commit 90788902 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add doc for arithmetic binary operators

parent 26972b25
No related branches found
No related tags found
1 merge request!145git subrepo clone git@gitlab.com:OlMon/org-themes.git packages/org-themes
......@@ -1422,8 +1422,123 @@ they follow a few rules.
#+end_src
- Shift operators ~<<~ and ~>>~ are not used to define binary operators
between two basic types
- Arithmetic operators are defined
between two basic types.
- Arithmetic operators (~+~, ~-~, ~*~ and ~/~) are defined for a set of
combinations of basic types. We classify them by their returned
types.
- Their is no arithmetic operation that returns a boolean ~B~.
- Operators that return a natural integer ~N~.
#+begin_src latex :results drawer :exports results
\begin{equation*}
\forall \mathbb{S}_1, \mathbb{S}_2 \in \{\mathbb{B},\mathbb{N}\},
\quad
\left|
\begin{array}{rl}
\mathtt{+}:& \mathbb{S}_1 \times \mathbb{S}_2 \to \mathbb{N}\\
\mathtt{*}:& \mathbb{S}_1 \times \mathbb{S}_2 \to \mathbb{N}\\
\mathtt{/}:& \mathbb{S}_1 \times \mathbb{S}_2 \to \mathbb{N}
\end{array}
\right.
\end{equation*}
#+end_src
Observe that ~-~ is *not* in the list.
- Operators that return an integer ~Z~.
#+begin_src latex :results drawer :exports results
\begin{equation*}
\forall \mathbb{S}_1, \mathbb{S}_2 \in \{\mathbb{B},\mathbb{N},\mathbb{Z}\},
\mbox{ such that }\mathbb{S}_1 = \mathbb{Z}\mbox{ or }\mathbb{S}_2 = \mathbb{Z},
\quad
\left|
\begin{array}{rl}
\mathtt{+}:& \mathbb{S}_1 \times \mathbb{S}_2 \to \mathbb{Z}\\
\mathtt{-}:& \mathbb{S}_1 \times \mathbb{S}_2 \to \mathbb{Z}\\
\mathtt{*}:& \mathbb{S}_1 \times \mathbb{S}_2 \to \mathbb{Z}\\
\mathtt{/}:& \mathbb{S}_1 \times \mathbb{S}_2 \to \mathbb{Z}
\end{array}
\right.
\end{equation*}
#+end_src
Finally the following operator is also defined
#+begin_src latex :results drawer :exports results
\begin{equation*}
\mathtt{-}: \mathbb{N} \times \mathbb{N} \to \mathbb{Z}
\end{equation*}
#+end_src
The difference of two natural integers returns a /signed/ integer.
- Operators that return a real ~R~.
#+begin_src latex :results drawer :exports results
\begin{equation*}
\forall \mathbb{S}_1, \mathbb{S}_2 \in \{\mathbb{B},\mathbb{N},\mathbb{Z},\mathbb{R}\},
\mbox{ such that }\mathbb{S}_1 = \mathbb{R}\mbox{ or }\mathbb{S}_2 = \mathbb{R},
\quad
\left|
\begin{array}{rl}
\mathtt{+}:& \mathbb{S}_1 \times \mathbb{S}_2 \to \mathbb{R}\\
\mathtt{-}:& \mathbb{S}_1 \times \mathbb{S}_2 \to \mathbb{R}\\
\mathtt{*}:& \mathbb{S}_1 \times \mathbb{S}_2 \to \mathbb{R}\\
\mathtt{/}:& \mathbb{S}_1 \times \mathbb{S}_2 \to \mathbb{R}
\end{array}
\right.
\end{equation*}
#+end_src
- Operators that return a small vector ~R^d~.
#+begin_src latex :results drawer :exports results
\begin{equation*}
\forall d \in\{1,2,3\},
\quad
\left|
\begin{array}{rl}
\mathtt{+}:& \mathbb{R}^d \times \mathbb{R}^d \to \mathbb{R}^d\\
\mathtt{-}:& \mathbb{R}^d \times \mathbb{R}^d \to \mathbb{R}^d\\
\mathtt{*}:& \mathbb{B} \times \mathbb{R}^d \to \mathbb{R}^d\\
\mathtt{*}:& \mathbb{N} \times \mathbb{R}^d \to \mathbb{R}^d\\
\mathtt{*}:& \mathbb{Z} \times \mathbb{R}^d \to \mathbb{R}^d\\
\mathtt{*}:& \mathbb{R} \times \mathbb{R}^d \to \mathbb{R}^d\\
\mathtt{*}:& \mathbb{R}^{d\times d} \times \mathbb{R}^d \to \mathbb{R}^d
\end{array}
\right.
\end{equation*}
#+end_src
- Operators that return a small matrix ~R^dxd~.
#+begin_src latex :results drawer :exports results
\begin{equation*}
\forall d \in\{1,2,3\},
\quad
\left|
\begin{array}{rl}
\mathtt{+}:& \mathbb{R}^{d\times d} \times \mathbb{R}^{d\times d} \to \mathbb{R}^{d\times d}\\
\mathtt{-}:& \mathbb{R}^{d\times d} \times \mathbb{R}^{d\times d} \to \mathbb{R}^{d\times d}\\
\mathtt{*}:& \mathbb{B} \times \mathbb{R}^{d\times d} \to \mathbb{R}^{d\times d}\\
\mathtt{*}:& \mathbb{N} \times \mathbb{R}^{d\times d} \to \mathbb{R}^{d\times d}\\
\mathtt{*}:& \mathbb{Z} \times \mathbb{R}^{d\times d} \to \mathbb{R}^{d\times d}\\
\mathtt{*}:& \mathbb{R} \times \mathbb{R}^{d\times d} \to \mathbb{R}^{d\times d}\\
\mathtt{*}:& \mathbb{R}^{d\times d} \times \mathbb{R}^{d\times d} \to \mathbb{R}^{d\times d}
\end{array}
\right.
\end{equation*}
#+end_src
- Operators that return a ~string~.
#+begin_src latex :results drawer :exports results
\begin{equation*}
\forall \mathbb{S} \in \{\mathbb{B},\mathbb{N},\mathbb{Z},\mathbb{R}, \mathbb{R}^1, \mathbb{R}^2, \mathbb{R}^3, \mathbb{R}^{1\times1}, \mathbb{R}^{2\times2}, \mathbb{R}^{3\times3}\},
\quad
\left|
\begin{array}{rl}
\mathtt{+}:& \mathbb{S} \times \mathtt{string} \to \mathtt{string}\\
\mathtt{+}:& \mathtt{string} \times \mathbb{S} \to \mathtt{string}\\
\mathtt{+}:& \mathtt{string} \times \mathtt{string} \to \mathtt{string}
\end{array}
\right.
\end{equation*}
#+end_src
*** TODO High-level types<<high-level-types>>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment