# List of GEL operators

As everything in gel is really just an expression, it is really just all connected together with operators. Here is a list of the operators in GEL.

    a;b

  The separator, just evaluates both `a` and `b`, but returns only the result of `b`.

    a=b

  The assignment operator. This assigns `b` to `a` (`a` must be a valid lvalue) (note however that this operator may be translated to `==` if used in a place where boolean expression is expected)

    a:=b

  The assignment operator. Assigns `b` to `a` (`a` must be a valid lvalue). This is different from `=` because it never gets translated to a `==`.

    |a|

  Absolute value or modulus (if `a` is a complex number).

  See Mathworld for more information.

    a^b

  Exponentiation, raises `a` to the `b`th power.

    a.^b

  Element by element exponentiation. Raise each element of a matrix `a` to the `b`th power. Or if `b` is a matrix of the same size as `a`, then do the operation element by element. If `a` is a number and `b` is a matrix then it creates matrix of the same size as `b` with `a` raised to all the different powers in `b`.

    a+b

  Addition. Adds two numbers, matrices, functions or strings. If you add a string to anything the result will just be a string.

    a-b

  Subtraction. Subtract two numbers, matrices or functions.

    a*b

  Multiplication. This is the normal matrix multiplication.

    a.*b

  Element by element multiplication if `a` and `b` are matrices.

    a/b

  Division.

    a./b

  Element by element division.

    a\b

  Back division. That is this is the same as `b/a`.

    a.\b

  Element by element back division.

    a%b

  The mod operator. This does not turn on the modular mode, but just returns the remainder of `a/b`.

    a.%b

  Element by element the mod operator. Returns the remaineder after element by element `a./b`.

    a mod b

  Modular evaluation operator. The expression `a` is evaluated modulo `b`. See . Some functions and operators behave differently modulo an integer.

    a!

  Factorial operator. This is like `1*...*(n-2)*(n-1)*n`.

    a!!

  Double factorial operator. This is like `1*...*(n-4)*(n-2)*n`.

    a==b

  Equality operator (returns `true` or `false`).

    a!=b

  Inequality operator, returns `true` if `a` does not equal `b` else returns `false`.

    a<>b

  Alternative inequality operator, returns `true` if `a` does not equal `b` else returns `false`.

    a<=b

  Less than or equal operator, returns `true` if `a` is less than or equal to `b` else returns `false`.

    a>=b

  Greater than or equal operator, returns `true` if `a` is greater than or equal to `b` else returns `false`.

    a<=>b

  Comparison operator. If `a` is equal to `b` it returns 0, if `a` is less than `b` it returns -1 and if `a` is greater than `b` it returns 1.

    a and b

  Logical and.

    a or b

  Logical or.

    a xor b

  Logical xor.

    not a

  Logical not.

    -a

  Negation operator.

    &a

  Variable referencing (to pass a reference to something). See .

    *a

  Variable dereferencing (to access a referenced varible). See .

    a'

  Matrix conjugate transpose.

    a.'

  Matrix transpose, does not conjugate the entries.

    a@(b,c)

  Get element of a matrix in row `b` and column `c`. If `b`, `c` are vectors, then this gets the corresponding rows columns or submatrices.

    a@(b,)

  Get row of a matrix (or rows if `b` is a vector).

    a@(b,:)

  Same as above.

    a@(,c)

  Get column of a matrix (or columns if `c` is a vector).

    a@(:,c)

  Same as above.

    a@(b)

  Get an element from a matrix treating it as a vector. This will traverse the matrix row-wise.

    a:b

  Build a vector from `a` to `b` (or specify a row, column region for the `@` operator). For example to get rows 2 to 4 of mamtrix `A` we could do

      A@(2:4,)

  as `2:4` will return a vector `[2,3,4]`.

    a:b:c

  Build a vector from `a` to `c` with `b` as a step. That is for example

      genius> 1:2:9
      =
      `[1     3       5       7       9]

    (a)i

  Make a imaginary number (multiply `a` by the imaginary). Note that normally the number `i` is written as `1i`. So the above is equal to

      (a)*1i

    `a

  Quote an identifier so that it doesn't get evaluated. Or quote a matrix so that it doesn't get expanded.

The @() operator makes the : operator most useful. With this you can specify regions of a matrix. So that a@(2:4,6) is the rows 2,3,4 of the column 6. Or a@(,1:2) will get you the first two columns of a matrix. You can also assign to the @() operator, as long as the right value is a matrix that matches the region in size, or if it is any other type of value.

The comparison operators (except for the <=> operator which behaves normally), are not strictly binary operators, they can in fact be grouped in the normal mathematical way, e.g.: (1<x<=y<5) is a legal boolean expression and means just what it should, that is (1<x and x≤y and y<5)

The unitary minus operates in a different fashion depending on where it appears. If it appears before a number it binds very closely, if it appears in front of an expression it binds less than the power and factorial operators. So for example -1^k is really (-1)^k, but -foo(1)^k is really -(foo(1)^k). So be careful how you use it and if in doubt, add parentheses.