Important
• x and y represent numerical values or variables.
• m, n, and p represent integer values or variables.
• a and b represent boolean values or variables.
• U and V represent matrices of numerical values.
• A and B represent matrices of boolean values.
Arithmetic operators
Operator | Operator name | Syntax |
---|---|---|
+ | Addition | x+y U + V (U and V are m x n matrices) |
- | Subtraction | x-y U + V (U and V are m x n matrices) |
* | Multiplication | x*y U*V (U is an m x n matrix and V is an n x p matrix) |
/ | Division | x/y |
% | Modulus | m%n U + V (U and V are m x n matrices of integer values). This operator operates element-wise on matrices. |
! | Factorial | m! |
^ | Power | x^y |
\ | Left division | x\y is equivalent to (1/x) * y U \ V (U and V are m x n matrices) is equivalent to (1/U) * V |
.* | Element-wise multiplication | U .* V (U and V are m x n matrices) |
./ | Element-wise division | U ./ V (U and V are m x n matrices) |
.\ | Element-wise left division | U .\ V (U and V are m x n matrices) is equivalent to (1/U) .* V |
.^ | Element-wise power | U .^ V (U and V are m x n matrices) |
Note
An Element-wise operator performs an operation on each pair of Elements, which is in the same location, of the operand matrices.
Assignment operators
Operator | Operator | Syntax |
---|---|---|
= | Assignment | x=y a=b U=V |
Comparison operators
Operator | Operator name | Syntax |
---|---|---|
> | Greater | x>y U>V |
< | Less | x<y U<V |
>= | Greater or Equal | x>=y U>=V |
<= | Less of Equal | x<=y U<=V |
== | Equality | x==y a==b U==V |
!= | Inequality | x!=y a!=b U!=V |
All comparison operators operate Element-wise on matrices in the example as follows
A = [1; 2; 3]
B = [3; 2; 1]
Then
A>B is [false; false; true];
Boolean operators
Operator | Operator Name | Syntax |
---|---|---|
! | NOT | !a !A |
& | AND | a&b A&B |
| | OR | a|b A|B |
^ | XOR (exclusive OR) | a^b A^B |
Important
All boolean operators operate element-wise on matrices in the example as follows
A = [true; true; false; false];
B = [true; false; true; false];
Then
A&B is [true; false; false; false];