/usr/share/doc/libitpp-dev/html/itfile.html is in libitpp-doc 4.3.1-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Welcome to IT++!</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="favicon.ico">
</head>
<body>
<div style="width: 100%; height: 40px; background-color: #ffff00; border: 1px solid #b0b0b0; margin: 5px 5px 5px 0; padding: 2px;">
<a href="http://itpp.sourceforge.net"><img src="itpp_logo.png" alt="IT++ Logo" style="float: left; border: 0;"></a>
</div>
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,true,'search.php','Search');
$(document).ready(function() {
if ($('.searchresults').length > 0) { searchBox.DOMSearchField().focus(); }
});
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">Writing and reading data from files </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>Here we will use the <code>it_file</code> class to store some data. The program <code>write_it_file.cpp</code> looks as follows:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include <<a class="code" href="itcomm_8h.html">itpp/itcomm.h</a>></span></div><div class="line"></div><div class="line"><span class="keyword">using namespace </span><a class="code" href="namespaceitpp.html">itpp</a>;</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main()</div><div class="line">{</div><div class="line"> <span class="comment">// Declare the it_file class</span></div><div class="line"> <a class="code" href="classitpp_1_1it__file.html">it_file</a> ff;</div><div class="line"></div><div class="line"> <span class="comment">// Open a file with the name "it_file_test.it"</span></div><div class="line"> ff.<a class="code" href="classitpp_1_1it__file.html#a549f27e6830fa68fc964041b79733168">open</a>(<span class="stringliteral">"it_file_test.it"</span>);</div><div class="line"></div><div class="line"> <span class="comment">// Create some data to put into the file</span></div><div class="line"> vec a = <a class="code" href="group__specmat.html#ga00d68c6d3fa03dee1c8a03670dc574f4">linspace</a>(1, 20, 20);</div><div class="line"></div><div class="line"> <span class="comment">// Put the variable a into the file. The Name("a") tells the file class</span></div><div class="line"> <span class="comment">// that the next variable shall be named "a".</span></div><div class="line"> ff << <a class="code" href="classitpp_1_1Name.html">Name</a>(<span class="stringliteral">"a"</span>) << a;</div><div class="line"></div><div class="line"> <span class="comment">// Force the file to be written to disc. This is useful when performing</span></div><div class="line"> <span class="comment">// iterations and ensures that the information is not stored in any cache</span></div><div class="line"> <span class="comment">// memory. In this simple example it is not necessary to flush the file.</span></div><div class="line"> ff.<a class="code" href="classitpp_1_1it__file.html#a1ca5957bb8c2d18112b758b0993b2f2a">flush</a>();</div><div class="line"></div><div class="line"> <span class="comment">// Close the file</span></div><div class="line"> ff.<a class="code" href="classitpp_1_1it__file.html#a6e7217f36b35d6ea866e5fa8148009fa">close</a>();</div><div class="line"></div><div class="line"> <span class="comment">// Exit program</span></div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --><p>When you run this program you will obtain a file called <code>it_file_test.it</code> in your current directory. You can read the file into Matlab/Octave to view the data by using the following commands:</p>
<div class="fragment"><div class="line">itload(<span class="stringliteral">'it_file_test.it'</span>)</div><div class="line">figure(1); clf;</div><div class="line">plot(a)</div></div><!-- fragment --><p>Note: Make sure that <code>$PREFIX/share/itpp</code> is in your Matlab/Octave path and that you run the code above from the directory where <code>it_file_test.it</code> is located (<code>$PREFIX</code> is the IT++ installation prefix; <code>/usr/local</code> by default).</p>
<p>The IT++ program <code>read_it_file.cpp</code> that reads the file and prints its content can look like this:</p>
<div class="fragment"><div class="line"><span class="preprocessor">#include <<a class="code" href="itcomm_8h.html">itpp/itcomm.h</a>></span></div><div class="line"></div><div class="line"><span class="keyword">using namespace </span><a class="code" href="namespaceitpp.html">itpp</a>;</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main()</div><div class="line">{</div><div class="line"> <span class="comment">// Declare the it_file class</span></div><div class="line"> <a class="code" href="classitpp_1_1it__file.html">it_file</a> ff;</div><div class="line"></div><div class="line"> <span class="comment">// Open the file "it_file_test.it" for reading</span></div><div class="line"> ff.<a class="code" href="classitpp_1_1it__file.html#a549f27e6830fa68fc964041b79733168">open</a>(<span class="stringliteral">"it_file_test.it"</span>);</div><div class="line"></div><div class="line"> <span class="comment">// Read the variable a from the file. Put result in vector a.</span></div><div class="line"> vec a;</div><div class="line"> ff >> <a class="code" href="classitpp_1_1Name.html">Name</a>(<span class="stringliteral">"a"</span>) >> a;</div><div class="line"></div><div class="line"> <span class="comment">// Print the result</span></div><div class="line"> std::cout << <span class="stringliteral">"a = "</span> << a << std::endl;</div><div class="line"></div><div class="line"> <span class="comment">// Exit the program</span></div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --><p>Here is the output of the program:</p>
<pre class="fragment">a = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]
</pre> </div></div><!-- contents -->
<div style="clear: both; width: 100%; height: 31px; background-color: #ffff00; border: 1px solid #b0b0b0; margin: 5px 5px 5px 0; padding: 2px;">
<p style="padding-left: 10px; font-size: 85%;">Generated on Sat Sep 30 2017 07:04:09 for IT++ by <a href="http://www.doxygen.org/index.html">Doxygen</a> 1.8.13</p>
</div>
</body>
</html>
|