📄 matfunc.htm
字号:
<html>
<head>
<link rel=stylesheet href="styles.css" type="text/css">
<title>Non-member functions</title>
</head>
<body>
<h6 align=right>
<a href="eigen.htm">Prev</a> |
<a href="manual.htm">Up</a> |
<a href="matio.htm">Next</a>
</h6>
<h2>Non-member functions</h2>
<p>
The following non-member functions are avaiable for the matrix class object.
</p>
<pre><code><a href="#e1">1</a>. matrix<T> pow (const matrix<T>& m, size_t n);
<a href="#e2">2</a>. matrix<T> abs (const matrix<T>& m);
<a href="#e3">3</a>. matrix<T> floor (const matrix<T>& m);
<a href="#e4">4</a>. matrix<T> ceil (const matrix<T>& m);
<a href="#e5">5</a>. void mswap (matrix<T>& x, matrix<T>& y);
</code></pre>
<p>
<ol>
<li><a name="e1"></a>Returns <i>m</i> to the power <i>n</i>, i.e., <i>m</i> is self multiplied <i>n</i> times. Here <i>m</i> must be a square matrix, otherwise, it throws <i>invalid_argument</i> exception if range checking is enabled.
</li><br><br>
<li><a name="e2"></a>Returns a matrix class object each of whose elements is an absolute value of corresponding element of the matrix <i>m</i>.
</li><br><br>
<li><a name="e3"></a>Returns a matrix class object each of whose elements is a floating-point value representing the largest integer that is less than or equal to corresponding element of the matrix <i>m</i>
</li><br><br>
<li><a name="e4"></a>Returns a matrix class object each of whose elements is a floating-point value representing smallest integer that is greater than or equal to corresponding element of the matrix <i>m</i>
</li><br><br>
<li><a name="e5"></a>Swaps values of two matrix objects. You can also use this function to swap rows, columns, or elements of the same or two different matrices.
</li><br><br>
</ol>
</p>
<h5>Examples</h5>
<pre><code>typedef matrix<double> Matrix;
Matrix A(4,4), B(4,4);
A.rand();
B = abs( A);
B = floor( A);
B = ceil( A);
B = pow( A, 9); // Multiplies A nine times
mswap( A, B);
mswap( A[1], B[1]); // Swaps row A[1] and row B[1]
mswap( A(1), A(2)); // Swaps column A(1) and column A(2)
mswap( A.diag(1), A.diag(-1)); // Swaps the upper and lower diagonals just below the main diagonal
mswap( A[2][3], A[3][2]);
mswap( A(2,3), B(3,2));
</code></pre>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -