88 | | <a name="l00125"></a><a class="code" href="classKalman.html#980fcd41c6c548c5da7b8b67c8e6da79">00125</a> mat& <a class="code" href="classKalman.html#980fcd41c6c548c5da7b8b67c8e6da79" title="access function">__K</a>() {<span class="keywordflow">return</span> <a class="code" href="classKalman.html#d422f51467c7a06174af2476d2826132" title="placeholder for Kalman gain">_K</a>;} |
89 | | <a name="l00127"></a><a class="code" href="classKalman.html#ac9540f3850b74d89a5fe4db6fc358ce">00127</a> vec <a class="code" href="classKalman.html#ac9540f3850b74d89a5fe4db6fc358ce" title="access function">_dP</a>() {<span class="keywordflow">return</span> <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>->getD();} |
90 | | <a name="l00128"></a>00128 }; |
91 | | <a name="l00129"></a>00129 |
92 | | <a name="l00132"></a><a class="code" href="classKalmanCh.html">00132</a> <span class="keyword">class </span><a class="code" href="classKalmanCh.html" title="Kalman filter in square root form.">KalmanCh</a> : <span class="keyword">public</span> <a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><chmat>{ |
93 | | <a name="l00133"></a>00133 <span class="keyword">protected</span>: |
94 | | <a name="l00135"></a><a class="code" href="classKalmanCh.html#94ee9da75b0e0f632e4a354988ca3798">00135</a> mat <a class="code" href="classKalmanCh.html#94ee9da75b0e0f632e4a354988ca3798" title="pre array (triangular matrix)">preA</a>; |
95 | | <a name="l00137"></a><a class="code" href="classKalmanCh.html#0d31a26dc72b5846cfe5af3ccb63ac87">00137</a> mat <a class="code" href="classKalmanCh.html#0d31a26dc72b5846cfe5af3ccb63ac87" title="post array (triangular matrix)">postA</a>; |
96 | | <a name="l00138"></a>00138 |
97 | | <a name="l00139"></a>00139 <span class="keyword">public</span>: |
98 | | <a name="l00141"></a><a class="code" href="classKalmanCh.html#d11f110cccaa66177514632d37b086bb">00141</a> <a class="code" href="classKalmanCh.html#d11f110cccaa66177514632d37b086bb" title="Default constructor.">KalmanCh</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx0, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvy0, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvu0 ):<a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><<a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>>(rvx0,rvy0,rvu0),<a class="code" href="classKalmanCh.html#94ee9da75b0e0f632e4a354988ca3798" title="pre array (triangular matrix)">preA</a>(<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>+<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>+<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>,<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>+<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>),<a class="code" href="classKalmanCh.html#0d31a26dc72b5846cfe5af3ccb63ac87" title="post array (triangular matrix)">postA</a>(<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>+<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>,<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>+<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>){}; |
99 | | <a name="l00143"></a>00143 <span class="keywordtype">void</span> <a class="code" href="classKalmanCh.html#92fb227287af05c9f0078d523c7c9793" title="Set parameters with check of relevance.">set_parameters</a> ( <span class="keyword">const</span> mat &A0,<span class="keyword">const</span> mat &B0,<span class="keyword">const</span> mat &C0,<span class="keyword">const</span> mat &D0,<span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &R0,<span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &Q0 ); |
100 | | <a name="l00144"></a><a class="code" href="classKalmanCh.html#b261b20f6210d4c85131d33302df0adc">00144</a> <span class="keywordtype">void</span> <a class="code" href="classKalmanCh.html#b261b20f6210d4c85131d33302df0adc" title="Set estimate values, used e.g. in initialization.">set_est</a> ( <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> &P0 ) { |
101 | | <a name="l00145"></a>00145 <a class="code" href="classKalman.html#5568c74bac67ae6d3b1061dba60c9424" title="posterior density on $x_t$">est</a>.<a class="code" href="classenorm.html#1394a65caa6e00d42e00cc99b12227af" title="Set mean value mu and covariance R.">set_parameters</a> ( mu0,P0 ); |
102 | | <a name="l00146"></a>00146 }; |
103 | | <a name="l00147"></a>00147 |
| 88 | <a name="l00124"></a><a class="code" href="classKalman.html#11f82ef04e3dbc54bd1d3d89edb6aa07">00124</a> <span class="keyword">const</span> <a class="code" href="classenorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T></a>* <a class="code" href="classKalman.html#11f82ef04e3dbc54bd1d3d89edb6aa07" title="Returns a pointer to the epdf representing posterior density on parameters. Use with...">_e</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> &<a class="code" href="classKalman.html#5568c74bac67ae6d3b1061dba60c9424" title="posterior density on $x_t$">est</a>;} |
| 89 | <a name="l00126"></a><a class="code" href="classKalman.html#980fcd41c6c548c5da7b8b67c8e6da79">00126</a> mat& <a class="code" href="classKalman.html#980fcd41c6c548c5da7b8b67c8e6da79" title="access function">__K</a>() {<span class="keywordflow">return</span> <a class="code" href="classKalman.html#d422f51467c7a06174af2476d2826132" title="placeholder for Kalman gain">_K</a>;} |
| 90 | <a name="l00128"></a><a class="code" href="classKalman.html#ac9540f3850b74d89a5fe4db6fc358ce">00128</a> vec <a class="code" href="classKalman.html#ac9540f3850b74d89a5fe4db6fc358ce" title="access function">_dP</a>() {<span class="keywordflow">return</span> <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>->getD();} |
| 91 | <a name="l00129"></a>00129 }; |
| 92 | <a name="l00130"></a>00130 |
| 93 | <a name="l00133"></a><a class="code" href="classKalmanCh.html">00133</a> <span class="keyword">class </span><a class="code" href="classKalmanCh.html" title="Kalman filter in square root form.">KalmanCh</a> : <span class="keyword">public</span> <a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><chmat>{ |
| 94 | <a name="l00134"></a>00134 <span class="keyword">protected</span>: |
| 95 | <a name="l00136"></a><a class="code" href="classKalmanCh.html#94ee9da75b0e0f632e4a354988ca3798">00136</a> mat <a class="code" href="classKalmanCh.html#94ee9da75b0e0f632e4a354988ca3798" title="pre array (triangular matrix)">preA</a>; |
| 96 | <a name="l00138"></a><a class="code" href="classKalmanCh.html#0d31a26dc72b5846cfe5af3ccb63ac87">00138</a> mat <a class="code" href="classKalmanCh.html#0d31a26dc72b5846cfe5af3ccb63ac87" title="post array (triangular matrix)">postA</a>; |
| 97 | <a name="l00139"></a>00139 |
| 98 | <a name="l00140"></a>00140 <span class="keyword">public</span>: |
| 99 | <a name="l00142"></a><a class="code" href="classKalmanCh.html#d11f110cccaa66177514632d37b086bb">00142</a> <a class="code" href="classKalmanCh.html#d11f110cccaa66177514632d37b086bb" title="Default constructor.">KalmanCh</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx0, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvy0, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvu0 ):<a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><<a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>>(rvx0,rvy0,rvu0),<a class="code" href="classKalmanCh.html#94ee9da75b0e0f632e4a354988ca3798" title="pre array (triangular matrix)">preA</a>(<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>+<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>+<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>,<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>+<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>),<a class="code" href="classKalmanCh.html#0d31a26dc72b5846cfe5af3ccb63ac87" title="post array (triangular matrix)">postA</a>(<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>+<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>,<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>+<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>){}; |
| 100 | <a name="l00144"></a>00144 <span class="keywordtype">void</span> <a class="code" href="classKalmanCh.html#92fb227287af05c9f0078d523c7c9793" title="Set parameters with check of relevance.">set_parameters</a> ( <span class="keyword">const</span> mat &A0,<span class="keyword">const</span> mat &B0,<span class="keyword">const</span> mat &C0,<span class="keyword">const</span> mat &D0,<span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &R0,<span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &Q0 ); |
| 101 | <a name="l00145"></a><a class="code" href="classKalmanCh.html#b261b20f6210d4c85131d33302df0adc">00145</a> <span class="keywordtype">void</span> <a class="code" href="classKalmanCh.html#b261b20f6210d4c85131d33302df0adc" title="Set estimate values, used e.g. in initialization.">set_est</a> ( <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> &P0 ) { |
| 102 | <a name="l00146"></a>00146 <a class="code" href="classKalman.html#5568c74bac67ae6d3b1061dba60c9424" title="posterior density on $x_t$">est</a>.<a class="code" href="classenorm.html#1394a65caa6e00d42e00cc99b12227af" title="Set mean value mu and covariance R.">set_parameters</a> ( mu0,P0 ); |
| 103 | <a name="l00147"></a>00147 }; |
105 | | <a name="l00162"></a>00162 <span class="keywordtype">void</span> <a class="code" href="classKalmanCh.html#cca758192846940409822b9bd778d4e1" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
106 | | <a name="l00163"></a>00163 }; |
107 | | <a name="l00164"></a>00164 |
108 | | <a name="l00170"></a><a class="code" href="classEKFfull.html">00170</a> <span class="keyword">class </span><a class="code" href="classEKFfull.html" title="Extended Kalman Filter in full matrices.">EKFfull</a> : <span class="keyword">public</span> <a class="code" href="classKalmanFull.html" title="Basic Kalman filter with full matrices (education purpose only)! Will be deleted...">KalmanFull</a>, <span class="keyword">public</span> <a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> { |
109 | | <a name="l00171"></a>00171 |
110 | | <a name="l00173"></a>00173 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu; |
111 | | <a name="l00175"></a>00175 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu; |
112 | | <a name="l00176"></a>00176 |
113 | | <a name="l00177"></a>00177 <a class="code" href="classenorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<fsqmat></a> E; |
114 | | <a name="l00178"></a>00178 <span class="keyword">public</span>: |
115 | | <a name="l00180"></a>00180 <a class="code" href="classEKFfull.html#67ac4de96fd025197da767fe0472c7f7" title="Default constructor.">EKFfull</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvy, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvu ); |
116 | | <a name="l00182"></a>00182 <span class="keywordtype">void</span> <a class="code" href="classEKFfull.html#fc753106e0d4cf68e4f2160fd54458c0" title="Set nonlinear functions for mean values and covariance matrices.">set_parameters</a> ( <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu, <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu, <span class="keyword">const</span> mat Q0, <span class="keyword">const</span> mat R0 ); |
117 | | <a name="l00184"></a>00184 <span class="keywordtype">void</span> <a class="code" href="classEKFfull.html#8ca46f177e395fa714bbd8bd29ea43e0" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
118 | | <a name="l00186"></a><a class="code" href="classEKFfull.html#7bb76ea74c144ea0b36db99f94750b7b">00186</a> <span class="keywordtype">void</span> <a class="code" href="classEKFfull.html#7bb76ea74c144ea0b36db99f94750b7b" title="set estimates">set_est</a> (vec mu0, mat P0){<a class="code" href="classKalmanFull.html#fb5aec635e2720cc5ac31bc01c18a68a" title="Mean value of the posterior density.">mu</a>=mu0;<a class="code" href="classKalmanFull.html#b75dc059e84fa8ffc076203b30f926cc" title="Variance of the posterior density.">P</a>=P0;}; |
119 | | <a name="l00188"></a><a class="code" href="classEKFfull.html#170a748ad944bdebb0b3073463876abe">00188</a> <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>& <a class="code" href="classEKFfull.html#170a748ad944bdebb0b3073463876abe" title="dummy!">_epdf</a>()<span class="keyword">const</span>{<span class="keywordflow">return</span> E;}; |
120 | | <a name="l00189"></a>00189 }; |
121 | | <a name="l00190"></a>00190 |
122 | | <a name="l00196"></a>00196 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
123 | | <a name="l00197"></a><a class="code" href="classEKF.html">00197</a> <span class="keyword">class </span><a class="code" href="classEKF.html" title="Extended Kalman Filter.">EKF</a> : <span class="keyword">public</span> <a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><fsqmat> { |
124 | | <a name="l00199"></a>00199 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu; |
125 | | <a name="l00201"></a>00201 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu; |
126 | | <a name="l00202"></a>00202 <span class="keyword">public</span>: |
127 | | <a name="l00204"></a>00204 <a class="code" href="classEKF.html#ea4f3254cacf0a92d2a820b1201d049e" title="Default constructor.">EKF</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalman.html#7501230c2fafa3655887d2da23b3184c" title="Indetifier of output rv.">rvy</a>, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalman.html#44a16ffd5ac1e6e39bae34fea9e1e498" title="Indetifier of exogeneous rv.">rvu</a> ); |
128 | | <a name="l00206"></a>00206 <span class="keywordtype">void</span> <a class="code" href="classEKF.html#28d058ae4d24d992d2f055419a06ee66" title="Set nonlinear functions for mean values and covariance matrices.">set_parameters</a> ( <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu, <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu, <span class="keyword">const</span> sq_T Q0, <span class="keyword">const</span> sq_T R0 ); |
129 | | <a name="l00208"></a>00208 <span class="keywordtype">void</span> <a class="code" href="classEKF.html#c79c62c9b3e0b56b3aaa1b6f1d9a7af7" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
130 | | <a name="l00209"></a>00209 }; |
131 | | <a name="l00210"></a>00210 |
132 | | <a name="l00217"></a><a class="code" href="classEKFCh.html">00217</a> <span class="keyword">class </span><a class="code" href="classEKFCh.html" title="Extended Kalman Filter in Square root.">EKFCh</a> : <span class="keyword">public</span> <a class="code" href="classKalmanCh.html" title="Kalman filter in square root form.">KalmanCh</a> { |
133 | | <a name="l00219"></a>00219 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu; |
134 | | <a name="l00221"></a>00221 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu; |
135 | | <a name="l00222"></a>00222 <span class="keyword">public</span>: |
136 | | <a name="l00224"></a>00224 <a class="code" href="classEKFCh.html#e9e39a9204db3dda88d06e47c1e19064" title="Default constructor.">EKFCh</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalman.html#7501230c2fafa3655887d2da23b3184c" title="Indetifier of output rv.">rvy</a>, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalman.html#44a16ffd5ac1e6e39bae34fea9e1e498" title="Indetifier of exogeneous rv.">rvu</a> ); |
137 | | <a name="l00226"></a>00226 <span class="keywordtype">void</span> <a class="code" href="classEKFCh.html#0216bed270df59fe65d0d62d41f8257c" title="Set nonlinear functions for mean values and covariance matrices.">set_parameters</a> ( <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu, <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu, <span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> Q0, <span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> R0 ); |
138 | | <a name="l00228"></a>00228 <span class="keywordtype">void</span> <a class="code" href="classEKFCh.html#96f6edda324a0b7ef8b4e86cc7af60c1" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
139 | | <a name="l00229"></a>00229 }; |
140 | | <a name="l00230"></a>00230 |
141 | | <a name="l00235"></a><a class="code" href="classKFcondQR.html">00235</a> <span class="keyword">class </span><a class="code" href="classKFcondQR.html" title="Kalman Filter with conditional diagonal matrices R and Q.">KFcondQR</a> : <span class="keyword">public</span> <a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><ldmat>, <span class="keyword">public</span> <a class="code" href="classBMcond.html" title="Conditional Bayesian Filter.">BMcond</a> { |
142 | | <a name="l00236"></a>00236 <span class="comment">//protected:</span> |
143 | | <a name="l00237"></a>00237 <span class="keyword">public</span>: |
144 | | <a name="l00239"></a><a class="code" href="classKFcondQR.html#3f3968f92c7bbe4b0902d5e14ecc1cb4">00239</a> <a class="code" href="classKFcondQR.html#3f3968f92c7bbe4b0902d5e14ecc1cb4" title="Default constructor.">KFcondQR</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalman.html#7501230c2fafa3655887d2da23b3184c" title="Indetifier of output rv.">rvy</a>, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalman.html#44a16ffd5ac1e6e39bae34fea9e1e498" title="Indetifier of exogeneous rv.">rvu</a>, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvRQ ) : <a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><<a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a>> ( rvx, rvy,rvu ),<a class="code" href="classBMcond.html" title="Conditional Bayesian Filter.">BMcond</a> ( rvRQ ) {}; |
145 | | <a name="l00240"></a>00240 |
146 | | <a name="l00241"></a>00241 <span class="keywordtype">void</span> <a class="code" href="classKFcondQR.html#c9ecf292a85327aa6309c9fd70ceb606" title="Substitute val for rvc.">condition</a> ( <span class="keyword">const</span> vec &RQ ); |
147 | | <a name="l00242"></a>00242 }; |
148 | | <a name="l00243"></a>00243 |
149 | | <a name="l00248"></a><a class="code" href="classKFcondR.html">00248</a> <span class="keyword">class </span><a class="code" href="classKFcondR.html" title="Kalman Filter with conditional diagonal matrices R and Q.">KFcondR</a> : <span class="keyword">public</span> <a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><ldmat>, <span class="keyword">public</span> <a class="code" href="classBMcond.html" title="Conditional Bayesian Filter.">BMcond</a> { |
150 | | <a name="l00249"></a>00249 <span class="comment">//protected:</span> |
151 | | <a name="l00250"></a>00250 <span class="keyword">public</span>: |
152 | | <a name="l00252"></a><a class="code" href="classKFcondR.html#d2acbb8e66c7ee592b1a9da5b429a69e">00252</a> <a class="code" href="classKFcondR.html#d2acbb8e66c7ee592b1a9da5b429a69e" title="Default constructor.">KFcondR</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalman.html#7501230c2fafa3655887d2da23b3184c" title="Indetifier of output rv.">rvy</a>, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalman.html#44a16ffd5ac1e6e39bae34fea9e1e498" title="Indetifier of exogeneous rv.">rvu</a>, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvR ) : <a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><<a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a>> ( rvx, rvy,rvu ),<a class="code" href="classBMcond.html" title="Conditional Bayesian Filter.">BMcond</a> ( rvR ) {}; |
153 | | <a name="l00253"></a>00253 |
154 | | <a name="l00254"></a>00254 <span class="keywordtype">void</span> <a class="code" href="classKFcondR.html#8c0721e47879bb8840d829db7a174a7f" title="Substitute val for rvc.">condition</a> ( <span class="keyword">const</span> vec &<a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a> ); |
155 | | <a name="l00255"></a>00255 }; |
156 | | <a name="l00256"></a>00256 |
| 105 | <a name="l00149"></a>00149 |
| 106 | <a name="l00163"></a>00163 <span class="keywordtype">void</span> <a class="code" href="classKalmanCh.html#cca758192846940409822b9bd778d4e1" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
| 107 | <a name="l00164"></a>00164 }; |
| 108 | <a name="l00165"></a>00165 |
| 109 | <a name="l00171"></a><a class="code" href="classEKFfull.html">00171</a> <span class="keyword">class </span><a class="code" href="classEKFfull.html" title="Extended Kalman Filter in full matrices.">EKFfull</a> : <span class="keyword">public</span> <a class="code" href="classKalmanFull.html" title="Basic Kalman filter with full matrices (education purpose only)! Will be deleted...">KalmanFull</a>, <span class="keyword">public</span> <a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> { |
| 110 | <a name="l00172"></a>00172 |
| 111 | <a name="l00174"></a>00174 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu; |
| 112 | <a name="l00176"></a>00176 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu; |
| 113 | <a name="l00177"></a>00177 |
| 114 | <a name="l00178"></a>00178 <a class="code" href="classenorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<fsqmat></a> E; |
| 115 | <a name="l00179"></a>00179 <span class="keyword">public</span>: |
| 116 | <a name="l00181"></a>00181 <a class="code" href="classEKFfull.html#67ac4de96fd025197da767fe0472c7f7" title="Default constructor.">EKFfull</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvy, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvu ); |
| 117 | <a name="l00183"></a>00183 <span class="keywordtype">void</span> <a class="code" href="classEKFfull.html#fc753106e0d4cf68e4f2160fd54458c0" title="Set nonlinear functions for mean values and covariance matrices.">set_parameters</a> ( <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu, <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu, <span class="keyword">const</span> mat Q0, <span class="keyword">const</span> mat R0 ); |
| 118 | <a name="l00185"></a>00185 <span class="keywordtype">void</span> <a class="code" href="classEKFfull.html#8ca46f177e395fa714bbd8bd29ea43e0" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
| 119 | <a name="l00187"></a><a class="code" href="classEKFfull.html#7bb76ea74c144ea0b36db99f94750b7b">00187</a> <span class="keywordtype">void</span> <a class="code" href="classEKFfull.html#7bb76ea74c144ea0b36db99f94750b7b" title="set estimates">set_est</a> (vec mu0, mat P0){<a class="code" href="classKalmanFull.html#fb5aec635e2720cc5ac31bc01c18a68a" title="Mean value of the posterior density.">mu</a>=mu0;<a class="code" href="classKalmanFull.html#b75dc059e84fa8ffc076203b30f926cc" title="Variance of the posterior density.">P</a>=P0;}; |
| 120 | <a name="l00189"></a><a class="code" href="classEKFfull.html#170a748ad944bdebb0b3073463876abe">00189</a> <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>& <a class="code" href="classEKFfull.html#170a748ad944bdebb0b3073463876abe" title="dummy!">_epdf</a>()<span class="keyword">const</span>{<span class="keywordflow">return</span> E;}; |
| 121 | <a name="l00190"></a><a class="code" href="classEKFfull.html#820987401e922a03c7d36013e42d8c48">00190</a> <span class="keyword">const</span> <a class="code" href="classenorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<fsqmat></a>* <a class="code" href="classEKFfull.html#820987401e922a03c7d36013e42d8c48" title="Returns a pointer to the epdf representing posterior density on parameters. Use with...">_e</a>()<span class="keyword">const</span>{<span class="keywordflow">return</span> &E;}; |
| 122 | <a name="l00191"></a>00191 }; |
| 123 | <a name="l00192"></a>00192 |
| 124 | <a name="l00198"></a>00198 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 125 | <a name="l00199"></a><a class="code" href="classEKF.html">00199</a> <span class="keyword">class </span><a class="code" href="classEKF.html" title="Extended Kalman Filter.">EKF</a> : <span class="keyword">public</span> <a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><fsqmat> { |
| 126 | <a name="l00201"></a>00201 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu; |
| 127 | <a name="l00203"></a>00203 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu; |
| 128 | <a name="l00204"></a>00204 <span class="keyword">public</span>: |
| 129 | <a name="l00206"></a>00206 <a class="code" href="classEKF.html#ea4f3254cacf0a92d2a820b1201d049e" title="Default constructor.">EKF</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalman.html#7501230c2fafa3655887d2da23b3184c" title="Indetifier of output rv.">rvy</a>, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalman.html#44a16ffd5ac1e6e39bae34fea9e1e498" title="Indetifier of exogeneous rv.">rvu</a> ); |
| 130 | <a name="l00208"></a>00208 <span class="keywordtype">void</span> <a class="code" href="classEKF.html#28d058ae4d24d992d2f055419a06ee66" title="Set nonlinear functions for mean values and covariance matrices.">set_parameters</a> ( <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu, <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu, <span class="keyword">const</span> sq_T Q0, <span class="keyword">const</span> sq_T R0 ); |
| 131 | <a name="l00210"></a>00210 <span class="keywordtype">void</span> <a class="code" href="classEKF.html#c79c62c9b3e0b56b3aaa1b6f1d9a7af7" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
| 132 | <a name="l00211"></a>00211 }; |
| 133 | <a name="l00212"></a>00212 |
| 134 | <a name="l00219"></a><a class="code" href="classEKFCh.html">00219</a> <span class="keyword">class </span><a class="code" href="classEKFCh.html" title="Extended Kalman Filter in Square root.">EKFCh</a> : <span class="keyword">public</span> <a class="code" href="classKalmanCh.html" title="Kalman filter in square root form.">KalmanCh</a> { |
| 135 | <a name="l00221"></a>00221 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu; |
| 136 | <a name="l00223"></a>00223 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu; |
| 137 | <a name="l00224"></a>00224 <span class="keyword">public</span>: |
| 138 | <a name="l00226"></a>00226 <a class="code" href="classEKFCh.html#e9e39a9204db3dda88d06e47c1e19064" title="Default constructor.">EKFCh</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalman.html#7501230c2fafa3655887d2da23b3184c" title="Indetifier of output rv.">rvy</a>, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalman.html#44a16ffd5ac1e6e39bae34fea9e1e498" title="Indetifier of exogeneous rv.">rvu</a> ); |
| 139 | <a name="l00228"></a>00228 <span class="keywordtype">void</span> <a class="code" href="classEKFCh.html#0216bed270df59fe65d0d62d41f8257c" title="Set nonlinear functions for mean values and covariance matrices.">set_parameters</a> ( <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu, <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu, <span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> Q0, <span class="keyword">const</span> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> R0 ); |
| 140 | <a name="l00230"></a>00230 <span class="keywordtype">void</span> <a class="code" href="classEKFCh.html#96f6edda324a0b7ef8b4e86cc7af60c1" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
| 141 | <a name="l00231"></a>00231 }; |
| 142 | <a name="l00232"></a>00232 |
| 143 | <a name="l00237"></a><a class="code" href="classKFcondQR.html">00237</a> <span class="keyword">class </span><a class="code" href="classKFcondQR.html" title="Kalman Filter with conditional diagonal matrices R and Q.">KFcondQR</a> : <span class="keyword">public</span> <a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><ldmat>, <span class="keyword">public</span> <a class="code" href="classBMcond.html" title="Conditional Bayesian Filter.">BMcond</a> { |
| 144 | <a name="l00238"></a>00238 <span class="comment">//protected:</span> |
| 145 | <a name="l00239"></a>00239 <span class="keyword">public</span>: |
| 146 | <a name="l00241"></a><a class="code" href="classKFcondQR.html#3f3968f92c7bbe4b0902d5e14ecc1cb4">00241</a> <a class="code" href="classKFcondQR.html#3f3968f92c7bbe4b0902d5e14ecc1cb4" title="Default constructor.">KFcondQR</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalman.html#7501230c2fafa3655887d2da23b3184c" title="Indetifier of output rv.">rvy</a>, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalman.html#44a16ffd5ac1e6e39bae34fea9e1e498" title="Indetifier of exogeneous rv.">rvu</a>, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvRQ ) : <a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><<a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a>> ( rvx, rvy,rvu ),<a class="code" href="classBMcond.html" title="Conditional Bayesian Filter.">BMcond</a> ( rvRQ ) {}; |
| 147 | <a name="l00242"></a>00242 |
| 148 | <a name="l00243"></a>00243 <span class="keywordtype">void</span> <a class="code" href="classKFcondQR.html#c9ecf292a85327aa6309c9fd70ceb606" title="Substitute val for rvc.">condition</a> ( <span class="keyword">const</span> vec &RQ ); |
| 149 | <a name="l00244"></a>00244 }; |
| 150 | <a name="l00245"></a>00245 |
| 151 | <a name="l00250"></a><a class="code" href="classKFcondR.html">00250</a> <span class="keyword">class </span><a class="code" href="classKFcondR.html" title="Kalman Filter with conditional diagonal matrices R and Q.">KFcondR</a> : <span class="keyword">public</span> <a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><ldmat>, <span class="keyword">public</span> <a class="code" href="classBMcond.html" title="Conditional Bayesian Filter.">BMcond</a> { |
| 152 | <a name="l00251"></a>00251 <span class="comment">//protected:</span> |
| 153 | <a name="l00252"></a>00252 <span class="keyword">public</span>: |
| 154 | <a name="l00254"></a><a class="code" href="classKFcondR.html#d2acbb8e66c7ee592b1a9da5b429a69e">00254</a> <a class="code" href="classKFcondR.html#d2acbb8e66c7ee592b1a9da5b429a69e" title="Default constructor.">KFcondR</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalman.html#7501230c2fafa3655887d2da23b3184c" title="Indetifier of output rv.">rvy</a>, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalman.html#44a16ffd5ac1e6e39bae34fea9e1e498" title="Indetifier of exogeneous rv.">rvu</a>, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvR ) : <a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><<a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a>> ( rvx, rvy,rvu ),<a class="code" href="classBMcond.html" title="Conditional Bayesian Filter.">BMcond</a> ( rvR ) {}; |
| 155 | <a name="l00255"></a>00255 |
| 156 | <a name="l00256"></a>00256 <span class="keywordtype">void</span> <a class="code" href="classKFcondR.html#8c0721e47879bb8840d829db7a174a7f" title="Substitute val for rvc.">condition</a> ( <span class="keyword">const</span> vec &<a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a> ); |
| 157 | <a name="l00257"></a>00257 }; |
158 | | <a name="l00259"></a>00259 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
159 | | <a name="l00260"></a><a class="code" href="classKalman.html#ce38e31810aea4db45a83ad05eaba009">00260</a> <a class="code" href="classKalman.html#3d56b0a97b8c1e25fdd3b10eef3c2ad3" title="Default constructor.">Kalman<sq_T>::Kalman</a> ( <span class="keyword">const</span> <a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman<sq_T></a> &K0 ) : <a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> ( K0.rv ),rvy ( K0.rvy ),rvu ( K0.rvu ), |
160 | | <a name="l00261"></a>00261 dimx ( rv.count() ), dimy ( rvy.count() ),dimu ( rvu.count() ), |
161 | | <a name="l00262"></a>00262 A ( dimx,dimx ), B ( dimx,dimu ), C ( dimy,dimx ), D ( dimy,dimu ), |
162 | | <a name="l00263"></a>00263 Q(dimx), R(dimy), |
163 | | <a name="l00264"></a>00264 est ( rv ), fy ( rvy ), _yp(fy._mu()),_Ry(fy._R()), _mu(est._mu()), _P(est._R()) { |
164 | | <a name="l00265"></a>00265 |
165 | | <a name="l00266"></a>00266 this-><a class="code" href="classKalman.html#239b28a0380946f5749b2f8d2807f93a" title="Set parameters with check of relevance.">set_parameters</a> ( K0.<a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a>, K0.<a class="code" href="classKalman.html#dc87704284a6c0bca13bf51f4345a50a" title="Matrix B.">B</a>, K0.<a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>, K0.<a class="code" href="classKalman.html#d69f774ba3335c970c1c5b1d182f4dd1" title="Matrix D.">D</a>, K0.<a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a>, K0.<a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a> ); |
| 159 | <a name="l00260"></a>00260 |
| 160 | <a name="l00261"></a>00261 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 161 | <a name="l00262"></a><a class="code" href="classKalman.html#ce38e31810aea4db45a83ad05eaba009">00262</a> <a class="code" href="classKalman.html#3d56b0a97b8c1e25fdd3b10eef3c2ad3" title="Default constructor.">Kalman<sq_T>::Kalman</a> ( <span class="keyword">const</span> <a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman<sq_T></a> &K0 ) : <a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> ( K0.rv ),rvy ( K0.rvy ),rvu ( K0.rvu ), |
| 162 | <a name="l00263"></a>00263 dimx ( rv.count() ), dimy ( rvy.count() ),dimu ( rvu.count() ), |
| 163 | <a name="l00264"></a>00264 A ( dimx,dimx ), B ( dimx,dimu ), C ( dimy,dimx ), D ( dimy,dimu ), |
| 164 | <a name="l00265"></a>00265 Q(dimx), R(dimy), |
| 165 | <a name="l00266"></a>00266 est ( rv ), fy ( rvy ), _yp(fy._mu()),_Ry(fy._R()), _mu(est._mu()), _P(est._R()) { |
175 | | <a name="l00276"></a>00276 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
176 | | <a name="l00277"></a><a class="code" href="classKalman.html#3d56b0a97b8c1e25fdd3b10eef3c2ad3">00277</a> <a class="code" href="classKalman.html#3d56b0a97b8c1e25fdd3b10eef3c2ad3" title="Default constructor.">Kalman<sq_T>::Kalman</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvy0, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvu0 ) : <a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> ( rvx ),<a class="code" href="classKalman.html#7501230c2fafa3655887d2da23b3184c" title="Indetifier of output rv.">rvy</a> ( rvy0 ),<a class="code" href="classKalman.html#44a16ffd5ac1e6e39bae34fea9e1e498" title="Indetifier of exogeneous rv.">rvu</a> ( rvu0 ), |
177 | | <a name="l00278"></a>00278 <a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a> ( rvx.count() ), <a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a> ( <a class="code" href="classKalman.html#7501230c2fafa3655887d2da23b3184c" title="Indetifier of output rv.">rvy</a>.count() ),<a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a> ( <a class="code" href="classKalman.html#44a16ffd5ac1e6e39bae34fea9e1e498" title="Indetifier of exogeneous rv.">rvu</a>.count() ), |
178 | | <a name="l00279"></a>00279 <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a> ( <a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>,<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a> ), <a class="code" href="classKalman.html#dc87704284a6c0bca13bf51f4345a50a" title="Matrix B.">B</a> ( <a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>,<a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a> ), <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a> ( <a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>,<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a> ), <a class="code" href="classKalman.html#d69f774ba3335c970c1c5b1d182f4dd1" title="Matrix D.">D</a> ( <a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>,<a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a> ), |
179 | | <a name="l00280"></a>00280 <a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a>(<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>), <a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a> (<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>), |
180 | | <a name="l00281"></a>00281 <a class="code" href="classKalman.html#5568c74bac67ae6d3b1061dba60c9424" title="posterior density on $x_t$">est</a> ( rvx ), <a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a> ( <a class="code" href="classKalman.html#7501230c2fafa3655887d2da23b3184c" title="Indetifier of output rv.">rvy</a> ), <a class="code" href="classKalman.html#764bbc95238eda11fc81c5ebd0b1dcfd" title="cache of fy.mu">_yp</a>(<a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a>.<a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>()),<a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a>(<a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a>._R()),<a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>(<a class="code" href="classKalman.html#5568c74bac67ae6d3b1061dba60c9424" title="posterior density on $x_t$">est</a>.<a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>()), <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>(<a class="code" href="classKalman.html#5568c74bac67ae6d3b1061dba60c9424" title="posterior density on $x_t$">est</a>._R()) { |
181 | | <a name="l00282"></a>00282 }; |
182 | | <a name="l00283"></a>00283 |
183 | | <a name="l00284"></a>00284 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
184 | | <a name="l00285"></a><a class="code" href="classKalman.html#239b28a0380946f5749b2f8d2807f93a">00285</a> <span class="keywordtype">void</span> <a class="code" href="classKalman.html#239b28a0380946f5749b2f8d2807f93a" title="Set parameters with check of relevance.">Kalman<sq_T>::set_parameters</a> ( <span class="keyword">const</span> mat &A0,<span class="keyword">const</span> mat &B0, <span class="keyword">const</span> mat &C0, <span class="keyword">const</span> mat &D0, <span class="keyword">const</span> sq_T &R0, <span class="keyword">const</span> sq_T &Q0 ) { |
185 | | <a name="l00286"></a>00286 it_assert_debug ( A0.cols() ==<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>, <span class="stringliteral">"Kalman: A is not square"</span> ); |
186 | | <a name="l00287"></a>00287 it_assert_debug ( B0.rows() ==<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>, <span class="stringliteral">"Kalman: B is not compatible"</span> ); |
187 | | <a name="l00288"></a>00288 it_assert_debug ( C0.cols() ==<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>, <span class="stringliteral">"Kalman: C is not square"</span> ); |
188 | | <a name="l00289"></a>00289 it_assert_debug ( ( D0.rows() ==<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a> ) || ( D0.cols() ==<a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a> ), <span class="stringliteral">"Kalman: D is not compatible"</span> ); |
189 | | <a name="l00290"></a>00290 it_assert_debug ( ( R0.cols() ==<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a> ) || ( R0.rows() ==<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a> ), <span class="stringliteral">"Kalman: R is not compatible"</span> ); |
190 | | <a name="l00291"></a>00291 it_assert_debug ( ( Q0.cols() ==<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a> ) || ( Q0.rows() ==<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a> ), <span class="stringliteral">"Kalman: Q is not compatible"</span> ); |
191 | | <a name="l00292"></a>00292 |
192 | | <a name="l00293"></a>00293 <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a> = A0; |
193 | | <a name="l00294"></a>00294 <a class="code" href="classKalman.html#dc87704284a6c0bca13bf51f4345a50a" title="Matrix B.">B</a> = B0; |
194 | | <a name="l00295"></a>00295 <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a> = C0; |
195 | | <a name="l00296"></a>00296 <a class="code" href="classKalman.html#d69f774ba3335c970c1c5b1d182f4dd1" title="Matrix D.">D</a> = D0; |
196 | | <a name="l00297"></a>00297 <a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a> = R0; |
197 | | <a name="l00298"></a>00298 <a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a> = Q0; |
198 | | <a name="l00299"></a>00299 } |
199 | | <a name="l00300"></a>00300 |
200 | | <a name="l00301"></a>00301 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
201 | | <a name="l00302"></a><a class="code" href="classKalman.html#7750ffd73f261828a32c18aaeb65c75c">00302</a> <span class="keywordtype">void</span> <a class="code" href="classKalman.html#7750ffd73f261828a32c18aaeb65c75c" title="Here dt = [yt;ut] of appropriate dimensions.">Kalman<sq_T>::bayes</a> ( <span class="keyword">const</span> vec &dt ) { |
202 | | <a name="l00303"></a>00303 it_assert_debug ( dt.length() == ( <a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>+<a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a> ),<span class="stringliteral">"KalmanFull::bayes wrong size of dt"</span> ); |
203 | | <a name="l00304"></a>00304 |
204 | | <a name="l00305"></a>00305 sq_T iRy(<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>); |
205 | | <a name="l00306"></a>00306 vec u = dt.get ( <a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>,<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>+<a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a>-1 ); |
206 | | <a name="l00307"></a>00307 vec y = dt.get ( 0,<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>-1 ); |
207 | | <a name="l00308"></a>00308 <span class="comment">//Time update</span> |
208 | | <a name="l00309"></a>00309 <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a> = <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a>* <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a> + <a class="code" href="classKalman.html#dc87704284a6c0bca13bf51f4345a50a" title="Matrix B.">B</a>*u; |
209 | | <a name="l00310"></a>00310 <span class="comment">//P = A*P*A.transpose() + Q; in sq_T</span> |
210 | | <a name="l00311"></a>00311 <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>.mult_sym ( <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a> ); |
211 | | <a name="l00312"></a>00312 <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a> +=<a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a>; |
212 | | <a name="l00313"></a>00313 |
213 | | <a name="l00314"></a>00314 <span class="comment">//Data update</span> |
214 | | <a name="l00315"></a>00315 <span class="comment">//_Ry = C*P*C.transpose() + R; in sq_T</span> |
215 | | <a name="l00316"></a>00316 <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>.mult_sym ( <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>, <a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a> ); |
216 | | <a name="l00317"></a>00317 <a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a> +=<a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a>; |
217 | | <a name="l00318"></a>00318 |
218 | | <a name="l00319"></a>00319 mat Pfull = <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>.to_mat(); |
| 175 | <a name="l00276"></a>00276 } |
| 176 | <a name="l00277"></a>00277 |
| 177 | <a name="l00278"></a>00278 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 178 | <a name="l00279"></a><a class="code" href="classKalman.html#3d56b0a97b8c1e25fdd3b10eef3c2ad3">00279</a> <a class="code" href="classKalman.html#3d56b0a97b8c1e25fdd3b10eef3c2ad3" title="Default constructor.">Kalman<sq_T>::Kalman</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvy0, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvu0 ) : <a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> ( rvx ),<a class="code" href="classKalman.html#7501230c2fafa3655887d2da23b3184c" title="Indetifier of output rv.">rvy</a> ( rvy0 ),<a class="code" href="classKalman.html#44a16ffd5ac1e6e39bae34fea9e1e498" title="Indetifier of exogeneous rv.">rvu</a> ( rvu0 ), |
| 179 | <a name="l00280"></a>00280 <a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a> ( rvx.count() ), <a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a> ( <a class="code" href="classKalman.html#7501230c2fafa3655887d2da23b3184c" title="Indetifier of output rv.">rvy</a>.count() ),<a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a> ( <a class="code" href="classKalman.html#44a16ffd5ac1e6e39bae34fea9e1e498" title="Indetifier of exogeneous rv.">rvu</a>.count() ), |
| 180 | <a name="l00281"></a>00281 <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a> ( <a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>,<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a> ), <a class="code" href="classKalman.html#dc87704284a6c0bca13bf51f4345a50a" title="Matrix B.">B</a> ( <a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>,<a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a> ), <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a> ( <a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>,<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a> ), <a class="code" href="classKalman.html#d69f774ba3335c970c1c5b1d182f4dd1" title="Matrix D.">D</a> ( <a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>,<a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a> ), |
| 181 | <a name="l00282"></a>00282 <a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a>(<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>), <a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a> (<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>), |
| 182 | <a name="l00283"></a>00283 <a class="code" href="classKalman.html#5568c74bac67ae6d3b1061dba60c9424" title="posterior density on $x_t$">est</a> ( rvx ), <a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a> ( <a class="code" href="classKalman.html#7501230c2fafa3655887d2da23b3184c" title="Indetifier of output rv.">rvy</a> ), <a class="code" href="classKalman.html#764bbc95238eda11fc81c5ebd0b1dcfd" title="cache of fy.mu">_yp</a>(<a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a>.<a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>()),<a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a>(<a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a>._R()),<a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>(<a class="code" href="classKalman.html#5568c74bac67ae6d3b1061dba60c9424" title="posterior density on $x_t$">est</a>.<a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>()), <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>(<a class="code" href="classKalman.html#5568c74bac67ae6d3b1061dba60c9424" title="posterior density on $x_t$">est</a>._R()) { |
| 183 | <a name="l00284"></a>00284 }; |
| 184 | <a name="l00285"></a>00285 |
| 185 | <a name="l00286"></a>00286 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 186 | <a name="l00287"></a><a class="code" href="classKalman.html#239b28a0380946f5749b2f8d2807f93a">00287</a> <span class="keywordtype">void</span> <a class="code" href="classKalman.html#239b28a0380946f5749b2f8d2807f93a" title="Set parameters with check of relevance.">Kalman<sq_T>::set_parameters</a> ( <span class="keyword">const</span> mat &A0,<span class="keyword">const</span> mat &B0, <span class="keyword">const</span> mat &C0, <span class="keyword">const</span> mat &D0, <span class="keyword">const</span> sq_T &R0, <span class="keyword">const</span> sq_T &Q0 ) { |
| 187 | <a name="l00288"></a>00288 it_assert_debug ( A0.cols() ==<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>, <span class="stringliteral">"Kalman: A is not square"</span> ); |
| 188 | <a name="l00289"></a>00289 it_assert_debug ( B0.rows() ==<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>, <span class="stringliteral">"Kalman: B is not compatible"</span> ); |
| 189 | <a name="l00290"></a>00290 it_assert_debug ( C0.cols() ==<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>, <span class="stringliteral">"Kalman: C is not square"</span> ); |
| 190 | <a name="l00291"></a>00291 it_assert_debug ( ( D0.rows() ==<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a> ) || ( D0.cols() ==<a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a> ), <span class="stringliteral">"Kalman: D is not compatible"</span> ); |
| 191 | <a name="l00292"></a>00292 it_assert_debug ( ( R0.cols() ==<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a> ) || ( R0.rows() ==<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a> ), <span class="stringliteral">"Kalman: R is not compatible"</span> ); |
| 192 | <a name="l00293"></a>00293 it_assert_debug ( ( Q0.cols() ==<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a> ) || ( Q0.rows() ==<a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a> ), <span class="stringliteral">"Kalman: Q is not compatible"</span> ); |
| 193 | <a name="l00294"></a>00294 |
| 194 | <a name="l00295"></a>00295 <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a> = A0; |
| 195 | <a name="l00296"></a>00296 <a class="code" href="classKalman.html#dc87704284a6c0bca13bf51f4345a50a" title="Matrix B.">B</a> = B0; |
| 196 | <a name="l00297"></a>00297 <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a> = C0; |
| 197 | <a name="l00298"></a>00298 <a class="code" href="classKalman.html#d69f774ba3335c970c1c5b1d182f4dd1" title="Matrix D.">D</a> = D0; |
| 198 | <a name="l00299"></a>00299 <a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a> = R0; |
| 199 | <a name="l00300"></a>00300 <a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a> = Q0; |
| 200 | <a name="l00301"></a>00301 } |
| 201 | <a name="l00302"></a>00302 |
| 202 | <a name="l00303"></a>00303 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 203 | <a name="l00304"></a><a class="code" href="classKalman.html#7750ffd73f261828a32c18aaeb65c75c">00304</a> <span class="keywordtype">void</span> <a class="code" href="classKalman.html#7750ffd73f261828a32c18aaeb65c75c" title="Here dt = [yt;ut] of appropriate dimensions.">Kalman<sq_T>::bayes</a> ( <span class="keyword">const</span> vec &dt ) { |
| 204 | <a name="l00305"></a>00305 it_assert_debug ( dt.length() == ( <a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>+<a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a> ),<span class="stringliteral">"KalmanFull::bayes wrong size of dt"</span> ); |
| 205 | <a name="l00306"></a>00306 |
| 206 | <a name="l00307"></a>00307 sq_T iRy(<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>); |
| 207 | <a name="l00308"></a>00308 vec u = dt.get ( <a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>,<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>+<a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a>-1 ); |
| 208 | <a name="l00309"></a>00309 vec y = dt.get ( 0,<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>-1 ); |
| 209 | <a name="l00310"></a>00310 <span class="comment">//Time update</span> |
| 210 | <a name="l00311"></a>00311 <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a> = <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a>* <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a> + <a class="code" href="classKalman.html#dc87704284a6c0bca13bf51f4345a50a" title="Matrix B.">B</a>*u; |
| 211 | <a name="l00312"></a>00312 <span class="comment">//P = A*P*A.transpose() + Q; in sq_T</span> |
| 212 | <a name="l00313"></a>00313 <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>.mult_sym ( <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a> ); |
| 213 | <a name="l00314"></a>00314 <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a> +=<a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a>; |
| 214 | <a name="l00315"></a>00315 |
| 215 | <a name="l00316"></a>00316 <span class="comment">//Data update</span> |
| 216 | <a name="l00317"></a>00317 <span class="comment">//_Ry = C*P*C.transpose() + R; in sq_T</span> |
| 217 | <a name="l00318"></a>00318 <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>.mult_sym ( <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>, <a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a> ); |
| 218 | <a name="l00319"></a>00319 <a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a> +=<a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a>; |
220 | | <a name="l00321"></a>00321 <a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a>.inv ( iRy ); <span class="comment">// result is in _iRy;</span> |
221 | | <a name="l00322"></a>00322 <a class="code" href="classKalman.html#d422f51467c7a06174af2476d2826132" title="placeholder for Kalman gain">_K</a> = Pfull*<a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>.transpose() * ( iRy.to_mat() ); |
222 | | <a name="l00323"></a>00323 |
223 | | <a name="l00324"></a>00324 sq_T pom ( ( <span class="keywordtype">int</span> ) Pfull.rows() ); |
224 | | <a name="l00325"></a>00325 iRy.mult_sym_t ( <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>*Pfull,pom ); |
225 | | <a name="l00326"></a>00326 (<a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a> ) -= pom; <span class="comment">// P = P -PC'iRy*CP;</span> |
226 | | <a name="l00327"></a>00327 (<a class="code" href="classKalman.html#764bbc95238eda11fc81c5ebd0b1dcfd" title="cache of fy.mu">_yp</a> ) = <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>* <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a> +<a class="code" href="classKalman.html#d69f774ba3335c970c1c5b1d182f4dd1" title="Matrix D.">D</a>*u; <span class="comment">//y prediction</span> |
227 | | <a name="l00328"></a>00328 (<a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a> ) += <a class="code" href="classKalman.html#d422f51467c7a06174af2476d2826132" title="placeholder for Kalman gain">_K</a>* ( y- <a class="code" href="classKalman.html#764bbc95238eda11fc81c5ebd0b1dcfd" title="cache of fy.mu">_yp</a> ); |
228 | | <a name="l00329"></a>00329 |
229 | | <a name="l00330"></a>00330 |
230 | | <a name="l00331"></a>00331 <span class="keywordflow">if</span> ( <a class="code" href="classBM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>==<span class="keyword">true</span> ) { <span class="comment">//likelihood of observation y</span> |
231 | | <a name="l00332"></a>00332 <a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979" title="Logarithm of marginalized data likelihood.">ll</a>=<a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a>.evalpdflog ( y ); |
232 | | <a name="l00333"></a>00333 } |
233 | | <a name="l00334"></a>00334 |
234 | | <a name="l00335"></a>00335 <span class="comment">//cout << "y: " << y-(*_yp) <<" R: " << _Ry->to_mat() << " iR: " << _iRy->to_mat() << " ll: " << ll <<endl;</span> |
| 220 | <a name="l00321"></a>00321 mat Pfull = <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>.to_mat(); |
| 221 | <a name="l00322"></a>00322 |
| 222 | <a name="l00323"></a>00323 <a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a>.inv ( iRy ); <span class="comment">// result is in _iRy;</span> |
| 223 | <a name="l00324"></a>00324 <a class="code" href="classKalman.html#d422f51467c7a06174af2476d2826132" title="placeholder for Kalman gain">_K</a> = Pfull*<a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>.transpose() * ( iRy.to_mat() ); |
| 224 | <a name="l00325"></a>00325 |
| 225 | <a name="l00326"></a>00326 sq_T pom ( ( <span class="keywordtype">int</span> ) Pfull.rows() ); |
| 226 | <a name="l00327"></a>00327 iRy.mult_sym_t ( <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>*Pfull,pom ); |
| 227 | <a name="l00328"></a>00328 (<a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a> ) -= pom; <span class="comment">// P = P -PC'iRy*CP;</span> |
| 228 | <a name="l00329"></a>00329 (<a class="code" href="classKalman.html#764bbc95238eda11fc81c5ebd0b1dcfd" title="cache of fy.mu">_yp</a> ) = <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>* <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a> +<a class="code" href="classKalman.html#d69f774ba3335c970c1c5b1d182f4dd1" title="Matrix D.">D</a>*u; <span class="comment">//y prediction</span> |
| 229 | <a name="l00330"></a>00330 (<a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a> ) += <a class="code" href="classKalman.html#d422f51467c7a06174af2476d2826132" title="placeholder for Kalman gain">_K</a>* ( y- <a class="code" href="classKalman.html#764bbc95238eda11fc81c5ebd0b1dcfd" title="cache of fy.mu">_yp</a> ); |
| 230 | <a name="l00331"></a>00331 |
| 231 | <a name="l00332"></a>00332 |
| 232 | <a name="l00333"></a>00333 <span class="keywordflow">if</span> ( <a class="code" href="classBM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>==<span class="keyword">true</span> ) { <span class="comment">//likelihood of observation y</span> |
| 233 | <a name="l00334"></a>00334 <a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979" title="Logarithm of marginalized data likelihood.">ll</a>=<a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a>.evalpdflog ( y ); |
| 234 | <a name="l00335"></a>00335 } |
242 | | <a name="l00343"></a>00343 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
243 | | <a name="l00344"></a><a class="code" href="classEKF.html#ea4f3254cacf0a92d2a820b1201d049e">00344</a> <a class="code" href="classEKF.html#ea4f3254cacf0a92d2a820b1201d049e" title="Default constructor.">EKF<sq_T>::EKF</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx0, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvy0, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvu0 ) : <a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><sq_T> ( rvx0,rvy0,rvu0 ) {} |
244 | | <a name="l00345"></a>00345 |
245 | | <a name="l00346"></a>00346 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
246 | | <a name="l00347"></a><a class="code" href="classEKF.html#28d058ae4d24d992d2f055419a06ee66">00347</a> <span class="keywordtype">void</span> <a class="code" href="classEKF.html#28d058ae4d24d992d2f055419a06ee66" title="Set nonlinear functions for mean values and covariance matrices.">EKF<sq_T>::set_parameters</a> ( <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu0, <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu0,<span class="keyword">const</span> sq_T Q0,<span class="keyword">const</span> sq_T R0 ) { |
247 | | <a name="l00348"></a>00348 pfxu = pfxu0; |
248 | | <a name="l00349"></a>00349 phxu = phxu0; |
249 | | <a name="l00350"></a>00350 |
250 | | <a name="l00351"></a>00351 <span class="comment">//initialize matrices A C, later, these will be only updated!</span> |
251 | | <a name="l00352"></a>00352 pfxu-><a class="code" href="classdiffbifn.html#6d217a02d4fa13931258d4bebdd0feb4" title="Evaluates and writes result into A .">dfdx_cond</a> ( <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>,zeros ( <a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a> ),<a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a>,<span class="keyword">true</span> ); |
252 | | <a name="l00353"></a>00353 <span class="comment">// pfxu->dfdu_cond ( *_mu,zeros ( dimu ),B,true );</span> |
253 | | <a name="l00354"></a>00354 <a class="code" href="classKalman.html#dc87704284a6c0bca13bf51f4345a50a" title="Matrix B.">B</a>.clear(); |
254 | | <a name="l00355"></a>00355 phxu-><a class="code" href="classdiffbifn.html#6d217a02d4fa13931258d4bebdd0feb4" title="Evaluates and writes result into A .">dfdx_cond</a> ( <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>,zeros ( <a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a> ),<a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>,<span class="keyword">true</span> ); |
255 | | <a name="l00356"></a>00356 <span class="comment">// phxu->dfdu_cond ( *_mu,zeros ( dimu ),D,true );</span> |
256 | | <a name="l00357"></a>00357 <a class="code" href="classKalman.html#d69f774ba3335c970c1c5b1d182f4dd1" title="Matrix D.">D</a>.clear(); |
257 | | <a name="l00358"></a>00358 |
258 | | <a name="l00359"></a>00359 <a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a> = R0; |
259 | | <a name="l00360"></a>00360 <a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a> = Q0; |
260 | | <a name="l00361"></a>00361 } |
261 | | <a name="l00362"></a>00362 |
262 | | <a name="l00363"></a>00363 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
263 | | <a name="l00364"></a><a class="code" href="classEKF.html#c79c62c9b3e0b56b3aaa1b6f1d9a7af7">00364</a> <span class="keywordtype">void</span> <a class="code" href="classEKF.html#c79c62c9b3e0b56b3aaa1b6f1d9a7af7" title="Here dt = [yt;ut] of appropriate dimensions.">EKF<sq_T>::bayes</a> ( <span class="keyword">const</span> vec &dt ) { |
264 | | <a name="l00365"></a>00365 it_assert_debug ( dt.length() == ( <a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>+<a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a> ),<span class="stringliteral">"KalmanFull::bayes wrong size of dt"</span> ); |
265 | | <a name="l00366"></a>00366 |
266 | | <a name="l00367"></a>00367 sq_T iRy(<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>,<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>); |
267 | | <a name="l00368"></a>00368 vec u = dt.get ( <a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>,<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>+<a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a>-1 ); |
268 | | <a name="l00369"></a>00369 vec y = dt.get ( 0,<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>-1 ); |
269 | | <a name="l00370"></a>00370 <span class="comment">//Time update</span> |
270 | | <a name="l00371"></a>00371 <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a> = pfxu-><a class="code" href="classdiffbifn.html#ad7673e16aa1a046b131b24c731c4632" title="Evaluates (VS: Do we really need common eval? ).">eval</a> ( <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>, u ); |
271 | | <a name="l00372"></a>00372 pfxu-><a class="code" href="classdiffbifn.html#6d217a02d4fa13931258d4bebdd0feb4" title="Evaluates and writes result into A .">dfdx_cond</a> ( <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>,u,<a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a>,<span class="keyword">false</span> ); <span class="comment">//update A by a derivative of fx</span> |
272 | | <a name="l00373"></a>00373 |
273 | | <a name="l00374"></a>00374 <span class="comment">//P = A*P*A.transpose() + Q; in sq_T</span> |
274 | | <a name="l00375"></a>00375 <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>.<a class="code" href="classfsqmat.html#5530d2756b5d991de755e6121c9a452e" title="Inplace symmetric multiplication by a SQUARE matrix , i.e. .">mult_sym</a> ( <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a> ); |
275 | | <a name="l00376"></a>00376 <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a> +=<a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a>; |
276 | | <a name="l00377"></a>00377 |
277 | | <a name="l00378"></a>00378 <span class="comment">//Data update</span> |
278 | | <a name="l00379"></a>00379 phxu-><a class="code" href="classdiffbifn.html#6d217a02d4fa13931258d4bebdd0feb4" title="Evaluates and writes result into A .">dfdx_cond</a> ( <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>,u,<a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>,<span class="keyword">false</span> ); <span class="comment">//update C by a derivative hx</span> |
279 | | <a name="l00380"></a>00380 <span class="comment">//_Ry = C*P*C.transpose() + R; in sq_T</span> |
280 | | <a name="l00381"></a>00381 <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>.<a class="code" href="classfsqmat.html#5530d2756b5d991de755e6121c9a452e" title="Inplace symmetric multiplication by a SQUARE matrix , i.e. .">mult_sym</a> ( <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>, <a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a> ); |
281 | | <a name="l00382"></a>00382 ( <a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a> ) +=<a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a>; |
282 | | <a name="l00383"></a>00383 |
283 | | <a name="l00384"></a>00384 mat Pfull = <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>.<a class="code" href="classfsqmat.html#f54fc955e8e3b43d15afa92124bc24b3" title="Conversion to full matrix.">to_mat</a>(); |
| 242 | <a name="l00343"></a>00343 <span class="comment">//TODO why not const pointer??</span> |
| 243 | <a name="l00344"></a>00344 |
| 244 | <a name="l00345"></a>00345 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 245 | <a name="l00346"></a><a class="code" href="classEKF.html#ea4f3254cacf0a92d2a820b1201d049e">00346</a> <a class="code" href="classEKF.html#ea4f3254cacf0a92d2a820b1201d049e" title="Default constructor.">EKF<sq_T>::EKF</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx0, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvy0, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvu0 ) : <a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><sq_T> ( rvx0,rvy0,rvu0 ) {} |
| 246 | <a name="l00347"></a>00347 |
| 247 | <a name="l00348"></a>00348 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 248 | <a name="l00349"></a><a class="code" href="classEKF.html#28d058ae4d24d992d2f055419a06ee66">00349</a> <span class="keywordtype">void</span> <a class="code" href="classEKF.html#28d058ae4d24d992d2f055419a06ee66" title="Set nonlinear functions for mean values and covariance matrices.">EKF<sq_T>::set_parameters</a> ( <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu0, <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu0,<span class="keyword">const</span> sq_T Q0,<span class="keyword">const</span> sq_T R0 ) { |
| 249 | <a name="l00350"></a>00350 pfxu = pfxu0; |
| 250 | <a name="l00351"></a>00351 phxu = phxu0; |
| 251 | <a name="l00352"></a>00352 |
| 252 | <a name="l00353"></a>00353 <span class="comment">//initialize matrices A C, later, these will be only updated!</span> |
| 253 | <a name="l00354"></a>00354 pfxu-><a class="code" href="classdiffbifn.html#6d217a02d4fa13931258d4bebdd0feb4" title="Evaluates and writes result into A .">dfdx_cond</a> ( <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>,zeros ( <a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a> ),<a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a>,<span class="keyword">true</span> ); |
| 254 | <a name="l00355"></a>00355 <span class="comment">// pfxu->dfdu_cond ( *_mu,zeros ( dimu ),B,true );</span> |
| 255 | <a name="l00356"></a>00356 <a class="code" href="classKalman.html#dc87704284a6c0bca13bf51f4345a50a" title="Matrix B.">B</a>.clear(); |
| 256 | <a name="l00357"></a>00357 phxu-><a class="code" href="classdiffbifn.html#6d217a02d4fa13931258d4bebdd0feb4" title="Evaluates and writes result into A .">dfdx_cond</a> ( <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>,zeros ( <a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a> ),<a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>,<span class="keyword">true</span> ); |
| 257 | <a name="l00358"></a>00358 <span class="comment">// phxu->dfdu_cond ( *_mu,zeros ( dimu ),D,true );</span> |
| 258 | <a name="l00359"></a>00359 <a class="code" href="classKalman.html#d69f774ba3335c970c1c5b1d182f4dd1" title="Matrix D.">D</a>.clear(); |
| 259 | <a name="l00360"></a>00360 |
| 260 | <a name="l00361"></a>00361 <a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a> = R0; |
| 261 | <a name="l00362"></a>00362 <a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a> = Q0; |
| 262 | <a name="l00363"></a>00363 } |
| 263 | <a name="l00364"></a>00364 |
| 264 | <a name="l00365"></a>00365 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 265 | <a name="l00366"></a><a class="code" href="classEKF.html#c79c62c9b3e0b56b3aaa1b6f1d9a7af7">00366</a> <span class="keywordtype">void</span> <a class="code" href="classEKF.html#c79c62c9b3e0b56b3aaa1b6f1d9a7af7" title="Here dt = [yt;ut] of appropriate dimensions.">EKF<sq_T>::bayes</a> ( <span class="keyword">const</span> vec &dt ) { |
| 266 | <a name="l00367"></a>00367 it_assert_debug ( dt.length() == ( <a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>+<a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a> ),<span class="stringliteral">"KalmanFull::bayes wrong size of dt"</span> ); |
| 267 | <a name="l00368"></a>00368 |
| 268 | <a name="l00369"></a>00369 sq_T iRy(<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>,<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>); |
| 269 | <a name="l00370"></a>00370 vec u = dt.get ( <a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>,<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>+<a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a>-1 ); |
| 270 | <a name="l00371"></a>00371 vec y = dt.get ( 0,<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>-1 ); |
| 271 | <a name="l00372"></a>00372 <span class="comment">//Time update</span> |
| 272 | <a name="l00373"></a>00373 <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a> = pfxu-><a class="code" href="classdiffbifn.html#ad7673e16aa1a046b131b24c731c4632" title="Evaluates (VS: Do we really need common eval? ).">eval</a> ( <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>, u ); |
| 273 | <a name="l00374"></a>00374 pfxu-><a class="code" href="classdiffbifn.html#6d217a02d4fa13931258d4bebdd0feb4" title="Evaluates and writes result into A .">dfdx_cond</a> ( <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>,u,<a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a>,<span class="keyword">false</span> ); <span class="comment">//update A by a derivative of fx</span> |
| 274 | <a name="l00375"></a>00375 |
| 275 | <a name="l00376"></a>00376 <span class="comment">//P = A*P*A.transpose() + Q; in sq_T</span> |
| 276 | <a name="l00377"></a>00377 <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>.<a class="code" href="classfsqmat.html#5530d2756b5d991de755e6121c9a452e" title="Inplace symmetric multiplication by a SQUARE matrix , i.e. .">mult_sym</a> ( <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a> ); |
| 277 | <a name="l00378"></a>00378 <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a> +=<a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a>; |
| 278 | <a name="l00379"></a>00379 |
| 279 | <a name="l00380"></a>00380 <span class="comment">//Data update</span> |
| 280 | <a name="l00381"></a>00381 phxu-><a class="code" href="classdiffbifn.html#6d217a02d4fa13931258d4bebdd0feb4" title="Evaluates and writes result into A .">dfdx_cond</a> ( <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>,u,<a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>,<span class="keyword">false</span> ); <span class="comment">//update C by a derivative hx</span> |
| 281 | <a name="l00382"></a>00382 <span class="comment">//_Ry = C*P*C.transpose() + R; in sq_T</span> |
| 282 | <a name="l00383"></a>00383 <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>.<a class="code" href="classfsqmat.html#5530d2756b5d991de755e6121c9a452e" title="Inplace symmetric multiplication by a SQUARE matrix , i.e. .">mult_sym</a> ( <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>, <a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a> ); |
| 283 | <a name="l00384"></a>00384 ( <a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a> ) +=<a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a>; |
285 | | <a name="l00386"></a>00386 <a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a>.<a class="code" href="classfsqmat.html#9fa853e1ca28f2a1a1c43377e798ecb1" title="Matrix inversion preserving the chosen form.">inv</a> ( iRy ); <span class="comment">// result is in _iRy;</span> |
286 | | <a name="l00387"></a>00387 <a class="code" href="classKalman.html#d422f51467c7a06174af2476d2826132" title="placeholder for Kalman gain">_K</a> = Pfull*<a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>.transpose() * ( iRy.to_mat() ); |
287 | | <a name="l00388"></a>00388 |
288 | | <a name="l00389"></a>00389 sq_T pom ( ( <span class="keywordtype">int</span> ) Pfull.rows() ); |
289 | | <a name="l00390"></a>00390 iRy.mult_sym_t ( <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>*Pfull,pom ); |
290 | | <a name="l00391"></a>00391 (<a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a> ) -= pom; <span class="comment">// P = P -PC'iRy*CP;</span> |
291 | | <a name="l00392"></a>00392 <a class="code" href="classKalman.html#764bbc95238eda11fc81c5ebd0b1dcfd" title="cache of fy.mu">_yp</a> = phxu-><a class="code" href="classdiffbifn.html#ad7673e16aa1a046b131b24c731c4632" title="Evaluates (VS: Do we really need common eval? ).">eval</a> ( <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>,u ); <span class="comment">//y prediction</span> |
292 | | <a name="l00393"></a>00393 ( <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a> ) += <a class="code" href="classKalman.html#d422f51467c7a06174af2476d2826132" title="placeholder for Kalman gain">_K</a>* ( y-<a class="code" href="classKalman.html#764bbc95238eda11fc81c5ebd0b1dcfd" title="cache of fy.mu">_yp</a> ); |
293 | | <a name="l00394"></a>00394 |
294 | | <a name="l00395"></a>00395 <span class="keywordflow">if</span> ( <a class="code" href="classBM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>==<span class="keyword">true</span> ) {<a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979" title="Logarithm of marginalized data likelihood.">ll</a>+=<a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a>.<a class="code" href="classeEF.html#6466e8d4aa9dd64698ed288cbb1afc03" title="Evaluate normalized log-probability.">evalpdflog</a> ( y );} |
295 | | <a name="l00396"></a>00396 }; |
296 | | <a name="l00397"></a>00397 |
297 | | <a name="l00398"></a>00398 |
298 | | <a name="l00399"></a>00399 <span class="preprocessor">#endif // KF_H</span> |
299 | | <a name="l00400"></a>00400 <span class="preprocessor"></span> |
300 | | <a name="l00401"></a>00401 |
| 285 | <a name="l00386"></a>00386 mat Pfull = <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>.<a class="code" href="classfsqmat.html#f54fc955e8e3b43d15afa92124bc24b3" title="Conversion to full matrix.">to_mat</a>(); |
| 286 | <a name="l00387"></a>00387 |
| 287 | <a name="l00388"></a>00388 <a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a>.<a class="code" href="classfsqmat.html#9fa853e1ca28f2a1a1c43377e798ecb1" title="Matrix inversion preserving the chosen form.">inv</a> ( iRy ); <span class="comment">// result is in _iRy;</span> |
| 288 | <a name="l00389"></a>00389 <a class="code" href="classKalman.html#d422f51467c7a06174af2476d2826132" title="placeholder for Kalman gain">_K</a> = Pfull*<a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>.transpose() * ( iRy.to_mat() ); |
| 289 | <a name="l00390"></a>00390 |
| 290 | <a name="l00391"></a>00391 sq_T pom ( ( <span class="keywordtype">int</span> ) Pfull.rows() ); |
| 291 | <a name="l00392"></a>00392 iRy.mult_sym_t ( <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>*Pfull,pom ); |
| 292 | <a name="l00393"></a>00393 (<a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a> ) -= pom; <span class="comment">// P = P -PC'iRy*CP;</span> |
| 293 | <a name="l00394"></a>00394 <a class="code" href="classKalman.html#764bbc95238eda11fc81c5ebd0b1dcfd" title="cache of fy.mu">_yp</a> = phxu-><a class="code" href="classdiffbifn.html#ad7673e16aa1a046b131b24c731c4632" title="Evaluates (VS: Do we really need common eval? ).">eval</a> ( <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>,u ); <span class="comment">//y prediction</span> |
| 294 | <a name="l00395"></a>00395 ( <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a> ) += <a class="code" href="classKalman.html#d422f51467c7a06174af2476d2826132" title="placeholder for Kalman gain">_K</a>* ( y-<a class="code" href="classKalman.html#764bbc95238eda11fc81c5ebd0b1dcfd" title="cache of fy.mu">_yp</a> ); |
| 295 | <a name="l00396"></a>00396 |
| 296 | <a name="l00397"></a>00397 <span class="keywordflow">if</span> ( <a class="code" href="classBM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>==<span class="keyword">true</span> ) {<a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979" title="Logarithm of marginalized data likelihood.">ll</a>+=<a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a>.<a class="code" href="classeEF.html#6466e8d4aa9dd64698ed288cbb1afc03" title="Evaluate normalized log-probability.">evalpdflog</a> ( y );} |
| 297 | <a name="l00398"></a>00398 }; |
| 298 | <a name="l00399"></a>00399 |
| 299 | <a name="l00400"></a>00400 |
| 300 | <a name="l00401"></a>00401 <span class="preprocessor">#endif // KF_H</span> |
| 301 | <a name="l00402"></a>00402 <span class="preprocessor"></span> |
| 302 | <a name="l00403"></a>00403 |