Sophie

Sophie

distrib > Mageia > 7 > armv7hl > by-pkgid > 641ebb3060c35990cc021d8f7aaf9aca > files > 390

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>Operator Overloading (GNU Octave (version 5.1.0))</title>

<meta name="description" content="Operator Overloading (GNU Octave (version 5.1.0))">
<meta name="keywords" content="Operator Overloading (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="Overloading-Objects.html#Overloading-Objects" rel="up" title="Overloading Objects">
<link href="Precedence-of-Objects.html#Precedence-of-Objects" rel="next" title="Precedence of Objects">
<link href="Function-Overloading.html#Function-Overloading" rel="prev" title="Function Overloading">
<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="Operator-Overloading"></a>
<div class="header">
<p>
Next: <a href="Precedence-of-Objects.html#Precedence-of-Objects" accesskey="n" rel="next">Precedence of Objects</a>, Previous: <a href="Function-Overloading.html#Function-Overloading" accesskey="p" rel="prev">Function Overloading</a>, Up: <a href="Overloading-Objects.html#Overloading-Objects" accesskey="u" rel="up">Overloading Objects</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="Operator-Overloading-1"></a>
<h4 class="subsection">34.4.2 Operator Overloading</h4>
<a name="index-addition-1"></a>
<a name="index-and-operator-1"></a>
<a name="index-arithmetic-operators-1"></a>
<a name="index-boolean-expressions-1"></a>
<a name="index-boolean-operators-1"></a>
<a name="index-comparison-expressions-1"></a>
<a name="index-complex_002dconjugate-transpose-1"></a>
<a name="index-division-1"></a>
<a name="index-equality-operator-1"></a>
<a name="index-equality_002c-tests-for-1"></a>
<a name="index-exponentiation-1"></a>
<a name="index-expressions_002c-boolean-1"></a>
<a name="index-expressions_002c-comparison-1"></a>
<a name="index-expressions_002c-logical-1"></a>
<a name="index-greater-than-operator-1"></a>
<a name="index-Hermitian-operator-1"></a>
<a name="index-less-than-operator-1"></a>
<a name="index-logical-expressions-1"></a>
<a name="index-logical-operators-1"></a>
<a name="index-matrix-multiplication-1"></a>
<a name="index-multiplication-1"></a>
<a name="index-negation-1"></a>
<a name="index-not-operator-1"></a>
<a name="index-operators_002c-arithmetic-1"></a>
<a name="index-operators_002c-boolean-1"></a>
<a name="index-operators_002c-logical-1"></a>
<a name="index-operators_002c-relational-1"></a>
<a name="index-or-operator-1"></a>
<a name="index-quotient-1"></a>
<a name="index-relational-operators-1"></a>
<a name="index-subtraction-1"></a>
<a name="index-tests-for-equality-1"></a>
<a name="index-transpose-1"></a>
<a name="index-transpose_002c-complex_002dconjugate-1"></a>
<a name="index-unary-minus-1"></a>

<p>The following table shows, for each built-in numerical operation, the
corresponding function name to use when providing an overloaded method for a
user class.
</p>
<div class="float"><a name="tab_003aoverload_005fops"></a>
<a name="index-_002b-4"></a>
<a name="index-_002d-4"></a>
<a name="index-_002e_002a-2"></a>
<a name="index-_002a-2"></a>
<a name="index-_002e_002f-2"></a>
<a name="index-_002f-2"></a>
<a name="index-_002e_005c-2"></a>
<a name="index-_005c-2"></a>
<a name="index-_002e_005e-2"></a>
<a name="index-_005e-2"></a>
<a name="index-_003c-2"></a>
<a name="index-_003c_003d-2"></a>
<a name="index-_003e-2"></a>
<a name="index-_003e_003d-2"></a>
<a name="index-_003d_003d-2"></a>
<a name="index-_0021_003d-2"></a>
<a name="index-_007e_003d-2"></a>
<a name="index-_0026-2"></a>
<a name="index-_007c-2"></a>
<a name="index-_0021-2"></a>
<a name="index-_0027-4"></a>
<a name="index-_002e_0027-2"></a>
<a name="index-_003a-1"></a>
<a name="index-_003c-3"></a>

<table>
<thead><tr><th>Operation</th><th>Method</th><th>Description</th></tr></thead>
<tr><td><code>a + b</code></td><td><code>plus (a, b)</code></td><td>Binary addition</td></tr>
<tr><td><code>a - b</code></td><td><code>minus (a, b)</code></td><td>Binary subtraction</td></tr>
<tr><td><code>+a</code></td><td><code>uplus (a)</code></td><td>Unary addition</td></tr>
<tr><td><code>-a</code></td><td><code>uminus (a)</code></td><td>Unary subtraction</td></tr>
<tr><td><code>a .* b</code></td><td><code>times (a, b)</code></td><td>Element-wise multiplication</td></tr>
<tr><td><code>a * b</code></td><td><code>mtimes (a, b)</code></td><td>Matrix multiplication</td></tr>
<tr><td><code>a ./ b</code></td><td><code>rdivide (a, b)</code></td><td>Element-wise right division</td></tr>
<tr><td><code>a / b</code></td><td><code>mrdivide (a, b)</code></td><td>Matrix right division</td></tr>
<tr><td><code>a .\ b</code></td><td><code>ldivide (a, b)</code></td><td>Element-wise left division</td></tr>
<tr><td><code>a \ b</code></td><td><code>mldivide (a, b)</code></td><td>Matrix left division</td></tr>
<tr><td><code>a .^ b</code></td><td><code>power (a, b)</code></td><td>Element-wise power</td></tr>
<tr><td><code>a ^ b</code></td><td><code>mpower (a, b)</code></td><td>Matrix power</td></tr>
<tr><td><code>a &lt; b</code></td><td><code>lt (a, b)</code></td><td>Less than</td></tr>
<tr><td><code>a &lt;= b</code></td><td><code>le (a, b)</code></td><td>Less than or equal to</td></tr>
<tr><td><code>a &gt; b</code></td><td><code>gt (a, b)</code></td><td>Greater than</td></tr>
<tr><td><code>a &gt;= b</code></td><td><code>ge (a, b)</code></td><td>Greater than or equal to</td></tr>
<tr><td><code>a == b</code></td><td><code>eq (a, b)</code></td><td>Equal to</td></tr>
<tr><td><code>a != b</code></td><td><code>ne (a, b)</code></td><td>Not equal to</td></tr>
<tr><td><code>a &amp; b</code></td><td><code>and (a, b)</code></td><td>Logical and</td></tr>
<tr><td><code>a | b</code></td><td><code>or (a, b)</code></td><td>Logical or</td></tr>
<tr><td><code>!a</code></td><td><code>not (a)</code></td><td>Logical not</td></tr>
<tr><td><code>a'</code></td><td><code>ctranspose (a)</code></td><td>Complex conjugate transpose</td></tr>
<tr><td><code>a.'</code></td><td><code>transpose (a)</code></td><td>Transpose</td></tr>
<tr><td><code>a:b</code></td><td><code>colon (a, b)</code></td><td>Two element range</td></tr>
<tr><td><code>a:b:c</code></td><td><code>colon (a, b, c)</code></td><td>Three element range</td></tr>
<tr><td><code>[a, b]</code></td><td><code>horzcat (a, b)</code></td><td>Horizontal concatenation</td></tr>
<tr><td><code>[a; b]</code></td><td><code>vertcat (a, b)</code></td><td>Vertical concatenation</td></tr>
<tr><td><code>a(s<em>_1</em>,&hellip;,s<em>_n</em>)</code></td><td><code>subsref (a, s)</code></td><td>Subscripted reference</td></tr>
<tr><td><code>a(s<em>_1</em>,&hellip;,s<em>_n</em>) = b</code></td><td><code>subsasgn (a, s, b)</code></td><td>Subscripted assignment</td></tr>
<tr><td><code>b(a)</code></td><td><code>subsindex (a)</code></td><td>Convert object to index</td></tr>
<tr><td><code>disp</code></td><td><code>disp (a)</code></td><td>Object display</td></tr>
</table>

<div class="float-caption"><p><strong>Table 34.1: </strong>Available overloaded operators and their corresponding class method</p></div></div>
<p>An example <code>mtimes</code> method for the polynomial class might look like
</p>
<div class="example">
<pre class="verbatim">function p = mtimes (a, b)
  p = polynomial (conv (double (a), double (b)));
endfunction
</pre></div>

<hr>
<div class="header">
<p>
Next: <a href="Precedence-of-Objects.html#Precedence-of-Objects" accesskey="n" rel="next">Precedence of Objects</a>, Previous: <a href="Function-Overloading.html#Function-Overloading" accesskey="p" rel="prev">Function Overloading</a>, Up: <a href="Overloading-Objects.html#Overloading-Objects" accesskey="u" rel="up">Overloading Objects</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>