96 | | <a name="l00058"></a>00058 <a class="code" href="classbdm_1_1FileDS.html">FileDS</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &fname, <span class="keyword">const</span> <span class="keywordtype">string</span> &varname ) :<a class="code" href="classbdm_1_1MemDS.html#1ea231f4066652996cde4826560d93e3" title="Default constructor.">MemDS</a>() { |
97 | | <a name="l00059"></a>00059 it_file it ( fname ); |
98 | | <a name="l00060"></a>00060 it << Name ( varname ); |
99 | | <a name="l00061"></a>00061 it >> <a class="code" href="classbdm_1_1MemDS.html#a724f4cbfc32e79bacc044253234e260" title="internal matrix of data">Data</a>; |
100 | | <a name="l00062"></a>00062 <a class="code" href="classbdm_1_1MemDS.html#681ee3831f68f4f20ed54e04e8b3f107" title="active column in the Data matrix">time</a> =0; |
101 | | <a name="l00063"></a>00063 <span class="comment">//rowid and delays are ignored</span> |
102 | | <a name="l00064"></a>00064 } |
103 | | <a name="l00065"></a><a class="code" href="classbdm_1_1FileDS.html#0bf36650e9d1af2d0743ffe8a3fcff14">00065</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1FileDS.html#0bf36650e9d1af2d0743ffe8a3fcff14" title="Returns full vector of observed data=[output, input].">getdata</a> ( vec &dt ) { |
104 | | <a name="l00066"></a>00066 it_assert_debug ( dt.length() ==<a class="code" href="classbdm_1_1MemDS.html#a724f4cbfc32e79bacc044253234e260" title="internal matrix of data">Data</a>.rows(),<span class="stringliteral">""</span> ); |
105 | | <a name="l00067"></a>00067 dt = <a class="code" href="classbdm_1_1MemDS.html#a724f4cbfc32e79bacc044253234e260" title="internal matrix of data">Data</a>.get_col(<a class="code" href="classbdm_1_1MemDS.html#681ee3831f68f4f20ed54e04e8b3f107" title="active column in the Data matrix">time</a>); |
106 | | <a name="l00068"></a>00068 }; |
107 | | <a name="l00069"></a><a class="code" href="classbdm_1_1FileDS.html#ed680c40e53fd838c044dc223421c0fe">00069</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1FileDS.html#ed680c40e53fd838c044dc223421c0fe" title="Returns data records at indeces.">getdata</a> ( vec &dt, <span class="keyword">const</span> ivec &indeces ){ |
108 | | <a name="l00070"></a>00070 it_assert_debug ( dt.length() ==indeces.length(),<span class="stringliteral">""</span> ); |
109 | | <a name="l00071"></a>00071 vec tmp(indeces.length()); |
110 | | <a name="l00072"></a>00072 tmp = <a class="code" href="classbdm_1_1MemDS.html#a724f4cbfc32e79bacc044253234e260" title="internal matrix of data">Data</a>.get_col(<a class="code" href="classbdm_1_1MemDS.html#681ee3831f68f4f20ed54e04e8b3f107" title="active column in the Data matrix">time</a>); |
111 | | <a name="l00073"></a>00073 dt = tmp(indeces); |
112 | | <a name="l00074"></a>00074 }; |
113 | | <a name="l00076"></a><a class="code" href="classbdm_1_1FileDS.html#a6af63065097147b390e684a7842a26a">00076</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1FileDS.html#a6af63065097147b390e684a7842a26a" title="returns number of data in the file;">ndat</a>(){<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1MemDS.html#a724f4cbfc32e79bacc044253234e260" title="internal matrix of data">Data</a>.cols();} |
114 | | <a name="l00077"></a>00077 }; |
115 | | <a name="l00078"></a>00078 |
116 | | <a name="l00083"></a><a class="code" href="classbdm_1_1ArxDS.html">00083</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1ArxDS.html" title="Generator of ARX data.">ArxDS</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1DS.html" title="Abstract class for discrete-time sources of data.">DS</a> { |
117 | | <a name="l00084"></a>00084 <span class="keyword">protected</span>: |
118 | | <a name="l00086"></a><a class="code" href="classbdm_1_1ArxDS.html#c7b3cc6cd059ff3d7f4462cedff4bdeb">00086</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1ArxDS.html#c7b3cc6cd059ff3d7f4462cedff4bdeb" title="Rv of the regressor.">Rrv</a>; |
119 | | <a name="l00088"></a><a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597">00088</a> vec <a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a>; |
120 | | <a name="l00090"></a><a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5">00090</a> vec <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a>; |
121 | | <a name="l00092"></a><a class="code" href="classbdm_1_1ArxDS.html#b2d7530264499b92c3aa32454b960abe">00092</a> vec <a class="code" href="classbdm_1_1ArxDS.html#b2d7530264499b92c3aa32454b960abe" title="temporary variable for regressor">rgr</a>; |
122 | | <a name="l00094"></a><a class="code" href="classbdm_1_1ArxDS.html#fbe7b993ec5f75c195ae1b2ccd96a898">00094</a> <a class="code" href="classbdm_1_1datalink.html" title="DataLink is a connection between two data vectors Up and Down.">datalink</a> <a class="code" href="classbdm_1_1ArxDS.html#fbe7b993ec5f75c195ae1b2ccd96a898" title="data link: H -&gt; rgr">rgrlnk</a>; |
123 | | <a name="l00096"></a><a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb">00096</a> <a class="code" href="classbdm_1_1mlnorm.html">mlnorm<chmat></a> <a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>; |
124 | | <a name="l00098"></a><a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1">00098</a> <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a>; |
125 | | <a name="l00100"></a><a class="code" href="classbdm_1_1ArxDS.html#e13e5ffdfe9d896089310b0fc54e0c85">00100</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1ArxDS.html#e13e5ffdfe9d896089310b0fc54e0c85" title="loggers">L_theta</a>; |
126 | | <a name="l00101"></a>00101 <span class="keywordtype">int</span> L_R; |
127 | | <a name="l00102"></a>00102 <span class="keywordtype">int</span> dt_size; |
128 | | <a name="l00103"></a>00103 <span class="keyword">public</span>: |
129 | | <a name="l00104"></a><a class="code" href="classbdm_1_1ArxDS.html#db242e35812c311c8415bb7e31c3f595">00104</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#db242e35812c311c8415bb7e31c3f595" title="Returns full vector of observed data=[output, input].">getdata</a> ( vec &dt ) { |
130 | | <a name="l00105"></a>00105 <span class="comment">//it_assert_debug ( dt.length() ==Drv.count(),"ArxDS" );</span> |
131 | | <a name="l00106"></a>00106 dt=<a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a>; |
132 | | <a name="l00107"></a>00107 }; |
133 | | <a name="l00108"></a><a class="code" href="classbdm_1_1ArxDS.html#701151418bc5fc3861acef8359fb0d80">00108</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#701151418bc5fc3861acef8359fb0d80" title="Returns data records at indeces.">getdata</a> ( vec &dt, <span class="keyword">const</span> ivec &indices ) { |
134 | | <a name="l00109"></a>00109 it_assert_debug ( dt.length() ==indices.length(),<span class="stringliteral">"ArxDS"</span> ); |
135 | | <a name="l00110"></a>00110 dt=<a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a> ( indices ); |
136 | | <a name="l00111"></a>00111 }; |
137 | | <a name="l00112"></a><a class="code" href="classbdm_1_1ArxDS.html#8f6da8a00abba70bc58c7a4030bd8940">00112</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#8f6da8a00abba70bc58c7a4030bd8940" title="Accepts action variable and schedule it for application.">write</a> ( vec &ut ) { |
138 | | <a name="l00113"></a>00113 <span class="comment">//it_assert_debug ( ut.length() ==Urv.count(),"ArxDS" );</span> |
139 | | <a name="l00114"></a>00114 <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a>=ut; |
140 | | <a name="l00115"></a>00115 }; |
141 | | <a name="l00116"></a><a class="code" href="classbdm_1_1ArxDS.html#477fd706639535f520e9dbbd19f73318">00116</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#477fd706639535f520e9dbbd19f73318" title="Accepts action variables at specific indeces.">write</a> ( vec &ut, <span class="keyword">const</span> ivec &indices ) { |
142 | | <a name="l00117"></a>00117 it_assert_debug ( ut.length() ==indices.length(),<span class="stringliteral">"ArxDS"</span> ); |
143 | | <a name="l00118"></a>00118 set_subvector ( <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a>, indices,ut ); |
144 | | <a name="l00119"></a>00119 }; |
145 | | <a name="l00120"></a>00120 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#57dfa26b23cc03d53b123fa7e0474b19" title="Moves from to , i.e. perfroms the actions and reads response of the system.">step</a>(); |
146 | | <a name="l00122"></a><a class="code" href="classbdm_1_1ArxDS.html#7c8b418677a48041adacac8e8e9c9849">00122</a> <a class="code" href="classbdm_1_1ArxDS.html#7c8b418677a48041adacac8e8e9c9849" title="Default constructor.">ArxDS</a> ( ) {}; |
147 | | <a name="l00124"></a><a class="code" href="classbdm_1_1ArxDS.html#2d9abc62f1fee862f0e1c60c5c4a3c8a">00124</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#2d9abc62f1fee862f0e1c60c5c4a3c8a" title="Set parameters of the internal model, H is maximum time delay.">set_parameters</a> ( <span class="keyword">const</span> mat &Th0, <span class="keyword">const</span> vec mu0, <span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &sqR0 ) |
148 | | <a name="l00125"></a>00125 { <a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#5d18dec3167584338a4775c1d165d96f" title="Set A and R.">set_parameters</a> ( Th0, mu0, sqR0 );}; |
149 | | <a name="l00127"></a><a class="code" href="classbdm_1_1ArxDS.html#bf9cd9d4043d7e0dc61de56db37ec703">00127</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#bf9cd9d4043d7e0dc61de56db37ec703" title="Set.">set_drv</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &yrv, <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &urv, <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rrv ) { |
150 | | <a name="l00128"></a>00128 <a class="code" href="classbdm_1_1ArxDS.html#c7b3cc6cd059ff3d7f4462cedff4bdeb" title="Rv of the regressor.">Rrv</a> = rrv; |
151 | | <a name="l00129"></a>00129 <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a> = urv; |
152 | | <a name="l00130"></a>00130 dt_size = yrv.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>() +urv.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
153 | | <a name="l00131"></a>00131 |
154 | | <a name="l00132"></a>00132 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> drv = concat ( yrv,urv ); |
155 | | <a name="l00133"></a>00133 <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a> = drv; |
156 | | <a name="l00134"></a>00134 <span class="keywordtype">int</span> td = rrv.<a class="code" href="classbdm_1_1RV.html#9a5c5aeeaf39299d07763377b05a8241" title="Minimum time-offset.">mint</a>(); |
157 | | <a name="l00135"></a>00135 <a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a>.set_size ( drv.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>() * ( -td+1 ) ); |
158 | | <a name="l00136"></a>00136 <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a>.set_size ( <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>() ); |
159 | | <a name="l00137"></a>00137 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=-1;i>=td;i-- ) { |
160 | | <a name="l00138"></a>00138 drv.<a class="code" href="classbdm_1_1RV.html#bd77cb0899f7fba1d0e34396137b7f1f" title="Shift time shifted by delta.">t</a> ( -1 ); |
161 | | <a name="l00139"></a>00139 <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>.<a class="code" href="classbdm_1_1RV.html#87841b5ee43997b79789c0c22047e224" title="Add (concat) another variable to the current one,.">add</a> ( drv ); <span class="comment">//shift u1</span> |
162 | | <a name="l00140"></a>00140 } |
163 | | <a name="l00141"></a>00141 <a class="code" href="classbdm_1_1ArxDS.html#fbe7b993ec5f75c195ae1b2ccd96a898" title="data link: H -&gt; rgr">rgrlnk</a>.<a class="code" href="classbdm_1_1datalink.html#fb8337aac8329eb0ca96bfb3ff73ec67" title="set connection, rv must be fully present in rv_up">set_connection</a> ( rrv,<a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a> ); |
164 | | <a name="l00142"></a>00142 |
165 | | <a name="l00143"></a>00143 dtsize = <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
166 | | <a name="l00144"></a>00144 utsize = <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
167 | | <a name="l00145"></a>00145 } |
168 | | <a name="l00147"></a><a class="code" href="classbdm_1_1ArxDS.html#e7438127de87c5a8128edfa12255b436">00147</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#e7438127de87c5a8128edfa12255b436" title="set options from a string">set_options</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &s ) { |
169 | | <a name="l00148"></a>00148 <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a>= ( s.find ( <span class="stringliteral">"L_theta"</span> ) !=string::npos ); |
170 | | <a name="l00149"></a>00149 }; |
171 | | <a name="l00150"></a><a class="code" href="classbdm_1_1ArxDS.html#64819633a1191fcaa60d0de26ade2e52">00150</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#64819633a1191fcaa60d0de26ade2e52" title="Register DS for logging into logger L.">log_add</a> ( <a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L ) { |
172 | | <a name="l00151"></a>00151 <span class="comment">//DS::log_add ( L ); too long!!</span> |
173 | | <a name="l00152"></a>00152 <a class="code" href="classbdm_1_1DS.html#b4b7bdb9d98a11ab587aa0ad803bb867" title="Remember its own index in Logger L.">L_dt</a>=L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a> ( 0,dt_size ),<span class="stringliteral">""</span> ); |
174 | | <a name="l00153"></a>00153 L_ut=L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>,<span class="stringliteral">""</span> ); |
175 | | <a name="l00154"></a>00154 |
176 | | <a name="l00155"></a>00155 mat &A =<a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#262a2a486bff585f34bb6a5005b02614" title="access function">_A</a>(); |
177 | | <a name="l00156"></a>00156 mat R =<a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#78120ecd1c2b1d7e80124b4603504604" title="access function">_R</a>(); |
178 | | <a name="l00157"></a>00157 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a> ) {<a class="code" href="classbdm_1_1ArxDS.html#e13e5ffdfe9d896089310b0fc54e0c85" title="loggers">L_theta</a>=L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> ( <span class="stringliteral">"{th }"</span>, vec_1 ( A.rows() *A.cols() ) ),<span class="stringliteral">"t"</span> );} |
179 | | <a name="l00158"></a>00158 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a> ) {L_R=L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> ( <span class="stringliteral">"{R }"</span>, vec_1 ( R.rows() *R.cols() ) ),<span class="stringliteral">"r"</span> );} |
180 | | <a name="l00159"></a>00159 } |
181 | | <a name="l00160"></a><a class="code" href="classbdm_1_1ArxDS.html#4128f5dc3a04063d62fc7e35635aeb90">00160</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#4128f5dc3a04063d62fc7e35635aeb90" title="Register DS for logging into logger L.">logit</a> ( <a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L ) { |
182 | | <a name="l00161"></a>00161 <span class="comment">//DS::logit ( L );</span> |
183 | | <a name="l00162"></a>00162 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( <a class="code" href="classbdm_1_1DS.html#b4b7bdb9d98a11ab587aa0ad803bb867" title="Remember its own index in Logger L.">L_dt</a>, <a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a>.left ( dt_size ) ); |
184 | | <a name="l00163"></a>00163 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( L_ut, <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a> ); |
185 | | <a name="l00164"></a>00164 |
186 | | <a name="l00165"></a>00165 mat &A =<a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#262a2a486bff585f34bb6a5005b02614" title="access function">_A</a>(); |
187 | | <a name="l00166"></a>00166 mat R =<a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#78120ecd1c2b1d7e80124b4603504604" title="access function">_R</a>(); |
188 | | <a name="l00167"></a>00167 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a> ) {L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( <a class="code" href="classbdm_1_1ArxDS.html#e13e5ffdfe9d896089310b0fc54e0c85" title="loggers">L_theta</a>,vec ( A._data(), A.rows() *A.cols() ) );}; |
189 | | <a name="l00168"></a>00168 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a> ) {L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( L_R, vec ( R._data(), R.rows() *R.rows() ) );}; |
190 | | <a name="l00169"></a>00169 } |
191 | | <a name="l00170"></a>00170 |
192 | | <a name="l00171"></a>00171 }; |
193 | | <a name="l00172"></a>00172 |
194 | | <a name="l00173"></a>00173 <span class="keyword">class </span>stateDS : <span class="keyword">public</span> DS { |
195 | | <a name="l00174"></a>00174 <span class="keyword">protected</span>: |
196 | | <a name="l00176"></a>00176 mpdf* IM; |
197 | | <a name="l00178"></a>00178 mpdf* OM; |
198 | | <a name="l00180"></a>00180 vec dt; |
199 | | <a name="l00182"></a>00182 vec xt; |
200 | | <a name="l00184"></a>00184 vec ut; |
201 | | <a name="l00186"></a>00186 <span class="keywordtype">int</span> L_xt; |
202 | | <a name="l00187"></a>00187 <span class="keyword">public</span>: |
203 | | <a name="l00188"></a>00188 <span class="keywordtype">void</span> getdata ( vec &dt0 ) {dt0=dt;} |
204 | | <a name="l00189"></a>00189 <span class="keywordtype">void</span> getdata ( vec &dt0, <span class="keyword">const</span> ivec &indeces ) {dt0=dt ( indeces );} |
205 | | <a name="l00190"></a>00190 |
206 | | <a name="l00191"></a>00191 stateDS ( mpdf* IM0, mpdf* OM0, <span class="keywordtype">int</span> usize ) :<a class="code" href="classbdm_1_1DS.html#bedd82e08ae6686b4b1732a122c2201a" title="default constructors">DS</a> ( ),IM ( IM0 ),OM ( OM0 ), |
207 | | <a name="l00192"></a>00192 dt ( OM0->dimension() ), xt ( IM0->dimension() ), ut ( usize ) {} |
208 | | <a name="l00193"></a>00193 ~stateDS() {<span class="keyword">delete</span> IM; <span class="keyword">delete</span> OM;} |
209 | | <a name="l00194"></a>00194 <span class="keyword">virtual</span> <span class="keywordtype">void</span> step() { |
210 | | <a name="l00195"></a>00195 xt=IM->samplecond ( concat ( xt,ut ) ); |
211 | | <a name="l00196"></a>00196 dt=OM->samplecond ( concat ( xt,ut ) ); |
212 | | <a name="l00197"></a>00197 }; |
213 | | <a name="l00198"></a>00198 |
214 | | <a name="l00199"></a>00199 <span class="keyword">virtual</span> <span class="keywordtype">void</span> log_add ( logger &L ) { |
215 | | <a name="l00200"></a>00200 <a class="code" href="classbdm_1_1DS.html#3c9e417d85052396fe74c164857ee67e" title="Register DS for logging into logger L.">DS::log_add</a> ( L ); |
216 | | <a name="l00201"></a>00201 L_xt=L.add ( IM->_rv(),<span class="stringliteral">"true"</span> ); |
217 | | <a name="l00202"></a>00202 } |
218 | | <a name="l00203"></a>00203 <span class="keyword">virtual</span> <span class="keywordtype">void</span> logit ( logger &L ) { |
219 | | <a name="l00204"></a>00204 <a class="code" href="classbdm_1_1DS.html#e03d2c93cddd5c3a03107ddd3ae999cf" title="Register DS for logging into logger L.">DS::logit</a> ( L ); |
220 | | <a name="l00205"></a>00205 L.logit ( L_xt,xt ); |
221 | | <a name="l00206"></a>00206 } |
222 | | <a name="l00207"></a>00207 |
223 | | <a name="l00208"></a>00208 }; |
224 | | <a name="l00209"></a>00209 |
225 | | <a name="l00210"></a>00210 }; <span class="comment">//namespace</span> |
226 | | <a name="l00211"></a>00211 |
227 | | <a name="l00212"></a>00212 <span class="preprocessor">#endif // DS_H</span> |
| 96 | <a name="l00058"></a><a class="code" href="classbdm_1_1FileDS.html#0bf36650e9d1af2d0743ffe8a3fcff14">00058</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1FileDS.html#0bf36650e9d1af2d0743ffe8a3fcff14" title="Returns full vector of observed data=[output, input].">getdata</a> ( vec &dt ) { |
| 97 | <a name="l00059"></a>00059 it_assert_debug ( dt.length() ==<a class="code" href="classbdm_1_1MemDS.html#a724f4cbfc32e79bacc044253234e260" title="internal matrix of data">Data</a>.rows(),<span class="stringliteral">""</span> ); |
| 98 | <a name="l00060"></a>00060 dt = <a class="code" href="classbdm_1_1MemDS.html#a724f4cbfc32e79bacc044253234e260" title="internal matrix of data">Data</a>.get_col(<a class="code" href="classbdm_1_1MemDS.html#681ee3831f68f4f20ed54e04e8b3f107" title="active column in the Data matrix">time</a>); |
| 99 | <a name="l00061"></a>00061 }; |
| 100 | <a name="l00062"></a><a class="code" href="classbdm_1_1FileDS.html#ed680c40e53fd838c044dc223421c0fe">00062</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1FileDS.html#ed680c40e53fd838c044dc223421c0fe" title="Returns data records at indeces.">getdata</a> ( vec &dt, <span class="keyword">const</span> ivec &indeces ){ |
| 101 | <a name="l00063"></a>00063 it_assert_debug ( dt.length() ==indeces.length(),<span class="stringliteral">""</span> ); |
| 102 | <a name="l00064"></a>00064 vec tmp(indeces.length()); |
| 103 | <a name="l00065"></a>00065 tmp = <a class="code" href="classbdm_1_1MemDS.html#a724f4cbfc32e79bacc044253234e260" title="internal matrix of data">Data</a>.get_col(<a class="code" href="classbdm_1_1MemDS.html#681ee3831f68f4f20ed54e04e8b3f107" title="active column in the Data matrix">time</a>); |
| 104 | <a name="l00066"></a>00066 dt = tmp(indeces); |
| 105 | <a name="l00067"></a>00067 }; |
| 106 | <a name="l00069"></a><a class="code" href="classbdm_1_1FileDS.html#a6af63065097147b390e684a7842a26a">00069</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1FileDS.html#a6af63065097147b390e684a7842a26a" title="returns number of data in the file;">ndat</a>(){<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1MemDS.html#a724f4cbfc32e79bacc044253234e260" title="internal matrix of data">Data</a>.cols();} |
| 107 | <a name="l00070"></a>00070 }; |
| 108 | <a name="l00071"></a>00071 |
| 109 | <a name="l00078"></a><a class="code" href="classbdm_1_1ItppFileDS.html">00078</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1ItppFileDS.html" title="Read Data Matrix from an IT file.">ItppFileDS</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1FileDS.html">FileDS</a> { |
| 110 | <a name="l00079"></a>00079 |
| 111 | <a name="l00080"></a>00080 <span class="keyword">public</span>: |
| 112 | <a name="l00081"></a>00081 <a class="code" href="classbdm_1_1ItppFileDS.html" title="Read Data Matrix from an IT file.">ItppFileDS</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &fname, <span class="keyword">const</span> <span class="keywordtype">string</span> &varname ) :<a class="code" href="classbdm_1_1FileDS.html">FileDS</a>() { |
| 113 | <a name="l00082"></a>00082 it_file it ( fname ); |
| 114 | <a name="l00083"></a>00083 it << Name ( varname ); |
| 115 | <a name="l00084"></a>00084 it >> <a class="code" href="classbdm_1_1MemDS.html#a724f4cbfc32e79bacc044253234e260" title="internal matrix of data">Data</a>; |
| 116 | <a name="l00085"></a>00085 <a class="code" href="classbdm_1_1MemDS.html#681ee3831f68f4f20ed54e04e8b3f107" title="active column in the Data matrix">time</a> = 0; |
| 117 | <a name="l00086"></a>00086 <span class="comment">//rowid and delays are ignored</span> |
| 118 | <a name="l00087"></a>00087 } |
| 119 | <a name="l00088"></a>00088 }; |
| 120 | <a name="l00089"></a>00089 |
| 121 | <a name="l00097"></a><a class="code" href="classbdm_1_1CsvFileDS.html">00097</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1CsvFileDS.html" title="CSV file data storage The constructor creates Data matrix from the records in a CSV...">CsvFileDS</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1FileDS.html">FileDS</a> { |
| 122 | <a name="l00098"></a>00098 |
| 123 | <a name="l00099"></a>00099 <span class="keyword">public</span>: |
| 124 | <a name="l00101"></a>00101 <a class="code" href="classbdm_1_1CsvFileDS.html#8d9d56cdf6b8d0236e32a80e11c238b0" title="Constructor - create DS from a CSV file.">CsvFileDS</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span>& fname, <span class="keyword">const</span> <span class="keywordtype">string</span>& orientation = <span class="stringliteral">"BY_COL"</span> ); |
| 125 | <a name="l00102"></a>00102 }; |
| 126 | <a name="l00103"></a>00103 |
| 127 | <a name="l00104"></a>00104 |
| 128 | <a name="l00105"></a>00105 |
| 129 | <a name="l00110"></a><a class="code" href="classbdm_1_1ArxDS.html">00110</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1ArxDS.html" title="Generator of ARX data.">ArxDS</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1DS.html" title="Abstract class for discrete-time sources of data.">DS</a> { |
| 130 | <a name="l00111"></a>00111 <span class="keyword">protected</span>: |
| 131 | <a name="l00113"></a><a class="code" href="classbdm_1_1ArxDS.html#c7b3cc6cd059ff3d7f4462cedff4bdeb">00113</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1ArxDS.html#c7b3cc6cd059ff3d7f4462cedff4bdeb" title="Rv of the regressor.">Rrv</a>; |
| 132 | <a name="l00115"></a><a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597">00115</a> vec <a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a>; |
| 133 | <a name="l00117"></a><a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5">00117</a> vec <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a>; |
| 134 | <a name="l00119"></a><a class="code" href="classbdm_1_1ArxDS.html#b2d7530264499b92c3aa32454b960abe">00119</a> vec <a class="code" href="classbdm_1_1ArxDS.html#b2d7530264499b92c3aa32454b960abe" title="temporary variable for regressor">rgr</a>; |
| 135 | <a name="l00121"></a><a class="code" href="classbdm_1_1ArxDS.html#fbe7b993ec5f75c195ae1b2ccd96a898">00121</a> <a class="code" href="classbdm_1_1datalink.html" title="DataLink is a connection between two data vectors Up and Down.">datalink</a> <a class="code" href="classbdm_1_1ArxDS.html#fbe7b993ec5f75c195ae1b2ccd96a898" title="data link: H -&gt; rgr">rgrlnk</a>; |
| 136 | <a name="l00123"></a><a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb">00123</a> <a class="code" href="classbdm_1_1mlnorm.html">mlnorm<chmat></a> <a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>; |
| 137 | <a name="l00125"></a><a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1">00125</a> <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a>; |
| 138 | <a name="l00127"></a><a class="code" href="classbdm_1_1ArxDS.html#e13e5ffdfe9d896089310b0fc54e0c85">00127</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1ArxDS.html#e13e5ffdfe9d896089310b0fc54e0c85" title="loggers">L_theta</a>; |
| 139 | <a name="l00128"></a>00128 <span class="keywordtype">int</span> L_R; |
| 140 | <a name="l00129"></a>00129 <span class="keywordtype">int</span> dt_size; |
| 141 | <a name="l00130"></a>00130 <span class="keyword">public</span>: |
| 142 | <a name="l00131"></a><a class="code" href="classbdm_1_1ArxDS.html#db242e35812c311c8415bb7e31c3f595">00131</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#db242e35812c311c8415bb7e31c3f595" title="Returns full vector of observed data=[output, input].">getdata</a> ( vec &dt ) { |
| 143 | <a name="l00132"></a>00132 <span class="comment">//it_assert_debug ( dt.length() ==Drv.count(),"ArxDS" );</span> |
| 144 | <a name="l00133"></a>00133 dt=<a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a>; |
| 145 | <a name="l00134"></a>00134 }; |
| 146 | <a name="l00135"></a><a class="code" href="classbdm_1_1ArxDS.html#701151418bc5fc3861acef8359fb0d80">00135</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#701151418bc5fc3861acef8359fb0d80" title="Returns data records at indeces.">getdata</a> ( vec &dt, <span class="keyword">const</span> ivec &indices ) { |
| 147 | <a name="l00136"></a>00136 it_assert_debug ( dt.length() ==indices.length(),<span class="stringliteral">"ArxDS"</span> ); |
| 148 | <a name="l00137"></a>00137 dt=<a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a> ( indices ); |
| 149 | <a name="l00138"></a>00138 }; |
| 150 | <a name="l00139"></a><a class="code" href="classbdm_1_1ArxDS.html#8f6da8a00abba70bc58c7a4030bd8940">00139</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#8f6da8a00abba70bc58c7a4030bd8940" title="Accepts action variable and schedule it for application.">write</a> ( vec &ut ) { |
| 151 | <a name="l00140"></a>00140 <span class="comment">//it_assert_debug ( ut.length() ==Urv.count(),"ArxDS" );</span> |
| 152 | <a name="l00141"></a>00141 <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a>=ut; |
| 153 | <a name="l00142"></a>00142 }; |
| 154 | <a name="l00143"></a><a class="code" href="classbdm_1_1ArxDS.html#477fd706639535f520e9dbbd19f73318">00143</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#477fd706639535f520e9dbbd19f73318" title="Accepts action variables at specific indeces.">write</a> ( vec &ut, <span class="keyword">const</span> ivec &indices ) { |
| 155 | <a name="l00144"></a>00144 it_assert_debug ( ut.length() ==indices.length(),<span class="stringliteral">"ArxDS"</span> ); |
| 156 | <a name="l00145"></a>00145 set_subvector ( <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a>, indices,ut ); |
| 157 | <a name="l00146"></a>00146 }; |
| 158 | <a name="l00147"></a>00147 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#57dfa26b23cc03d53b123fa7e0474b19" title="Moves from to , i.e. perfroms the actions and reads response of the system.">step</a>(); |
| 159 | <a name="l00149"></a><a class="code" href="classbdm_1_1ArxDS.html#7c8b418677a48041adacac8e8e9c9849">00149</a> <a class="code" href="classbdm_1_1ArxDS.html#7c8b418677a48041adacac8e8e9c9849" title="Default constructor.">ArxDS</a> ( ) {}; |
| 160 | <a name="l00151"></a><a class="code" href="classbdm_1_1ArxDS.html#2d9abc62f1fee862f0e1c60c5c4a3c8a">00151</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#2d9abc62f1fee862f0e1c60c5c4a3c8a" title="Set parameters of the internal model, H is maximum time delay.">set_parameters</a> ( <span class="keyword">const</span> mat &Th0, <span class="keyword">const</span> vec mu0, <span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &sqR0 ) |
| 161 | <a name="l00152"></a>00152 { <a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#5d18dec3167584338a4775c1d165d96f" title="Set A and R.">set_parameters</a> ( Th0, mu0, sqR0 );}; |
| 162 | <a name="l00154"></a><a class="code" href="classbdm_1_1ArxDS.html#bf9cd9d4043d7e0dc61de56db37ec703">00154</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#bf9cd9d4043d7e0dc61de56db37ec703" title="Set.">set_drv</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &yrv, <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &urv, <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rrv ) { |
| 163 | <a name="l00155"></a>00155 <a class="code" href="classbdm_1_1ArxDS.html#c7b3cc6cd059ff3d7f4462cedff4bdeb" title="Rv of the regressor.">Rrv</a> = rrv; |
| 164 | <a name="l00156"></a>00156 <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a> = urv; |
| 165 | <a name="l00157"></a>00157 dt_size = yrv.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>() +urv.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
| 166 | <a name="l00158"></a>00158 |
| 167 | <a name="l00159"></a>00159 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> drv = concat ( yrv,urv ); |
| 168 | <a name="l00160"></a>00160 <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a> = drv; |
| 169 | <a name="l00161"></a>00161 <span class="keywordtype">int</span> td = rrv.<a class="code" href="classbdm_1_1RV.html#9a5c5aeeaf39299d07763377b05a8241" title="Minimum time-offset.">mint</a>(); |
| 170 | <a name="l00162"></a>00162 <a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a>.set_size ( drv.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>() * ( -td+1 ) ); |
| 171 | <a name="l00163"></a>00163 <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a>.set_size ( <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>() ); |
| 172 | <a name="l00164"></a>00164 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=-1;i>=td;i-- ) { |
| 173 | <a name="l00165"></a>00165 drv.<a class="code" href="classbdm_1_1RV.html#bd77cb0899f7fba1d0e34396137b7f1f" title="Shift time shifted by delta.">t</a> ( -1 ); |
| 174 | <a name="l00166"></a>00166 <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>.<a class="code" href="classbdm_1_1RV.html#87841b5ee43997b79789c0c22047e224" title="Add (concat) another variable to the current one,.">add</a> ( drv ); <span class="comment">//shift u1</span> |
| 175 | <a name="l00167"></a>00167 } |
| 176 | <a name="l00168"></a>00168 <a class="code" href="classbdm_1_1ArxDS.html#fbe7b993ec5f75c195ae1b2ccd96a898" title="data link: H -&gt; rgr">rgrlnk</a>.<a class="code" href="classbdm_1_1datalink.html#fb8337aac8329eb0ca96bfb3ff73ec67" title="set connection, rv must be fully present in rv_up">set_connection</a> ( rrv,<a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a> ); |
| 177 | <a name="l00169"></a>00169 |
| 178 | <a name="l00170"></a>00170 dtsize = <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
| 179 | <a name="l00171"></a>00171 utsize = <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
| 180 | <a name="l00172"></a>00172 } |
| 181 | <a name="l00174"></a><a class="code" href="classbdm_1_1ArxDS.html#e7438127de87c5a8128edfa12255b436">00174</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#e7438127de87c5a8128edfa12255b436" title="set options from a string">set_options</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> &s ) { |
| 182 | <a name="l00175"></a>00175 <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a>= ( s.find ( <span class="stringliteral">"L_theta"</span> ) !=string::npos ); |
| 183 | <a name="l00176"></a>00176 }; |
| 184 | <a name="l00177"></a><a class="code" href="classbdm_1_1ArxDS.html#64819633a1191fcaa60d0de26ade2e52">00177</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#64819633a1191fcaa60d0de26ade2e52" title="Register DS for logging into logger L.">log_add</a> ( <a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L ) { |
| 185 | <a name="l00178"></a>00178 <span class="comment">//DS::log_add ( L ); too long!!</span> |
| 186 | <a name="l00179"></a>00179 <a class="code" href="classbdm_1_1DS.html#b4b7bdb9d98a11ab587aa0ad803bb867" title="Remember its own index in Logger L.">L_dt</a>=L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a> ( 0,dt_size ),<span class="stringliteral">""</span> ); |
| 187 | <a name="l00180"></a>00180 L_ut=L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>,<span class="stringliteral">""</span> ); |
| 188 | <a name="l00181"></a>00181 |
| 189 | <a name="l00182"></a>00182 mat &A =<a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#262a2a486bff585f34bb6a5005b02614" title="access function">_A</a>(); |
| 190 | <a name="l00183"></a>00183 mat R =<a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#78120ecd1c2b1d7e80124b4603504604" title="access function">_R</a>(); |
| 191 | <a name="l00184"></a>00184 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a> ) {<a class="code" href="classbdm_1_1ArxDS.html#e13e5ffdfe9d896089310b0fc54e0c85" title="loggers">L_theta</a>=L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> ( <span class="stringliteral">"{th }"</span>, vec_1 ( A.rows() *A.cols() ) ),<span class="stringliteral">"t"</span> );} |
| 192 | <a name="l00185"></a>00185 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a> ) {L_R=L.<a class="code" href="classbdm_1_1logger.html#cfb4807e20b3d00f3d33e55ada528dc1">add</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> ( <span class="stringliteral">"{R }"</span>, vec_1 ( R.rows() *R.cols() ) ),<span class="stringliteral">"r"</span> );} |
| 193 | <a name="l00186"></a>00186 } |
| 194 | <a name="l00187"></a><a class="code" href="classbdm_1_1ArxDS.html#4128f5dc3a04063d62fc7e35635aeb90">00187</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1ArxDS.html#4128f5dc3a04063d62fc7e35635aeb90" title="Register DS for logging into logger L.">logit</a> ( <a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L ) { |
| 195 | <a name="l00188"></a>00188 <span class="comment">//DS::logit ( L );</span> |
| 196 | <a name="l00189"></a>00189 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( <a class="code" href="classbdm_1_1DS.html#b4b7bdb9d98a11ab587aa0ad803bb867" title="Remember its own index in Logger L.">L_dt</a>, <a class="code" href="classbdm_1_1ArxDS.html#a11a3f3fbeea1d17b66b073017964597" title="History, ordered as .">H</a>.left ( dt_size ) ); |
| 197 | <a name="l00190"></a>00190 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( L_ut, <a class="code" href="classbdm_1_1ArxDS.html#392b87be85675cb3d55fa4953d671bb5" title="(future) input">U</a> ); |
| 198 | <a name="l00191"></a>00191 |
| 199 | <a name="l00192"></a>00192 mat &A =<a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#262a2a486bff585f34bb6a5005b02614" title="access function">_A</a>(); |
| 200 | <a name="l00193"></a>00193 mat R =<a class="code" href="classbdm_1_1ArxDS.html#0aa9d8d35792159dc9611802f6c190eb" title="model of Y - linear Gaussian">model</a>.<a class="code" href="classbdm_1_1mlnorm.html#78120ecd1c2b1d7e80124b4603504604" title="access function">_R</a>(); |
| 201 | <a name="l00194"></a>00194 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a> ) {L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( <a class="code" href="classbdm_1_1ArxDS.html#e13e5ffdfe9d896089310b0fc54e0c85" title="loggers">L_theta</a>,vec ( A._data(), A.rows() *A.cols() ) );}; |
| 202 | <a name="l00195"></a>00195 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1ArxDS.html#064e5d3f2dc0b39459c7ca53d05223e1" title="options">opt_L_theta</a> ) {L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> ( L_R, vec ( R._data(), R.rows() *R.rows() ) );}; |
| 203 | <a name="l00196"></a>00196 } |
| 204 | <a name="l00197"></a>00197 |
| 205 | <a name="l00198"></a>00198 }; |
| 206 | <a name="l00199"></a>00199 |
| 207 | <a name="l00200"></a>00200 <span class="keyword">class </span>stateDS : <span class="keyword">public</span> DS { |
| 208 | <a name="l00201"></a>00201 <span class="keyword">protected</span>: |
| 209 | <a name="l00203"></a>00203 mpdf* IM; |
| 210 | <a name="l00205"></a>00205 mpdf* OM; |
| 211 | <a name="l00207"></a>00207 vec dt; |
| 212 | <a name="l00209"></a>00209 vec xt; |
| 213 | <a name="l00211"></a>00211 vec ut; |
| 214 | <a name="l00213"></a>00213 <span class="keywordtype">int</span> L_xt; |
| 215 | <a name="l00214"></a>00214 <span class="keyword">public</span>: |
| 216 | <a name="l00215"></a>00215 <span class="keywordtype">void</span> getdata ( vec &dt0 ) {dt0=dt;} |
| 217 | <a name="l00216"></a>00216 <span class="keywordtype">void</span> getdata ( vec &dt0, <span class="keyword">const</span> ivec &indeces ) {dt0=dt ( indeces );} |
| 218 | <a name="l00217"></a>00217 |
| 219 | <a name="l00218"></a>00218 stateDS ( mpdf* IM0, mpdf* OM0, <span class="keywordtype">int</span> usize ) :<a class="code" href="classbdm_1_1DS.html#bedd82e08ae6686b4b1732a122c2201a" title="default constructors">DS</a> ( ),IM ( IM0 ),OM ( OM0 ), |
| 220 | <a name="l00219"></a>00219 dt ( OM0->dimension() ), xt ( IM0->dimension() ), ut ( usize ) {} |
| 221 | <a name="l00220"></a>00220 ~stateDS() {<span class="keyword">delete</span> IM; <span class="keyword">delete</span> OM;} |
| 222 | <a name="l00221"></a>00221 <span class="keyword">virtual</span> <span class="keywordtype">void</span> step() { |
| 223 | <a name="l00222"></a>00222 xt=IM->samplecond ( concat ( xt,ut ) ); |
| 224 | <a name="l00223"></a>00223 dt=OM->samplecond ( concat ( xt,ut ) ); |
| 225 | <a name="l00224"></a>00224 }; |
| 226 | <a name="l00225"></a>00225 |
| 227 | <a name="l00226"></a>00226 <span class="keyword">virtual</span> <span class="keywordtype">void</span> log_add ( logger &L ) { |
| 228 | <a name="l00227"></a>00227 <a class="code" href="classbdm_1_1DS.html#3c9e417d85052396fe74c164857ee67e" title="Register DS for logging into logger L.">DS::log_add</a> ( L ); |
| 229 | <a name="l00228"></a>00228 L_xt=L.add ( IM->_rv(),<span class="stringliteral">"true"</span> ); |
| 230 | <a name="l00229"></a>00229 } |
| 231 | <a name="l00230"></a>00230 <span class="keyword">virtual</span> <span class="keywordtype">void</span> logit ( logger &L ) { |
| 232 | <a name="l00231"></a>00231 <a class="code" href="classbdm_1_1DS.html#e03d2c93cddd5c3a03107ddd3ae999cf" title="Register DS for logging into logger L.">DS::logit</a> ( L ); |
| 233 | <a name="l00232"></a>00232 L.logit ( L_xt,xt ); |
| 234 | <a name="l00233"></a>00233 } |
| 235 | <a name="l00234"></a>00234 |
| 236 | <a name="l00235"></a>00235 }; |
| 237 | <a name="l00236"></a>00236 |
| 238 | <a name="l00237"></a>00237 }; <span class="comment">//namespace</span> |
| 239 | <a name="l00238"></a>00238 |
| 240 | <a name="l00239"></a>00239 <span class="preprocessor">#endif // DS_H</span> |