⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 assignop.htm

📁 This matrix C++ template class library is for performing common matrix operations in your C++ progra
💻 HTM
字号:
<html>
<head>
  <link rel=stylesheet href="styles.css" type="text/css">
  <title>Assignment and computed assignment operators</title>
</head>
<body>

<h6 align=right>
<a href="submat.htm">Prev</a> |
<a href="manual.htm">Up</a> |
<a href="unaryop.htm">Next</a>
</h6>

<h2>Assignment and computed assignment operators</h2>

<p>
The following assignment and computed assignment operators are available for the matrix class.
</p>

<pre><code><a href="#o1">1</a>. matrix&lt;T&gt;&amp; operator= (const matrix&lt;T&gt;& <i>m</i>);
<a href="#o2">2</a>. matrix&lt;T&gt;&amp; operator= (const T& <i>e</i>);
<a href="#o3">3</a>. template &lt;class X&gt; matrix&lt;T&gt;&amp; operator= (const matrix&lt;X&gt;&amp; <i>m</i>);

<a href="#o4">4</a>. matrix&lt;T&gt;&amp; operator+= (const matrix&lt;T&gt;&amp; <i>m</i>);
<a href="#o5">5</a>. matrix&lt;T&gt;&amp; operator-= (const matrix&lt;T&gt;&amp; <i>m</i>);
<a href="#o6">6</a>. matrix&lt;T&gt;&amp; operator*= (const matrix&lt;T&gt;&amp; <i>m</i>);
<a href="#o7">7</a>. matrix&lt;T&gt;&amp; operator/= (const matrix&lt;T&gt;&amp; <i>m</i>);
<a href="#o8">8</a>. matrix&lt;T&gt;&amp; operator*= (const T&amp; <i>e</i>);
<a href="#o9">9</a>. matrix&lt;T&gt;&amp; operator/= (const T&amp; <i>e</i>);

</code></pre>

<h4>Parameter</h4>

<p>
<dl>
<dt><i>m</i></dt>
<dd>A matrix object.</dd>

<dt><i>e</i></dt>
<dd>A number of type T.</dd>
</dl>
</p>

<p>
<ol>
<li><a name="o1">Assigns the matrix <i>m</i> to the left-hand side matrix. The size of the matrices need not be equal.</li><br><br>

<li><a name="o2">Assigns the value of <i>e</i> to all elements of the left-hand side matrix.</li><br><br>

<li><a name="o3">Assigns the matrix <i>m</i> of type X to the left hand-side matrix. The compiler must have member template support for this operator to work.</li><br><br>

<li><a name="o4">Adds the matrix <i>m</i> to the left-hand side matrix. The matrices must be equal in row and column size, otherwise this operator throws <i>invalid_argument</i> exception if range checking is enabled.
</li><br><br>

<li><a name="o5">Subtracts the matrix <i>m</i> from the left-hand side matrix. The matrices must be equal in row and column size, otherwise, this operator throws <i>invalid_argument</i> exception if range checking is enabled.</li><br><br>

<li><a name="o6">Multiply the matrix <i>m</i> to the left-hand side matrix. The column number of left-hand side matrix must be equal to row number of right-hand side matrix, otherwise, this operator throws <i>invalid_argument</i> exception if range checking is enabled.</li><br><br>

<li><a name="o7">Performs a simulated division by multiplying the inverse of the matrix <i>m</i> to the left-hand side matrix. The column number of left-hand side matrix must be equal to row number of right-hand side matrix, and the right-hand side matrix must be non-singular. This operator may throw <i>invalid_argument</i> or <i>runtime_error</i> exception.
</li><br><br>

<li><a name="o8">Multiplies all elements of the left-hand side matrix by <i>e</i>.</li><br><br>

<li><a name="o9">Divides all elements of the left-hand side matrix by <i>e</i>.</li><br><br>
</ol>
</p>

<h5>Examples</h5>

<pre><code>typedef matrix&lt;double&gt; Matrix;
typedef matrix&lt;complex&lt;double&gt; &gt; CMatrix;

Matrix A, B(3,3);
CMatrix CA(3,3);

B.rand();
A = B;
A = 0.0;

CA = A;

CA += CA;

A *= 3.0;
A /= 2;

A -= B;
A *= B;
A /= B;

</code></pre>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -