📄 binaryop.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<T> operator+ (const matrix<T>& <i>m1</i>, const matrix<T>& <i>m2</i>);
<a href="#b2">2</a>. matrix<T> operator- (const matrix<T>& <i>m1</i>, const matrix<T>& <i>m2</i>);
<a href="#b3">3</a>. matrix<T> operator* (const matrix<T>& <i>m1</i>, const matrix<T>& <i>m2</i>);
<a href="#b4">4</a>. matrix<T> operator* (const matrix<T>& <i>m</i>, const T& <i>e</i>);
<a href="#b5">5</a>. matrix<T> operator* (const T& <i>e</i>, const matrix<T>& <i>m</i>);
<a href="#b6">6</a>. matrix<T> operator/ (const matrix<T>& <i>m1</i>, const matrix<T>& <i>m2</i>);
<a href="#b7">7</a>. matrix<T> operator/ (const matrix<T>& <i>m</i>, const T& <i>e</i>);
<a href="#b8">8</a>. matrix<T> operator/ (const T& <i>e</i>, const matrix<T>& <i>m</i>);
<a href="#b9">9</a>. valarray<T> operator* (const matrix<T>& <i>m</i>, const valarray<T>& <i>v</i>);
<a href="#b10">10</a>. valarray<T> operator* (const valarray<T>& <i>v</i>, const matrix<T>& <i>m</i>);
<a href="#b11">11</a>. valarray<T> operator/ (const matrix<T>& <i>m</i>, const valarray<T>& <i>v</i>);
<a href="#b12">12</a>. valarray<T> operator/ (const valarray<T>& <i>v</i>, const matrix<T>& <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<double> Matrix;
typedef valarray<double> 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 + -