root/doc/html/loggers_8h-source.html @ 145

Revision 145, 13.9 kB (checked in by smidl, 16 years ago)

Oprava dokumentace

Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3<title>mixpp: work/git/mixpp/bdm/stat/loggers.h Source File</title>
4<link href="doxygen.css" rel="stylesheet" type="text/css">
5<link href="tabs.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.5.6 -->
8<div class="navigation" id="top">
9  <div class="tabs">
10    <ul>
11      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
12      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
13      <li><a href="annotated.html"><span>Classes</span></a></li>
14      <li class="current"><a href="files.html"><span>Files</span></a></li>
15    </ul>
16  </div>
17<h1>work/git/mixpp/bdm/stat/loggers.h</h1><a href="loggers_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
18<a name="l00013"></a>00013 <span class="preprocessor">#ifndef LGR_H</span>
19<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define LGR_H</span>
20<a name="l00015"></a>00015 <span class="preprocessor"></span>
21<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;itpp/itbase.h&gt;</span>
22<a name="l00017"></a>00017 <span class="preprocessor">#include "<a class="code" href="libBM_8h.html" title="Bayesian Models (bm) that use Bayes rule to learn from observations.">libBM.h</a>"</span>
23<a name="l00018"></a>00018 <span class="preprocessor">#include "../itpp_ext.h"</span>
24<a name="l00019"></a>00019
25<a name="l00020"></a>00020 <span class="keyword">using namespace </span>itpp;
26<a name="l00021"></a>00021 <span class="keyword">using</span> std::string;
27<a name="l00022"></a>00022
28<a name="l00028"></a><a class="code" href="classlogger.html">00028</a> <span class="keyword">class </span><a class="code" href="classlogger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> {
29<a name="l00029"></a>00029 <span class="keyword">protected</span>:
30<a name="l00031"></a><a class="code" href="classlogger.html#83eea0cf4fbca59474d015f751f128a7">00031</a>         Array&lt;RV&gt; <a class="code" href="classlogger.html#83eea0cf4fbca59474d015f751f128a7" title="RVs of all logged variables.">entries</a>;
31<a name="l00033"></a><a class="code" href="classlogger.html#39cb79e839ca8f8bb9dcbc8c5b9c7786">00033</a>         Array&lt;string&gt; <a class="code" href="classlogger.html#39cb79e839ca8f8bb9dcbc8c5b9c7786" title="Names of logged quantities, e.g. names of algorithm variants.">names</a>;
32<a name="l00034"></a>00034 <span class="keyword">public</span>:
33<a name="l00036"></a><a class="code" href="classlogger.html#4f753a510e00c892b38e95c2284363a6">00036</a>         <a class="code" href="classlogger.html#4f753a510e00c892b38e95c2284363a6" title="Default constructor.">logger</a> ( ) : <a class="code" href="classlogger.html#83eea0cf4fbca59474d015f751f128a7" title="RVs of all logged variables.">entries</a>(0),<a class="code" href="classlogger.html#39cb79e839ca8f8bb9dcbc8c5b9c7786" title="Names of logged quantities, e.g. names of algorithm variants.">names</a> ( 0 ) {}
34<a name="l00037"></a>00037
35<a name="l00039"></a><a class="code" href="classlogger.html#3d6c6ab580b36619c4010e3ebec55378">00039</a>         <span class="keyword">virtual</span> <span class="keywordtype">int</span> <span class="keyword">add</span> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rv, <span class="keywordtype">string</span> name=<span class="stringliteral">""</span> ) {
36<a name="l00040"></a>00040                 <span class="keywordtype">int</span> <span class="keywordtype">id</span>=<a class="code" href="classlogger.html#83eea0cf4fbca59474d015f751f128a7" title="RVs of all logged variables.">entries</a>.length();
37<a name="l00041"></a>00041                 <a class="code" href="classlogger.html#39cb79e839ca8f8bb9dcbc8c5b9c7786" title="Names of logged quantities, e.g. names of algorithm variants.">names</a>=concat ( <a class="code" href="classlogger.html#39cb79e839ca8f8bb9dcbc8c5b9c7786" title="Names of logged quantities, e.g. names of algorithm variants.">names</a>, name ); <span class="comment">// diff</span>
38<a name="l00042"></a>00042                 <a class="code" href="classlogger.html#83eea0cf4fbca59474d015f751f128a7" title="RVs of all logged variables.">entries</a>.set_length(<span class="keywordtype">id</span>+1,<span class="keyword">true</span>);
39<a name="l00043"></a>00043                 <a class="code" href="classlogger.html#83eea0cf4fbca59474d015f751f128a7" title="RVs of all logged variables.">entries</a>(<span class="keywordtype">id</span>)= rv;
40<a name="l00044"></a>00044                 <span class="keywordflow">return</span> id; <span class="comment">// identifier of the last entry</span>
41<a name="l00045"></a>00045         }
42<a name="l00046"></a>00046
43<a name="l00048"></a>00048         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classlogger.html#efb5a59cb329f58810b09bd9cc270b78" title="log this vector">logit</a> ( <span class="keywordtype">int</span> <span class="keywordtype">id</span>, vec v ) =0;
44<a name="l00049"></a>00049
45<a name="l00051"></a>00051         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classlogger.html#2b86e4ad1d970cb4a0db4ded3ca59924" title="consider this record to be complete">step</a>(<span class="keywordtype">bool</span> <span class="keyword">final</span>=<span class="keyword">false</span>) =0;
46<a name="l00052"></a>00052
47<a name="l00054"></a><a class="code" href="classlogger.html#92c63a0a87392c62b9ed3c00faa9d5df">00054</a>         <span class="keyword">virtual</span> <a class="code" href="classlogger.html#92c63a0a87392c62b9ed3c00faa9d5df" title="for future use">~logger</a>() {};
48<a name="l00055"></a>00055 };
49<a name="l00056"></a>00056
50<a name="l00057"></a>00057
51<a name="l00064"></a><a class="code" href="classmemlog.html">00064</a> <span class="keyword">class </span><a class="code" href="classmemlog.html" title="Logging into matrices in data format in memory.">memlog</a> : <span class="keyword">public</span> <a class="code" href="classlogger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> {
52<a name="l00065"></a>00065
53<a name="l00066"></a>00066 <span class="keyword">protected</span>:
54<a name="l00068"></a><a class="code" href="classmemlog.html#4195f322897ededdac66c404b848ced3">00068</a>         <span class="keywordtype">int</span> <a class="code" href="classmemlog.html#4195f322897ededdac66c404b848ced3" title="Maximum length of vectors stored in memory.">maxlen</a>;
55<a name="l00070"></a><a class="code" href="classmemlog.html#3410b4c002636508c43ddcba8d394520">00070</a>         <span class="keywordtype">int</span> <a class="code" href="classmemlog.html#3410b4c002636508c43ddcba8d394520" title="Currect record to be written.">ind</a>;
56<a name="l00072"></a><a class="code" href="classmemlog.html#f0f5bc7b83539ad102e8f65297852d91">00072</a>         Array&lt;mat&gt; <a class="code" href="classmemlog.html#f0f5bc7b83539ad102e8f65297852d91" title="Storage.">vectors</a>;
57<a name="l00074"></a>00074 <span class="keyword">public</span>:
58<a name="l00076"></a><a class="code" href="classmemlog.html#e056e819c5a65d4431bfe7955b1efe97">00076</a>         <a class="code" href="classmemlog.html#e056e819c5a65d4431bfe7955b1efe97" title="Default constructor.">memlog</a> ( <span class="keywordtype">int</span> maxlen0 ) : <a class="code" href="classlogger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a>(),<a class="code" href="classmemlog.html#4195f322897ededdac66c404b848ced3" title="Maximum length of vectors stored in memory.">maxlen</a> ( maxlen0 ),<a class="code" href="classmemlog.html#3410b4c002636508c43ddcba8d394520" title="Currect record to be written.">ind</a> ( 0 ),<a class="code" href="classmemlog.html#f0f5bc7b83539ad102e8f65297852d91" title="Storage.">vectors</a> ( 0 ) {}
59<a name="l00078"></a><a class="code" href="classmemlog.html#b081ef5acb4816e6b5fcb56c19cc7e47">00078</a>         <span class="keywordtype">void</span> <a class="code" href="classmemlog.html#b081ef5acb4816e6b5fcb56c19cc7e47" title="Initialize storage.">init</a>() {
60<a name="l00079"></a>00079                 <span class="keywordtype">int</span> i; <span class="keywordtype">int</span> n =<a class="code" href="classlogger.html#83eea0cf4fbca59474d015f751f128a7" title="RVs of all logged variables.">entries</a>.length();
61<a name="l00080"></a>00080                 <a class="code" href="classmemlog.html#f0f5bc7b83539ad102e8f65297852d91" title="Storage.">vectors</a>.set_size ( n );
62<a name="l00081"></a>00081                 <span class="keywordflow">for</span> ( i=0;i&lt;n;i++ ) {<a class="code" href="classmemlog.html#f0f5bc7b83539ad102e8f65297852d91" title="Storage.">vectors</a>(i).set_size (<a class="code" href="classmemlog.html#4195f322897ededdac66c404b848ced3" title="Maximum length of vectors stored in memory.">maxlen</a>,<a class="code" href="classlogger.html#83eea0cf4fbca59474d015f751f128a7" title="RVs of all logged variables.">entries</a>(i).count() );}
63<a name="l00082"></a>00082                 ;
64<a name="l00083"></a>00083         }
65<a name="l00084"></a><a class="code" href="classmemlog.html#9ebaf88cda26992f4f50aa13aeafc691">00084</a>         <span class="keywordtype">void</span> <a class="code" href="classmemlog.html#9ebaf88cda26992f4f50aa13aeafc691" title="consider this record to be complete">step</a>(<span class="keywordtype">bool</span> <span class="keyword">final</span>=<span class="keyword">false</span>) {<span class="keywordflow">if</span> ( <a class="code" href="classmemlog.html#3410b4c002636508c43ddcba8d394520" title="Currect record to be written.">ind</a>&lt;<a class="code" href="classmemlog.html#4195f322897ededdac66c404b848ced3" title="Maximum length of vectors stored in memory.">maxlen</a> ) <a class="code" href="classmemlog.html#3410b4c002636508c43ddcba8d394520" title="Currect record to be written.">ind</a>++; <span class="keywordflow">else</span> it_error ( <span class="stringliteral">"memlog::ind is too high;"</span> );}
66<a name="l00085"></a><a class="code" href="classmemlog.html#8d2feeb826f7249e9104d616b5a67144">00085</a>         <span class="keywordtype">void</span> <a class="code" href="classmemlog.html#8d2feeb826f7249e9104d616b5a67144" title="log this vector">logit</a> ( <span class="keywordtype">int</span> <span class="keywordtype">id</span>, vec v ) {<a class="code" href="classmemlog.html#f0f5bc7b83539ad102e8f65297852d91" title="Storage.">vectors</a> ( <span class="keywordtype">id</span> ).set_row ( <a class="code" href="classmemlog.html#3410b4c002636508c43ddcba8d394520" title="Currect record to be written.">ind</a>,v );}
67<a name="l00087"></a>00087         <span class="keywordtype">void</span> <a class="code" href="classmemlog.html#65571ebbb16577b5211adbb27baf769c" title="Save values into an itfile named after fname.">itsave</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* fname);
68<a name="l00088"></a>00088 };
69<a name="l00089"></a>00089
70<a name="l00098"></a><a class="code" href="classdirfilelog.html">00098</a> <span class="keyword">class </span><a class="code" href="classdirfilelog.html" title="Logging into dirfile with buffer in memory.">dirfilelog</a> : <span class="keyword">public</span> <a class="code" href="classmemlog.html" title="Logging into matrices in data format in memory.">memlog</a> {
71<a name="l00099"></a>00099
72<a name="l00100"></a>00100 <span class="keyword">protected</span>:
73<a name="l00102"></a><a class="code" href="classdirfilelog.html#cba5ff1f74ed22910ed7d63aadf21771">00102</a>         <span class="keywordtype">string</span> <a class="code" href="classdirfilelog.html#cba5ff1f74ed22910ed7d63aadf21771" title="name of the directory">dirname</a>;
74<a name="l00104"></a><a class="code" href="classdirfilelog.html#854b7e7cc4cb40542b4a3ea06d915772">00104</a>         Array&lt;string&gt; <a class="code" href="classdirfilelog.html#854b7e7cc4cb40542b4a3ea06d915772" title="Automatically generated.">scalarnames</a>;
75<a name="l00105"></a>00105 <span class="keyword">public</span>:
76<a name="l00109"></a><a class="code" href="classdirfilelog.html#802eeb6fc4ebf11d97638fd5dc651c68">00109</a>         <a class="code" href="classdirfilelog.html#802eeb6fc4ebf11d97638fd5dc651c68" title="Default constructor.">dirfilelog</a> ( std::string dirname0, <span class="keywordtype">int</span> maxlen0 ) : <a class="code" href="classmemlog.html" title="Logging into matrices in data format in memory.">memlog</a> ( maxlen0 ), <a class="code" href="classdirfilelog.html#cba5ff1f74ed22910ed7d63aadf21771" title="name of the directory">dirname</a> ( dirname0 ), <a class="code" href="classdirfilelog.html#854b7e7cc4cb40542b4a3ea06d915772" title="Automatically generated.">scalarnames</a> ( 0 ) {}
77<a name="l00111"></a>00111         <span class="keywordtype">void</span> <a class="code" href="classdirfilelog.html#afeaebe003110f9db1ac43edf8e53a92" title="Initialize storage.">init</a>();
78<a name="l00112"></a>00112         <span class="keywordtype">void</span> <a class="code" href="classdirfilelog.html#887f2bb97e8c92ca42eea1fbac34eb51" title="consider this record to be complete">step</a>(<span class="keywordtype">bool</span> <span class="keyword">final</span>=<span class="keyword">false</span>);
79<a name="l00116"></a>00116         <span class="keywordtype">void</span> <a class="code" href="classdirfilelog.html#bd95cdb46af194245f88a7b4bf4c66c7" title="Write memory storage to disk.">write_buffers</a> ( <span class="keywordtype">int</span> Len );
80<a name="l00117"></a>00117 };
81<a name="l00118"></a>00118
82<a name="l00119"></a>00119
83<a name="l00120"></a>00120 <span class="preprocessor">#endif // LGR_H</span>
84</pre></div></div>
85<hr size="1"><address style="text-align: right;"><small>Generated on Sat Aug 16 17:22:03 2008 for mixpp by&nbsp;
86<a href="http://www.doxygen.org/index.html">
87<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
88</body>
89</html>
Note: See TracBrowser for help on using the browser.