Operators - zward/Amua GitHub Wiki

The following types of operators are available:

Parentheses may be used to define the order of operations in an expression. For example (3 + 3) / 3 = 2, while 3 + 3 / 3 = 4.

Real Number Operators

The following operators can be used for any 2 real numbers.

Operator Description Example
+ Addition 3 + 3 = 6
- Subtraction 3 - 3 = 0
* Multiplication 3 * 3 = 9
/ Division 3 / 3 = 1
^ Exponentiation 3 ^ 3 = 27
% Modulus 6 % 3 = 0

Logical Operators

Logical operators evaluate an expression and return either true or false.

Operator Description Example
== Equal 3 == 3 returns true
!= Not equal 3 != 3 returns false
< Less than 3 < 4 returns true
> Greater than 3 > 4 returns false
<= Less than or equal to 3 <= 3 returns true
>= Greater than or equal to 3 >= 3 returns true
& And (3 > 4) & (3 > 2) returns false
| Or (3 > 4) | (3 > 2) returns true
^| Exclusive Or (2 > 1) ^| (3 > 2) returns false

Matrix Operators

Matrix operations can be performed on 2 matrices that are conformable, or on a matrix and real number. The following operators are supported.

Operator Description Expression Format Example
+ Addition Real number + Matrix 2 + [3 , 2] = [5 , 4]
Matrix + Real number [3 , 2] + 2 = [5 , 4]
Matrix + Matrix [1 , 2] + [3 , 4] = [4 , 6]
- Subtraction Real number - Matrix 2 - [3 , 2] = [-1 , 0]
Matrix - Real number [3 , 2] - 2 = [1 , 0]
Matrix - Matrix [1 , 2] - [3 , 4] = [-2 , -2]
* Multiplication Real number * Matrix 2 * [3 , 2] = [6 , 4]
Matrix * Real Number [3 , 2] * 2 = [6 , 4]
Matrix * Matrix [3 , 2] * tp([1 , 4]) = 11
/ Division Matrix / Real Number [6 , 4] / 2 = [3 , 2]
^ Exponentiation Matrix ^ Positive Integer n (multiplies a matrix by itself n times) [0.3 , 0.7] , [0.1 , 0.9](/zward/Amua/wiki/0.3-,-0.7]-,-[0.1-,-0.9) ^ 10 = [0.125 , 0.875] , [0.125 , 0.875](/zward/Amua/wiki/0.125-,-0.875]-,-[0.125-,-0.875)
% Modulus Matrix % Real Number [8 , 6] % 4 = [0 , 2]