(octave.info)Arithmetic Ops


Next: Comparison Ops Prev: Calling Functions Up: Expressions
Enter node , (file) or (file)node

8.3 Arithmetic Operators
========================

The following arithmetic operators are available, and work on scalars
and matrices.  The element-by-element operators and functions broadcast
(Note: Broadcasting).

X + Y
     Addition.  If both operands are matrices, the number of rows and
     columns must both agree, or they must be broadcastable to the same
     shape.

X .+ Y
     Element-by-element addition.  This operator is equivalent to ‘+’.

X - Y
     Subtraction.  If both operands are matrices, the number of rows and
     columns of both must agree, or they must be broadcastable to the
     same shape.

X .- Y
     Element-by-element subtraction.  This operator is equivalent to
     ‘-’.

X * Y
     Matrix multiplication.  The number of columns of X must agree with
     the number of rows of Y.

X .* Y
     Element-by-element multiplication.  If both operands are matrices,
     the number of rows and columns must both agree, or they must be
     broadcastable to the same shape.

X / Y
     Right division.  This is conceptually equivalent to the expression

          (inverse (y') * x')'

     but it is computed without forming the inverse of Y’.

     If the system is not square, or if the coefficient matrix is
     singular, a minimum norm solution is computed.

X ./ Y
     Element-by-element right division.

X \ Y
     Left division.  This is conceptually equivalent to the expression

          inverse (x) * y

     but it is computed without forming the inverse of X.

     If the system is not square, or if the coefficient matrix is
     singular, a minimum norm solution is computed.

X .\ Y
     Element-by-element left division.  Each element of Y is divided by
     each corresponding element of X.

X ^ Y
X ** Y
     Power operator.  If X and Y are both scalars, this operator returns
     X raised to the power Y.  If X is a scalar and Y is a square
     matrix, the result is computed using an eigenvalue expansion.  If X
     is a square matrix, the result is computed by repeated
     multiplication if Y is an integer, and by an eigenvalue expansion
     if Y is not an integer.  An error results if both X and Y are
     matrices.

     The implementation of this operator needs to be improved.

X .^ Y
X .** Y
     Element-by-element power operator.  If both operands are matrices,
     the number of rows and columns must both agree, or they must be
     broadcastable to the same shape.  If several complex results are
     possible, the one with smallest non-negative argument (angle) is
     taken.  This rule may return a complex root even when a real root
     is also possible.  Use ‘realpow’, ‘realsqrt’, ‘cbrt’, or ‘nthroot’
     if a real result is preferred.

-X
     Negation.

+X
     Unary plus.  This operator has no effect on the operand.

X’
     Complex conjugate transpose.  For real arguments, this operator is
     the same as the transpose operator.  For complex arguments, this
     operator is equivalent to the expression

          conj (x.')

X.’
     Transpose.

   Note that because Octave’s element-by-element operators begin with a
‘.’, there is a possible ambiguity for statements like

     1./m

because the period could be interpreted either as part of the constant
or as part of the operator.  To resolve this conflict, Octave treats the
expression as if you had typed

     (1) ./ m

and not

     (1.) / m

Although this is inconsistent with the normal behavior of Octave’s
lexer, which usually prefers to break the input into tokens by
preferring the longest possible match at any given point, it is more
useful in this case.

 -- : ctranspose (X)
     Return the complex conjugate transpose of X.

     This function and X’ are equivalent.

     See also: Note: transpose.

 -- : ldivide (X, Y)
     Return the element-by-element left division of X and Y.

     This function and X .\ Y are equivalent.

     See also: Note: rdivide, Note: mldivide,
     Note: times, Note: plus.

 -- : minus (X, Y)
     This function and X - Y are equivalent.

     See also: Note: plus, Note: uminus.

 -- : mldivide (X, Y)
     Return the matrix left division of X and Y.

     This function and X \ Y are equivalent.

     See also: Note: mrdivide, Note: ldivide,
     Note: rdivide.

 -- : mpower (X, Y)
     Return the matrix power operation of X raised to the Y power.

     This function and X ^ Y are equivalent.

     See also: Note: power, Note: mtimes, Note:
     plus, Note: minus.

 -- : mrdivide (X, Y)
     Return the matrix right division of X and Y.

     This function and X / Y are equivalent.

     See also: Note: mldivide, Note: rdivide,
     Note: plus, Note: minus.

 -- : mtimes (X, Y)
 -- : mtimes (X1, X2, ...)
     Return the matrix multiplication product of inputs.

     This function and X * Y are equivalent.  If more arguments are
     given, the multiplication is applied cumulatively from left to
     right:

          (...((X1 * X2) * X3) * ...)

     At least one argument is required.

     See also: Note: times, Note: plus, Note:
     minus, Note: rdivide, *note mrdivide:
     XREFmrdivide, Note: mldivide, *note mpower:
     XREFmpower.

 -- : plus (X, Y)
 -- : plus (X1, X2, ...)
     This function and X + Y are equivalent.

     If more arguments are given, the summation is applied cumulatively
     from left to right:

          (...((X1 + X2) + X3) + ...)

     At least one argument is required.

     See also: Note: minus, Note: uplus.

 -- : power (X, Y)
     Return the element-by-element operation of X raised to the Y power.

     This function and X .^ Y are equivalent.

     If several complex results are possible, returns the one with
     smallest non-negative argument (angle).  Use ‘realpow’, ‘realsqrt’,
     ‘cbrt’, or ‘nthroot’ if a real result is preferred.

     See also: Note: mpower, Note: realpow,
     Note: realsqrt, Note: cbrt, *note nthroot:
     XREFnthroot.

 -- : rdivide (X, Y)
     Return the element-by-element right division of X and Y.

     This function and X ./ Y are equivalent.

     See also: Note: ldivide, Note: mrdivide,
     Note: times, Note: plus.

 -- : times (X, Y)
 -- : times (X1, X2, ...)
     Return the element-by-element multiplication product of inputs.

     This function and X .* Y are equivalent.  If more arguments are
     given, the multiplication is applied cumulatively from left to
     right:

          (...((X1 .* X2) .* X3) .* ...)

     At least one argument is required.

     See also: Note: mtimes, Note: rdivide.

 -- : transpose (X)
     Return the transpose of X.

     This function and X.’ are equivalent.

     See also: Note: ctranspose.

 -- : uminus (X)
     This function and - X are equivalent.

     See also: Note: uplus, Note: minus.

 -- : uplus (X)
     This function and + X are equivalent.

     See also: Note: uminus, Note: plus, Note:
     minus.


automatically generated by info2www version 1.2.2.9