Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 641ebb3060c35990cc021d8f7aaf9aca > files > 89

octave-doc-5.1.0-7.1.mga7.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Arithmetic Ops (GNU Octave (version 5.1.0))</title>

<meta name="description" content="Arithmetic Ops (GNU Octave (version 5.1.0))">
<meta name="keywords" content="Arithmetic Ops (GNU Octave (version 5.1.0))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Expressions.html#Expressions" rel="up" title="Expressions">
<link href="Comparison-Ops.html#Comparison-Ops" rel="next" title="Comparison Ops">
<link href="Access-via-Handle.html#Access-via-Handle" rel="prev" title="Access via Handle">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>
<link rel="stylesheet" type="text/css" href="octave.css">


</head>

<body lang="en">
<a name="Arithmetic-Ops"></a>
<div class="header">
<p>
Next: <a href="Comparison-Ops.html#Comparison-Ops" accesskey="n" rel="next">Comparison Ops</a>, Previous: <a href="Calling-Functions.html#Calling-Functions" accesskey="p" rel="prev">Calling Functions</a>, Up: <a href="Expressions.html#Expressions" accesskey="u" rel="up">Expressions</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Arithmetic-Operators"></a>
<h3 class="section">8.3 Arithmetic Operators</h3>
<a name="index-arithmetic-operators"></a>
<a name="index-operators_002c-arithmetic"></a>
<a name="index-addition"></a>
<a name="index-subtraction"></a>
<a name="index-multiplication"></a>
<a name="index-matrix-multiplication"></a>
<a name="index-division"></a>
<a name="index-quotient"></a>
<a name="index-negation"></a>
<a name="index-unary-minus"></a>
<a name="index-exponentiation"></a>
<a name="index-transpose"></a>
<a name="index-Hermitian-operator"></a>
<a name="index-transpose_002c-complex_002dconjugate"></a>
<a name="index-complex_002dconjugate-transpose"></a>

<p>The following arithmetic operators are available, and work on scalars
and matrices.  The element-by-element operators and functions broadcast
(see <a href="Broadcasting.html#Broadcasting">Broadcasting</a>).
</p>
<dl compact="compact">
<dt><var>x</var> + <var>y</var></dt>
<dd><a name="index-_002b"></a>
<p>Addition.  If both operands are matrices, the number of rows and columns
must both agree, or they must be broadcastable to the same shape.
</p>
</dd>
<dt><var>x</var> .+ <var>y</var></dt>
<dd><a name="index-_002e_002b"></a>
<p>Element-by-element addition.  This operator is equivalent to <code>+</code>.
</p>
</dd>
<dt><var>x</var> - <var>y</var></dt>
<dd><a name="index-_002d"></a>
<p>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.
</p>
</dd>
<dt><var>x</var> .- <var>y</var></dt>
<dd><p>Element-by-element subtraction.  This operator is equivalent to <code>-</code>.
</p>
</dd>
<dt><var>x</var> * <var>y</var></dt>
<dd><a name="index-_002a"></a>
<p>Matrix multiplication.  The number of columns of <var>x</var> must agree with
the number of rows of <var>y</var>.
</p>
</dd>
<dt><var>x</var> .* <var>y</var></dt>
<dd><a name="index-_002e_002a"></a>
<p>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.
</p>
</dd>
<dt><var>x</var> / <var>y</var></dt>
<dd><a name="index-_002f"></a>
<p>Right division.  This is conceptually equivalent to the expression
</p>
<div class="example">
<pre class="example">(inverse (y') * x')'
</pre></div>

<p>but it is computed without forming the inverse of <var>y&rsquo;</var>.
</p>
<p>If the system is not square, or if the coefficient matrix is singular,
a minimum norm solution is computed.
</p>
</dd>
<dt><var>x</var> ./ <var>y</var></dt>
<dd><a name="index-_002e_002f"></a>
<p>Element-by-element right division.
</p>
</dd>
<dt><var>x</var> \ <var>y</var></dt>
<dd><a name="index-_005c"></a>
<p>Left division.  This is conceptually equivalent to the expression
</p>
<div class="example">
<pre class="example">inverse (x) * y
</pre></div>

<p>but it is computed without forming the inverse of <var>x</var>.
</p>
<p>If the system is not square, or if the coefficient matrix is singular,
a minimum norm solution is computed.
</p>
</dd>
<dt><var>x</var> .\ <var>y</var></dt>
<dd><a name="index-_002e_005c"></a>
<p>Element-by-element left division.  Each element of <var>y</var> is divided
by each corresponding element of <var>x</var>.
</p>
</dd>
<dt><var>x</var> ^ <var>y</var></dt>
<dt><var>x</var> ** <var>y</var></dt>
<dd><a name="index-_002a_002a"></a>
<a name="index-_005e"></a>
<p>Power operator.  If <var>x</var> and <var>y</var> are both scalars, this operator
returns <var>x</var> raised to the power <var>y</var>.  If <var>x</var> is a scalar and
<var>y</var> is a square matrix, the result is computed using an eigenvalue
expansion.  If <var>x</var> is a square matrix, the result is computed by
repeated multiplication if <var>y</var> is an integer, and by an eigenvalue
expansion if <var>y</var> is not an integer.  An error results if both
<var>x</var> and <var>y</var> are matrices.
</p>
<p>The implementation of this operator needs to be improved.
</p>
</dd>
<dt><var>x</var> .^ <var>y</var></dt>
<dt><var>x</var> .** <var>y</var></dt>
<dd><a name="index-_002e_002a_002a"></a>
<a name="index-_002e_005e"></a>
<p>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 <code>realpow</code>, <code>realsqrt</code>, <code>cbrt</code>, or <code>nthroot</code> if a
real result is preferred.
</p>
</dd>
<dt>-<var>x</var></dt>
<dd><a name="index-_002d-1"></a>
<p>Negation.
</p>
</dd>
<dt>+<var>x</var></dt>
<dd><a name="index-_002b-1"></a>
<p>Unary plus.  This operator has no effect on the operand.
</p>
</dd>
<dt><var>x</var>&rsquo;</dt>
<dd><a name="index-_0027-2"></a>
<p>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
</p>
<div class="example">
<pre class="example">conj (x.')
</pre></div>

</dd>
<dt><var>x</var>.&rsquo;</dt>
<dd><a name="index-_002e_0027"></a>
<p>Transpose.
</p></dd>
</dl>

<p>Note that because Octave&rsquo;s element-by-element operators begin with a
&lsquo;<samp>.</samp>&rsquo;, there is a possible ambiguity for statements like
</p>
<div class="example">
<pre class="example">1./m
</pre></div>

<p>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
</p>
<div class="example">
<pre class="example">(1) ./ m
</pre></div>

<p>and not
</p>
<div class="example">
<pre class="example">(1.) / m
</pre></div>

<p>Although this is inconsistent with the normal behavior of Octave&rsquo;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.
</p>
<a name="index-_0027-3"></a>
<a name="XREFctranspose"></a><dl>
<dt><a name="index-ctranspose"></a><em></em> <strong>ctranspose</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Return the complex conjugate transpose of <var>x</var>.
</p>
<p>This function and <code><var>x</var>'</code> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFtranspose">transpose</a>.
</p></dd></dl>


<a name="index-_002e_005c-1"></a>
<a name="XREFldivide"></a><dl>
<dt><a name="index-ldivide"></a><em></em> <strong>ldivide</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dd><p>Return the element-by-element left division of <var>x</var> and <var>y</var>.
</p>
<p>This function and <code><var>x</var>&nbsp;.\&nbsp;<var>y</var></code><!-- /@w --> are
equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFrdivide">rdivide</a>, <a href="#XREFmldivide">mldivide</a>, <a href="#XREFtimes">times</a>, <a href="#XREFplus">plus</a>.
</p></dd></dl>


<a name="index-_002d-2"></a>
<a name="XREFminus"></a><dl>
<dt><a name="index-minus"></a><em></em> <strong>minus</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dd><p>This function and <code><var>x</var>&nbsp;<span class="nolinebreak">-</span>&nbsp;<var>y</var></code><!-- /@w --> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFplus">plus</a>, <a href="#XREFuminus">uminus</a>.
</p></dd></dl>


<a name="index-_005c-1"></a>
<a name="XREFmldivide"></a><dl>
<dt><a name="index-mldivide"></a><em></em> <strong>mldivide</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dd><p>Return the matrix left division of <var>x</var> and <var>y</var>.
</p>
<p>This function and <code><var>x</var>&nbsp;\&nbsp;<var>y</var></code><!-- /@w --> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFmrdivide">mrdivide</a>, <a href="#XREFldivide">ldivide</a>, <a href="#XREFrdivide">rdivide</a>.
</p></dd></dl>


<a name="index-_002a_002a-1"></a>
<a name="index-_005e-1"></a>
<a name="XREFmpower"></a><dl>
<dt><a name="index-mpower"></a><em></em> <strong>mpower</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dd><p>Return the matrix power operation of <var>x</var> raised to the <var>y</var> power.
</p>
<p>This function and <code><var>x</var>&nbsp;^&nbsp;<var>y</var></code><!-- /@w --> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFpower">power</a>, <a href="#XREFmtimes">mtimes</a>, <a href="#XREFplus">plus</a>, <a href="#XREFminus">minus</a>.
</p></dd></dl>


<a name="index-_002f-1"></a>
<a name="XREFmrdivide"></a><dl>
<dt><a name="index-mrdivide"></a><em></em> <strong>mrdivide</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dd><p>Return the matrix right division of <var>x</var> and <var>y</var>.
</p>
<p>This function and <code><var>x</var>&nbsp;/&nbsp;<var>y</var></code><!-- /@w --> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFmldivide">mldivide</a>, <a href="#XREFrdivide">rdivide</a>, <a href="#XREFplus">plus</a>, <a href="#XREFminus">minus</a>.
</p></dd></dl>


<a name="index-_002a-1"></a>
<a name="XREFmtimes"></a><dl>
<dt><a name="index-mtimes"></a><em></em> <strong>mtimes</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dt><a name="index-mtimes-1"></a><em></em> <strong>mtimes</strong> <em>(<var>x1</var>, <var>x2</var>, &hellip;)</em></dt>
<dd><p>Return the matrix multiplication product of inputs.
</p>
<p>This function and <code><var>x</var>&nbsp;*&nbsp;<var>y</var></code><!-- /@w --> are equivalent.
If more arguments are given, the multiplication is applied
cumulatively from left to right:
</p>
<div class="example">
<pre class="example">(&hellip;((<var>x1</var> * <var>x2</var>) * <var>x3</var>) * &hellip;)
</pre></div>


<p><strong>See also:</strong> <a href="#XREFtimes">times</a>, <a href="#XREFplus">plus</a>, <a href="#XREFminus">minus</a>, <a href="#XREFrdivide">rdivide</a>, <a href="#XREFmrdivide">mrdivide</a>, <a href="#XREFmldivide">mldivide</a>, <a href="#XREFmpower">mpower</a>.
</p></dd></dl>


<a name="index-_002b-2"></a>
<a name="XREFplus"></a><dl>
<dt><a name="index-plus"></a><em></em> <strong>plus</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dt><a name="index-plus-1"></a><em></em> <strong>plus</strong> <em>(<var>x1</var>, <var>x2</var>, &hellip;)</em></dt>
<dd><p>This function and <code><var>x</var>&nbsp;+&nbsp;<var>y</var></code><!-- /@w --> are equivalent.
</p>
<p>If more arguments are given, the summation is applied
cumulatively from left to right:
</p>
<div class="example">
<pre class="example">(&hellip;((<var>x1</var> + <var>x2</var>) + <var>x3</var>) + &hellip;)
</pre></div>


<p><strong>See also:</strong> <a href="#XREFminus">minus</a>, <a href="#XREFuplus">uplus</a>.
</p></dd></dl>


<a name="index-_002e_002a_002a-1"></a>
<a name="index-_002e_005e-1"></a>
<a name="XREFpower"></a><dl>
<dt><a name="index-power"></a><em></em> <strong>power</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dd><p>Return the element-by-element operation of <var>x</var> raised to the
<var>y</var> power.
</p>
<p>This function and <code><var>x</var>&nbsp;.^&nbsp;<var>y</var></code><!-- /@w --> are equivalent.
</p>
<p>If several complex results are possible, returns the one with smallest
non-negative argument (angle).  Use <code>realpow</code>, <code>realsqrt</code>,
<code>cbrt</code>, or <code>nthroot</code> if a real result is preferred.
</p>

<p><strong>See also:</strong> <a href="#XREFmpower">mpower</a>, <a href="Exponents-and-Logarithms.html#XREFrealpow">realpow</a>, <a href="Exponents-and-Logarithms.html#XREFrealsqrt">realsqrt</a>, <a href="Exponents-and-Logarithms.html#XREFcbrt">cbrt</a>, <a href="Exponents-and-Logarithms.html#XREFnthroot">nthroot</a>.
</p></dd></dl>


<a name="index-_002e_002f-1"></a>
<a name="XREFrdivide"></a><dl>
<dt><a name="index-rdivide"></a><em></em> <strong>rdivide</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dd><p>Return the element-by-element right division of <var>x</var> and <var>y</var>.
</p>
<p>This function and <code><var>x</var>&nbsp;./&nbsp;<var>y</var></code><!-- /@w --> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFldivide">ldivide</a>, <a href="#XREFmrdivide">mrdivide</a>, <a href="#XREFtimes">times</a>, <a href="#XREFplus">plus</a>.
</p></dd></dl>


<a name="index-_002e_002a-1"></a>
<a name="XREFtimes"></a><dl>
<dt><a name="index-times"></a><em></em> <strong>times</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dt><a name="index-times-1"></a><em></em> <strong>times</strong> <em>(<var>x1</var>, <var>x2</var>, &hellip;)</em></dt>
<dd><p>Return the element-by-element multiplication product of inputs.
</p>
<p>This function and <code><var>x</var>&nbsp;.*&nbsp;<var>y</var></code><!-- /@w --> are equivalent.
If more arguments are given, the multiplication is applied
cumulatively from left to right:
</p>
<div class="example">
<pre class="example">(&hellip;((<var>x1</var> .* <var>x2</var>) .* <var>x3</var>) .* &hellip;)
</pre></div>


<p><strong>See also:</strong> <a href="#XREFmtimes">mtimes</a>, <a href="#XREFrdivide">rdivide</a>.
</p></dd></dl>


<a name="index-_002e_0027-1"></a>
<a name="XREFtranspose"></a><dl>
<dt><a name="index-transpose-2"></a><em></em> <strong>transpose</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Return the transpose of <var>x</var>.
</p>
<p>This function and <code><var>x</var>.'</code> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFctranspose">ctranspose</a>.
</p></dd></dl>


<a name="index-_002d-3"></a>
<a name="XREFuminus"></a><dl>
<dt><a name="index-uminus"></a><em></em> <strong>uminus</strong> <em>(<var>x</var>)</em></dt>
<dd><p>This function and <code><span class="nolinebreak">-</span>&nbsp;<var>x</var></code><!-- /@w --> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFuplus">uplus</a>, <a href="#XREFminus">minus</a>.
</p></dd></dl>


<a name="index-_002b-3"></a>
<a name="XREFuplus"></a><dl>
<dt><a name="index-uplus"></a><em></em> <strong>uplus</strong> <em>(<var>x</var>)</em></dt>
<dd><p>This function and <code>+&nbsp;<var>x</var></code><!-- /@w --> are equivalent.
</p>
<p><strong>See also:</strong> <a href="#XREFuminus">uminus</a>, <a href="#XREFplus">plus</a>, <a href="#XREFminus">minus</a>.
</p></dd></dl>


<hr>
<div class="header">
<p>
Next: <a href="Comparison-Ops.html#Comparison-Ops" accesskey="n" rel="next">Comparison Ops</a>, Previous: <a href="Calling-Functions.html#Calling-Functions" accesskey="p" rel="prev">Calling Functions</a>, Up: <a href="Expressions.html#Expressions" accesskey="u" rel="up">Expressions</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>