1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
---|
3 | <title>mixpp: libKF.h Source File</title> |
---|
4 | <link href="tabs.css" rel="stylesheet" type="text/css"> |
---|
5 | <link href="doxygen.css" rel="stylesheet" type="text/css"> |
---|
6 | </head><body> |
---|
7 | <!-- Generated by Doxygen 1.5.8 --> |
---|
8 | <script type="text/javascript"> |
---|
9 | <!-- |
---|
10 | function changeDisplayState (e){ |
---|
11 | var num=this.id.replace(/[^[0-9]/g,''); |
---|
12 | var button=this.firstChild; |
---|
13 | var sectionDiv=document.getElementById('dynsection'+num); |
---|
14 | if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){ |
---|
15 | sectionDiv.style.display='block'; |
---|
16 | button.src='open.gif'; |
---|
17 | }else{ |
---|
18 | sectionDiv.style.display='none'; |
---|
19 | button.src='closed.gif'; |
---|
20 | } |
---|
21 | } |
---|
22 | function initDynSections(){ |
---|
23 | var divs=document.getElementsByTagName('div'); |
---|
24 | var sectionCounter=1; |
---|
25 | for(var i=0;i<divs.length-1;i++){ |
---|
26 | if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){ |
---|
27 | var header=divs[i]; |
---|
28 | var section=divs[i+1]; |
---|
29 | var button=header.firstChild; |
---|
30 | if (button!='IMG'){ |
---|
31 | divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild); |
---|
32 | button=document.createElement('img'); |
---|
33 | divs[i].insertBefore(button,divs[i].firstChild); |
---|
34 | } |
---|
35 | header.style.cursor='pointer'; |
---|
36 | header.onclick=changeDisplayState; |
---|
37 | header.id='dynheader'+sectionCounter; |
---|
38 | button.src='closed.gif'; |
---|
39 | section.id='dynsection'+sectionCounter; |
---|
40 | section.style.display='none'; |
---|
41 | section.style.marginLeft='14px'; |
---|
42 | sectionCounter++; |
---|
43 | } |
---|
44 | } |
---|
45 | } |
---|
46 | window.onload = initDynSections; |
---|
47 | --> |
---|
48 | </script> |
---|
49 | <div class="navigation" id="top"> |
---|
50 | <div class="tabs"> |
---|
51 | <ul> |
---|
52 | <li><a href="main.html"><span>Main Page</span></a></li> |
---|
53 | <li><a href="pages.html"><span>Related Pages</span></a></li> |
---|
54 | <li><a href="modules.html"><span>Modules</span></a></li> |
---|
55 | <li><a href="annotated.html"><span>Classes</span></a></li> |
---|
56 | <li class="current"><a href="files.html"><span>Files</span></a></li> |
---|
57 | </ul> |
---|
58 | </div> |
---|
59 | <div class="tabs"> |
---|
60 | <ul> |
---|
61 | <li><a href="files.html"><span>File List</span></a></li> |
---|
62 | <li><a href="globals.html"><span>File Members</span></a></li> |
---|
63 | </ul> |
---|
64 | </div> |
---|
65 | <h1>libKF.h</h1><a href="libKF_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 |
---|
66 | <a name="l00013"></a>00013 <span class="preprocessor">#ifndef KF_H</span> |
---|
67 | <a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define KF_H</span> |
---|
68 | <a name="l00015"></a>00015 <span class="preprocessor"></span> |
---|
69 | <a name="l00016"></a>00016 |
---|
70 | <a name="l00017"></a>00017 <span class="preprocessor">#include "../stat/libFN.h"</span> |
---|
71 | <a name="l00018"></a>00018 <span class="preprocessor">#include "../stat/libEF.h"</span> |
---|
72 | <a name="l00019"></a>00019 <span class="preprocessor">#include "../math/chmat.h"</span> |
---|
73 | <a name="l00020"></a>00020 |
---|
74 | <a name="l00021"></a>00021 <span class="keyword">namespace </span>bdm { |
---|
75 | <a name="l00022"></a>00022 |
---|
76 | <a name="l00027"></a><a class="code" href="classbdm_1_1KalmanFull.html">00027</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1KalmanFull.html" title="Basic Kalman filter with full matrices (education purpose only)! Will be deleted...">KalmanFull</a> { |
---|
77 | <a name="l00028"></a>00028 <span class="keyword">protected</span>: |
---|
78 | <a name="l00029"></a>00029 <span class="keywordtype">int</span> dimx, dimy, dimu; |
---|
79 | <a name="l00030"></a>00030 mat A, B, C, D, R, Q; |
---|
80 | <a name="l00031"></a>00031 |
---|
81 | <a name="l00032"></a>00032 <span class="comment">//cache</span> |
---|
82 | <a name="l00033"></a>00033 mat _Pp, _Ry, _iRy, _K; |
---|
83 | <a name="l00034"></a>00034 <span class="keyword">public</span>: |
---|
84 | <a name="l00035"></a>00035 <span class="comment">//posterior</span> |
---|
85 | <a name="l00037"></a><a class="code" href="classbdm_1_1KalmanFull.html#2defb75e58892615c5f95fd844f3a666">00037</a> <span class="comment"></span> vec <a class="code" href="classbdm_1_1KalmanFull.html#2defb75e58892615c5f95fd844f3a666" title="Mean value of the posterior density.">mu</a>; |
---|
86 | <a name="l00039"></a><a class="code" href="classbdm_1_1KalmanFull.html#acacd228e100c3e937de575ad2d7cd9c">00039</a> mat <a class="code" href="classbdm_1_1KalmanFull.html#acacd228e100c3e937de575ad2d7cd9c" title="Variance of the posterior density.">P</a>; |
---|
87 | <a name="l00040"></a>00040 |
---|
88 | <a name="l00041"></a>00041 <span class="keywordtype">bool</span> evalll; |
---|
89 | <a name="l00042"></a>00042 <span class="keywordtype">double</span> ll; |
---|
90 | <a name="l00043"></a>00043 <span class="keyword">public</span>: |
---|
91 | <a name="l00045"></a>00045 <a class="code" href="classbdm_1_1KalmanFull.html#bdcc98c8b18c1cbdebdf218ae838fd11" title="For EKFfull;.">KalmanFull</a> ( mat A, mat B, mat C, mat D, mat R, mat Q, mat P0, vec mu0 ); |
---|
92 | <a name="l00047"></a>00047 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1KalmanFull.html#081924bc97f453f674bb982b7951d053" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
---|
93 | <a name="l00049"></a>00049 <span class="keyword">friend</span> std::ostream &<a class="code" href="classbdm_1_1KalmanFull.html#86ba216243ed95bb46d80d88775d16af" title="print elements of KF">operator<< </a>( std::ostream &os, <span class="keyword">const</span> <a class="code" href="classbdm_1_1KalmanFull.html" title="Basic Kalman filter with full matrices (education purpose only)! Will be deleted...">KalmanFull</a> &kf ); |
---|
94 | <a name="l00051"></a><a class="code" href="classbdm_1_1KalmanFull.html#bdcc98c8b18c1cbdebdf218ae838fd11">00051</a> <a class="code" href="classbdm_1_1KalmanFull.html#bdcc98c8b18c1cbdebdf218ae838fd11" title="For EKFfull;.">KalmanFull</a>() {}; |
---|
95 | <a name="l00052"></a>00052 }; |
---|
96 | <a name="l00053"></a>00053 |
---|
97 | <a name="l00054"></a>00054 |
---|
98 | <a name="l00062"></a>00062 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
---|
99 | <a name="l00063"></a>00063 |
---|
100 | <a name="l00064"></a><a class="code" href="classbdm_1_1Kalman.html">00064</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1Kalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a> { |
---|
101 | <a name="l00065"></a>00065 <span class="keyword">protected</span>: |
---|
102 | <a name="l00067"></a><a class="code" href="classbdm_1_1Kalman.html#3fe475a1e920b20b63bb342c0e1571f7">00067</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1Kalman.html#3fe475a1e920b20b63bb342c0e1571f7" title="Indetifier of output rv.">rvy</a>; |
---|
103 | <a name="l00069"></a><a class="code" href="classbdm_1_1Kalman.html#149e27424fd1a7cc1c998ea088618a94">00069</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1Kalman.html#149e27424fd1a7cc1c998ea088618a94" title="Indetifier of exogeneous rv.">rvu</a>; |
---|
104 | <a name="l00071"></a><a class="code" href="classbdm_1_1Kalman.html#ba7699cdb3b1382a54d3e28b9b7517fa">00071</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1Kalman.html#ba7699cdb3b1382a54d3e28b9b7517fa" title="cache of rv.count()">dimx</a>; |
---|
105 | <a name="l00073"></a><a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f">00073</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a>; |
---|
106 | <a name="l00075"></a><a class="code" href="classbdm_1_1Kalman.html#c5136ef617f6ac0e426bea222755d92b">00075</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1Kalman.html#c5136ef617f6ac0e426bea222755d92b" title="cache of rvu.count()">dimu</a>; |
---|
107 | <a name="l00077"></a><a class="code" href="classbdm_1_1Kalman.html#0a2072e2090c10fac74ad30a023a4ace">00077</a> mat <a class="code" href="classbdm_1_1Kalman.html#0a2072e2090c10fac74ad30a023a4ace" title="Matrix A.">A</a>; |
---|
108 | <a name="l00079"></a><a class="code" href="classbdm_1_1Kalman.html#5977b2c81857948a35105f0e7840203c">00079</a> mat <a class="code" href="classbdm_1_1Kalman.html#5977b2c81857948a35105f0e7840203c" title="Matrix B.">B</a>; |
---|
109 | <a name="l00081"></a><a class="code" href="classbdm_1_1Kalman.html#818eba63a23972786a4579ad30294177">00081</a> mat <a class="code" href="classbdm_1_1Kalman.html#818eba63a23972786a4579ad30294177" title="Matrix C.">C</a>; |
---|
110 | <a name="l00083"></a><a class="code" href="classbdm_1_1Kalman.html#7b56ac423d0654b5755e4f852a870456">00083</a> mat <a class="code" href="classbdm_1_1Kalman.html#7b56ac423d0654b5755e4f852a870456" title="Matrix D.">D</a>; |
---|
111 | <a name="l00085"></a><a class="code" href="classbdm_1_1Kalman.html#70f8bf19e81b532c60fd3a7a152425ee">00085</a> sq_T <a class="code" href="classbdm_1_1Kalman.html#70f8bf19e81b532c60fd3a7a152425ee" title="Matrix Q in square-root form.">Q</a>; |
---|
112 | <a name="l00087"></a><a class="code" href="classbdm_1_1Kalman.html#475b088287cdfbba4dc60a3d027728b7">00087</a> sq_T <a class="code" href="classbdm_1_1Kalman.html#475b088287cdfbba4dc60a3d027728b7" title="Matrix R in square-root form.">R</a>; |
---|
113 | <a name="l00088"></a>00088 |
---|
114 | <a name="l00090"></a><a class="code" href="classbdm_1_1Kalman.html#383f329ff18bbe219254c8b3b916f40d">00090</a> <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T></a> <a class="code" href="classbdm_1_1Kalman.html#383f329ff18bbe219254c8b3b916f40d" title="posterior density on $x_t$">est</a>; |
---|
115 | <a name="l00092"></a><a class="code" href="classbdm_1_1Kalman.html#ba555c394c429f6831c9bbabfa2c944c">00092</a> <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T></a> <a class="code" href="classbdm_1_1Kalman.html#ba555c394c429f6831c9bbabfa2c944c" title="preditive density on $y_t$">fy</a>; |
---|
116 | <a name="l00093"></a>00093 |
---|
117 | <a name="l00095"></a><a class="code" href="classbdm_1_1Kalman.html#bd69dfb802465f22dd84d73a180d5c92">00095</a> mat <a class="code" href="classbdm_1_1Kalman.html#bd69dfb802465f22dd84d73a180d5c92" title="placeholder for Kalman gain">_K</a>; |
---|
118 | <a name="l00097"></a><a class="code" href="classbdm_1_1Kalman.html#c249d45258c8578b13858ad3e7b729b1">00097</a> vec& <a class="code" href="classbdm_1_1Kalman.html#c249d45258c8578b13858ad3e7b729b1" title="cache of fy.mu">_yp</a>; |
---|
119 | <a name="l00099"></a><a class="code" href="classbdm_1_1Kalman.html#2dd268f2d7fbe6382cb8825a1114192a">00099</a> sq_T& <a class="code" href="classbdm_1_1Kalman.html#2dd268f2d7fbe6382cb8825a1114192a" title="cache of fy.R">_Ry</a>; |
---|
120 | <a name="l00101"></a><a class="code" href="classbdm_1_1Kalman.html#fa172078091e45561343fa513dd573b0">00101</a> vec& <a class="code" href="classbdm_1_1Kalman.html#fa172078091e45561343fa513dd573b0" title="cache of est.mu">_mu</a>; |
---|
121 | <a name="l00103"></a><a class="code" href="classbdm_1_1Kalman.html#00c27b0bf324f0018497921ca23c71ed">00103</a> sq_T& <a class="code" href="classbdm_1_1Kalman.html#00c27b0bf324f0018497921ca23c71ed" title="cache of est.R">_P</a>; |
---|
122 | <a name="l00104"></a>00104 |
---|
123 | <a name="l00105"></a>00105 <span class="keyword">public</span>: |
---|
124 | <a name="l00107"></a>00107 <a class="code" href="classbdm_1_1Kalman.html#025a0196cbcc2e6adb13311f9d3d52b4" title="Default constructor.">Kalman</a> ( ); |
---|
125 | <a name="l00109"></a>00109 <a class="code" href="classbdm_1_1Kalman.html#025a0196cbcc2e6adb13311f9d3d52b4" title="Default constructor.">Kalman</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1Kalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman<sq_T></a> &K0 ); |
---|
126 | <a name="l00111"></a>00111 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1Kalman.html#3c7fb87fb6b87d08deb6a5a7862da957" 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> sq_T &Q0,<span class="keyword">const</span> sq_T &R0 ); |
---|
127 | <a name="l00113"></a><a class="code" href="classbdm_1_1Kalman.html#9264fc6b173ecb803d2684b883f32c68">00113</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1Kalman.html#9264fc6b173ecb803d2684b883f32c68" title="Set estimate values, used e.g. in initialization.">set_est</a> ( <span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> sq_T &P0 ) { |
---|
128 | <a name="l00114"></a>00114 sq_T pom ( <a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a> ); |
---|
129 | <a name="l00115"></a>00115 <a class="code" href="classbdm_1_1Kalman.html#383f329ff18bbe219254c8b3b916f40d" title="posterior density on $x_t$">est</a>.set_parameters ( mu0,P0 ); |
---|
130 | <a name="l00116"></a>00116 P0.mult_sym ( <a class="code" href="classbdm_1_1Kalman.html#818eba63a23972786a4579ad30294177" title="Matrix C.">C</a>,pom ); |
---|
131 | <a name="l00117"></a>00117 <a class="code" href="classbdm_1_1Kalman.html#ba555c394c429f6831c9bbabfa2c944c" title="preditive density on $y_t$">fy</a>.set_parameters ( <a class="code" href="classbdm_1_1Kalman.html#818eba63a23972786a4579ad30294177" title="Matrix C.">C</a>*mu0, pom ); |
---|
132 | <a name="l00118"></a>00118 }; |
---|
133 | <a name="l00119"></a>00119 |
---|
134 | <a name="l00121"></a>00121 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1Kalman.html#4a39330c14eff8d13179e868a1d1aa8c" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
---|
135 | <a name="l00123"></a><a class="code" href="classbdm_1_1Kalman.html#f75e487ff6c129d7012d702030f8c890">00123</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>& <a class="code" href="classbdm_1_1Kalman.html#f75e487ff6c129d7012d702030f8c890" title="access function">posterior</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1Kalman.html#383f329ff18bbe219254c8b3b916f40d" title="posterior density on $x_t$">est</a>;} |
---|
136 | <a name="l00124"></a>00124 <span class="keyword">const</span> <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T></a>* _e()<span class="keyword"> const </span>{<span class="keywordflow">return</span> &<a class="code" href="classbdm_1_1Kalman.html#383f329ff18bbe219254c8b3b916f40d" title="posterior density on $x_t$">est</a>;} |
---|
137 | <a name="l00126"></a><a class="code" href="classbdm_1_1Kalman.html#c788ec6e6c6f5f5861ae8a56d8ede277">00126</a> mat& <a class="code" href="classbdm_1_1Kalman.html#c788ec6e6c6f5f5861ae8a56d8ede277" title="access function">__K</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1Kalman.html#bd69dfb802465f22dd84d73a180d5c92" title="placeholder for Kalman gain">_K</a>;} |
---|
138 | <a name="l00128"></a><a class="code" href="classbdm_1_1Kalman.html#a250d1dbe7bba861dba2a324520cfa48">00128</a> vec <a class="code" href="classbdm_1_1Kalman.html#a250d1dbe7bba861dba2a324520cfa48" title="access function">_dP</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1Kalman.html#00c27b0bf324f0018497921ca23c71ed" title="cache of est.R">_P</a>->getD();} |
---|
139 | <a name="l00129"></a>00129 }; |
---|
140 | <a name="l00130"></a>00130 |
---|
141 | <a name="l00137"></a><a class="code" href="classbdm_1_1KalmanCh.html">00137</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1KalmanCh.html" title="Kalman filter in square root form.">KalmanCh</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1Kalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><chmat> { |
---|
142 | <a name="l00138"></a>00138 <span class="keyword">protected</span>: |
---|
143 | <a name="l00140"></a><a class="code" href="classbdm_1_1KalmanCh.html#48611c8582706cfa62e832be0972e75d">00140</a> mat <a class="code" href="classbdm_1_1KalmanCh.html#48611c8582706cfa62e832be0972e75d" title="pre array (triangular matrix)">preA</a>; |
---|
144 | <a name="l00142"></a><a class="code" href="classbdm_1_1KalmanCh.html#bcbd68f51d4b57246e7784ca5900171f">00142</a> mat <a class="code" href="classbdm_1_1KalmanCh.html#bcbd68f51d4b57246e7784ca5900171f" title="post array (triangular matrix)">postA</a>; |
---|
145 | <a name="l00143"></a>00143 |
---|
146 | <a name="l00144"></a>00144 <span class="keyword">public</span>: |
---|
147 | <a name="l00146"></a><a class="code" href="classbdm_1_1KalmanCh.html#24ce65bdaa538d4d5153d709a929b996">00146</a> <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a>* <a class="code" href="classbdm_1_1KalmanCh.html#24ce65bdaa538d4d5153d709a929b996" title="copy constructor">_copy_</a>()<span class="keyword"> const </span>{ |
---|
148 | <a name="l00147"></a>00147 <a class="code" href="classbdm_1_1KalmanCh.html" title="Kalman filter in square root form.">KalmanCh</a>* K=<span class="keyword">new</span> <a class="code" href="classbdm_1_1KalmanCh.html" title="Kalman filter in square root form.">KalmanCh</a>; |
---|
149 | <a name="l00148"></a>00148 K-><a class="code" href="classbdm_1_1KalmanCh.html#20a4d4c664e8ac8a3f1bb7b0d11c6d87" title="Set parameters with check of relevance.">set_parameters</a> ( <a class="code" href="classbdm_1_1Kalman.html#0a2072e2090c10fac74ad30a023a4ace" title="Matrix A.">A</a>,<a class="code" href="classbdm_1_1Kalman.html#5977b2c81857948a35105f0e7840203c" title="Matrix B.">B</a>,<a class="code" href="classbdm_1_1Kalman.html#818eba63a23972786a4579ad30294177" title="Matrix C.">C</a>,<a class="code" href="classbdm_1_1Kalman.html#7b56ac423d0654b5755e4f852a870456" title="Matrix D.">D</a>,<a class="code" href="classbdm_1_1Kalman.html#70f8bf19e81b532c60fd3a7a152425ee" title="Matrix Q in square-root form.">Q</a>,<a class="code" href="classbdm_1_1Kalman.html#475b088287cdfbba4dc60a3d027728b7" title="Matrix R in square-root form.">R</a> ); |
---|
150 | <a name="l00149"></a>00149 K-><a class="code" href="classbdm_1_1KalmanCh.html#6e169272657ed101f3d128b49c59b890">set_statistics</a> ( <a class="code" href="classbdm_1_1Kalman.html#fa172078091e45561343fa513dd573b0" title="cache of est.mu">_mu</a>,<a class="code" href="classbdm_1_1Kalman.html#00c27b0bf324f0018497921ca23c71ed" title="cache of est.R">_P</a> ); |
---|
151 | <a name="l00150"></a>00150 <span class="keywordflow">return</span> K; |
---|
152 | <a name="l00151"></a>00151 } |
---|
153 | <a name="l00153"></a>00153 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1KalmanCh.html#20a4d4c664e8ac8a3f1bb7b0d11c6d87" 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> &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 ); |
---|
154 | <a name="l00154"></a>00154 <span class="keywordtype">void</span> set_statistics ( <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 ) { |
---|
155 | <a name="l00155"></a>00155 <a class="code" href="classbdm_1_1Kalman.html#383f329ff18bbe219254c8b3b916f40d" title="posterior density on $x_t$">est</a>.<a class="code" href="classbdm_1_1enorm.html#b8322f2c11560871dd922c660f4771bb">set_parameters</a> ( mu0,P0 ); |
---|
156 | <a name="l00156"></a>00156 }; |
---|
157 | <a name="l00157"></a>00157 |
---|
158 | <a name="l00158"></a>00158 |
---|
159 | <a name="l00172"></a>00172 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1KalmanCh.html#b41fe5540548100b08e1684c3be767b6" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
---|
160 | <a name="l00173"></a>00173 }; |
---|
161 | <a name="l00174"></a>00174 |
---|
162 | <a name="l00180"></a><a class="code" href="classbdm_1_1EKFfull.html">00180</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1EKFfull.html" title="Extended Kalman Filter in full matrices.">EKFfull</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1KalmanFull.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="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a> { |
---|
163 | <a name="l00181"></a>00181 |
---|
164 | <a name="l00183"></a>00183 <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu; |
---|
165 | <a name="l00185"></a>00185 <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu; |
---|
166 | <a name="l00186"></a>00186 |
---|
167 | <a name="l00187"></a>00187 <a class="code" href="classbdm_1_1enorm.html">enorm<fsqmat></a> E; |
---|
168 | <a name="l00188"></a>00188 <span class="keyword">public</span>: |
---|
169 | <a name="l00190"></a>00190 <a class="code" href="classbdm_1_1EKFfull.html#6939c345389abb8b2481457b4cfe1165" title="Default constructor.">EKFfull</a> ( ); |
---|
170 | <a name="l00192"></a>00192 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1EKFfull.html#78748da361ba61fef162b0d8956d1743" title="Set nonlinear functions for mean values and covariance matrices.">set_parameters</a> ( <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu, <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu, <span class="keyword">const</span> mat Q0, <span class="keyword">const</span> mat R0 ); |
---|
171 | <a name="l00194"></a>00194 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1EKFfull.html#f149ae8e9ce14d9931a7bb2850736699" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
---|
172 | <a name="l00196"></a><a class="code" href="classbdm_1_1EKFfull.html#7562b3d3c17241dab3baf70258742eb2">00196</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1EKFfull.html#7562b3d3c17241dab3baf70258742eb2" title="set estimates">set_est</a> ( vec mu0, mat P0 ) {<a class="code" href="classbdm_1_1KalmanFull.html#2defb75e58892615c5f95fd844f3a666" title="Mean value of the posterior density.">mu</a>=mu0;<a class="code" href="classbdm_1_1KalmanFull.html#acacd228e100c3e937de575ad2d7cd9c" title="Variance of the posterior density.">P</a>=P0;}; |
---|
173 | <a name="l00198"></a><a class="code" href="classbdm_1_1EKFfull.html#7e9a69f36a0a0615c9abb806772ef36d">00198</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>& <a class="code" href="classbdm_1_1EKFfull.html#7e9a69f36a0a0615c9abb806772ef36d" title="dummy!">posterior</a>()<span class="keyword"> const</span>{<span class="keywordflow">return</span> E;}; |
---|
174 | <a name="l00199"></a>00199 <span class="keyword">const</span> <a class="code" href="classbdm_1_1enorm.html">enorm<fsqmat></a>* _e()<span class="keyword"> const</span>{<span class="keywordflow">return</span> &E;}; |
---|
175 | <a name="l00200"></a>00200 <span class="keyword">const</span> mat _R() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1KalmanFull.html#acacd228e100c3e937de575ad2d7cd9c" title="Variance of the posterior density.">P</a>;} |
---|
176 | <a name="l00201"></a>00201 }; |
---|
177 | <a name="l00202"></a>00202 |
---|
178 | <a name="l00208"></a>00208 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
---|
179 | <a name="l00209"></a><a class="code" href="classbdm_1_1EKF.html">00209</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1EKF.html" title="Extended Kalman Filter.">EKF</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1Kalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><fsqmat> { |
---|
180 | <a name="l00211"></a>00211 <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu; |
---|
181 | <a name="l00213"></a>00213 <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu; |
---|
182 | <a name="l00214"></a>00214 <span class="keyword">public</span>: |
---|
183 | <a name="l00216"></a>00216 <a class="code" href="classbdm_1_1EKF.html#d087a8bb408d26ac4f5c542746b81059" title="Default constructor.">EKF</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rvx, <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1Kalman.html#3fe475a1e920b20b63bb342c0e1571f7" title="Indetifier of output rv.">rvy</a>, <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1Kalman.html#149e27424fd1a7cc1c998ea088618a94" title="Indetifier of exogeneous rv.">rvu</a> ); |
---|
184 | <a name="l00218"></a><a class="code" href="classbdm_1_1EKF.html#fe9b2e227255ad32dc73df316b7318f4">00218</a> <a class="code" href="classbdm_1_1EKF.html" title="Extended Kalman Filter.">EKF<sq_T></a>* <a class="code" href="classbdm_1_1EKF.html#fe9b2e227255ad32dc73df316b7318f4" title="copy constructor">_copy_</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classbdm_1_1EKF.html" title="Extended Kalman Filter.">EKF<sq_T></a>(<span class="keyword">this</span>); } |
---|
185 | <a name="l00220"></a>00220 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1EKF.html#00fec1a0a6a467eb83fb36c65eba7bcb" title="Set nonlinear functions for mean values and covariance matrices.">set_parameters</a> ( <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu, <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu, <span class="keyword">const</span> sq_T Q0, <span class="keyword">const</span> sq_T R0 ); |
---|
186 | <a name="l00222"></a>00222 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1EKF.html#3fb182ecc29b10ca1163cecbf3bcccfa" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
---|
187 | <a name="l00223"></a>00223 }; |
---|
188 | <a name="l00224"></a>00224 |
---|
189 | <a name="l00231"></a><a class="code" href="classbdm_1_1EKFCh.html">00231</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1EKFCh.html" title="Extended Kalman Filter in Square root.">EKFCh</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1KalmanCh.html" title="Kalman filter in square root form.">KalmanCh</a> { |
---|
190 | <a name="l00232"></a>00232 <span class="keyword">protected</span>: |
---|
191 | <a name="l00234"></a><a class="code" href="classbdm_1_1EKFCh.html#e1e895f994398a55bc425551fc275ba3">00234</a> <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* <a class="code" href="classbdm_1_1EKFCh.html#e1e895f994398a55bc425551fc275ba3" title="Internal Model f(x,u).">pfxu</a>; |
---|
192 | <a name="l00236"></a><a class="code" href="classbdm_1_1EKFCh.html#6b34c69641826322467b704e8252f317">00236</a> <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* <a class="code" href="classbdm_1_1EKFCh.html#6b34c69641826322467b704e8252f317" title="Observation Model h(x,u).">phxu</a>; |
---|
193 | <a name="l00237"></a>00237 <span class="keyword">public</span>: |
---|
194 | <a name="l00239"></a><a class="code" href="classbdm_1_1EKFCh.html#1d1d91400e3f177de9fe7962ea17adc4">00239</a> <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a>* <a class="code" href="classbdm_1_1EKFCh.html#1d1d91400e3f177de9fe7962ea17adc4" title="copy constructor duplicated - calls different set_parameters">_copy_</a>()<span class="keyword"> const </span>{ |
---|
195 | <a name="l00240"></a>00240 <a class="code" href="classbdm_1_1EKFCh.html" title="Extended Kalman Filter in Square root.">EKFCh</a>* E=<span class="keyword">new</span> <a class="code" href="classbdm_1_1EKFCh.html" title="Extended Kalman Filter in Square root.">EKFCh</a>; |
---|
196 | <a name="l00241"></a>00241 E-><a class="code" href="classbdm_1_1EKFCh.html#50f9fbffad721f35e5ccb75d0f6b842a" title="Set nonlinear functions for mean values and covariance matrices.">set_parameters</a> ( <a class="code" href="classbdm_1_1EKFCh.html#e1e895f994398a55bc425551fc275ba3" title="Internal Model f(x,u).">pfxu</a>,<a class="code" href="classbdm_1_1EKFCh.html#6b34c69641826322467b704e8252f317" title="Observation Model h(x,u).">phxu</a>,<a class="code" href="classbdm_1_1Kalman.html#70f8bf19e81b532c60fd3a7a152425ee" title="Matrix Q in square-root form.">Q</a>,<a class="code" href="classbdm_1_1Kalman.html#475b088287cdfbba4dc60a3d027728b7" title="Matrix R in square-root form.">R</a> ); |
---|
197 | <a name="l00242"></a>00242 E-><a class="code" href="classbdm_1_1KalmanCh.html#6e169272657ed101f3d128b49c59b890">set_statistics</a> ( <a class="code" href="classbdm_1_1Kalman.html#fa172078091e45561343fa513dd573b0" title="cache of est.mu">_mu</a>,<a class="code" href="classbdm_1_1Kalman.html#00c27b0bf324f0018497921ca23c71ed" title="cache of est.R">_P</a> ); |
---|
198 | <a name="l00243"></a>00243 <span class="keywordflow">return</span> E; |
---|
199 | <a name="l00244"></a>00244 } |
---|
200 | <a name="l00246"></a>00246 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1EKFCh.html#50f9fbffad721f35e5ccb75d0f6b842a" title="Set nonlinear functions for mean values and covariance matrices.">set_parameters</a> ( <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* <a class="code" href="classbdm_1_1EKFCh.html#e1e895f994398a55bc425551fc275ba3" title="Internal Model f(x,u).">pfxu</a>, <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* <a class="code" href="classbdm_1_1EKFCh.html#6b34c69641826322467b704e8252f317" title="Observation Model h(x,u).">phxu</a>, <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 ); |
---|
201 | <a name="l00248"></a>00248 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1EKFCh.html#4c8609c37290b158f88a31dae4047225" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
---|
202 | <a name="l00249"></a>00249 }; |
---|
203 | <a name="l00250"></a>00250 |
---|
204 | <a name="l00255"></a><a class="code" href="classbdm_1_1KFcondQR.html">00255</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1KFcondQR.html" title="Kalman Filter with conditional diagonal matrices R and Q.">KFcondQR</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1Kalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><ldmat> { |
---|
205 | <a name="l00256"></a>00256 <span class="comment">//protected:</span> |
---|
206 | <a name="l00257"></a>00257 <span class="keyword">public</span>: |
---|
207 | <a name="l00258"></a><a class="code" href="classbdm_1_1KFcondQR.html#31bc31087ee7ed6c0bfb92d626321b91">00258</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1KFcondQR.html#31bc31087ee7ed6c0bfb92d626321b91" title="Substitute val for rvc.">condition</a> ( <span class="keyword">const</span> vec &QR ) { |
---|
208 | <a name="l00259"></a>00259 it_assert_debug ( QR.length() == ( <a class="code" href="classbdm_1_1Kalman.html#ba7699cdb3b1382a54d3e28b9b7517fa" title="cache of rv.count()">dimx</a>+<a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a> ),<span class="stringliteral">"KFcondRQ: conditioning by incompatible vector"</span> ); |
---|
209 | <a name="l00260"></a>00260 |
---|
210 | <a name="l00261"></a>00261 <a class="code" href="classbdm_1_1Kalman.html#70f8bf19e81b532c60fd3a7a152425ee" title="Matrix Q in square-root form.">Q</a>.<a class="code" href="classldmat.html#0884a613b94fde61bfc84288e73ce57f" title="Access functions.">setD</a> ( QR ( 0, <a class="code" href="classbdm_1_1Kalman.html#ba7699cdb3b1382a54d3e28b9b7517fa" title="cache of rv.count()">dimx</a>-1 ) ); |
---|
211 | <a name="l00262"></a>00262 <a class="code" href="classbdm_1_1Kalman.html#475b088287cdfbba4dc60a3d027728b7" title="Matrix R in square-root form.">R</a>.<a class="code" href="classldmat.html#0884a613b94fde61bfc84288e73ce57f" title="Access functions.">setD</a> ( QR ( <a class="code" href="classbdm_1_1Kalman.html#ba7699cdb3b1382a54d3e28b9b7517fa" title="cache of rv.count()">dimx</a>, -1 ) ); |
---|
212 | <a name="l00263"></a>00263 }; |
---|
213 | <a name="l00264"></a>00264 }; |
---|
214 | <a name="l00265"></a>00265 |
---|
215 | <a name="l00270"></a><a class="code" href="classbdm_1_1KFcondR.html">00270</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1KFcondR.html" title="Kalman Filter with conditional diagonal matrices R and Q.">KFcondR</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1Kalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><ldmat> { |
---|
216 | <a name="l00271"></a>00271 <span class="comment">//protected:</span> |
---|
217 | <a name="l00272"></a>00272 <span class="keyword">public</span>: |
---|
218 | <a name="l00274"></a><a class="code" href="classbdm_1_1KFcondR.html#f11639d79f10b1e7dad16a0d8233450d">00274</a> <a class="code" href="classbdm_1_1KFcondR.html#f11639d79f10b1e7dad16a0d8233450d" title="Default constructor.">KFcondR</a> ( ) : <a class="code" href="classbdm_1_1Kalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><<a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a>> ( ) {}; |
---|
219 | <a name="l00275"></a>00275 |
---|
220 | <a name="l00276"></a><a class="code" href="classbdm_1_1KFcondR.html#7d42a421acbdcf9b610a5682ee5fb9a8">00276</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1KFcondR.html#7d42a421acbdcf9b610a5682ee5fb9a8" title="Substitute val for rvc.">condition</a> ( <span class="keyword">const</span> vec &R0 ) { |
---|
221 | <a name="l00277"></a>00277 it_assert_debug ( R0.length() == ( <a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a> ),<span class="stringliteral">"KFcondR: conditioning by incompatible vector"</span> ); |
---|
222 | <a name="l00278"></a>00278 |
---|
223 | <a name="l00279"></a>00279 <a class="code" href="classbdm_1_1Kalman.html#475b088287cdfbba4dc60a3d027728b7" title="Matrix R in square-root form.">R</a>.<a class="code" href="classldmat.html#0884a613b94fde61bfc84288e73ce57f" title="Access functions.">setD</a> ( R0 ); |
---|
224 | <a name="l00280"></a>00280 }; |
---|
225 | <a name="l00281"></a>00281 |
---|
226 | <a name="l00282"></a>00282 }; |
---|
227 | <a name="l00283"></a>00283 |
---|
228 | <a name="l00285"></a>00285 |
---|
229 | <a name="l00286"></a>00286 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
---|
230 | <a name="l00287"></a><a class="code" href="classbdm_1_1Kalman.html#8b22c45cffa949d70b8e5ac92ed5ce25">00287</a> <a class="code" href="classbdm_1_1Kalman.html#025a0196cbcc2e6adb13311f9d3d52b4" title="Default constructor.">Kalman<sq_T>::Kalman</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1Kalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman<sq_T></a> &K0 ) : <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a> ( ),rvy ( K0.rvy ),rvu ( K0.rvu ), |
---|
231 | <a name="l00288"></a>00288 dimx ( K0.dimx ), dimy ( K0.dimy ),dimu ( K0.dimu ), |
---|
232 | <a name="l00289"></a>00289 A ( K0.A ), B ( K0.B ), C ( K0.C ), D ( K0.D ), |
---|
233 | <a name="l00290"></a>00290 Q ( K0.Q ), R ( K0.R ), |
---|
234 | <a name="l00291"></a>00291 est ( K0.est ), fy ( K0.fy ), _yp ( fy._mu() ),_Ry ( fy._R() ), _mu ( est._mu() ), _P ( est._R() ) { |
---|
235 | <a name="l00292"></a>00292 |
---|
236 | <a name="l00293"></a>00293 <span class="comment">// copy values in pointers</span> |
---|
237 | <a name="l00294"></a>00294 <span class="comment">// _mu = K0._mu;</span> |
---|
238 | <a name="l00295"></a>00295 <span class="comment">// _P = K0._P;</span> |
---|
239 | <a name="l00296"></a>00296 <span class="comment">// _yp = K0._yp;</span> |
---|
240 | <a name="l00297"></a>00297 <span class="comment">// _Ry = K0._Ry;</span> |
---|
241 | <a name="l00298"></a>00298 |
---|
242 | <a name="l00299"></a>00299 } |
---|
243 | <a name="l00300"></a>00300 |
---|
244 | <a name="l00301"></a>00301 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
---|
245 | <a name="l00302"></a><a class="code" href="classbdm_1_1Kalman.html#025a0196cbcc2e6adb13311f9d3d52b4">00302</a> <a class="code" href="classbdm_1_1Kalman.html#025a0196cbcc2e6adb13311f9d3d52b4" title="Default constructor.">Kalman<sq_T>::Kalman</a> ( ) : <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a> (), est ( ), fy (), _yp ( fy._mu() ), _Ry ( fy._R() ), _mu ( est._mu() ), _P ( est._R() ) { |
---|
246 | <a name="l00303"></a>00303 }; |
---|
247 | <a name="l00304"></a>00304 |
---|
248 | <a name="l00305"></a>00305 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
---|
249 | <a name="l00306"></a><a class="code" href="classbdm_1_1Kalman.html#3c7fb87fb6b87d08deb6a5a7862da957">00306</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1Kalman.html#3c7fb87fb6b87d08deb6a5a7862da957" 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 &Q0, <span class="keyword">const</span> sq_T &R0 ) { |
---|
250 | <a name="l00307"></a>00307 <a class="code" href="classbdm_1_1Kalman.html#ba7699cdb3b1382a54d3e28b9b7517fa" title="cache of rv.count()">dimx</a> = A0.rows(); |
---|
251 | <a name="l00308"></a>00308 <a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a> = C0.rows(); |
---|
252 | <a name="l00309"></a>00309 <a class="code" href="classbdm_1_1Kalman.html#c5136ef617f6ac0e426bea222755d92b" title="cache of rvu.count()">dimu</a> = B0.cols(); |
---|
253 | <a name="l00310"></a>00310 |
---|
254 | <a name="l00311"></a>00311 it_assert_debug ( A0.cols() ==<a class="code" href="classbdm_1_1Kalman.html#ba7699cdb3b1382a54d3e28b9b7517fa" title="cache of rv.count()">dimx</a>, <span class="stringliteral">"Kalman: A is not square"</span> ); |
---|
255 | <a name="l00312"></a>00312 it_assert_debug ( B0.rows() ==<a class="code" href="classbdm_1_1Kalman.html#ba7699cdb3b1382a54d3e28b9b7517fa" title="cache of rv.count()">dimx</a>, <span class="stringliteral">"Kalman: B is not compatible"</span> ); |
---|
256 | <a name="l00313"></a>00313 it_assert_debug ( C0.cols() ==<a class="code" href="classbdm_1_1Kalman.html#ba7699cdb3b1382a54d3e28b9b7517fa" title="cache of rv.count()">dimx</a>, <span class="stringliteral">"Kalman: C is not square"</span> ); |
---|
257 | <a name="l00314"></a>00314 it_assert_debug ( ( D0.rows() ==<a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a> ) || ( D0.cols() ==<a class="code" href="classbdm_1_1Kalman.html#c5136ef617f6ac0e426bea222755d92b" title="cache of rvu.count()">dimu</a> ), <span class="stringliteral">"Kalman: D is not compatible"</span> ); |
---|
258 | <a name="l00315"></a>00315 it_assert_debug ( ( R0.cols() ==<a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a> ) || ( R0.rows() ==<a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a> ), <span class="stringliteral">"Kalman: R is not compatible"</span> ); |
---|
259 | <a name="l00316"></a>00316 it_assert_debug ( ( Q0.cols() ==<a class="code" href="classbdm_1_1Kalman.html#ba7699cdb3b1382a54d3e28b9b7517fa" title="cache of rv.count()">dimx</a> ) || ( Q0.rows() ==<a class="code" href="classbdm_1_1Kalman.html#ba7699cdb3b1382a54d3e28b9b7517fa" title="cache of rv.count()">dimx</a> ), <span class="stringliteral">"Kalman: Q is not compatible"</span> ); |
---|
260 | <a name="l00317"></a>00317 |
---|
261 | <a name="l00318"></a>00318 <a class="code" href="classbdm_1_1Kalman.html#0a2072e2090c10fac74ad30a023a4ace" title="Matrix A.">A</a> = A0; |
---|
262 | <a name="l00319"></a>00319 <a class="code" href="classbdm_1_1Kalman.html#5977b2c81857948a35105f0e7840203c" title="Matrix B.">B</a> = B0; |
---|
263 | <a name="l00320"></a>00320 <a class="code" href="classbdm_1_1Kalman.html#818eba63a23972786a4579ad30294177" title="Matrix C.">C</a> = C0; |
---|
264 | <a name="l00321"></a>00321 <a class="code" href="classbdm_1_1Kalman.html#7b56ac423d0654b5755e4f852a870456" title="Matrix D.">D</a> = D0; |
---|
265 | <a name="l00322"></a>00322 <a class="code" href="classbdm_1_1Kalman.html#475b088287cdfbba4dc60a3d027728b7" title="Matrix R in square-root form.">R</a> = R0; |
---|
266 | <a name="l00323"></a>00323 <a class="code" href="classbdm_1_1Kalman.html#70f8bf19e81b532c60fd3a7a152425ee" title="Matrix Q in square-root form.">Q</a> = Q0; |
---|
267 | <a name="l00324"></a>00324 } |
---|
268 | <a name="l00325"></a>00325 |
---|
269 | <a name="l00326"></a>00326 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
---|
270 | <a name="l00327"></a><a class="code" href="classbdm_1_1Kalman.html#4a39330c14eff8d13179e868a1d1aa8c">00327</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1Kalman.html#4a39330c14eff8d13179e868a1d1aa8c" title="Here dt = [yt;ut] of appropriate dimensions.">Kalman<sq_T>::bayes</a> ( <span class="keyword">const</span> vec &dt ) { |
---|
271 | <a name="l00328"></a>00328 it_assert_debug ( dt.length() == ( <a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a>+<a class="code" href="classbdm_1_1Kalman.html#c5136ef617f6ac0e426bea222755d92b" title="cache of rvu.count()">dimu</a> ),<span class="stringliteral">"KalmanFull::bayes wrong size of dt"</span> ); |
---|
272 | <a name="l00329"></a>00329 |
---|
273 | <a name="l00330"></a>00330 sq_T iRy ( <a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a> ); |
---|
274 | <a name="l00331"></a>00331 vec u = dt.get ( <a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a>,<a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a>+<a class="code" href="classbdm_1_1Kalman.html#c5136ef617f6ac0e426bea222755d92b" title="cache of rvu.count()">dimu</a>-1 ); |
---|
275 | <a name="l00332"></a>00332 vec y = dt.get ( 0,<a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a>-1 ); |
---|
276 | <a name="l00333"></a>00333 <span class="comment">//Time update</span> |
---|
277 | <a name="l00334"></a>00334 <a class="code" href="classbdm_1_1Kalman.html#fa172078091e45561343fa513dd573b0" title="cache of est.mu">_mu</a> = <a class="code" href="classbdm_1_1Kalman.html#0a2072e2090c10fac74ad30a023a4ace" title="Matrix A.">A</a>* <a class="code" href="classbdm_1_1Kalman.html#fa172078091e45561343fa513dd573b0" title="cache of est.mu">_mu</a> + <a class="code" href="classbdm_1_1Kalman.html#5977b2c81857948a35105f0e7840203c" title="Matrix B.">B</a>*u; |
---|
278 | <a name="l00335"></a>00335 <span class="comment">//P = A*P*A.transpose() + Q; in sq_T</span> |
---|
279 | <a name="l00336"></a>00336 <a class="code" href="classbdm_1_1Kalman.html#00c27b0bf324f0018497921ca23c71ed" title="cache of est.R">_P</a>.mult_sym ( <a class="code" href="classbdm_1_1Kalman.html#0a2072e2090c10fac74ad30a023a4ace" title="Matrix A.">A</a> ); |
---|
280 | <a name="l00337"></a>00337 <a class="code" href="classbdm_1_1Kalman.html#00c27b0bf324f0018497921ca23c71ed" title="cache of est.R">_P</a> +=<a class="code" href="classbdm_1_1Kalman.html#70f8bf19e81b532c60fd3a7a152425ee" title="Matrix Q in square-root form.">Q</a>; |
---|
281 | <a name="l00338"></a>00338 |
---|
282 | <a name="l00339"></a>00339 <span class="comment">//Data update</span> |
---|
283 | <a name="l00340"></a>00340 <span class="comment">//_Ry = C*P*C.transpose() + R; in sq_T</span> |
---|
284 | <a name="l00341"></a>00341 <a class="code" href="classbdm_1_1Kalman.html#00c27b0bf324f0018497921ca23c71ed" title="cache of est.R">_P</a>.mult_sym ( <a class="code" href="classbdm_1_1Kalman.html#818eba63a23972786a4579ad30294177" title="Matrix C.">C</a>, <a class="code" href="classbdm_1_1Kalman.html#2dd268f2d7fbe6382cb8825a1114192a" title="cache of fy.R">_Ry</a> ); |
---|
285 | <a name="l00342"></a>00342 <a class="code" href="classbdm_1_1Kalman.html#2dd268f2d7fbe6382cb8825a1114192a" title="cache of fy.R">_Ry</a> +=<a class="code" href="classbdm_1_1Kalman.html#475b088287cdfbba4dc60a3d027728b7" title="Matrix R in square-root form.">R</a>; |
---|
286 | <a name="l00343"></a>00343 |
---|
287 | <a name="l00344"></a>00344 mat Pfull = <a class="code" href="classbdm_1_1Kalman.html#00c27b0bf324f0018497921ca23c71ed" title="cache of est.R">_P</a>.to_mat(); |
---|
288 | <a name="l00345"></a>00345 |
---|
289 | <a name="l00346"></a>00346 <a class="code" href="classbdm_1_1Kalman.html#2dd268f2d7fbe6382cb8825a1114192a" title="cache of fy.R">_Ry</a>.inv ( iRy ); <span class="comment">// result is in _iRy;</span> |
---|
290 | <a name="l00347"></a>00347 <a class="code" href="classbdm_1_1Kalman.html#bd69dfb802465f22dd84d73a180d5c92" title="placeholder for Kalman gain">_K</a> = Pfull*<a class="code" href="classbdm_1_1Kalman.html#818eba63a23972786a4579ad30294177" title="Matrix C.">C</a>.transpose() * ( iRy.to_mat() ); |
---|
291 | <a name="l00348"></a>00348 |
---|
292 | <a name="l00349"></a>00349 sq_T pom ( ( <span class="keywordtype">int</span> ) Pfull.rows() ); |
---|
293 | <a name="l00350"></a>00350 iRy.mult_sym_t ( <a class="code" href="classbdm_1_1Kalman.html#818eba63a23972786a4579ad30294177" title="Matrix C.">C</a>*Pfull,pom ); |
---|
294 | <a name="l00351"></a>00351 ( <a class="code" href="classbdm_1_1Kalman.html#00c27b0bf324f0018497921ca23c71ed" title="cache of est.R">_P</a> ) -= pom; <span class="comment">// P = P -PC'iRy*CP;</span> |
---|
295 | <a name="l00352"></a>00352 ( <a class="code" href="classbdm_1_1Kalman.html#c249d45258c8578b13858ad3e7b729b1" title="cache of fy.mu">_yp</a> ) = <a class="code" href="classbdm_1_1Kalman.html#818eba63a23972786a4579ad30294177" title="Matrix C.">C</a>* <a class="code" href="classbdm_1_1Kalman.html#fa172078091e45561343fa513dd573b0" title="cache of est.mu">_mu</a> +<a class="code" href="classbdm_1_1Kalman.html#7b56ac423d0654b5755e4f852a870456" title="Matrix D.">D</a>*u; <span class="comment">//y prediction</span> |
---|
296 | <a name="l00353"></a>00353 ( <a class="code" href="classbdm_1_1Kalman.html#fa172078091e45561343fa513dd573b0" title="cache of est.mu">_mu</a> ) += <a class="code" href="classbdm_1_1Kalman.html#bd69dfb802465f22dd84d73a180d5c92" title="placeholder for Kalman gain">_K</a>* ( y- <a class="code" href="classbdm_1_1Kalman.html#c249d45258c8578b13858ad3e7b729b1" title="cache of fy.mu">_yp</a> ); |
---|
297 | <a name="l00354"></a>00354 |
---|
298 | <a name="l00355"></a>00355 |
---|
299 | <a name="l00356"></a>00356 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee" 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> |
---|
300 | <a name="l00357"></a>00357 <a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a>=<a class="code" href="classbdm_1_1Kalman.html#ba555c394c429f6831c9bbabfa2c944c" title="preditive density on $y_t$">fy</a>.evallog ( y ); |
---|
301 | <a name="l00358"></a>00358 } |
---|
302 | <a name="l00359"></a>00359 |
---|
303 | <a name="l00360"></a>00360 <span class="comment">//cout << "y: " << y-(*_yp) <<" R: " << _Ry->to_mat() << " iR: " << _iRy->to_mat() << " ll: " << ll <<endl;</span> |
---|
304 | <a name="l00361"></a>00361 |
---|
305 | <a name="l00362"></a>00362 }; |
---|
306 | <a name="l00363"></a>00363 |
---|
307 | <a name="l00364"></a>00364 |
---|
308 | <a name="l00365"></a>00365 |
---|
309 | <a name="l00366"></a>00366 <span class="comment">//TODO why not const pointer??</span> |
---|
310 | <a name="l00367"></a>00367 |
---|
311 | <a name="l00368"></a>00368 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
---|
312 | <a name="l00369"></a><a class="code" href="classbdm_1_1EKF.html#d087a8bb408d26ac4f5c542746b81059">00369</a> <a class="code" href="classbdm_1_1EKF.html#d087a8bb408d26ac4f5c542746b81059" title="Default constructor.">EKF<sq_T>::EKF</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rvx0, <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rvy0, <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rvu0 ) : <a class="code" href="classbdm_1_1Kalman.html" title="Kalman filter with covariance matrices in square root form.">Kalman</a><sq_T> ( rvx0,rvy0,rvu0 ) {} |
---|
313 | <a name="l00370"></a>00370 |
---|
314 | <a name="l00371"></a>00371 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
---|
315 | <a name="l00372"></a><a class="code" href="classbdm_1_1EKF.html#00fec1a0a6a467eb83fb36c65eba7bcb">00372</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1EKF.html#00fec1a0a6a467eb83fb36c65eba7bcb" title="Set nonlinear functions for mean values and covariance matrices.">EKF<sq_T>::set_parameters</a> ( <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* pfxu0, <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>* phxu0,<span class="keyword">const</span> sq_T Q0,<span class="keyword">const</span> sq_T R0 ) { |
---|
316 | <a name="l00373"></a>00373 pfxu = pfxu0; |
---|
317 | <a name="l00374"></a>00374 phxu = phxu0; |
---|
318 | <a name="l00375"></a>00375 |
---|
319 | <a name="l00376"></a>00376 <span class="comment">//initialize matrices A C, later, these will be only updated!</span> |
---|
320 | <a name="l00377"></a>00377 pfxu-><a class="code" href="classbdm_1_1diffbifn.html#651184f808a35f236dbfea21aca1b6ac" title="Evaluates and writes result into A .">dfdx_cond</a> ( <a class="code" href="classbdm_1_1Kalman.html#fa172078091e45561343fa513dd573b0" title="cache of est.mu">_mu</a>,zeros ( <a class="code" href="classbdm_1_1Kalman.html#c5136ef617f6ac0e426bea222755d92b" title="cache of rvu.count()">dimu</a> ),<a class="code" href="classbdm_1_1Kalman.html#0a2072e2090c10fac74ad30a023a4ace" title="Matrix A.">A</a>,<span class="keyword">true</span> ); |
---|
321 | <a name="l00378"></a>00378 <span class="comment">// pfxu->dfdu_cond ( *_mu,zeros ( dimu ),B,true );</span> |
---|
322 | <a name="l00379"></a>00379 <a class="code" href="classbdm_1_1Kalman.html#5977b2c81857948a35105f0e7840203c" title="Matrix B.">B</a>.clear(); |
---|
323 | <a name="l00380"></a>00380 phxu-><a class="code" href="classbdm_1_1diffbifn.html#651184f808a35f236dbfea21aca1b6ac" title="Evaluates and writes result into A .">dfdx_cond</a> ( <a class="code" href="classbdm_1_1Kalman.html#fa172078091e45561343fa513dd573b0" title="cache of est.mu">_mu</a>,zeros ( <a class="code" href="classbdm_1_1Kalman.html#c5136ef617f6ac0e426bea222755d92b" title="cache of rvu.count()">dimu</a> ),<a class="code" href="classbdm_1_1Kalman.html#818eba63a23972786a4579ad30294177" title="Matrix C.">C</a>,<span class="keyword">true</span> ); |
---|
324 | <a name="l00381"></a>00381 <span class="comment">// phxu->dfdu_cond ( *_mu,zeros ( dimu ),D,true );</span> |
---|
325 | <a name="l00382"></a>00382 <a class="code" href="classbdm_1_1Kalman.html#7b56ac423d0654b5755e4f852a870456" title="Matrix D.">D</a>.clear(); |
---|
326 | <a name="l00383"></a>00383 |
---|
327 | <a name="l00384"></a>00384 <a class="code" href="classbdm_1_1Kalman.html#475b088287cdfbba4dc60a3d027728b7" title="Matrix R in square-root form.">R</a> = R0; |
---|
328 | <a name="l00385"></a>00385 <a class="code" href="classbdm_1_1Kalman.html#70f8bf19e81b532c60fd3a7a152425ee" title="Matrix Q in square-root form.">Q</a> = Q0; |
---|
329 | <a name="l00386"></a>00386 } |
---|
330 | <a name="l00387"></a>00387 |
---|
331 | <a name="l00388"></a>00388 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
---|
332 | <a name="l00389"></a><a class="code" href="classbdm_1_1EKF.html#3fb182ecc29b10ca1163cecbf3bcccfa">00389</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1EKF.html#3fb182ecc29b10ca1163cecbf3bcccfa" title="Here dt = [yt;ut] of appropriate dimensions.">EKF<sq_T>::bayes</a> ( <span class="keyword">const</span> vec &dt ) { |
---|
333 | <a name="l00390"></a>00390 it_assert_debug ( dt.length() == ( <a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a>+<a class="code" href="classbdm_1_1Kalman.html#c5136ef617f6ac0e426bea222755d92b" title="cache of rvu.count()">dimu</a> ),<span class="stringliteral">"KalmanFull::bayes wrong size of dt"</span> ); |
---|
334 | <a name="l00391"></a>00391 |
---|
335 | <a name="l00392"></a>00392 sq_T iRy ( <a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a>,<a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a> ); |
---|
336 | <a name="l00393"></a>00393 vec u = dt.get ( <a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a>,<a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a>+<a class="code" href="classbdm_1_1Kalman.html#c5136ef617f6ac0e426bea222755d92b" title="cache of rvu.count()">dimu</a>-1 ); |
---|
337 | <a name="l00394"></a>00394 vec y = dt.get ( 0,<a class="code" href="classbdm_1_1Kalman.html#d2c36ba01760bf207b985bf321b7817f" title="cache of rvy.count()">dimy</a>-1 ); |
---|
338 | <a name="l00395"></a>00395 <span class="comment">//Time update</span> |
---|
339 | <a name="l00396"></a>00396 <a class="code" href="classbdm_1_1Kalman.html#fa172078091e45561343fa513dd573b0" title="cache of est.mu">_mu</a> = pfxu-><a class="code" href="classbdm_1_1diffbifn.html#188f31066bd72e1bf0ddacd1eb0e6af3" title="Evaluates (VS: Do we really need common eval? ).">eval</a> ( <a class="code" href="classbdm_1_1Kalman.html#fa172078091e45561343fa513dd573b0" title="cache of est.mu">_mu</a>, u ); |
---|
340 | <a name="l00397"></a>00397 pfxu-><a class="code" href="classbdm_1_1diffbifn.html#651184f808a35f236dbfea21aca1b6ac" title="Evaluates and writes result into A .">dfdx_cond</a> ( <a class="code" href="classbdm_1_1Kalman.html#fa172078091e45561343fa513dd573b0" title="cache of est.mu">_mu</a>,u,<a class="code" href="classbdm_1_1Kalman.html#0a2072e2090c10fac74ad30a023a4ace" title="Matrix A.">A</a>,<span class="keyword">false</span> ); <span class="comment">//update A by a derivative of fx</span> |
---|
341 | <a name="l00398"></a>00398 |
---|
342 | <a name="l00399"></a>00399 <span class="comment">//P = A*P*A.transpose() + Q; in sq_T</span> |
---|
343 | <a name="l00400"></a>00400 <a class="code" href="classbdm_1_1Kalman.html#00c27b0bf324f0018497921ca23c71ed" 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="classbdm_1_1Kalman.html#0a2072e2090c10fac74ad30a023a4ace" title="Matrix A.">A</a> ); |
---|
344 | <a name="l00401"></a>00401 <a class="code" href="classbdm_1_1Kalman.html#00c27b0bf324f0018497921ca23c71ed" title="cache of est.R">_P</a> +=<a class="code" href="classbdm_1_1Kalman.html#70f8bf19e81b532c60fd3a7a152425ee" title="Matrix Q in square-root form.">Q</a>; |
---|
345 | <a name="l00402"></a>00402 |
---|
346 | <a name="l00403"></a>00403 <span class="comment">//Data update</span> |
---|
347 | <a name="l00404"></a>00404 phxu-><a class="code" href="classbdm_1_1diffbifn.html#651184f808a35f236dbfea21aca1b6ac" title="Evaluates and writes result into A .">dfdx_cond</a> ( <a class="code" href="classbdm_1_1Kalman.html#fa172078091e45561343fa513dd573b0" title="cache of est.mu">_mu</a>,u,<a class="code" href="classbdm_1_1Kalman.html#818eba63a23972786a4579ad30294177" title="Matrix C.">C</a>,<span class="keyword">false</span> ); <span class="comment">//update C by a derivative hx</span> |
---|
348 | <a name="l00405"></a>00405 <span class="comment">//_Ry = C*P*C.transpose() + R; in sq_T</span> |
---|
349 | <a name="l00406"></a>00406 <a class="code" href="classbdm_1_1Kalman.html#00c27b0bf324f0018497921ca23c71ed" 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="classbdm_1_1Kalman.html#818eba63a23972786a4579ad30294177" title="Matrix C.">C</a>, <a class="code" href="classbdm_1_1Kalman.html#2dd268f2d7fbe6382cb8825a1114192a" title="cache of fy.R">_Ry</a> ); |
---|
350 | <a name="l00407"></a>00407 ( <a class="code" href="classbdm_1_1Kalman.html#2dd268f2d7fbe6382cb8825a1114192a" title="cache of fy.R">_Ry</a> ) +=<a class="code" href="classbdm_1_1Kalman.html#475b088287cdfbba4dc60a3d027728b7" title="Matrix R in square-root form.">R</a>; |
---|
351 | <a name="l00408"></a>00408 |
---|
352 | <a name="l00409"></a>00409 mat Pfull = <a class="code" href="classbdm_1_1Kalman.html#00c27b0bf324f0018497921ca23c71ed" title="cache of est.R">_P</a>.<a class="code" href="classfsqmat.html#f54fc955e8e3b43d15afa92124bc24b3" title="Conversion to full matrix.">to_mat</a>(); |
---|
353 | <a name="l00410"></a>00410 |
---|
354 | <a name="l00411"></a>00411 <a class="code" href="classbdm_1_1Kalman.html#2dd268f2d7fbe6382cb8825a1114192a" 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> |
---|
355 | <a name="l00412"></a>00412 <a class="code" href="classbdm_1_1Kalman.html#bd69dfb802465f22dd84d73a180d5c92" title="placeholder for Kalman gain">_K</a> = Pfull*<a class="code" href="classbdm_1_1Kalman.html#818eba63a23972786a4579ad30294177" title="Matrix C.">C</a>.transpose() * ( iRy.to_mat() ); |
---|
356 | <a name="l00413"></a>00413 |
---|
357 | <a name="l00414"></a>00414 sq_T pom ( ( <span class="keywordtype">int</span> ) Pfull.rows() ); |
---|
358 | <a name="l00415"></a>00415 iRy.mult_sym_t ( <a class="code" href="classbdm_1_1Kalman.html#818eba63a23972786a4579ad30294177" title="Matrix C.">C</a>*Pfull,pom ); |
---|
359 | <a name="l00416"></a>00416 ( <a class="code" href="classbdm_1_1Kalman.html#00c27b0bf324f0018497921ca23c71ed" title="cache of est.R">_P</a> ) -= pom; <span class="comment">// P = P -PC'iRy*CP;</span> |
---|
360 | <a name="l00417"></a>00417 <a class="code" href="classbdm_1_1Kalman.html#c249d45258c8578b13858ad3e7b729b1" title="cache of fy.mu">_yp</a> = phxu-><a class="code" href="classbdm_1_1diffbifn.html#188f31066bd72e1bf0ddacd1eb0e6af3" title="Evaluates (VS: Do we really need common eval? ).">eval</a> ( <a class="code" href="classbdm_1_1Kalman.html#fa172078091e45561343fa513dd573b0" title="cache of est.mu">_mu</a>,u ); <span class="comment">//y prediction</span> |
---|
361 | <a name="l00418"></a>00418 ( <a class="code" href="classbdm_1_1Kalman.html#fa172078091e45561343fa513dd573b0" title="cache of est.mu">_mu</a> ) += <a class="code" href="classbdm_1_1Kalman.html#bd69dfb802465f22dd84d73a180d5c92" title="placeholder for Kalman gain">_K</a>* ( y-<a class="code" href="classbdm_1_1Kalman.html#c249d45258c8578b13858ad3e7b729b1" title="cache of fy.mu">_yp</a> ); |
---|
362 | <a name="l00419"></a>00419 |
---|
363 | <a name="l00420"></a>00420 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>==<span class="keyword">true</span> ) {<a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a>+=<a class="code" href="classbdm_1_1Kalman.html#ba555c394c429f6831c9bbabfa2c944c" title="preditive density on $y_t$">fy</a>.<a class="code" href="classbdm_1_1eEF.html#a36d06ecdd6f4c79dc122510eaccc692" title="Evaluate normalized log-probability.">evallog</a> ( y );} |
---|
364 | <a name="l00421"></a>00421 }; |
---|
365 | <a name="l00422"></a>00422 |
---|
366 | <a name="l00423"></a>00423 |
---|
367 | <a name="l00424"></a>00424 } |
---|
368 | <a name="l00425"></a>00425 <span class="preprocessor">#endif // KF_H</span> |
---|
369 | <a name="l00426"></a>00426 <span class="preprocessor"></span> |
---|
370 | <a name="l00427"></a>00427 |
---|
371 | </pre></div></div> |
---|
372 | <hr size="1"><address style="text-align: right;"><small>Generated on Tue Mar 17 18:33:03 2009 for mixpp by |
---|
373 | <a href="http://www.doxygen.org/index.html"> |
---|
374 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address> |
---|
375 | </body> |
---|
376 | </html> |
---|