28 | | <a name="l00028"></a>00028 <span class="keywordtype">int</span> dimx, dimy, dimu; |
29 | | <a name="l00029"></a>00029 mat A, B, C, D, R, Q; |
30 | | <a name="l00030"></a>00030 |
31 | | <a name="l00031"></a>00031 <span class="comment">//cache</span> |
32 | | <a name="l00032"></a>00032 mat _Pp, _Ry, _iRy, _K; |
33 | | <a name="l00033"></a>00033 <span class="keyword">public</span>: |
34 | | <a name="l00034"></a>00034 <span class="comment">//posterior</span> |
35 | | <a name="l00036"></a><a class="code" href="classKalmanFull.html#fb5aec635e2720cc5ac31bc01c18a68a">00036</a> <span class="comment"></span> vec <a class="code" href="classKalmanFull.html#fb5aec635e2720cc5ac31bc01c18a68a" title="Mean value of the posterior density.">mu</a>; |
36 | | <a name="l00038"></a><a class="code" href="classKalmanFull.html#b75dc059e84fa8ffc076203b30f926cc">00038</a> mat <a class="code" href="classKalmanFull.html#b75dc059e84fa8ffc076203b30f926cc" title="Variance of the posterior density.">P</a>; |
37 | | <a name="l00039"></a>00039 |
38 | | <a name="l00040"></a>00040 <span class="keyword">public</span>: |
39 | | <a name="l00042"></a>00042 <a class="code" href="classKalmanFull.html#7197ab6e7380790006394eabd3b97043" title="Full constructor.">KalmanFull</a> ( mat A, mat B, mat C, mat D, mat R, mat Q, mat P0, vec mu0 ); |
40 | | <a name="l00044"></a>00044 <span class="keywordtype">void</span> <a class="code" href="classKalmanFull.html#13a041cd98ff157703766be275a657bb" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
41 | | <a name="l00046"></a>00046 <span class="keyword">friend</span> std::ostream &<a class="code" href="classKalmanFull.html#86ba216243ed95bb46d80d88775d16af" title="print elements of KF">operator<< </a>( std::ostream &os, <span class="keyword">const</span> <a class="code" href="classKalmanFull.html" title="Basic Kalman filter with full matrices (education purpose only)! Will be deleted...">KalmanFull</a> &kf ); |
42 | | <a name="l00047"></a>00047 |
43 | | <a name="l00048"></a>00048 }; |
44 | | <a name="l00049"></a>00049 |
45 | | <a name="l00050"></a>00050 |
46 | | <a name="l00058"></a>00058 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
47 | | <a name="l00059"></a>00059 |
48 | | <a name="l00060"></a><a class="code" href="classKalman.html">00060</a> <span class="keyword">class </span><a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</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> { |
49 | | <a name="l00061"></a>00061 <span class="keyword">protected</span>: |
50 | | <a name="l00063"></a><a class="code" href="classKalman.html#7501230c2fafa3655887d2da23b3184c">00063</a> <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>; |
51 | | <a name="l00065"></a><a class="code" href="classKalman.html#44a16ffd5ac1e6e39bae34fea9e1e498">00065</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>; |
52 | | <a name="l00067"></a><a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb">00067</a> <span class="keywordtype">int</span> <a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>; |
53 | | <a name="l00069"></a><a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a">00069</a> <span class="keywordtype">int</span> <a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>; |
54 | | <a name="l00071"></a><a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce">00071</a> <span class="keywordtype">int</span> <a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a>; |
55 | | <a name="l00073"></a><a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9">00073</a> mat <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a>; |
56 | | <a name="l00075"></a><a class="code" href="classKalman.html#dc87704284a6c0bca13bf51f4345a50a">00075</a> mat <a class="code" href="classKalman.html#dc87704284a6c0bca13bf51f4345a50a" title="Matrix B.">B</a>; |
57 | | <a name="l00077"></a><a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13">00077</a> mat <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>; |
58 | | <a name="l00079"></a><a class="code" href="classKalman.html#d69f774ba3335c970c1c5b1d182f4dd1">00079</a> mat <a class="code" href="classKalman.html#d69f774ba3335c970c1c5b1d182f4dd1" title="Matrix D.">D</a>; |
59 | | <a name="l00081"></a><a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9">00081</a> sq_T <a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a>; |
60 | | <a name="l00083"></a><a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec">00083</a> sq_T <a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a>; |
61 | | <a name="l00084"></a>00084 |
62 | | <a name="l00086"></a><a class="code" href="classKalman.html#5568c74bac67ae6d3b1061dba60c9424">00086</a> <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#5568c74bac67ae6d3b1061dba60c9424" title="posterior density on $x_t$">est</a>; |
63 | | <a name="l00088"></a><a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f">00088</a> <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#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a>; |
64 | | <a name="l00089"></a>00089 |
65 | | <a name="l00091"></a><a class="code" href="classKalman.html#d422f51467c7a06174af2476d2826132">00091</a> mat <a class="code" href="classKalman.html#d422f51467c7a06174af2476d2826132" title="placeholder for Kalman gain">_K</a>; |
66 | | <a name="l00093"></a><a class="code" href="classKalman.html#5188eb0329f8561f0b357af329769bf8">00093</a> vec* <a class="code" href="classKalman.html#5188eb0329f8561f0b357af329769bf8" title="cache of fy.mu">_yp</a>; |
67 | | <a name="l00095"></a><a class="code" href="classKalman.html#e17dd745daa8a958035a334a56fa4674">00095</a> sq_T* <a class="code" href="classKalman.html#e17dd745daa8a958035a334a56fa4674" title="cache of fy.R">_Ry</a>; |
68 | | <a name="l00097"></a><a class="code" href="classKalman.html#8a35bd14afa5a2d9bbd23ad333bec874">00097</a> sq_T* <a class="code" href="classKalman.html#8a35bd14afa5a2d9bbd23ad333bec874" title="cache of fy.iR">_iRy</a>; |
69 | | <a name="l00099"></a><a class="code" href="classKalman.html#d1f669b5b3421a070cc75d77b55ba734">00099</a> vec* <a class="code" href="classKalman.html#d1f669b5b3421a070cc75d77b55ba734" title="cache of est.mu">_mu</a>; |
70 | | <a name="l00101"></a><a class="code" href="classKalman.html#b3388218567128a797e69b109138271d">00101</a> sq_T* <a class="code" href="classKalman.html#b3388218567128a797e69b109138271d" title="cache of est.R">_P</a>; |
71 | | <a name="l00103"></a><a class="code" href="classKalman.html#13fec2c93d8a132201e28b70270acf5c">00103</a> sq_T* <a class="code" href="classKalman.html#13fec2c93d8a132201e28b70270acf5c" title="cache of est.iR">_iP</a>; |
| 28 | <a name="l00028"></a>00028 <span class="keyword">protected</span>: |
| 29 | <a name="l00029"></a>00029 <span class="keywordtype">int</span> dimx, dimy, dimu; |
| 30 | <a name="l00030"></a>00030 mat A, B, C, D, R, Q; |
| 31 | <a name="l00031"></a>00031 |
| 32 | <a name="l00032"></a>00032 <span class="comment">//cache</span> |
| 33 | <a name="l00033"></a>00033 mat _Pp, _Ry, _iRy, _K; |
| 34 | <a name="l00034"></a>00034 <span class="keyword">public</span>: |
| 35 | <a name="l00035"></a>00035 <span class="comment">//posterior</span> |
| 36 | <a name="l00037"></a><a class="code" href="classKalmanFull.html#fb5aec635e2720cc5ac31bc01c18a68a">00037</a> <span class="comment"></span> vec <a class="code" href="classKalmanFull.html#fb5aec635e2720cc5ac31bc01c18a68a" title="Mean value of the posterior density.">mu</a>; |
| 37 | <a name="l00039"></a><a class="code" href="classKalmanFull.html#b75dc059e84fa8ffc076203b30f926cc">00039</a> mat <a class="code" href="classKalmanFull.html#b75dc059e84fa8ffc076203b30f926cc" title="Variance of the posterior density.">P</a>; |
| 38 | <a name="l00040"></a>00040 |
| 39 | <a name="l00041"></a>00041 <span class="keywordtype">bool</span> evalll; |
| 40 | <a name="l00042"></a>00042 <span class="keywordtype">double</span> ll; |
| 41 | <a name="l00043"></a>00043 <span class="keyword">public</span>: |
| 42 | <a name="l00045"></a>00045 <a class="code" href="classKalmanFull.html#9d7cc2235b643d9662cd9c8b8469747d" title="For EKFfull;.">KalmanFull</a> ( mat A, mat B, mat C, mat D, mat R, mat Q, mat P0, vec mu0 ); |
| 43 | <a name="l00047"></a>00047 <span class="keywordtype">void</span> <a class="code" href="classKalmanFull.html#13a041cd98ff157703766be275a657bb" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
| 44 | <a name="l00049"></a>00049 <span class="keyword">friend</span> std::ostream &<a class="code" href="classKalmanFull.html#86ba216243ed95bb46d80d88775d16af" title="print elements of KF">operator<< </a>( std::ostream &os, <span class="keyword">const</span> <a class="code" href="classKalmanFull.html" title="Basic Kalman filter with full matrices (education purpose only)! Will be deleted...">KalmanFull</a> &kf ); |
| 45 | <a name="l00051"></a><a class="code" href="classKalmanFull.html#9d7cc2235b643d9662cd9c8b8469747d">00051</a> <a class="code" href="classKalmanFull.html#9d7cc2235b643d9662cd9c8b8469747d" title="For EKFfull;.">KalmanFull</a>(){}; |
| 46 | <a name="l00052"></a>00052 }; |
| 47 | <a name="l00053"></a>00053 |
| 48 | <a name="l00054"></a>00054 |
| 49 | <a name="l00062"></a>00062 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 50 | <a name="l00063"></a>00063 |
| 51 | <a name="l00064"></a><a class="code" href="classKalman.html">00064</a> <span class="keyword">class </span><a class="code" href="classKalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</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> { |
| 52 | <a name="l00065"></a>00065 <span class="keyword">protected</span>: |
| 53 | <a name="l00067"></a><a class="code" href="classKalman.html#7501230c2fafa3655887d2da23b3184c">00067</a> <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>; |
| 54 | <a name="l00069"></a><a class="code" href="classKalman.html#44a16ffd5ac1e6e39bae34fea9e1e498">00069</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>; |
| 55 | <a name="l00071"></a><a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb">00071</a> <span class="keywordtype">int</span> <a class="code" href="classKalman.html#39c8c403b46fa3b8c7da77cb2e3729eb" title="cache of rv.count()">dimx</a>; |
| 56 | <a name="l00073"></a><a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a">00073</a> <span class="keywordtype">int</span> <a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>; |
| 57 | <a name="l00075"></a><a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce">00075</a> <span class="keywordtype">int</span> <a class="code" href="classKalman.html#b0153795a1444b6968a86409c778d9ce" title="cache of rvu.count()">dimu</a>; |
| 58 | <a name="l00077"></a><a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9">00077</a> mat <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a>; |
| 59 | <a name="l00079"></a><a class="code" href="classKalman.html#dc87704284a6c0bca13bf51f4345a50a">00079</a> mat <a class="code" href="classKalman.html#dc87704284a6c0bca13bf51f4345a50a" title="Matrix B.">B</a>; |
| 60 | <a name="l00081"></a><a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13">00081</a> mat <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>; |
| 61 | <a name="l00083"></a><a class="code" href="classKalman.html#d69f774ba3335c970c1c5b1d182f4dd1">00083</a> mat <a class="code" href="classKalman.html#d69f774ba3335c970c1c5b1d182f4dd1" title="Matrix D.">D</a>; |
| 62 | <a name="l00085"></a><a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9">00085</a> sq_T <a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a>; |
| 63 | <a name="l00087"></a><a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec">00087</a> sq_T <a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a>; |
| 64 | <a name="l00088"></a>00088 |
| 65 | <a name="l00090"></a><a class="code" href="classKalman.html#5568c74bac67ae6d3b1061dba60c9424">00090</a> <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#5568c74bac67ae6d3b1061dba60c9424" title="posterior density on $x_t$">est</a>; |
| 66 | <a name="l00092"></a><a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f">00092</a> <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#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a>; |
| 67 | <a name="l00093"></a>00093 |
| 68 | <a name="l00095"></a><a class="code" href="classKalman.html#d422f51467c7a06174af2476d2826132">00095</a> mat <a class="code" href="classKalman.html#d422f51467c7a06174af2476d2826132" title="placeholder for Kalman gain">_K</a>; |
| 69 | <a name="l00097"></a><a class="code" href="classKalman.html#764bbc95238eda11fc81c5ebd0b1dcfd">00097</a> vec& <a class="code" href="classKalman.html#764bbc95238eda11fc81c5ebd0b1dcfd" title="cache of fy.mu">_yp</a>; |
| 70 | <a name="l00099"></a><a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904">00099</a> sq_T& <a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a>; |
| 71 | <a name="l00101"></a><a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061">00101</a> vec& <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>; |
| 72 | <a name="l00103"></a><a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf">00103</a> sq_T& <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>; |
86 | | <a name="l00124"></a>00124 }; |
87 | | <a name="l00125"></a>00125 |
88 | | <a name="l00128"></a><a class="code" href="classKalmanCh.html">00128</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="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a>{ |
89 | | <a name="l00129"></a>00129 <span class="keyword">protected</span>: |
90 | | <a name="l00131"></a><a class="code" href="classKalmanCh.html#e1b7369670041b75231242f7293c4f90">00131</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalmanCh.html#e1b7369670041b75231242f7293c4f90" title="Indetifier of output rv.">rvy</a>; |
91 | | <a name="l00133"></a><a class="code" href="classKalmanCh.html#1cebd72aaff9f146b9b2400cc69e1b1a">00133</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classKalmanCh.html#1cebd72aaff9f146b9b2400cc69e1b1a" title="Indetifier of exogeneous rv.">rvu</a>; |
92 | | <a name="l00135"></a><a class="code" href="classKalmanCh.html#5c34f0f5cc4e1dd1be4b4489d2fc83d0">00135</a> <span class="keywordtype">int</span> <a class="code" href="classKalmanCh.html#5c34f0f5cc4e1dd1be4b4489d2fc83d0" title="cache of rv.count()">dimx</a>; |
93 | | <a name="l00137"></a><a class="code" href="classKalmanCh.html#c8302d61db0512d8a0d4f34715117445">00137</a> <span class="keywordtype">int</span> <a class="code" href="classKalmanCh.html#c8302d61db0512d8a0d4f34715117445" title="cache of rvy.count()">dimy</a>; |
94 | | <a name="l00139"></a><a class="code" href="classKalmanCh.html#bac7284585a271e28f928acabd990146">00139</a> <span class="keywordtype">int</span> <a class="code" href="classKalmanCh.html#bac7284585a271e28f928acabd990146" title="cache of rvu.count()">dimu</a>; |
95 | | <a name="l00141"></a><a class="code" href="classKalmanCh.html#2ca9afe2042fbda38af3da8e7d8d9d3c">00141</a> mat <a class="code" href="classKalmanCh.html#2ca9afe2042fbda38af3da8e7d8d9d3c" title="Matrix A.">A</a>; |
96 | | <a name="l00143"></a><a class="code" href="classKalmanCh.html#5a5ee93d6d32f45b5d15e87764efd529">00143</a> mat <a class="code" href="classKalmanCh.html#5a5ee93d6d32f45b5d15e87764efd529" title="Matrix B.">B</a>; |
97 | | <a name="l00145"></a><a class="code" href="classKalmanCh.html#3c1ce2fe15dae5c0882a99c34b19cc40">00145</a> mat <a class="code" href="classKalmanCh.html#3c1ce2fe15dae5c0882a99c34b19cc40" title="Matrix C.">C</a>; |
98 | | <a name="l00147"></a><a class="code" href="classKalmanCh.html#50d3e4c9e411f8c96b87a1883b7e7154">00147</a> mat <a class="code" href="classKalmanCh.html#50d3e4c9e411f8c96b87a1883b7e7154" title="Matrix D.">D</a>; |
99 | | <a name="l00149"></a><a class="code" href="classKalmanCh.html#eb21fe7ab03feb24005c331070d28040">00149</a> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> <a class="code" href="classKalmanCh.html#eb21fe7ab03feb24005c331070d28040" title="Matrix Q in square-root form.">Q</a>; |
100 | | <a name="l00151"></a><a class="code" href="classKalmanCh.html#6716e9f9208fc7191b38fd801810b30a">00151</a> <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> <a class="code" href="classKalmanCh.html#6716e9f9208fc7191b38fd801810b30a" title="Matrix R in square-root form.">R</a>; |
101 | | <a name="l00152"></a>00152 |
102 | | <a name="l00154"></a><a class="code" href="classKalmanCh.html#94ee9da75b0e0f632e4a354988ca3798">00154</a> mat <a class="code" href="classKalmanCh.html#94ee9da75b0e0f632e4a354988ca3798" title="pre array (triangular matrix)">preA</a>; |
103 | | <a name="l00156"></a><a class="code" href="classKalmanCh.html#0d31a26dc72b5846cfe5af3ccb63ac87">00156</a> mat <a class="code" href="classKalmanCh.html#0d31a26dc72b5846cfe5af3ccb63ac87" title="post array (triangular matrix)">postA</a>; |
104 | | <a name="l00157"></a>00157 |
105 | | <a name="l00159"></a><a class="code" href="classKalmanCh.html#c0ffeeb2ca028ae2c1b1e166d4015804">00159</a> <a class="code" href="classenorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<chmat></a> <a class="code" href="classKalmanCh.html#c0ffeeb2ca028ae2c1b1e166d4015804" title="predictive density on $x_t$">pred</a>; |
106 | | <a name="l00161"></a><a class="code" href="classKalmanCh.html#9086baae040b9c4e5cc42a445853862a">00161</a> <a class="code" href="classenorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<chmat></a> <a class="code" href="classKalmanCh.html#9086baae040b9c4e5cc42a445853862a" title="predictive density on $y_t$">fy</a>; |
107 | | <a name="l00162"></a>00162 |
108 | | <a name="l00163"></a>00163 vec* _mu; |
109 | | <a name="l00164"></a>00164 <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>* _P; |
110 | | <a name="l00165"></a>00165 vec* _yp; |
111 | | <a name="l00166"></a>00166 <a class="code" href="classchmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>* _Ry; |
112 | | <a name="l00167"></a>00167 |
113 | | <a name="l00168"></a>00168 <span class="keyword">public</span>: |
114 | | <a name="l00170"></a>00170 <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 ); |
115 | | <a name="l00172"></a>00172 <a class="code" href="classKalmanCh.html#d11f110cccaa66177514632d37b086bb" title="Default constructor.">KalmanCh</a> ( <span class="keyword">const</span> <a class="code" href="classKalmanCh.html" title="Kalman filter in square root form.">KalmanCh</a> &K0 ); |
116 | | <a name="l00174"></a>00174 <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 ); |
117 | | <a name="l00176"></a><a class="code" href="classKalmanCh.html#7fe9b65d626971542e35213d11b4b98d">00176</a> <span class="keywordtype">void</span> <a class="code" href="classKalmanCh.html#7fe9b65d626971542e35213d11b4b98d" title="Set estimate values, used e.g. in initialization.">set_pred</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 ) { |
118 | | <a name="l00177"></a>00177 <a class="code" href="classKalmanCh.html#c0ffeeb2ca028ae2c1b1e166d4015804" title="predictive density on $x_t$">pred</a>.<a class="code" href="classenorm.html#1394a65caa6e00d42e00cc99b12227af" title="Set mean value mu and covariance R.">set_parameters</a> ( mu0,P0 ); |
119 | | <a name="l00178"></a>00178 }; |
120 | | <a name="l00179"></a>00179 |
121 | | <a name="l00190"></a>00190 <span class="keywordtype">void</span> <a class="code" href="classKalmanCh.html#cca758192846940409822b9bd778d4e1" title="Here dt = [yt;ut] of appropriate dimensions The following equality hold::.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
122 | | <a name="l00192"></a><a class="code" href="classKalmanCh.html#221892e744e7020ac5735978803d357d">00192</a> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>& <a class="code" href="classKalmanCh.html#221892e744e7020ac5735978803d357d" title="access function">_epdf</a>() {it_warning(<span class="stringliteral">"this is predictor, not estimator"</span>);<span class="keywordflow">return</span> <a class="code" href="classKalmanCh.html#c0ffeeb2ca028ae2c1b1e166d4015804" title="predictive density on $x_t$">pred</a>;} |
123 | | <a name="l00194"></a><a class="code" href="classKalmanCh.html#1d62f16738a29f25c468acd3b1289ec7">00194</a> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>& <a class="code" href="classKalmanCh.html#1d62f16738a29f25c468acd3b1289ec7" title="access function">_pred</a>() {<span class="keywordflow">return</span> <a class="code" href="classKalmanCh.html#c0ffeeb2ca028ae2c1b1e166d4015804" title="predictive density on $x_t$">pred</a>;} |
124 | | <a name="l00195"></a>00195 }; |
125 | | <a name="l00196"></a>00196 |
126 | | <a name="l00202"></a>00202 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
127 | | <a name="l00203"></a><a class="code" href="classEKF.html">00203</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><ldmat> { |
128 | | <a name="l00205"></a>00205 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables $f(x,u)$.">diffbifn</a>* pfxu; |
129 | | <a name="l00207"></a>00207 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables $f(x,u)$.">diffbifn</a>* phxu; |
130 | | <a name="l00208"></a>00208 <span class="keyword">public</span>: |
131 | | <a name="l00210"></a>00210 <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> ); |
132 | | <a name="l00212"></a>00212 <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 $f(x,u)$.">diffbifn</a>* pfxu, <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables $f(x,u)$.">diffbifn</a>* phxu, <span class="keyword">const</span> sq_T Q0, <span class="keyword">const</span> sq_T R0 ); |
133 | | <a name="l00214"></a>00214 <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 ); |
134 | | <a name="l00215"></a>00215 }; |
135 | | <a name="l00216"></a>00216 |
136 | | <a name="l00221"></a><a class="code" href="classKFcondQR.html">00221</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> { |
137 | | <a name="l00222"></a>00222 <span class="comment">//protected:</span> |
138 | | <a name="l00223"></a>00223 <span class="keyword">public</span>: |
139 | | <a name="l00225"></a><a class="code" href="classKFcondQR.html#3f3968f92c7bbe4b0902d5e14ecc1cb4">00225</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, (typically known as UD).">ldmat</a>> ( rvx, rvy,rvu ),<a class="code" href="classBMcond.html" title="Conditional Bayesian Filter.">BMcond</a> ( rvRQ ) {}; |
140 | | <a name="l00226"></a>00226 |
141 | | <a name="l00227"></a>00227 <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 ); |
142 | | <a name="l00228"></a>00228 }; |
143 | | <a name="l00229"></a>00229 |
144 | | <a name="l00234"></a><a class="code" href="classKFcondR.html">00234</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> { |
145 | | <a name="l00235"></a>00235 <span class="comment">//protected:</span> |
146 | | <a name="l00236"></a>00236 <span class="keyword">public</span>: |
147 | | <a name="l00238"></a><a class="code" href="classKFcondR.html#d2acbb8e66c7ee592b1a9da5b429a69e">00238</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, (typically known as UD).">ldmat</a>> ( rvx, rvy,rvu ),<a class="code" href="classBMcond.html" title="Conditional Bayesian Filter.">BMcond</a> ( rvR ) {}; |
148 | | <a name="l00239"></a>00239 |
149 | | <a name="l00240"></a>00240 <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> ); |
150 | | <a name="l00241"></a>00241 }; |
151 | | <a name="l00242"></a>00242 |
152 | | <a name="l00244"></a>00244 |
153 | | <a name="l00245"></a>00245 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
154 | | <a name="l00246"></a><a class="code" href="classKalman.html#ce38e31810aea4db45a83ad05eaba009">00246</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 ), |
155 | | <a name="l00247"></a>00247 dimx ( rv.count() ), dimy ( rvy.count() ),dimu ( rvu.count() ), |
156 | | <a name="l00248"></a>00248 A ( dimx,dimx ), B ( dimx,dimu ), C ( dimy,dimx ), D ( dimy,dimu ),est ( rv ), fy ( rvy ) { |
157 | | <a name="l00249"></a>00249 |
158 | | <a name="l00250"></a>00250 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="l00251"></a>00251 |
160 | | <a name="l00252"></a>00252 <span class="comment">//establish pointers</span> |
161 | | <a name="l00253"></a>00253 <a class="code" href="classKalman.html#d1f669b5b3421a070cc75d77b55ba734" title="cache of est.mu">_mu</a> = <a class="code" href="classKalman.html#5568c74bac67ae6d3b1061dba60c9424" title="posterior density on $x_t$">est</a>._mu(); |
162 | | <a name="l00254"></a>00254 <a class="code" href="classKalman.html#5568c74bac67ae6d3b1061dba60c9424" title="posterior density on $x_t$">est</a>._R ( <a class="code" href="classKalman.html#b3388218567128a797e69b109138271d" title="cache of est.R">_P</a>,<a class="code" href="classKalman.html#13fec2c93d8a132201e28b70270acf5c" title="cache of est.iR">_iP</a> ); |
163 | | <a name="l00255"></a>00255 |
164 | | <a name="l00256"></a>00256 <span class="comment">//fy</span> |
165 | | <a name="l00257"></a>00257 <a class="code" href="classKalman.html#5188eb0329f8561f0b357af329769bf8" title="cache of fy.mu">_yp</a> = <a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a>._mu(); |
166 | | <a name="l00258"></a>00258 <a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a>._R ( <a class="code" href="classKalman.html#e17dd745daa8a958035a334a56fa4674" title="cache of fy.R">_Ry</a>,<a class="code" href="classKalman.html#8a35bd14afa5a2d9bbd23ad333bec874" title="cache of fy.iR">_iRy</a> ); |
167 | | <a name="l00259"></a>00259 |
168 | | <a name="l00260"></a>00260 <span class="comment">// copy values in pointers</span> |
169 | | <a name="l00261"></a>00261 *<a class="code" href="classKalman.html#d1f669b5b3421a070cc75d77b55ba734" title="cache of est.mu">_mu</a> = *K0.<a class="code" href="classKalman.html#d1f669b5b3421a070cc75d77b55ba734" title="cache of est.mu">_mu</a>; |
170 | | <a name="l00262"></a>00262 *<a class="code" href="classKalman.html#b3388218567128a797e69b109138271d" title="cache of est.R">_P</a> = *K0.<a class="code" href="classKalman.html#b3388218567128a797e69b109138271d" title="cache of est.R">_P</a>; |
171 | | <a name="l00263"></a>00263 *<a class="code" href="classKalman.html#13fec2c93d8a132201e28b70270acf5c" title="cache of est.iR">_iP</a> = *K0.<a class="code" href="classKalman.html#13fec2c93d8a132201e28b70270acf5c" title="cache of est.iR">_iP</a>; |
172 | | <a name="l00264"></a>00264 *<a class="code" href="classKalman.html#5188eb0329f8561f0b357af329769bf8" title="cache of fy.mu">_yp</a> = *K0.<a class="code" href="classKalman.html#5188eb0329f8561f0b357af329769bf8" title="cache of fy.mu">_yp</a>; |
173 | | <a name="l00265"></a>00265 *<a class="code" href="classKalman.html#8a35bd14afa5a2d9bbd23ad333bec874" title="cache of fy.iR">_iRy</a> = *K0.<a class="code" href="classKalman.html#8a35bd14afa5a2d9bbd23ad333bec874" title="cache of fy.iR">_iRy</a>; |
174 | | <a name="l00266"></a>00266 *<a class="code" href="classKalman.html#e17dd745daa8a958035a334a56fa4674" title="cache of fy.R">_Ry</a> = *K0.<a class="code" href="classKalman.html#e17dd745daa8a958035a334a56fa4674" title="cache of fy.R">_Ry</a>; |
| 87 | <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>;} |
| 88 | <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();} |
| 89 | <a name="l00128"></a>00128 }; |
| 90 | <a name="l00129"></a>00129 |
| 91 | <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>{ |
| 92 | <a name="l00133"></a>00133 <span class="keyword">protected</span>: |
| 93 | <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>; |
| 94 | <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>; |
| 95 | <a name="l00138"></a>00138 |
| 96 | <a name="l00139"></a>00139 <span class="keyword">public</span>: |
| 97 | <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>){}; |
| 98 | <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 ); |
| 99 | <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 ) { |
| 100 | <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 ); |
| 101 | <a name="l00146"></a>00146 }; |
| 102 | <a name="l00147"></a>00147 |
| 103 | <a name="l00148"></a>00148 |
| 104 | <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 ); |
| 105 | <a name="l00163"></a>00163 }; |
| 106 | <a name="l00164"></a>00164 |
| 107 | <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> { |
| 108 | <a name="l00171"></a>00171 |
| 109 | <a name="l00173"></a>00173 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables $f(x,u)$.">diffbifn</a>* pfxu; |
| 110 | <a name="l00175"></a>00175 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables $f(x,u)$.">diffbifn</a>* phxu; |
| 111 | <a name="l00176"></a>00176 |
| 112 | <a name="l00177"></a>00177 <a class="code" href="classenorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<fsqmat></a> E; |
| 113 | <a name="l00178"></a>00178 <span class="keyword">public</span>: |
| 114 | <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 ); |
| 115 | <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 $f(x,u)$.">diffbifn</a>* pfxu, <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables $f(x,u)$.">diffbifn</a>* phxu, <span class="keyword">const</span> mat Q0, <span class="keyword">const</span> mat R0 ); |
| 116 | <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 ); |
| 117 | <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;}; |
| 118 | <a name="l00188"></a><a class="code" href="classEKFfull.html#4080d68f79dade36ccf547d57e64bdc2">00188</a> <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#4080d68f79dade36ccf547d57e64bdc2" title="dummy!">_epdf</a>(){<span class="keywordflow">return</span> E;}; |
| 119 | <a name="l00189"></a>00189 }; |
| 120 | <a name="l00190"></a>00190 |
| 121 | <a name="l00196"></a>00196 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 122 | <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> { |
| 123 | <a name="l00199"></a>00199 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables $f(x,u)$.">diffbifn</a>* pfxu; |
| 124 | <a name="l00201"></a>00201 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables $f(x,u)$.">diffbifn</a>* phxu; |
| 125 | <a name="l00202"></a>00202 <span class="keyword">public</span>: |
| 126 | <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> ); |
| 127 | <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 $f(x,u)$.">diffbifn</a>* pfxu, <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables $f(x,u)$.">diffbifn</a>* phxu, <span class="keyword">const</span> sq_T Q0, <span class="keyword">const</span> sq_T R0 ); |
| 128 | <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 ); |
| 129 | <a name="l00209"></a>00209 }; |
| 130 | <a name="l00210"></a>00210 |
| 131 | <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> { |
| 132 | <a name="l00219"></a>00219 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables $f(x,u)$.">diffbifn</a>* pfxu; |
| 133 | <a name="l00221"></a>00221 <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables $f(x,u)$.">diffbifn</a>* phxu; |
| 134 | <a name="l00222"></a>00222 <span class="keyword">public</span>: |
| 135 | <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> ); |
| 136 | <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 $f(x,u)$.">diffbifn</a>* pfxu, <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables $f(x,u)$.">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 ); |
| 137 | <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 ); |
| 138 | <a name="l00229"></a>00229 }; |
| 139 | <a name="l00230"></a>00230 |
| 140 | <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> { |
| 141 | <a name="l00236"></a>00236 <span class="comment">//protected:</span> |
| 142 | <a name="l00237"></a>00237 <span class="keyword">public</span>: |
| 143 | <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, (typically known as UD).">ldmat</a>> ( rvx, rvy,rvu ),<a class="code" href="classBMcond.html" title="Conditional Bayesian Filter.">BMcond</a> ( rvRQ ) {}; |
| 144 | <a name="l00240"></a>00240 |
| 145 | <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 ); |
| 146 | <a name="l00242"></a>00242 }; |
| 147 | <a name="l00243"></a>00243 |
| 148 | <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> { |
| 149 | <a name="l00249"></a>00249 <span class="comment">//protected:</span> |
| 150 | <a name="l00250"></a>00250 <span class="keyword">public</span>: |
| 151 | <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, (typically known as UD).">ldmat</a>> ( rvx, rvy,rvu ),<a class="code" href="classBMcond.html" title="Conditional Bayesian Filter.">BMcond</a> ( rvR ) {}; |
| 152 | <a name="l00253"></a>00253 |
| 153 | <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> ); |
| 154 | <a name="l00255"></a>00255 }; |
| 155 | <a name="l00256"></a>00256 |
| 156 | <a name="l00258"></a>00258 |
| 157 | <a name="l00259"></a>00259 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 158 | <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 ), |
| 159 | <a name="l00261"></a>00261 dimx ( rv.count() ), dimy ( rvy.count() ),dimu ( rvu.count() ), |
| 160 | <a name="l00262"></a>00262 A ( dimx,dimx ), B ( dimx,dimu ), C ( dimy,dimx ), D ( dimy,dimu ), |
| 161 | <a name="l00263"></a>00263 Q(dimx), R(dimy), |
| 162 | <a name="l00264"></a>00264 est ( rv ), fy ( rvy ), _mu(est._mu()), _P(est._R()), _yp(fy._mu()),_Ry(fy._R()) { |
| 163 | <a name="l00265"></a>00265 |
| 164 | <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> ); |
176 | | <a name="l00268"></a>00268 } |
177 | | <a name="l00269"></a>00269 |
178 | | <a name="l00270"></a>00270 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
179 | | <a name="l00271"></a><a class="code" href="classKalman.html#3d56b0a97b8c1e25fdd3b10eef3c2ad3">00271</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 ), |
180 | | <a name="l00272"></a>00272 <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() ), |
181 | | <a name="l00273"></a>00273 <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> ), |
182 | | <a name="l00274"></a>00274 <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>), |
183 | | <a name="l00275"></a>00275 <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> ) { |
184 | | <a name="l00276"></a>00276 <span class="comment">//assign cache</span> |
185 | | <a name="l00277"></a>00277 <span class="comment">//est</span> |
186 | | <a name="l00278"></a>00278 <a class="code" href="classKalman.html#d1f669b5b3421a070cc75d77b55ba734" title="cache of est.mu">_mu</a> = <a class="code" href="classKalman.html#5568c74bac67ae6d3b1061dba60c9424" title="posterior density on $x_t$">est</a>._mu(); |
187 | | <a name="l00279"></a>00279 <a class="code" href="classKalman.html#5568c74bac67ae6d3b1061dba60c9424" title="posterior density on $x_t$">est</a>._R ( <a class="code" href="classKalman.html#b3388218567128a797e69b109138271d" title="cache of est.R">_P</a>,<a class="code" href="classKalman.html#13fec2c93d8a132201e28b70270acf5c" title="cache of est.iR">_iP</a> ); |
188 | | <a name="l00280"></a>00280 |
189 | | <a name="l00281"></a>00281 <span class="comment">//fy</span> |
190 | | <a name="l00282"></a>00282 <a class="code" href="classKalman.html#5188eb0329f8561f0b357af329769bf8" title="cache of fy.mu">_yp</a> = <a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a>._mu(); |
191 | | <a name="l00283"></a>00283 <a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a>._R ( <a class="code" href="classKalman.html#e17dd745daa8a958035a334a56fa4674" title="cache of fy.R">_Ry</a>,<a class="code" href="classKalman.html#8a35bd14afa5a2d9bbd23ad333bec874" title="cache of fy.iR">_iRy</a> ); |
192 | | <a name="l00284"></a>00284 }; |
193 | | <a name="l00285"></a>00285 |
194 | | <a name="l00286"></a>00286 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
195 | | <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 ) { |
196 | | <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> ); |
197 | | <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> ); |
198 | | <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> ); |
199 | | <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> ); |
200 | | <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> ); |
201 | | <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> ); |
202 | | <a name="l00294"></a>00294 |
203 | | <a name="l00295"></a>00295 <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a> = A0; |
204 | | <a name="l00296"></a>00296 <a class="code" href="classKalman.html#dc87704284a6c0bca13bf51f4345a50a" title="Matrix B.">B</a> = B0; |
205 | | <a name="l00297"></a>00297 <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a> = C0; |
206 | | <a name="l00298"></a>00298 <a class="code" href="classKalman.html#d69f774ba3335c970c1c5b1d182f4dd1" title="Matrix D.">D</a> = D0; |
207 | | <a name="l00299"></a>00299 <a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a> = R0; |
208 | | <a name="l00300"></a>00300 <a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a> = Q0; |
209 | | <a name="l00301"></a>00301 } |
210 | | <a name="l00302"></a>00302 |
211 | | <a name="l00303"></a>00303 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
212 | | <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 ) { |
213 | | <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> ); |
214 | | <a name="l00306"></a>00306 |
215 | | <a name="l00307"></a>00307 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 ); |
216 | | <a name="l00308"></a>00308 vec y = dt.get ( 0,<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>-1 ); |
217 | | <a name="l00309"></a>00309 <span class="comment">//Time update</span> |
218 | | <a name="l00310"></a>00310 *<a class="code" href="classKalman.html#d1f669b5b3421a070cc75d77b55ba734" title="cache of est.mu">_mu</a> = <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a>* ( *_mu ) + <a class="code" href="classKalman.html#dc87704284a6c0bca13bf51f4345a50a" title="Matrix B.">B</a>*u; |
219 | | <a name="l00311"></a>00311 <span class="comment">//P = A*P*A.transpose() + Q; in sq_T</span> |
220 | | <a name="l00312"></a>00312 <a class="code" href="classKalman.html#b3388218567128a797e69b109138271d" title="cache of est.R">_P</a>->mult_sym ( <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a> ); |
221 | | <a name="l00313"></a>00313 ( *_P ) +=<a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a>; |
222 | | <a name="l00314"></a>00314 |
223 | | <a name="l00315"></a>00315 <span class="comment">//Data update</span> |
224 | | <a name="l00316"></a>00316 <span class="comment">//_Ry = C*P*C.transpose() + R; in sq_T</span> |
225 | | <a name="l00317"></a>00317 <a class="code" href="classKalman.html#b3388218567128a797e69b109138271d" 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#e17dd745daa8a958035a334a56fa4674" title="cache of fy.R">_Ry</a> ); |
226 | | <a name="l00318"></a>00318 ( *_Ry ) +=<a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a>; |
227 | | <a name="l00319"></a>00319 |
228 | | <a name="l00320"></a>00320 mat Pfull = <a class="code" href="classKalman.html#b3388218567128a797e69b109138271d" title="cache of est.R">_P</a>->to_mat(); |
229 | | <a name="l00321"></a>00321 |
230 | | <a name="l00322"></a>00322 <a class="code" href="classKalman.html#e17dd745daa8a958035a334a56fa4674" title="cache of fy.R">_Ry</a>->inv ( *<a class="code" href="classKalman.html#8a35bd14afa5a2d9bbd23ad333bec874" title="cache of fy.iR">_iRy</a> ); <span class="comment">// result is in _iRy;</span> |
231 | | <a name="l00323"></a>00323 <a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a>._cached ( <span class="keyword">true</span> ); |
232 | | <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() * ( <a class="code" href="classKalman.html#8a35bd14afa5a2d9bbd23ad333bec874" title="cache of fy.iR">_iRy</a>->to_mat() ); |
233 | | <a name="l00325"></a>00325 |
234 | | <a name="l00326"></a>00326 sq_T pom ( ( <span class="keywordtype">int</span> ) Pfull.rows() ); |
235 | | <a name="l00327"></a>00327 <a class="code" href="classKalman.html#8a35bd14afa5a2d9bbd23ad333bec874" title="cache of fy.iR">_iRy</a>->mult_sym_t ( <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>*Pfull,pom ); |
236 | | <a name="l00328"></a>00328 ( *_P ) -= pom; <span class="comment">// P = P -PC'iRy*CP;</span> |
237 | | <a name="l00329"></a>00329 ( *_yp ) = <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>* ( *_mu ) +<a class="code" href="classKalman.html#d69f774ba3335c970c1c5b1d182f4dd1" title="Matrix D.">D</a>*u; <span class="comment">//y prediction</span> |
238 | | <a name="l00330"></a>00330 ( *_mu ) += <a class="code" href="classKalman.html#d422f51467c7a06174af2476d2826132" title="placeholder for Kalman gain">_K</a>* ( y- ( *_yp ) ); |
239 | | <a name="l00331"></a>00331 |
240 | | <a name="l00332"></a>00332 |
241 | | <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> |
242 | | <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 ); |
243 | | <a name="l00335"></a>00335 } |
| 166 | <a name="l00268"></a>00268 <span class="comment">// copy values in pointers</span> |
| 167 | <a name="l00269"></a>00269 <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a> = K0.<a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>; |
| 168 | <a name="l00270"></a>00270 <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a> = K0.<a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>; |
| 169 | <a name="l00271"></a>00271 <a class="code" href="classKalman.html#764bbc95238eda11fc81c5ebd0b1dcfd" title="cache of fy.mu">_yp</a> = K0.<a class="code" href="classKalman.html#764bbc95238eda11fc81c5ebd0b1dcfd" title="cache of fy.mu">_yp</a>; |
| 170 | <a name="l00272"></a>00272 <a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a> = K0.<a class="code" href="classKalman.html#45c9f928d2d62e0c884900fb3380f904" title="cache of fy.R">_Ry</a>; |
| 171 | <a name="l00273"></a>00273 |
| 172 | <a name="l00274"></a>00274 } |
| 173 | <a name="l00275"></a>00275 |
| 174 | <a name="l00276"></a>00276 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 175 | <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 ), |
| 176 | <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() ), |
| 177 | <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> ), |
| 178 | <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>), |
| 179 | <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#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()), <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()) { |
| 180 | <a name="l00282"></a>00282 }; |
| 181 | <a name="l00283"></a>00283 |
| 182 | <a name="l00284"></a>00284 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 183 | <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 ) { |
| 184 | <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> ); |
| 185 | <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> ); |
| 186 | <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> ); |
| 187 | <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> ); |
| 188 | <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> ); |
| 189 | <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> ); |
| 190 | <a name="l00292"></a>00292 |
| 191 | <a name="l00293"></a>00293 <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a> = A0; |
| 192 | <a name="l00294"></a>00294 <a class="code" href="classKalman.html#dc87704284a6c0bca13bf51f4345a50a" title="Matrix B.">B</a> = B0; |
| 193 | <a name="l00295"></a>00295 <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a> = C0; |
| 194 | <a name="l00296"></a>00296 <a class="code" href="classKalman.html#d69f774ba3335c970c1c5b1d182f4dd1" title="Matrix D.">D</a> = D0; |
| 195 | <a name="l00297"></a>00297 <a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a> = R0; |
| 196 | <a name="l00298"></a>00298 <a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a> = Q0; |
| 197 | <a name="l00299"></a>00299 } |
| 198 | <a name="l00300"></a>00300 |
| 199 | <a name="l00301"></a>00301 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 200 | <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 ) { |
| 201 | <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> ); |
| 202 | <a name="l00304"></a>00304 |
| 203 | <a name="l00305"></a>00305 sq_T iRy(<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>); |
| 204 | <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 ); |
| 205 | <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 ); |
| 206 | <a name="l00308"></a>00308 <span class="comment">//Time update</span> |
| 207 | <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; |
| 208 | <a name="l00310"></a>00310 <span class="comment">//P = A*P*A.transpose() + Q; in sq_T</span> |
| 209 | <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> ); |
| 210 | <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>; |
| 211 | <a name="l00313"></a>00313 |
| 212 | <a name="l00314"></a>00314 <span class="comment">//Data update</span> |
| 213 | <a name="l00315"></a>00315 <span class="comment">//_Ry = C*P*C.transpose() + R; in sq_T</span> |
| 214 | <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> ); |
| 215 | <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>; |
| 216 | <a name="l00318"></a>00318 |
| 217 | <a name="l00319"></a>00319 mat Pfull = <a class="code" href="classKalman.html#9fb808cc94a4c2652e1fb93be9bb7dcf" title="cache of est.R">_P</a>.to_mat(); |
| 218 | <a name="l00320"></a>00320 |
| 219 | <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> |
| 220 | <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() ); |
| 221 | <a name="l00323"></a>00323 |
| 222 | <a name="l00324"></a>00324 sq_T pom ( ( <span class="keywordtype">int</span> ) Pfull.rows() ); |
| 223 | <a name="l00325"></a>00325 iRy.mult_sym_t ( <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>*Pfull,pom ); |
| 224 | <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> |
| 225 | <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> |
| 226 | <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> ); |
| 227 | <a name="l00329"></a>00329 |
| 228 | <a name="l00330"></a>00330 |
| 229 | <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> |
| 230 | <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 ); |
| 231 | <a name="l00333"></a>00333 } |
| 232 | <a name="l00334"></a>00334 |
| 233 | <a name="l00335"></a>00335 <span class="comment">//cout << "y: " << y-(*_yp) <<" R: " << _Ry->to_mat() << " iR: " << _iRy->to_mat() << " ll: " << ll <<endl;</span> |
275 | | <a name="l00367"></a>00367 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 ); |
276 | | <a name="l00368"></a>00368 vec y = dt.get ( 0,<a class="code" href="classKalman.html#ba17b956df1e38b31fbbc299c8213b6a" title="cache of rvy.count()">dimy</a>-1 ); |
277 | | <a name="l00369"></a>00369 <span class="comment">//Time update</span> |
278 | | <a name="l00370"></a>00370 *<a class="code" href="classKalman.html#d1f669b5b3421a070cc75d77b55ba734" title="cache of est.mu">_mu</a> = pfxu-><a class="code" href="classdiffbifn.html#ad7673e16aa1a046b131b24c731c4632" title="Evaluates $f(x0,u0)$ (VS: Do we really need common eval? ).">eval</a> ( *<a class="code" href="classKalman.html#d1f669b5b3421a070cc75d77b55ba734" title="cache of est.mu">_mu</a>, u ); |
279 | | <a name="l00371"></a>00371 pfxu-><a class="code" href="classdiffbifn.html#6d217a02d4fa13931258d4bebdd0feb4" title="Evaluates and writes result into A .">dfdx_cond</a> ( *<a class="code" href="classKalman.html#d1f669b5b3421a070cc75d77b55ba734" 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> |
280 | | <a name="l00372"></a>00372 |
281 | | <a name="l00373"></a>00373 <span class="comment">//P = A*P*A.transpose() + Q; in sq_T</span> |
282 | | <a name="l00374"></a>00374 <a class="code" href="classKalman.html#b3388218567128a797e69b109138271d" title="cache of est.R">_P</a>-><a class="code" href="classldmat.html#e967b9425007f0cb6cd59b845f9756d8" title="Inplace symmetric multiplication by a SQUARE matrix $C$, i.e. $V = C*V*C&#39;$.">mult_sym</a> ( <a class="code" href="classKalman.html#5e02efe86ee91e9c74b93b425fe060b9" title="Matrix A.">A</a> ); |
283 | | <a name="l00375"></a>00375 ( *_P ) +=<a class="code" href="classKalman.html#9b69015c800eb93f3ee49da23a6f55d9" title="Matrix Q in square-root form.">Q</a>; |
284 | | <a name="l00376"></a>00376 |
285 | | <a name="l00377"></a>00377 <span class="comment">//Data update</span> |
286 | | <a name="l00378"></a>00378 phxu-><a class="code" href="classdiffbifn.html#6d217a02d4fa13931258d4bebdd0feb4" title="Evaluates and writes result into A .">dfdx_cond</a> ( *<a class="code" href="classKalman.html#d1f669b5b3421a070cc75d77b55ba734" 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> |
287 | | <a name="l00379"></a>00379 <span class="comment">//_Ry = C*P*C.transpose() + R; in sq_T</span> |
288 | | <a name="l00380"></a>00380 <a class="code" href="classKalman.html#b3388218567128a797e69b109138271d" title="cache of est.R">_P</a>-><a class="code" href="classldmat.html#e967b9425007f0cb6cd59b845f9756d8" title="Inplace symmetric multiplication by a SQUARE matrix $C$, i.e. $V = C*V*C&#39;$.">mult_sym</a> ( <a class="code" href="classKalman.html#86a805cd6515872d1132ad0d6eb5dc13" title="Matrix C.">C</a>, *<a class="code" href="classKalman.html#e17dd745daa8a958035a334a56fa4674" title="cache of fy.R">_Ry</a> ); |
289 | | <a name="l00381"></a>00381 ( *_Ry ) +=<a class="code" href="classKalman.html#11d171dc0e0ab111c56a70f98b97b3ec" title="Matrix R in square-root form.">R</a>; |
290 | | <a name="l00382"></a>00382 |
291 | | <a name="l00383"></a>00383 mat Pfull = <a class="code" href="classKalman.html#b3388218567128a797e69b109138271d" title="cache of est.R">_P</a>-><a class="code" href="classldmat.html#5b0515da8dc2293d9e4360b74cc26c9e" title="Conversion to full matrix.">to_mat</a>(); |
292 | | <a name="l00384"></a>00384 |
293 | | <a name="l00385"></a>00385 <a class="code" href="classKalman.html#e17dd745daa8a958035a334a56fa4674" title="cache of fy.R">_Ry</a>-><a class="code" href="classldmat.html#2c160cb123c1102face7a50ec566a031" title="Matrix inversion preserving the chosen form.">inv</a> ( *<a class="code" href="classKalman.html#8a35bd14afa5a2d9bbd23ad333bec874" title="cache of fy.iR">_iRy</a> ); <span class="comment">// result is in _iRy;</span> |
294 | | <a name="l00386"></a>00386 <a class="code" href="classKalman.html#e580ab06483952bd03f2e651763e184f" title="preditive density on $y_t$">fy</a>.<a class="code" href="classenorm.html#c9ca4f2ca42568e40ca146168e7f3247" title="set cache as inconsistent">_cached</a> ( <span class="keyword">true</span> ); |
295 | | <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() * ( <a class="code" href="classKalman.html#8a35bd14afa5a2d9bbd23ad333bec874" title="cache of fy.iR">_iRy</a>-><a class="code" href="classldmat.html#5b0515da8dc2293d9e4360b74cc26c9e" title="Conversion to full matrix.">to_mat</a>() ); |
| 265 | <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>); |
| 266 | <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 ); |
| 267 | <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 ); |
| 268 | <a name="l00370"></a>00370 <span class="comment">//Time update</span> |
| 269 | <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 $f(x0,u0)$ (VS: Do we really need common eval? ).">eval</a> ( <a class="code" href="classKalman.html#fe803a81d2d847b0b1db3c6b29c18061" title="cache of est.mu">_mu</a>, u ); |
| 270 | <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> |
| 271 | <a name="l00373"></a>00373 |
| 272 | <a name="l00374"></a>00374 <span class="comment">//P = A*P*A.transpose() + Q; in sq_T</span> |
| 273 | <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> ); |
| 274 | <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>; |
| 275 | <a name="l00377"></a>00377 |
| 276 | <a name="l00378"></a>00378 <span class="comment">//Data update</span> |
| 277 | <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> |
| 278 | <a name="l00380"></a>00380 <span class="comment">//_Ry = C*P*C.transpose() + R; in sq_T</span> |
| 279 | <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> ); |
| 280 | <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>; |
| 281 | <a name="l00383"></a>00383 |
| 282 | <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#cedf4f048309056f4262c930914dfda8" title="Conversion to full matrix.">to_mat</a>(); |
| 283 | <a name="l00385"></a>00385 |
| 284 | <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> |
| 285 | <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() ); |