-
Notifications
You must be signed in to change notification settings - Fork 6
Language Operators
Fred Rothganger edited this page Sep 11, 2024
·
9 revisions
Associativity | Precedence | Operator | Description |
---|---|---|---|
Left to Right | 1 | . | Namespace delimiter |
function() | Function call | ||
variable() | Access matrix element | ||
[] | Matrix constant | ||
(expression) | Override precedence | ||
' | Derivative with respect to time | ||
Right to Left | 2 | ^ | Exponentiation |
3 | - | Unary minus (makes a negative number) | |
! | Logical NOT; Matrix inversion | ||
~ | Matrix transpose | ||
Left to Right | 4 | * | Multiply. For matrices, this is the usual whole-matrix multiply. |
& | Matrix elementwise (Hadamard) multiply | ||
/ | Divide | ||
% | Modulo. Result has same sign as divisor. | ||
5 | + | Add | |
- | Subtract | ||
6 | < | Less than | |
<= | Less than or equal to | ||
> | Greater than | ||
>= | Greater than or equal to | ||
7 | == | Equal to. For matrices, returns a matrix indicating the result of elementwise comparison. To get back a single scalar value indicating whole-matrix equality, use the function equal(A,B). | |
!= | Not equal to | ||
8 | && | Logical AND | |
9 | || | Logical OR | |
10 | , | Separate expressions in a list, or elements in a row of a matrix. | |
11 | ; | Separate rows in a matrix | |
None | 12 | = | Defines a variable. By default it is temporary unless the compiler determines that it must be state (saved and buffered). |
=: | Defines a variable and explicitly makes it state rather than temporary. | ||
=; | Defines a variable and hints that it should be temporary, even if some criteria are not met (see Language: Order of Evaluation). The compiler will respect this if possible, but may still need to make it a state variable. | ||
=+ | Defines a state variable that accumulates the sum across multiple parts. This is a type of reduction operator. There is no corresponding =- operator because it would be ambiguous with an equation that starts with negation. | ||
=* | Accumulates the product | ||
=/ | Accumulates the quotient (product of reciprocals) | ||
=< | Accumulates the minimum | ||
=> | Accumulates the maximum | ||
13 | @ | Indicates conditional execution of an expression. |