Operators ========= Arithmetic operators ----------------------- +----------+----------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+ | Operator | Description | Example | +==========+======================================================================+======================================================================================================+ | `+` | :doc:`Addition <../addition>` | ``a + b`` Adds ``a`` and ``b``. | +----------+----------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+ | `-` | :doc:`Subtraction <../subtraction>` | ``a - b`` Subtracts ``b`` from ``a``. | +----------+----------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+ | `*` | :doc:`Matrix Multiplication <../matrix-multiplication>` | ``a * b`` Multiplies ``a`` and ``b`` if ``a`` and ``b`` are matrices or vectors. | | | | If either operand is a scalar, element-by-element multiplication will be performed. | +----------+----------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+ | `.*` | :doc:`ExE Multiplication <../element-by-element-multiplication>` | ``a .* b`` Multiplies elements of ``a`` and ``b``. | +----------+----------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+ | `/` | :doc:`Matrix Division <../matrix-division>` | ``a / b`` Computes the least squares solution if ``a`` and ``b`` are matrices or vectors. | | | | If either operand is a scalar, element-by-element division will be performed. | +----------+----------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+ | `./` | :doc:`ExE Division <../element-by-element-division>` | ``a ./ b`` Divides each element of ``a`` by the corresponding element of ``b``. | +----------+----------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+ | `.^` | :doc:`ExE Power <../element-by-element-power>` | ``a .^ b`` Raises each element of ``a`` to the power of ``b``. | +----------+----------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+ | `'` | :doc:`Transpose <../transpose>` | ``a'`` Transposes matrix ``a``, swapping its rows with columns. | +----------+----------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+ | `.'` | :doc:`Bookkeeping Transpose <../bookkeeping-transpose>` | ``a.'`` Transposes matrix ``a`` without conjugation, applicable to complex matrices. | +----------+----------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+ | `=` | :doc:`Assignment <../assignment>` | ``a = b`` Assigns ``b`` to ``a``. | +----------+----------------------------------------------------------------------+------------------------------------------------------------------------------------------------------+ Relational operators ----------------------- +------------+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------+ | Operator | Description | Example | +============+================================================================================+==========================================================================================================+ | `.==` | :doc:`Element-by-Element Equality <../exe-equal>` | ``a .== b`` Compares each element of ``a`` with ``b``, resulting in a matrix of 1's and 0's. | +------------+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------+ | `==` | :doc:`Equality <../equality>` | ``a == b`` Returns a scalar 1 (true) if all elements of ``a`` and ``b`` are equal, otherwise 0 (false). | +------------+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------+ | `!=` | :doc:`Inequality <../inequality>` | ``a != b`` Returns a scalar 1 (true) if ``a`` and ``b`` are not equal, otherwise 0 (false). | +------------+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------+ | `.!=` | :doc:`Element-by-Element Inequality <../exe-not-equal>` | ``a .!= b`` Compares each element of ``a`` with ``b``, resulting in a matrix of 1's and 0's. | +------------+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------+ | `.>=` | :doc:`Element-by-Element Greater or Equal <../exe-greater-than-equal>` | ``a .>= b`` Compares each element of ``a`` with ``b``, resulting in a matrix of 1's and 0's. | +------------+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------+ | `>=` | :doc:`Greater or Equal <../greater-or-equal>` | ``a >= b`` Returns 1 (true) if all elements of ``a`` are greater than or equal to those of ``b``, | | | | otherwise 0 (false). | +------------+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------+ | `.<=` | :doc:`Element-by-Element Less or Equal <../exe-less-than-equal>` | ``a .<= b`` Compares each element of ``a`` with ``b``, resulting in a matrix of 1's and 0's. | +------------+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------+ | `<=` | :doc:`Less or Equal <../less-or-equal>` | ``a <= b`` Returns a scalar 1 (true) if all elements of ``a`` are less than or equal to those of ``b``, | | | | otherwise 0 (false). | +------------+--------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------+