Arithmetic Operators (MATRIX-END MATRIX command)
You can add, subtract, multiply, or exponentiate matrices according to the rules of matrix algebra, or you can perform elementwise arithmetic, in which you multiply, divide, or exponentiate each element of a matrix separately. The arithmetic operators are listed below.
Unary −
. Sign reversal. A minus sign placed in front of a matrix reverses the sign of each
element. (The unary + is also accepted but has no effect.)
+
. Matrix addition. Corresponding elements of the two matrices are added. The matrices
must have the same dimensions, or one must be a scalar.
−
. Matrix subtraction. Corresponding elements of the two matrices are subtracted. The matrices
must have the same dimensions, or one must be a scalar.
*
. Multiplication. There are two cases. First, scalar multiplication: if either of the
matrices is a scalar, each element of the other matrix is multiplied
by that scalar. Second, matrix multiplication.
/. Division. The division operator performs elementwise division (described below).
True matrix division, the inverse operation of matrix multiplication,
is accomplished by taking the INV
function (square matrices) or the GINV
function (rectangular matrices) of the denominator and multiplying.
**
. Matrix exponentiation. A matrix can be raised only to an integer power. The matrix, which
must be square, is multiplied by itself as many times as the absolute
value of the exponent. If the exponent is negative, the result is
then inverted.
&*
. Elementwise
multiplication. Each element of the matrix is multiplied
by the corresponding element of the second matrix. The matrices must
have the same dimensions, or one must be a scalar.
&/
. Elementwise
division. Each element of the matrix is divided by the
corresponding element of the second matrix. The matrices must have
the same dimensions, or one must be a scalar.
&**
. Elementwise
exponentiation. Each element of the first matrix is raised
to the power of the corresponding element of the second matrix. The
matrices must have the same dimensions, or one must be a scalar.
:
. Sequential
integers. This operator creates a vector of consecutive
integers from the value preceding the operator to the value following
it. You can specify an optional increment following a second colon.
See Matrix Notation Shorthand (MATRIX-END MATRIX command) for
the principal use of this operator.
- Use these operators only with numeric matrices. The results are undefined when they are used with string matrices.