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

📄 binaryop.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>Binary operators</title>
</head>
<body>

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

<h2>Binary operators</h2>

<p>
The following non-member binary operators are available for the matrix class. If the sizes of the matrices do not conform and range checking is enabled, i.e., the constant <i>RANGE_CHECK_</i> is defined, these operators may throw <i>invalid_argument</i> exception. 
</p>

<pre><code><a href="#b1">1</a>. matrix&lt;T&gt; operator+ (const matrix&lt;T&gt;&amp; <i>m1</i>, const matrix&lt;T&gt;&amp; <i>m2</i>);
<a href="#b2">2</a>. matrix&lt;T&gt; operator- (const matrix&lt;T&gt;&amp; <i>m1</i>, const matrix&lt;T&gt;&amp; <i>m2</i>);

<a href="#b3">3</a>. matrix&lt;T&gt; operator* (const matrix&lt;T&gt;&amp; <i>m1</i>, const matrix&lt;T&gt;&amp; <i>m2</i>);
<a href="#b4">4</a>. matrix&lt;T&gt; operator* (const matrix&lt;T&gt;&amp; <i>m</i>, const T&amp; <i>e</i>);
<a href="#b5">5</a>. matrix&lt;T&gt; operator* (const T&amp; <i>e</i>, const matrix&lt;T&gt;&amp; <i>m</i>);

<a href="#b6">6</a>. matrix&lt;T&gt; operator/ (const matrix&lt;T&gt;&amp; <i>m1</i>, const matrix&lt;T&gt;&amp; <i>m2</i>);
<a href="#b7">7</a>. matrix&lt;T&gt; operator/ (const matrix&lt;T&gt;&amp; <i>m</i>, const T&amp; <i>e</i>);
<a href="#b8">8</a>. matrix&lt;T&gt; operator/ (const T&amp; <i>e</i>, const matrix&lt;T&gt;&amp; <i>m</i>);

<a href="#b9">9</a>. valarray&lt;T&gt; operator* (const matrix&lt;T&gt;&amp; <i>m</i>, const valarray&lt;T&gt;&amp; <i>v</i>);
<a href="#b10">10</a>. valarray&lt;T&gt; operator* (const valarray&lt;T&gt;&amp; <i>v</i>, const matrix&lt;T&gt;&amp; <i>m</i>);

<a href="#b11">11</a>. valarray&lt;T&gt; operator/ (const matrix&lt;T&gt;&amp; <i>m</i>, const valarray&lt;T&gt;&amp; <i>v</i>);
<a href="#b12">12</a>. valarray&lt;T&gt; operator/ (const valarray&lt;T&gt;&amp; <i>v</i>, const matrix&lt;T&gt;&amp; <i>m</i>);

</code></pre>

<p>
<ol>
<li><a name="b1"></a>Adds the matrix <i>m1</i> and <i>m2</i> and returns the resultant matrix.</li><br><br>

<li><a name="b2"></a>Subtracts the matrix <i>m2</i> from <i>m1</i> and returns the resultant matrix.</li><br><br>

<li><a name="b3"></a>Multiplies the matrix <i>m1</i> by <i>m2</i> and returns the resultant matrix.</li><br><br>

<li><a name="b4"></a>Multiplies the matrix <i>m</i> by <i>e</i> and returns the resultant matrix.</li><br><br>

<li><a name="b5"></a>Multiplies the matrix <i>m</i> by <i>e</i> and returns the resultant matrix.</li><br><br>

<li><a name="b6"></a>Performs a simulated division by multiplying the matrix <i>m1</i> by the inverse of matrix <i>m2</i>, and returns the resultant matrix.</li><br><br>

<li><a name="b7"></a>Divides the matrix <i>m</i> by <i>e</i> and returns the resultant matrix.</li><br><br>

<li><a name="b8"></a>Performs a simulated division by multiplying the inverse of matrix <i>m</i> by <i>e</i>, and returns the resultant matrix.</li><br><br>

<li><a name="b9"></a>Multiplies the matrix <i>m</i> by the vector <i>v</i> and returns the resultant vector.</li><br><br>

<li><a name="b10"></a>Multiplies the matrix <i>m</i> by the vector <i>v</i> and returns the resultant vector.</li><br><br>

<li><a name="b11"></a>Performs a simulated division by multiplying the matrix <i>m</i> by the inverse of vector <i>v</i>, and returns the resultant vector.</li><br><br>

<li><a name="b12"></a>Performs a simulated division by multiplying the inverse of matrix <i>m</i> by the vector <i>v</i>, and returns the resultant vector.</li>
</ol>
</p>

<h5>Examples</h5>

<pre><code>typedef matrix&lt;double&gt; Matrix;
typedef valarray&lt;double&gt; Vector;

Matrix A(5,5), B(5,5);

A.rand();
B = A;

A += B;
B -= A;
B *= A;         
B /= A;         // B *= !A;

A *= 1.234;
B /= 2.34;

Matrix C = A * B - B;

Vector V(5), V2(5);

V = B[0];
V2 = V * A;
V2 = B / V;

</code></pre>

</body>
</html>

⌨️ 快捷键说明

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