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

📄 matio.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>Matrix I/O operators</title>
</head>
<body>

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

<h2>Matrix I/O operators</h2>

<p>
The following I/O operators are available for the matrix class.
</p>

<pre><code><a href="#e1">1</a>. istream& operator&gt;&gt; (istream& is, valarray&lt;T&gt;& v);
<a href="#e2">2</a>. istream& operator&gt;&gt; (istream& is, matrix&lt;T&gt;& m);

<a href="#e3">3</a>. ostream& operator&lt;&lt; (ostream& os, const valarray&lt;T&gt;& v);
<a href="#e4">4</a>. ostream& operator&lt;&lt; (ostream& os, const matrix&lt;T&gt;& m);

</code></pre>

<p>
<ol>
<li><a name="e1"></a>Use operator <i>&gt;&gt;</i> to read a <i>valarray</i> 
vector or row/column of a matrix object from a input stream like <i>cin</i> or a file.
</li><br><br>

<li><a name="e2"></a>Use operator <i>&gt;&gt;</i> to read a matrix object 
from a input stream like <i>cin</i> or a file.
</li><br><br>

<li><a name="e3"></a>Use operator <i>&lt;&lt;</i> to write a <i>valarray</i> 
vector or row/column of a matrix object to a output stream like <i>cout</i> 
or a file.
</li><br><br>

<li><a name="e4"></a>Use operator <i>&lt;&lt;</i> to write a matrix object to 
a output stream like <i>cout</i> or a file.
</li><br><br>
</ol>
</p>

<h5>Examples</h5>

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

Matrix A(4,4);
Vector V(4);
size_t i=1,j=2;

cin &gt;&gt; A[i][j];          // Read A<sub><small>ij</small></sub> th element from standard input
cin &gt;&gt; A.diag()[1];      // Read the 2nd diagonal element of matrix A

cin &gt;&gt; A[i];             // Read the <i>i</i> th row of matrix A
cin &gt;&gt; A(j);             // Read the <i>j</i> th column of matrix A
cin &gt;&gt; A.diag();         // Read the diagonal elements of matrix A
cin &gt;&gt; V;                // Read the vector V

cout &lt;&lt; A(i,j);          // Write A<sub><small>ij</small></sub> th element to standard output
cout &lt;&lt; A.diag()[1];     // Write the 2nd diagonal element of matrix A
cout &lt;&lt; A[i];            // Write the <i>i</i> th row of matrix A
cout &lt;&lt; A(j);            // Write the <i>j</i> th column of matrix A
cout &lt;&lt; A.diag();        // Write the diagonal elements of matrix A
cout &lt;&lt; V;               // Write the vector V

</code></pre>

</body>
</html>

⌨️ 快捷键说明

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