1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
3 | <head> |
---|
4 | <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
---|
5 | <title>mixpp: kalman.h Source File</title> |
---|
6 | <link href="tabs.css" rel="stylesheet" type="text/css"/> |
---|
7 | <link href="doxygen.css" rel="stylesheet" type="text/css"/> |
---|
8 | </head> |
---|
9 | <body> |
---|
10 | <!-- Generated by Doxygen 1.6.1 --> |
---|
11 | <script type="text/javascript"> |
---|
12 | <!-- |
---|
13 | function changeDisplayState (e){ |
---|
14 | var num=this.id.replace(/[^[0-9]/g,''); |
---|
15 | var button=this.firstChild; |
---|
16 | var sectionDiv=document.getElementById('dynsection'+num); |
---|
17 | if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){ |
---|
18 | sectionDiv.style.display='block'; |
---|
19 | button.src='open.gif'; |
---|
20 | }else{ |
---|
21 | sectionDiv.style.display='none'; |
---|
22 | button.src='closed.gif'; |
---|
23 | } |
---|
24 | } |
---|
25 | function initDynSections(){ |
---|
26 | var divs=document.getElementsByTagName('div'); |
---|
27 | var sectionCounter=1; |
---|
28 | for(var i=0;i<divs.length-1;i++){ |
---|
29 | if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){ |
---|
30 | var header=divs[i]; |
---|
31 | var section=divs[i+1]; |
---|
32 | var button=header.firstChild; |
---|
33 | if (button!='IMG'){ |
---|
34 | divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild); |
---|
35 | button=document.createElement('img'); |
---|
36 | divs[i].insertBefore(button,divs[i].firstChild); |
---|
37 | } |
---|
38 | header.style.cursor='pointer'; |
---|
39 | header.onclick=changeDisplayState; |
---|
40 | header.id='dynheader'+sectionCounter; |
---|
41 | button.src='closed.gif'; |
---|
42 | section.id='dynsection'+sectionCounter; |
---|
43 | section.style.display='none'; |
---|
44 | section.style.marginLeft='14px'; |
---|
45 | sectionCounter++; |
---|
46 | } |
---|
47 | } |
---|
48 | } |
---|
49 | window.onload = initDynSections; |
---|
50 | --> |
---|
51 | </script> |
---|
52 | <div class="navigation" id="top"> |
---|
53 | <div class="tabs"> |
---|
54 | <ul> |
---|
55 | <li><a href="main.html"><span>Main Page</span></a></li> |
---|
56 | <li><a href="pages.html"><span>Related Pages</span></a></li> |
---|
57 | <li><a href="annotated.html"><span>Classes</span></a></li> |
---|
58 | <li class="current"><a href="files.html"><span>Files</span></a></li> |
---|
59 | </ul> |
---|
60 | </div> |
---|
61 | <div class="tabs"> |
---|
62 | <ul> |
---|
63 | <li><a href="files.html"><span>File List</span></a></li> |
---|
64 | <li><a href="globals.html"><span>File Members</span></a></li> |
---|
65 | </ul> |
---|
66 | </div> |
---|
67 | <h1>kalman.h</h1><a href="kalman_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 |
---|
68 | <a name="l00013"></a>00013 <span class="preprocessor">#ifndef KF_H</span> |
---|
69 | <a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define KF_H</span> |
---|
70 | <a name="l00015"></a>00015 <span class="preprocessor"></span> |
---|
71 | <a name="l00016"></a>00016 |
---|
72 | <a name="l00017"></a>00017 <span class="preprocessor">#include "../math/functions.h"</span> |
---|
73 | <a name="l00018"></a>00018 <span class="preprocessor">#include "../stat/exp_family.h"</span> |
---|
74 | <a name="l00019"></a>00019 <span class="preprocessor">#include "../math/chmat.h"</span> |
---|
75 | <a name="l00020"></a>00020 <span class="preprocessor">#include "../base/user_info.h"</span> |
---|
76 | <a name="l00021"></a>00021 |
---|
77 | <a name="l00022"></a>00022 <span class="keyword">namespace </span>bdm |
---|
78 | <a name="l00023"></a>00023 { |
---|
79 | <a name="l00024"></a>00024 |
---|
80 | <a name="l00032"></a>00032 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
---|
81 | <a name="l00033"></a><a class="code" href="classbdm_1_1StateSpace.html">00033</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1StateSpace.html" title="Basic elements of linear state-space model.">StateSpace</a> |
---|
82 | <a name="l00034"></a>00034 { |
---|
83 | <a name="l00035"></a>00035 <span class="keyword">protected</span>: |
---|
84 | <a name="l00037"></a><a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21">00037</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a>; |
---|
85 | <a name="l00039"></a><a class="code" href="classbdm_1_1StateSpace.html#a3b784d85ca911866225a79193ae1441f">00039</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1StateSpace.html#a3b784d85ca911866225a79193ae1441f" title="cache of rvy.count()">dimy</a>; |
---|
86 | <a name="l00041"></a><a class="code" href="classbdm_1_1StateSpace.html#a95bb59ffbfd34c55d03d4d7a2a9b4faf">00041</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1StateSpace.html#a95bb59ffbfd34c55d03d4d7a2a9b4faf" title="cache of rvu.count()">dimu</a>; |
---|
87 | <a name="l00043"></a><a class="code" href="classbdm_1_1StateSpace.html#ade7d828a8d06cbbd5ac45afeaf9f0c7b">00043</a> mat <a class="code" href="classbdm_1_1StateSpace.html#ade7d828a8d06cbbd5ac45afeaf9f0c7b" title="Matrix A.">A</a>; |
---|
88 | <a name="l00045"></a><a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51">00045</a> mat <a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a>; |
---|
89 | <a name="l00047"></a><a class="code" href="classbdm_1_1StateSpace.html#ac7ec82d2200c956cff6dff559bd32ff9">00047</a> mat <a class="code" href="classbdm_1_1StateSpace.html#ac7ec82d2200c956cff6dff559bd32ff9" title="Matrix C.">C</a>; |
---|
90 | <a name="l00049"></a><a class="code" href="classbdm_1_1StateSpace.html#ad5769a41b34eb518716120cf04dbc23f">00049</a> mat <a class="code" href="classbdm_1_1StateSpace.html#ad5769a41b34eb518716120cf04dbc23f" title="Matrix D.">D</a>; |
---|
91 | <a name="l00051"></a><a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f">00051</a> sq_T <a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f" title="Matrix Q in square-root form.">Q</a>; |
---|
92 | <a name="l00053"></a><a class="code" href="classbdm_1_1StateSpace.html#a11dd3493d62ec9329860386adb3e6084">00053</a> sq_T <a class="code" href="classbdm_1_1StateSpace.html#a11dd3493d62ec9329860386adb3e6084" title="Matrix R in square-root form.">R</a>; |
---|
93 | <a name="l00054"></a>00054 <span class="keyword">public</span>: |
---|
94 | <a name="l00055"></a>00055 <a class="code" href="classbdm_1_1StateSpace.html" title="Basic elements of linear state-space model.">StateSpace</a>() : <a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a> (0), <a class="code" href="classbdm_1_1StateSpace.html#a3b784d85ca911866225a79193ae1441f" title="cache of rvy.count()">dimy</a> (0), <a class="code" href="classbdm_1_1StateSpace.html#a95bb59ffbfd34c55d03d4d7a2a9b4faf" title="cache of rvu.count()">dimu</a> (0), <a class="code" href="classbdm_1_1StateSpace.html#ade7d828a8d06cbbd5ac45afeaf9f0c7b" title="Matrix A.">A</a>(), <a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a>(), <a class="code" href="classbdm_1_1StateSpace.html#ac7ec82d2200c956cff6dff559bd32ff9" title="Matrix C.">C</a>(), <a class="code" href="classbdm_1_1StateSpace.html#ad5769a41b34eb518716120cf04dbc23f" title="Matrix D.">D</a>(), <a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f" title="Matrix Q in square-root form.">Q</a>(), <a class="code" href="classbdm_1_1StateSpace.html#a11dd3493d62ec9329860386adb3e6084" title="Matrix R in square-root form.">R</a>() {} |
---|
95 | <a name="l00056"></a>00056 <a class="code" href="classbdm_1_1StateSpace.html" title="Basic elements of linear state-space model.">StateSpace</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1StateSpace.html" title="Basic elements of linear state-space model.">StateSpace<sq_T></a> &S0) : <a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a> (S0.<a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a>), <a class="code" href="classbdm_1_1StateSpace.html#a3b784d85ca911866225a79193ae1441f" title="cache of rvy.count()">dimy</a> (S0.<a class="code" href="classbdm_1_1StateSpace.html#a3b784d85ca911866225a79193ae1441f" title="cache of rvy.count()">dimy</a>), <a class="code" href="classbdm_1_1StateSpace.html#a95bb59ffbfd34c55d03d4d7a2a9b4faf" title="cache of rvu.count()">dimu</a> (S0.<a class="code" href="classbdm_1_1StateSpace.html#a95bb59ffbfd34c55d03d4d7a2a9b4faf" title="cache of rvu.count()">dimu</a>), <a class="code" href="classbdm_1_1StateSpace.html#ade7d828a8d06cbbd5ac45afeaf9f0c7b" title="Matrix A.">A</a>(S0.<a class="code" href="classbdm_1_1StateSpace.html#ade7d828a8d06cbbd5ac45afeaf9f0c7b" title="Matrix A.">A</a>), <a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a>(S0.<a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a>), <a class="code" href="classbdm_1_1StateSpace.html#ac7ec82d2200c956cff6dff559bd32ff9" title="Matrix C.">C</a>(S0.<a class="code" href="classbdm_1_1StateSpace.html#ac7ec82d2200c956cff6dff559bd32ff9" title="Matrix C.">C</a>), <a class="code" href="classbdm_1_1StateSpace.html#ad5769a41b34eb518716120cf04dbc23f" title="Matrix D.">D</a>(S0.<a class="code" href="classbdm_1_1StateSpace.html#ad5769a41b34eb518716120cf04dbc23f" title="Matrix D.">D</a>), <a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f" title="Matrix Q in square-root form.">Q</a>(S0.<a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f" title="Matrix Q in square-root form.">Q</a>), <a class="code" href="classbdm_1_1StateSpace.html#a11dd3493d62ec9329860386adb3e6084" title="Matrix R in square-root form.">R</a>(S0.<a class="code" href="classbdm_1_1StateSpace.html#a11dd3493d62ec9329860386adb3e6084" title="Matrix R in square-root form.">R</a>) {} |
---|
96 | <a name="l00057"></a>00057 <span class="keywordtype">void</span> set_parameters (<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); |
---|
97 | <a name="l00058"></a>00058 <span class="keywordtype">void</span> validate(); |
---|
98 | <a name="l00060"></a><a class="code" href="classbdm_1_1StateSpace.html#a02470085bbf3c41fe8e36544813eecbd">00060</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1StateSpace.html#a02470085bbf3c41fe8e36544813eecbd" title="not virtual in this case">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>) { |
---|
99 | <a name="l00061"></a>00061 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1StateSpace.html#ade7d828a8d06cbbd5ac45afeaf9f0c7b" title="Matrix A.">A</a>, <span class="keyword">set</span>, <span class="stringliteral">"A"</span>, UI::compulsory); |
---|
100 | <a name="l00062"></a>00062 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a>, <span class="keyword">set</span>, <span class="stringliteral">"B"</span>, UI::compulsory); |
---|
101 | <a name="l00063"></a>00063 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1StateSpace.html#ac7ec82d2200c956cff6dff559bd32ff9" title="Matrix C.">C</a>, <span class="keyword">set</span>, <span class="stringliteral">"C"</span>, UI::compulsory); |
---|
102 | <a name="l00064"></a>00064 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1StateSpace.html#ad5769a41b34eb518716120cf04dbc23f" title="Matrix D.">D</a>, <span class="keyword">set</span>, <span class="stringliteral">"D"</span>, UI::compulsory); |
---|
103 | <a name="l00065"></a>00065 mat Qtm, Rtm; |
---|
104 | <a name="l00066"></a>00066 <span class="keywordflow">if</span>(!<a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a>(Qtm, <span class="keyword">set</span>, <span class="stringliteral">"Q"</span>, UI::optional)){ |
---|
105 | <a name="l00067"></a>00067 vec dq; |
---|
106 | <a name="l00068"></a>00068 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a>(dq, <span class="keyword">set</span>, <span class="stringliteral">"dQ"</span>, UI::compulsory); |
---|
107 | <a name="l00069"></a>00069 Qtm=diag(dq); |
---|
108 | <a name="l00070"></a>00070 } |
---|
109 | <a name="l00071"></a>00071 <span class="keywordflow">if</span>(!<a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a>(Rtm, <span class="keyword">set</span>, <span class="stringliteral">"R"</span>, UI::optional)){ |
---|
110 | <a name="l00072"></a>00072 vec dr; |
---|
111 | <a name="l00073"></a>00073 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a>(dr, <span class="keyword">set</span>, <span class="stringliteral">"dQ"</span>, UI::compulsory); |
---|
112 | <a name="l00074"></a>00074 Rtm=diag(dr); |
---|
113 | <a name="l00075"></a>00075 } |
---|
114 | <a name="l00076"></a>00076 <a class="code" href="classbdm_1_1StateSpace.html#a11dd3493d62ec9329860386adb3e6084" title="Matrix R in square-root form.">R</a>=Rtm; <span class="comment">// automatic conversion</span> |
---|
115 | <a name="l00077"></a>00077 <a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f" title="Matrix Q in square-root form.">Q</a>=Qtm; |
---|
116 | <a name="l00078"></a>00078 |
---|
117 | <a name="l00079"></a>00079 validate(); |
---|
118 | <a name="l00080"></a>00080 } |
---|
119 | <a name="l00082"></a><a class="code" href="classbdm_1_1StateSpace.html#ab1972e00d9b9dd22a0f983c7cb0b8b40">00082</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1StateSpace.html#ab1972e00d9b9dd22a0f983c7cb0b8b40" title="access function">_dimx</a>(){<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a>;} |
---|
120 | <a name="l00084"></a><a class="code" href="classbdm_1_1StateSpace.html#af3d83a4b39e05df9fb4246fd6ddc2a60">00084</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1StateSpace.html#af3d83a4b39e05df9fb4246fd6ddc2a60" title="access function">_dimy</a>(){<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1StateSpace.html#a3b784d85ca911866225a79193ae1441f" title="cache of rvy.count()">dimy</a>;} |
---|
121 | <a name="l00086"></a><a class="code" href="classbdm_1_1StateSpace.html#aa238842025a0eaade26d5d79a0e9000e">00086</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1StateSpace.html#aa238842025a0eaade26d5d79a0e9000e" title="access function">_dimu</a>(){<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1StateSpace.html#a95bb59ffbfd34c55d03d4d7a2a9b4faf" title="cache of rvu.count()">dimu</a>;} |
---|
122 | <a name="l00088"></a><a class="code" href="classbdm_1_1StateSpace.html#aae0dd610bf28f52c4c7acec87e39ed5e">00088</a> <span class="keyword">const</span> mat& <a class="code" href="classbdm_1_1StateSpace.html#aae0dd610bf28f52c4c7acec87e39ed5e" title="access function">_A</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1StateSpace.html#ade7d828a8d06cbbd5ac45afeaf9f0c7b" title="Matrix A.">A</a>;} |
---|
123 | <a name="l00090"></a><a class="code" href="classbdm_1_1StateSpace.html#a19cabf296793357c130778fe74df54a4">00090</a> <span class="keyword">const</span> mat& <a class="code" href="classbdm_1_1StateSpace.html#a19cabf296793357c130778fe74df54a4" title="access function">_B</a>()<span class="keyword">const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a>;} |
---|
124 | <a name="l00092"></a><a class="code" href="classbdm_1_1StateSpace.html#a5731f429df4a70dc0d0d1e6ea8e35125">00092</a> <span class="keyword">const</span> mat& <a class="code" href="classbdm_1_1StateSpace.html#a5731f429df4a70dc0d0d1e6ea8e35125" title="access function">_C</a>()<span class="keyword">const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1StateSpace.html#ac7ec82d2200c956cff6dff559bd32ff9" title="Matrix C.">C</a>;} |
---|
125 | <a name="l00094"></a><a class="code" href="classbdm_1_1StateSpace.html#a286286acb308f9ee596cab9af503b252">00094</a> <span class="keyword">const</span> mat& <a class="code" href="classbdm_1_1StateSpace.html#a286286acb308f9ee596cab9af503b252" title="access function">_D</a>()<span class="keyword">const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1StateSpace.html#ad5769a41b34eb518716120cf04dbc23f" title="Matrix D.">D</a>;} |
---|
126 | <a name="l00096"></a><a class="code" href="classbdm_1_1StateSpace.html#a38a71e31f22f5459d10c3cbee1e4d977">00096</a> <span class="keyword">const</span> sq_T& <a class="code" href="classbdm_1_1StateSpace.html#a38a71e31f22f5459d10c3cbee1e4d977" title="access function">_Q</a>()<span class="keyword">const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f" title="Matrix Q in square-root form.">Q</a>;} |
---|
127 | <a name="l00098"></a><a class="code" href="classbdm_1_1StateSpace.html#a69ddac45b7a4efbf83b2232d0d5595ba">00098</a> <span class="keyword">const</span> sq_T& <a class="code" href="classbdm_1_1StateSpace.html#a69ddac45b7a4efbf83b2232d0d5595ba" title="access function">_R</a>()<span class="keyword">const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1StateSpace.html#a11dd3493d62ec9329860386adb3e6084" title="Matrix R in square-root form.">R</a>;} |
---|
128 | <a name="l00099"></a>00099 }; |
---|
129 | <a name="l00100"></a>00100 |
---|
130 | <a name="l00102"></a>00102 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
---|
131 | <a name="l00103"></a><a class="code" href="classbdm_1_1Kalman.html">00103</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1Kalman.html" title="Common abstract base for Kalman filters.">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>, <span class="keyword">public</span> <a class="code" href="classbdm_1_1StateSpace.html" title="Basic elements of linear state-space model.">StateSpace</a><sq_T> |
---|
132 | <a name="l00104"></a>00104 { |
---|
133 | <a name="l00105"></a>00105 <span class="keyword">protected</span>: |
---|
134 | <a name="l00107"></a><a class="code" href="classbdm_1_1Kalman.html#aaac28e226fe6cbff5a9ae38d8d025d7a">00107</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#aaac28e226fe6cbff5a9ae38d8d025d7a" title="id of output">yrv</a>; |
---|
135 | <a name="l00109"></a><a class="code" href="classbdm_1_1Kalman.html#a44d4a8ab05d5311286e1da78b831633e">00109</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#a44d4a8ab05d5311286e1da78b831633e" title="id of input">urv</a>; |
---|
136 | <a name="l00111"></a><a class="code" href="classbdm_1_1Kalman.html#abd69dfb802465f22dd84d73a180d5c92">00111</a> mat <a class="code" href="classbdm_1_1Kalman.html#abd69dfb802465f22dd84d73a180d5c92" title="Kalman gain.">_K</a>; |
---|
137 | <a name="l00113"></a><a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43">00113</a> <a class="code" href="classbdm_1_1shared__ptr.html" title="A naive implementation of roughly a subset of the std::tr1::shared_ptr spec.">shared_ptr<enorm<sq_T></a> > <a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>; |
---|
138 | <a name="l00115"></a><a class="code" href="classbdm_1_1Kalman.html#aba555c394c429f6831c9bbabfa2c944c">00115</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#aba555c394c429f6831c9bbabfa2c944c" title="marginal on data f(y|y)">fy</a>; |
---|
139 | <a name="l00116"></a>00116 <span class="keyword">public</span>: |
---|
140 | <a name="l00117"></a>00117 <a class="code" href="classbdm_1_1Kalman.html" title="Common abstract base for Kalman filters.">Kalman<sq_T></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_1StateSpace.html" title="Basic elements of linear state-space model.">StateSpace<sq_T></a>(), <a class="code" href="classbdm_1_1Kalman.html#aaac28e226fe6cbff5a9ae38d8d025d7a" title="id of output">yrv</a>(),<a class="code" href="classbdm_1_1Kalman.html#a44d4a8ab05d5311286e1da78b831633e" title="id of input">urv</a>(), <a class="code" href="classbdm_1_1Kalman.html#abd69dfb802465f22dd84d73a180d5c92" title="Kalman gain.">_K</a>(), <a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>(<span class="keyword">new</span> <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T></a>){} |
---|
141 | <a name="l00118"></a>00118 <a class="code" href="classbdm_1_1Kalman.html" title="Common abstract base for Kalman filters.">Kalman<sq_T></a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1Kalman.html" title="Common abstract base for Kalman filters.">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>(K0), <a class="code" href="classbdm_1_1StateSpace.html" title="Basic elements of linear state-space model.">StateSpace<sq_T></a>(K0), <a class="code" href="classbdm_1_1Kalman.html#aaac28e226fe6cbff5a9ae38d8d025d7a" title="id of output">yrv</a>(K0.yrv),<a class="code" href="classbdm_1_1Kalman.html#a44d4a8ab05d5311286e1da78b831633e" title="id of input">urv</a>(K0.urv), <a class="code" href="classbdm_1_1Kalman.html#abd69dfb802465f22dd84d73a180d5c92" title="Kalman gain.">_K</a>(K0._K), <a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>(<span class="keyword">new</span> <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T></a>(*K0.est)), <a class="code" href="classbdm_1_1Kalman.html#aba555c394c429f6831c9bbabfa2c944c" title="marginal on data f(y|y)">fy</a>(K0.fy){} |
---|
142 | <a name="l00119"></a>00119 <span class="keywordtype">void</span> set_statistics (<span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> mat &P0) {<a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>->set_parameters (mu0, P0); }; |
---|
143 | <a name="l00120"></a>00120 <span class="keywordtype">void</span> set_statistics (<span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> sq_T &P0) {<a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>->set_parameters (mu0, P0); }; |
---|
144 | <a name="l00122"></a><a class="code" href="classbdm_1_1Kalman.html#a8b0c3db41eb292edb20b826832c9b5fa">00122</a> <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>& <a class="code" href="classbdm_1_1Kalman.html#a8b0c3db41eb292edb20b826832c9b5fa" title="posterior">posterior</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> *<a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>.<a class="code" href="classbdm_1_1shared__ptr.html#a37ebcfb6750dd7b5630f1d2354c07a96">get</a>();} |
---|
145 | <a name="l00124"></a><a class="code" href="classbdm_1_1Kalman.html#a4da2fdd01e9b335b133def9814eb0620">00124</a> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<epdf></a> <a class="code" href="classbdm_1_1Kalman.html#a4da2fdd01e9b335b133def9814eb0620" title="shared posterior">shared_posterior</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>;} |
---|
146 | <a name="l00126"></a><a class="code" href="classbdm_1_1Kalman.html#a7fe88fc3471cab1911707bcdb6b4690a">00126</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1Kalman.html#a7fe88fc3471cab1911707bcdb6b4690a" title="load basic elements of Kalman from structure">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>) { |
---|
147 | <a name="l00127"></a>00127 <a class="code" href="classbdm_1_1Kalman.html#a7fe88fc3471cab1911707bcdb6b4690a" title="load basic elements of Kalman from structure">StateSpace<sq_T>::from_setting</a>(<span class="keyword">set</span>); |
---|
148 | <a name="l00128"></a>00128 |
---|
149 | <a name="l00129"></a>00129 mat P0; vec mu0; |
---|
150 | <a name="l00130"></a>00130 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a>(mu0, <span class="keyword">set</span>, <span class="stringliteral">"mu0"</span>, UI::optional); |
---|
151 | <a name="l00131"></a>00131 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a>(P0, <span class="keyword">set</span>, <span class="stringliteral">"P0"</span>, UI::optional); |
---|
152 | <a name="l00132"></a>00132 set_statistics(mu0,P0); |
---|
153 | <a name="l00133"></a>00133 <span class="comment">// Initial values</span> |
---|
154 | <a name="l00134"></a>00134 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1Kalman.html#aaac28e226fe6cbff5a9ae38d8d025d7a" title="id of output">yrv</a>, <span class="keyword">set</span>, <span class="stringliteral">"yrv"</span>, UI::optional); |
---|
155 | <a name="l00135"></a>00135 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1Kalman.html#a44d4a8ab05d5311286e1da78b831633e" title="id of input">urv</a>, <span class="keyword">set</span>, <span class="stringliteral">"urv"</span>, UI::optional); |
---|
156 | <a name="l00136"></a>00136 set_drv(concat(<a class="code" href="classbdm_1_1Kalman.html#aaac28e226fe6cbff5a9ae38d8d025d7a" title="id of output">yrv</a>,<a class="code" href="classbdm_1_1Kalman.html#a44d4a8ab05d5311286e1da78b831633e" title="id of input">urv</a>)); |
---|
157 | <a name="l00137"></a>00137 |
---|
158 | <a name="l00138"></a>00138 validate(); |
---|
159 | <a name="l00139"></a>00139 } |
---|
160 | <a name="l00140"></a>00140 <span class="keywordtype">void</span> validate() { |
---|
161 | <a name="l00141"></a>00141 <a class="code" href="classbdm_1_1StateSpace.html" title="Basic elements of linear state-space model.">StateSpace<sq_T>::validate</a>(); |
---|
162 | <a name="l00142"></a>00142 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a>(<a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>->dimension(), <span class="stringliteral">"Statistics and model parameters mismatch"</span>); |
---|
163 | <a name="l00143"></a>00143 } |
---|
164 | <a name="l00144"></a>00144 }; |
---|
165 | <a name="l00149"></a><a class="code" href="classbdm_1_1KalmanFull.html">00149</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1KalmanFull.html" title="Basic Kalman filter with full matrices.">KalmanFull</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1Kalman.html" title="Common abstract base for Kalman filters.">Kalman</a><fsqmat> |
---|
166 | <a name="l00150"></a>00150 { |
---|
167 | <a name="l00151"></a>00151 <span class="keyword">public</span>: |
---|
168 | <a name="l00153"></a><a class="code" href="classbdm_1_1KalmanFull.html#abdcc98c8b18c1cbdebdf218ae838fd11">00153</a> <a class="code" href="classbdm_1_1KalmanFull.html#abdcc98c8b18c1cbdebdf218ae838fd11" title="For EKFfull;.">KalmanFull</a>() :<a class="code" href="classbdm_1_1Kalman.html" title="Common abstract base for Kalman filters.">Kalman</a><<a class="code" href="classbdm_1_1fsqmat.html" title="Fake sqmat. This class maps sqmat operations to operations on full matrix.">fsqmat</a>>(){}; |
---|
169 | <a name="l00155"></a>00155 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1KalmanFull.html#a081924bc97f453f674bb982b7951d053" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> (<span class="keyword">const</span> vec &dt); |
---|
170 | <a name="l00156"></a><a class="code" href="classbdm_1_1KalmanFull.html#ab77ade422273f60b8955122b81abf3c1">00156</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_1KalmanFull.html#ab77ade422273f60b8955122b81abf3c1" title="Copy function required in vectors, Arrays of BM etc. Have to be DELETED manually!...">_copy_</a>()<span class="keyword"> const </span>{ |
---|
171 | <a name="l00157"></a>00157 <a class="code" href="classbdm_1_1KalmanFull.html" title="Basic Kalman filter with full matrices.">KalmanFull</a>* K = <span class="keyword">new</span> <a class="code" href="classbdm_1_1KalmanFull.html" title="Basic Kalman filter with full matrices.">KalmanFull</a>; |
---|
172 | <a name="l00158"></a>00158 K->set_parameters (<a class="code" href="classbdm_1_1StateSpace.html#ade7d828a8d06cbbd5ac45afeaf9f0c7b" title="Matrix A.">A</a>, <a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a>, <a class="code" href="classbdm_1_1StateSpace.html#ac7ec82d2200c956cff6dff559bd32ff9" title="Matrix C.">C</a>, <a class="code" href="classbdm_1_1StateSpace.html#ad5769a41b34eb518716120cf04dbc23f" title="Matrix D.">D</a>, <a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f" title="Matrix Q in square-root form.">Q</a>, <a class="code" href="classbdm_1_1StateSpace.html#a11dd3493d62ec9329860386adb3e6084" title="Matrix R in square-root form.">R</a>); |
---|
173 | <a name="l00159"></a>00159 K->set_statistics (<a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>->_mu(), <a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>->_R()); |
---|
174 | <a name="l00160"></a>00160 <span class="keywordflow">return</span> K; |
---|
175 | <a name="l00161"></a>00161 } |
---|
176 | <a name="l00162"></a>00162 }; |
---|
177 | <a name="l00163"></a>00163 <a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a>(KalmanFull); |
---|
178 | <a name="l00164"></a>00164 |
---|
179 | <a name="l00165"></a>00165 |
---|
180 | <a name="l00173"></a><a class="code" href="classbdm_1_1KalmanCh.html">00173</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="Common abstract base for Kalman filters.">Kalman</a><chmat> |
---|
181 | <a name="l00174"></a>00174 { |
---|
182 | <a name="l00175"></a>00175 <span class="keyword">protected</span>: |
---|
183 | <a name="l00178"></a>00178 mat preA; |
---|
184 | <a name="l00180"></a><a class="code" href="classbdm_1_1KalmanCh.html#abcbd68f51d4b57246e7784ca5900171f">00180</a> mat <a class="code" href="classbdm_1_1KalmanCh.html#abcbd68f51d4b57246e7784ca5900171f" title="post array (triangular matrix)">postA</a>; |
---|
185 | <a name="l00182"></a>00182 <span class="keyword">public</span>: |
---|
186 | <a name="l00184"></a><a class="code" href="classbdm_1_1KalmanCh.html#a24ce65bdaa538d4d5153d709a929b996">00184</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#a24ce65bdaa538d4d5153d709a929b996" title="copy constructor">_copy_</a>()<span class="keyword"> const </span>{ |
---|
187 | <a name="l00185"></a>00185 <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>; |
---|
188 | <a name="l00186"></a>00186 K-><a class="code" href="classbdm_1_1KalmanCh.html#a20a4d4c664e8ac8a3f1bb7b0d11c6d87" title="set parameters for adapt from Kalman">set_parameters</a> (<a class="code" href="classbdm_1_1StateSpace.html#ade7d828a8d06cbbd5ac45afeaf9f0c7b" title="Matrix A.">A</a>, <a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a>, <a class="code" href="classbdm_1_1StateSpace.html#ac7ec82d2200c956cff6dff559bd32ff9" title="Matrix C.">C</a>, <a class="code" href="classbdm_1_1StateSpace.html#ad5769a41b34eb518716120cf04dbc23f" title="Matrix D.">D</a>, <a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f" title="Matrix Q in square-root form.">Q</a>, <a class="code" href="classbdm_1_1StateSpace.html#a11dd3493d62ec9329860386adb3e6084" title="Matrix R in square-root form.">R</a>); |
---|
189 | <a name="l00187"></a>00187 K->set_statistics (<a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>->_mu(), <a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>->_R()); |
---|
190 | <a name="l00188"></a>00188 <span class="keywordflow">return</span> K; |
---|
191 | <a name="l00189"></a>00189 } |
---|
192 | <a name="l00191"></a>00191 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1KalmanCh.html#a20a4d4c664e8ac8a3f1bb7b0d11c6d87" title="set parameters for adapt from Kalman">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="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &Q0, <span class="keyword">const</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> &R0); |
---|
193 | <a name="l00193"></a>00193 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1KalmanCh.html#ac983b1a2687312ab733d4c859cf83c1e" title="initialize internal parametetrs">initialize</a>(); |
---|
194 | <a name="l00194"></a>00194 |
---|
195 | <a name="l00208"></a>00208 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1KalmanCh.html#ab41fe5540548100b08e1684c3be767b6" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> (<span class="keyword">const</span> vec &dt); |
---|
196 | <a name="l00209"></a>00209 |
---|
197 | <a name="l00210"></a><a class="code" href="classbdm_1_1KalmanCh.html#a13f68cef5b14c8753012ad3ed695689d">00210</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1KalmanCh.html#a13f68cef5b14c8753012ad3ed695689d" title="load basic elements of Kalman from structure">from_setting</a>(<span class="keyword">const</span> Setting &<span class="keyword">set</span>){ |
---|
198 | <a name="l00211"></a>00211 <a class="code" href="classbdm_1_1KalmanCh.html#a13f68cef5b14c8753012ad3ed695689d" title="load basic elements of Kalman from structure">Kalman<chmat>::from_setting</a>(<span class="keyword">set</span>); |
---|
199 | <a name="l00212"></a>00212 <a class="code" href="classbdm_1_1KalmanCh.html#ac983b1a2687312ab733d4c859cf83c1e" title="initialize internal parametetrs">initialize</a>(); |
---|
200 | <a name="l00213"></a>00213 } |
---|
201 | <a name="l00214"></a>00214 }; |
---|
202 | <a name="l00215"></a>00215 <a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a>(KalmanCh); |
---|
203 | <a name="l00216"></a>00216 |
---|
204 | <a name="l00222"></a><a class="code" href="classbdm_1_1EKFfull.html">00222</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.">KalmanFull</a> |
---|
205 | <a name="l00223"></a>00223 { |
---|
206 | <a name="l00224"></a>00224 <span class="keyword">protected</span>: |
---|
207 | <a name="l00226"></a><a class="code" href="classbdm_1_1EKFfull.html#aee5bfb3f09dfa994596c5bc68306f7d6">00226</a> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<diffbifn></a> <a class="code" href="classbdm_1_1EKFfull.html#aee5bfb3f09dfa994596c5bc68306f7d6" title="Internal Model f(x,u).">pfxu</a>; |
---|
208 | <a name="l00227"></a>00227 |
---|
209 | <a name="l00229"></a><a class="code" href="classbdm_1_1EKFfull.html#a6432c675b1a9b83898b4ff19eab9b45c">00229</a> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<diffbifn></a> <a class="code" href="classbdm_1_1EKFfull.html#a6432c675b1a9b83898b4ff19eab9b45c" title="Observation Model h(x,u).">phxu</a>; |
---|
210 | <a name="l00230"></a>00230 |
---|
211 | <a name="l00231"></a>00231 <span class="keyword">public</span>: |
---|
212 | <a name="l00233"></a>00233 <a class="code" href="classbdm_1_1EKFfull.html#a6939c345389abb8b2481457b4cfe1165" title="Default constructor.">EKFfull</a> (); |
---|
213 | <a name="l00234"></a>00234 |
---|
214 | <a name="l00236"></a>00236 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1EKFfull.html#a8a68f95124a4b01f9ce23225f3c736a4" title="Set nonlinear functions for mean values and covariance matrices.">set_parameters</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<diffbifn></a> &<a class="code" href="classbdm_1_1EKFfull.html#aee5bfb3f09dfa994596c5bc68306f7d6" title="Internal Model f(x,u).">pfxu</a>, <span class="keyword">const</span> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<diffbifn></a> &<a class="code" href="classbdm_1_1EKFfull.html#a6432c675b1a9b83898b4ff19eab9b45c" title="Observation Model h(x,u).">phxu</a>, <span class="keyword">const</span> mat Q0, <span class="keyword">const</span> mat R0); |
---|
215 | <a name="l00237"></a>00237 |
---|
216 | <a name="l00239"></a>00239 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1EKFfull.html#af149ae8e9ce14d9931a7bb2850736699" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> (<span class="keyword">const</span> vec &dt); |
---|
217 | <a name="l00241"></a><a class="code" href="classbdm_1_1EKFfull.html#a44986d667c19bcf7708495a4a5afc841">00241</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1EKFfull.html#a44986d667c19bcf7708495a4a5afc841" title="set estimates">set_statistics</a> (<span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> mat &P0) { |
---|
218 | <a name="l00242"></a>00242 <a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>->set_parameters (mu0, P0); |
---|
219 | <a name="l00243"></a>00243 }; |
---|
220 | <a name="l00244"></a>00244 <span class="keyword">const</span> mat _R() { |
---|
221 | <a name="l00245"></a>00245 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>->_R().to_mat(); |
---|
222 | <a name="l00246"></a>00246 } |
---|
223 | <a name="l00247"></a><a class="code" href="classbdm_1_1EKFfull.html#afa89558667ff0f44f470f1146aa4681c">00247</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1EKFfull.html#afa89558667ff0f44f470f1146aa4681c" title="load basic elements of Kalman from structure">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>) { |
---|
224 | <a name="l00248"></a>00248 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<diffbifn></a> IM = UI::build<diffbifn> ( <span class="keyword">set</span>, <span class="stringliteral">"IM"</span>, UI::compulsory ); |
---|
225 | <a name="l00249"></a>00249 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<diffbifn></a> OM = UI::build<diffbifn> ( <span class="keyword">set</span>, <span class="stringliteral">"OM"</span>, UI::compulsory ); |
---|
226 | <a name="l00250"></a>00250 |
---|
227 | <a name="l00251"></a>00251 <span class="comment">//statistics</span> |
---|
228 | <a name="l00252"></a>00252 <span class="keywordtype">int</span> dim = IM->dimension(); |
---|
229 | <a name="l00253"></a>00253 vec mu0; |
---|
230 | <a name="l00254"></a>00254 <span class="keywordflow">if</span> ( !<a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> ( mu0, <span class="keyword">set</span>, <span class="stringliteral">"mu0"</span> ) ) |
---|
231 | <a name="l00255"></a>00255 mu0 = zeros ( dim ); |
---|
232 | <a name="l00256"></a>00256 |
---|
233 | <a name="l00257"></a>00257 mat P0; |
---|
234 | <a name="l00258"></a>00258 vec dP0; |
---|
235 | <a name="l00259"></a>00259 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> ( dP0, <span class="keyword">set</span>, <span class="stringliteral">"dP0"</span> ) ) |
---|
236 | <a name="l00260"></a>00260 P0 = diag ( dP0 ); |
---|
237 | <a name="l00261"></a>00261 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( !<a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> ( P0, <span class="keyword">set</span>, <span class="stringliteral">"P0"</span> ) ) |
---|
238 | <a name="l00262"></a>00262 P0 = eye ( dim ); |
---|
239 | <a name="l00263"></a>00263 |
---|
240 | <a name="l00264"></a>00264 <a class="code" href="classbdm_1_1EKFfull.html#a44986d667c19bcf7708495a4a5afc841" title="set estimates">set_statistics</a> ( mu0, P0 ); |
---|
241 | <a name="l00265"></a>00265 |
---|
242 | <a name="l00266"></a>00266 <span class="comment">//parameters</span> |
---|
243 | <a name="l00267"></a>00267 vec dQ, dR; |
---|
244 | <a name="l00268"></a>00268 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> ( dQ, <span class="keyword">set</span>, <span class="stringliteral">"dQ"</span>, UI::compulsory ); |
---|
245 | <a name="l00269"></a>00269 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> ( dR, <span class="keyword">set</span>, <span class="stringliteral">"dR"</span>, UI::compulsory ); |
---|
246 | <a name="l00270"></a>00270 <a class="code" href="classbdm_1_1EKFfull.html#a8a68f95124a4b01f9ce23225f3c736a4" title="Set nonlinear functions for mean values and covariance matrices.">set_parameters</a> ( IM, OM, diag ( dQ ), diag ( dR ) ); |
---|
247 | <a name="l00271"></a>00271 |
---|
248 | <a name="l00272"></a>00272 <span class="comment">//connect</span> |
---|
249 | <a name="l00273"></a>00273 <a class="code" href="classbdm_1_1shared__ptr.html" title="A naive implementation of roughly a subset of the std::tr1::shared_ptr spec.">shared_ptr<RV></a> <a class="code" href="classbdm_1_1BM.html#ac400357e37d27a4834b2b1d9211009ed" title="Random variable of the data (optional).">drv</a> = UI::build<RV> ( <span class="keyword">set</span>, <span class="stringliteral">"drv"</span>, UI::compulsory ); |
---|
250 | <a name="l00274"></a>00274 set_drv ( *drv ); |
---|
251 | <a name="l00275"></a>00275 <a class="code" href="classbdm_1_1shared__ptr.html" title="A naive implementation of roughly a subset of the std::tr1::shared_ptr spec.">shared_ptr<RV></a> rv = UI::build<RV> ( <span class="keyword">set</span>, <span class="stringliteral">"rv"</span>, UI::compulsory ); |
---|
252 | <a name="l00276"></a>00276 set_rv ( *rv ); |
---|
253 | <a name="l00277"></a>00277 |
---|
254 | <a name="l00278"></a>00278 <span class="keywordtype">string</span> options; |
---|
255 | <a name="l00279"></a>00279 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> ( options, <span class="keyword">set</span>, <span class="stringliteral">"options"</span> ) ) |
---|
256 | <a name="l00280"></a>00280 <a class="code" href="classbdm_1_1BM.html#aadb539fa2585c8a2a91c54e5aebf330e" title="Set boolean options from a string, recognized are: &quot;logbounds,logll&quot;.">set_options</a> ( options ); |
---|
257 | <a name="l00281"></a>00281 <span class="comment">// pfxu = UI::build<diffbifn>(set, "IM", UI::compulsory);</span> |
---|
258 | <a name="l00282"></a>00282 <span class="comment">// phxu = UI::build<diffbifn>(set, "OM", UI::compulsory);</span> |
---|
259 | <a name="l00283"></a>00283 <span class="comment">// </span> |
---|
260 | <a name="l00284"></a>00284 <span class="comment">// mat R0;</span> |
---|
261 | <a name="l00285"></a>00285 <span class="comment">// UI::get(R0, set, "R",UI::compulsory);</span> |
---|
262 | <a name="l00286"></a>00286 <span class="comment">// mat Q0;</span> |
---|
263 | <a name="l00287"></a>00287 <span class="comment">// UI::get(Q0, set, "Q",UI::compulsory);</span> |
---|
264 | <a name="l00288"></a>00288 <span class="comment">// </span> |
---|
265 | <a name="l00289"></a>00289 <span class="comment">// </span> |
---|
266 | <a name="l00290"></a>00290 <span class="comment">// mat P0; vec mu0;</span> |
---|
267 | <a name="l00291"></a>00291 <span class="comment">// UI::get(mu0, set, "mu0", UI::optional);</span> |
---|
268 | <a name="l00292"></a>00292 <span class="comment">// UI::get(P0, set, "P0", UI::optional);</span> |
---|
269 | <a name="l00293"></a>00293 <span class="comment">// set_statistics(mu0,P0);</span> |
---|
270 | <a name="l00294"></a>00294 <span class="comment">// // Initial values</span> |
---|
271 | <a name="l00295"></a>00295 <span class="comment">// UI::get (yrv, set, "yrv", UI::optional);</span> |
---|
272 | <a name="l00296"></a>00296 <span class="comment">// UI::get (urv, set, "urv", UI::optional);</span> |
---|
273 | <a name="l00297"></a>00297 <span class="comment">// set_drv(concat(yrv,urv));</span> |
---|
274 | <a name="l00298"></a>00298 <span class="comment">// </span> |
---|
275 | <a name="l00299"></a>00299 <span class="comment">// // setup StateSpace</span> |
---|
276 | <a name="l00300"></a>00300 <span class="comment">// pfxu->dfdu_cond(mu0, zeros(pfxu->_dimu()), A,true);</span> |
---|
277 | <a name="l00301"></a>00301 <span class="comment">// phxu->dfdu_cond(mu0, zeros(pfxu->_dimu()), C,true);</span> |
---|
278 | <a name="l00302"></a>00302 <span class="comment">// </span> |
---|
279 | <a name="l00303"></a>00303 validate(); |
---|
280 | <a name="l00304"></a>00304 } |
---|
281 | <a name="l00305"></a>00305 <span class="keywordtype">void</span> validate() { |
---|
282 | <a name="l00306"></a>00306 <span class="comment">// check stats and IM and OM</span> |
---|
283 | <a name="l00307"></a>00307 } |
---|
284 | <a name="l00308"></a>00308 }; |
---|
285 | <a name="l00309"></a>00309 <a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a>(EKFfull); |
---|
286 | <a name="l00310"></a>00310 |
---|
287 | <a name="l00311"></a>00311 |
---|
288 | <a name="l00318"></a><a class="code" href="classbdm_1_1EKFCh.html">00318</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> |
---|
289 | <a name="l00319"></a>00319 { |
---|
290 | <a name="l00320"></a>00320 <span class="keyword">protected</span>: |
---|
291 | <a name="l00322"></a><a class="code" href="classbdm_1_1EKFCh.html#a5dc1964a6058057c9e17ea3c2f33bd2a">00322</a> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<diffbifn></a> <a class="code" href="classbdm_1_1EKFCh.html#a5dc1964a6058057c9e17ea3c2f33bd2a" title="Internal Model f(x,u).">pfxu</a>; |
---|
292 | <a name="l00323"></a>00323 |
---|
293 | <a name="l00325"></a><a class="code" href="classbdm_1_1EKFCh.html#a27c29351b2cc8248c011af506208e8d1">00325</a> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<diffbifn></a> <a class="code" href="classbdm_1_1EKFCh.html#a27c29351b2cc8248c011af506208e8d1" title="Observation Model h(x,u).">phxu</a>; |
---|
294 | <a name="l00326"></a>00326 <span class="keyword">public</span>: |
---|
295 | <a name="l00328"></a><a class="code" href="classbdm_1_1EKFCh.html#a1d1d91400e3f177de9fe7962ea17adc4">00328</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#a1d1d91400e3f177de9fe7962ea17adc4" title="copy constructor duplicated - calls different set_parameters">_copy_</a>()<span class="keyword"> const </span>{ |
---|
296 | <a name="l00329"></a>00329 <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>; |
---|
297 | <a name="l00330"></a>00330 E-><a class="code" href="classbdm_1_1EKFCh.html#acd1697a0b3ac2e17c0c56a90a4dbfad1" title="Set nonlinear functions for mean values and covariance matrices.">set_parameters</a> (<a class="code" href="classbdm_1_1EKFCh.html#a5dc1964a6058057c9e17ea3c2f33bd2a" title="Internal Model f(x,u).">pfxu</a>, <a class="code" href="classbdm_1_1EKFCh.html#a27c29351b2cc8248c011af506208e8d1" title="Observation Model h(x,u).">phxu</a>, <a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f" title="Matrix Q in square-root form.">Q</a>, <a class="code" href="classbdm_1_1StateSpace.html#a11dd3493d62ec9329860386adb3e6084" title="Matrix R in square-root form.">R</a>); |
---|
298 | <a name="l00331"></a>00331 E->set_statistics (<a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>->_mu(), <a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>->_R()); |
---|
299 | <a name="l00332"></a>00332 <span class="keywordflow">return</span> E; |
---|
300 | <a name="l00333"></a>00333 } |
---|
301 | <a name="l00335"></a>00335 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1EKFCh.html#acd1697a0b3ac2e17c0c56a90a4dbfad1" title="Set nonlinear functions for mean values and covariance matrices.">set_parameters</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<diffbifn></a> &<a class="code" href="classbdm_1_1EKFCh.html#a5dc1964a6058057c9e17ea3c2f33bd2a" title="Internal Model f(x,u).">pfxu</a>, <span class="keyword">const</span> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<diffbifn></a> &<a class="code" href="classbdm_1_1EKFCh.html#a27c29351b2cc8248c011af506208e8d1" title="Observation Model h(x,u).">phxu</a>, <span class="keyword">const</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> Q0, <span class="keyword">const</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> R0); |
---|
302 | <a name="l00336"></a>00336 |
---|
303 | <a name="l00338"></a>00338 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1EKFCh.html#a4c8609c37290b158f88a31dae4047225" title="Here dt = [yt;ut] of appropriate dimensions.">bayes</a> (<span class="keyword">const</span> vec &dt); |
---|
304 | <a name="l00339"></a>00339 |
---|
305 | <a name="l00340"></a>00340 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1EKFCh.html#a3952e181ef0cf230c325ad3be1f002df" title="load basic elements of Kalman from structure">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>); |
---|
306 | <a name="l00341"></a>00341 |
---|
307 | <a name="l00342"></a>00342 <span class="comment">// TODO dodelat void to_setting( Setting &set ) const;</span> |
---|
308 | <a name="l00343"></a>00343 |
---|
309 | <a name="l00344"></a>00344 }; |
---|
310 | <a name="l00345"></a>00345 |
---|
311 | <a name="l00346"></a>00346 <a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> (EKFCh); |
---|
312 | <a name="l00347"></a>00347 SHAREDPTR (EKFCh); |
---|
313 | <a name="l00348"></a>00348 |
---|
314 | <a name="l00349"></a>00349 |
---|
315 | <a name="l00351"></a>00351 |
---|
316 | <a name="l00359"></a><a class="code" href="classbdm_1_1MultiModel.html">00359</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1MultiModel.html" title="(Switching) Multiple Model The model runs several models in parallel and evaluates...">MultiModel</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> |
---|
317 | <a name="l00360"></a>00360 { |
---|
318 | <a name="l00361"></a>00361 <span class="keyword">protected</span>: |
---|
319 | <a name="l00363"></a><a class="code" href="classbdm_1_1MultiModel.html#a33de5d07ee774070632de8963b5d4c93">00363</a> Array<EKFCh*> <a class="code" href="classbdm_1_1MultiModel.html#a33de5d07ee774070632de8963b5d4c93" title="List of models between which we switch.">Models</a>; |
---|
320 | <a name="l00365"></a><a class="code" href="classbdm_1_1MultiModel.html#aef85ea61575bffa8beac8040869ee47a">00365</a> vec <a class="code" href="classbdm_1_1MultiModel.html#aef85ea61575bffa8beac8040869ee47a" title="vector of model weights">w</a>; |
---|
321 | <a name="l00367"></a><a class="code" href="classbdm_1_1MultiModel.html#a7b4012fc2208ce4ddd5c0d1fe69d7634">00367</a> vec <a class="code" href="classbdm_1_1MultiModel.html#a7b4012fc2208ce4ddd5c0d1fe69d7634" title="cache of model lls">_lls</a>; |
---|
322 | <a name="l00369"></a><a class="code" href="classbdm_1_1MultiModel.html#a9b56bcde4664bd53f8995d7ee7ed415c">00369</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1MultiModel.html#a9b56bcde4664bd53f8995d7ee7ed415c" title="type of switching policy [1=maximum,2=...]">policy</a>; |
---|
323 | <a name="l00371"></a><a class="code" href="classbdm_1_1MultiModel.html#ad665551d045b1a1055eeb9185558ff0b">00371</a> <a class="code" href="classbdm_1_1enorm.html">enorm<chmat></a> <a class="code" href="classbdm_1_1MultiModel.html#ad665551d045b1a1055eeb9185558ff0b" title="internal statistics">est</a>; |
---|
324 | <a name="l00372"></a>00372 <span class="keyword">public</span>: |
---|
325 | <a name="l00373"></a>00373 <span class="keywordtype">void</span> set_parameters (Array<EKFCh*> A, <span class="keywordtype">int</span> pol0 = 1) { |
---|
326 | <a name="l00374"></a>00374 <a class="code" href="classbdm_1_1MultiModel.html#a33de5d07ee774070632de8963b5d4c93" title="List of models between which we switch.">Models</a> = A;<span class="comment">//TODO: test if evalll is set</span> |
---|
327 | <a name="l00375"></a>00375 <a class="code" href="classbdm_1_1MultiModel.html#aef85ea61575bffa8beac8040869ee47a" title="vector of model weights">w</a>.set_length (A.length()); |
---|
328 | <a name="l00376"></a>00376 <a class="code" href="classbdm_1_1MultiModel.html#a7b4012fc2208ce4ddd5c0d1fe69d7634" title="cache of model lls">_lls</a>.set_length (A.length()); |
---|
329 | <a name="l00377"></a>00377 <a class="code" href="classbdm_1_1MultiModel.html#a9b56bcde4664bd53f8995d7ee7ed415c" title="type of switching policy [1=maximum,2=...]">policy</a> = pol0; |
---|
330 | <a name="l00378"></a>00378 |
---|
331 | <a name="l00379"></a>00379 <a class="code" href="classbdm_1_1MultiModel.html#ad665551d045b1a1055eeb9185558ff0b" title="internal statistics">est</a>.<a class="code" href="classbdm_1_1epdf.html#af423e28448dbb69ef4905295ec8de8ff" title="Name its rv.">set_rv</a> (<a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> (<span class="stringliteral">"MM"</span>, A (0)-><a class="code" href="classbdm_1_1MultiModel.html#a2af3f8dc10dfdae0ddc8160a9f36aaee" title="posterior density">posterior</a>().dimension(), 0)); |
---|
332 | <a name="l00380"></a>00380 <a class="code" href="classbdm_1_1MultiModel.html#ad665551d045b1a1055eeb9185558ff0b" title="internal statistics">est</a>.set_parameters (A (0)-><a class="code" href="classbdm_1_1MultiModel.html#a2af3f8dc10dfdae0ddc8160a9f36aaee" title="posterior density">posterior</a>().mean(), A (0)-><a class="code" href="classbdm_1_1MultiModel.html#a2af3f8dc10dfdae0ddc8160a9f36aaee" title="posterior density">posterior</a>()._R()); |
---|
333 | <a name="l00381"></a>00381 } |
---|
334 | <a name="l00382"></a><a class="code" href="classbdm_1_1MultiModel.html#aa915deeddb0e94c337d02ebc0abe535e">00382</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1MultiModel.html#aa915deeddb0e94c337d02ebc0abe535e" title="Incremental Bayes rule.">bayes</a> (<span class="keyword">const</span> vec &dt) { |
---|
335 | <a name="l00383"></a>00383 <span class="keywordtype">int</span> n = <a class="code" href="classbdm_1_1MultiModel.html#a33de5d07ee774070632de8963b5d4c93" title="List of models between which we switch.">Models</a>.length(); |
---|
336 | <a name="l00384"></a>00384 <span class="keywordtype">int</span> i; |
---|
337 | <a name="l00385"></a>00385 <span class="keywordflow">for</span> (i = 0; i < n; i++) { |
---|
338 | <a name="l00386"></a>00386 <a class="code" href="classbdm_1_1MultiModel.html#a33de5d07ee774070632de8963b5d4c93" title="List of models between which we switch.">Models</a> (i)->bayes (dt); |
---|
339 | <a name="l00387"></a>00387 <a class="code" href="classbdm_1_1MultiModel.html#a7b4012fc2208ce4ddd5c0d1fe69d7634" title="cache of model lls">_lls</a> (i) = <a class="code" href="classbdm_1_1MultiModel.html#a33de5d07ee774070632de8963b5d4c93" title="List of models between which we switch.">Models</a> (i)->_ll(); |
---|
340 | <a name="l00388"></a>00388 } |
---|
341 | <a name="l00389"></a>00389 <span class="keywordtype">double</span> mlls = max (<a class="code" href="classbdm_1_1MultiModel.html#a7b4012fc2208ce4ddd5c0d1fe69d7634" title="cache of model lls">_lls</a>); |
---|
342 | <a name="l00390"></a>00390 <a class="code" href="classbdm_1_1MultiModel.html#aef85ea61575bffa8beac8040869ee47a" title="vector of model weights">w</a> = exp (<a class="code" href="classbdm_1_1MultiModel.html#a7b4012fc2208ce4ddd5c0d1fe69d7634" title="cache of model lls">_lls</a> - mlls); |
---|
343 | <a name="l00391"></a>00391 <a class="code" href="classbdm_1_1MultiModel.html#aef85ea61575bffa8beac8040869ee47a" title="vector of model weights">w</a> /= sum (<a class="code" href="classbdm_1_1MultiModel.html#aef85ea61575bffa8beac8040869ee47a" title="vector of model weights">w</a>); <span class="comment">//normalization</span> |
---|
344 | <a name="l00392"></a>00392 <span class="comment">//set statistics</span> |
---|
345 | <a name="l00393"></a>00393 <span class="keywordflow">switch</span> (<a class="code" href="classbdm_1_1MultiModel.html#a9b56bcde4664bd53f8995d7ee7ed415c" title="type of switching policy [1=maximum,2=...]">policy</a>) { |
---|
346 | <a name="l00394"></a>00394 <span class="keywordflow">case</span> 1: { |
---|
347 | <a name="l00395"></a>00395 <span class="keywordtype">int</span> mi = max_index (<a class="code" href="classbdm_1_1MultiModel.html#aef85ea61575bffa8beac8040869ee47a" title="vector of model weights">w</a>); |
---|
348 | <a name="l00396"></a>00396 <span class="keyword">const</span> <a class="code" href="classbdm_1_1enorm.html">enorm<chmat></a> &st = <a class="code" href="classbdm_1_1MultiModel.html#a33de5d07ee774070632de8963b5d4c93" title="List of models between which we switch.">Models</a> (mi)->posterior() ; |
---|
349 | <a name="l00397"></a>00397 <a class="code" href="classbdm_1_1MultiModel.html#ad665551d045b1a1055eeb9185558ff0b" title="internal statistics">est</a>.set_parameters (st.<a class="code" href="classbdm_1_1enorm.html#ab2fa2915c35366392fe9bb022ca1a600" title="return expected value">mean</a>(), st._R()); |
---|
350 | <a name="l00398"></a>00398 } |
---|
351 | <a name="l00399"></a>00399 <span class="keywordflow">break</span>; |
---|
352 | <a name="l00400"></a>00400 <span class="keywordflow">default</span>: |
---|
353 | <a name="l00401"></a>00401 <a class="code" href="bdmerror_8h.html#a7c43f3a72afe68ab0c85663a1bb3521a" title="Unconditionally throw std::runtime_error.">bdm_error</a> (<span class="stringliteral">"unknown policy"</span>); |
---|
354 | <a name="l00402"></a>00402 } |
---|
355 | <a name="l00403"></a>00403 <span class="comment">// copy result to all models</span> |
---|
356 | <a name="l00404"></a>00404 <span class="keywordflow">for</span> (i = 0; i < n; i++) { |
---|
357 | <a name="l00405"></a>00405 <a class="code" href="classbdm_1_1MultiModel.html#a33de5d07ee774070632de8963b5d4c93" title="List of models between which we switch.">Models</a> (i)->set_statistics (<a class="code" href="classbdm_1_1MultiModel.html#ad665551d045b1a1055eeb9185558ff0b" title="internal statistics">est</a>.<a class="code" href="classbdm_1_1enorm.html#ab2fa2915c35366392fe9bb022ca1a600" title="return expected value">mean</a>(), <a class="code" href="classbdm_1_1MultiModel.html#ad665551d045b1a1055eeb9185558ff0b" title="internal statistics">est</a>._R()); |
---|
358 | <a name="l00406"></a>00406 } |
---|
359 | <a name="l00407"></a>00407 } |
---|
360 | <a name="l00409"></a><a class="code" href="classbdm_1_1MultiModel.html#a2af3f8dc10dfdae0ddc8160a9f36aaee">00409</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1enorm.html">enorm<chmat></a>& <a class="code" href="classbdm_1_1MultiModel.html#a2af3f8dc10dfdae0ddc8160a9f36aaee" title="posterior density">posterior</a>()<span class="keyword"> const </span>{ |
---|
361 | <a name="l00410"></a>00410 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1MultiModel.html#ad665551d045b1a1055eeb9185558ff0b" title="internal statistics">est</a>; |
---|
362 | <a name="l00411"></a>00411 } |
---|
363 | <a name="l00412"></a>00412 |
---|
364 | <a name="l00413"></a>00413 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1MultiModel.html#a7bd320fa2540883749b3f83cf2261878" title="This method arrange instance properties according the data stored in the Setting...">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>); |
---|
365 | <a name="l00414"></a>00414 |
---|
366 | <a name="l00415"></a>00415 <span class="comment">// TODO dodelat void to_setting( Setting &set ) const;</span> |
---|
367 | <a name="l00416"></a>00416 |
---|
368 | <a name="l00417"></a>00417 }; |
---|
369 | <a name="l00418"></a>00418 |
---|
370 | <a name="l00419"></a>00419 <a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> (MultiModel); |
---|
371 | <a name="l00420"></a>00420 SHAREDPTR (MultiModel); |
---|
372 | <a name="l00421"></a>00421 |
---|
373 | <a name="l00423"></a>00423 |
---|
374 | <a name="l00431"></a>00431 <span class="comment">//template<class sq_T></span> |
---|
375 | <a name="l00432"></a><a class="code" href="classbdm_1_1StateCanonical.html">00432</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1StateCanonical.html" title="conversion of outer ARX model (mlnorm) to state space model">StateCanonical</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1StateSpace.html" title="Basic elements of linear state-space model.">StateSpace</a><fsqmat>{ |
---|
376 | <a name="l00433"></a>00433 <span class="keyword">protected</span>: |
---|
377 | <a name="l00435"></a><a class="code" href="classbdm_1_1StateCanonical.html#a4e6a4771f9444f9b55ddc0b6e65cb5d1">00435</a> <a class="code" href="classbdm_1_1datalink__part.html">datalink_part</a> <a class="code" href="classbdm_1_1StateCanonical.html#a4e6a4771f9444f9b55ddc0b6e65cb5d1" title="remember connection from theta -&gt;A">th2A</a>; |
---|
378 | <a name="l00437"></a><a class="code" href="classbdm_1_1StateCanonical.html#ab7c7aed9b66be7a24cc8ca43cea3123d">00437</a> <a class="code" href="classbdm_1_1datalink__part.html">datalink_part</a> <a class="code" href="classbdm_1_1StateCanonical.html#ab7c7aed9b66be7a24cc8ca43cea3123d" title="remember connection from theta -&gt;C">th2C</a>; |
---|
379 | <a name="l00439"></a><a class="code" href="classbdm_1_1StateCanonical.html#adf03b4d4c48d94f2f0510e086c651c89">00439</a> <a class="code" href="classbdm_1_1datalink__part.html">datalink_part</a> <a class="code" href="classbdm_1_1StateCanonical.html#adf03b4d4c48d94f2f0510e086c651c89" title="remember connection from theta -&gt;D">th2D</a>; |
---|
380 | <a name="l00441"></a><a class="code" href="classbdm_1_1StateCanonical.html#a770b84ff706d4888236096a96ef51730">00441</a> vec <a class="code" href="classbdm_1_1StateCanonical.html#a770b84ff706d4888236096a96ef51730" title="cached first row of A">A1row</a>; |
---|
381 | <a name="l00443"></a><a class="code" href="classbdm_1_1StateCanonical.html#a665df0310519066e7adbbd490baf157d">00443</a> vec <a class="code" href="classbdm_1_1StateCanonical.html#a665df0310519066e7adbbd490baf157d" title="cached first row of C">C1row</a>; |
---|
382 | <a name="l00445"></a><a class="code" href="classbdm_1_1StateCanonical.html#a8e890a7aee1e6c1d06074f6604609eb6">00445</a> vec <a class="code" href="classbdm_1_1StateCanonical.html#a8e890a7aee1e6c1d06074f6604609eb6" title="cached first row of D">D1row</a>; |
---|
383 | <a name="l00446"></a>00446 |
---|
384 | <a name="l00447"></a>00447 <span class="keyword">public</span>: |
---|
385 | <a name="l00449"></a><a class="code" href="classbdm_1_1StateCanonical.html#ad3ad57524c2af597b36ab1592fddc26c">00449</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1StateCanonical.html#ad3ad57524c2af597b36ab1592fddc26c" title="set up this object to match given mlnorm">connect_mlnorm</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<fsqmat></a> &ml){ |
---|
386 | <a name="l00450"></a>00450 <span class="comment">//get ids of yrv </span> |
---|
387 | <a name="l00451"></a>00451 <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &yrv = ml._rv(); |
---|
388 | <a name="l00452"></a>00452 <span class="comment">//need to determine u_t - it is all in _rvc that is not in ml._rv()</span> |
---|
389 | <a name="l00453"></a>00453 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rgr0 = ml._rvc().remove_time(); |
---|
390 | <a name="l00454"></a>00454 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> urv = rgr0.<a class="code" href="classbdm_1_1RV.html#aaec44dabdf0a6d90fbae95e1356eda39" title="Subtract another variable from the current one.">subt</a>(yrv); |
---|
391 | <a name="l00455"></a>00455 |
---|
392 | <a name="l00456"></a>00456 <span class="comment">//We can do only 1d now... :(</span> |
---|
393 | <a name="l00457"></a>00457 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a>(yrv.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>()==1, <span class="stringliteral">"Only for SISO so far..."</span> ); |
---|
394 | <a name="l00458"></a>00458 |
---|
395 | <a name="l00459"></a>00459 <span class="comment">// create names for </span> |
---|
396 | <a name="l00460"></a>00460 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> xrv; <span class="comment">//empty</span> |
---|
397 | <a name="l00461"></a>00461 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> Crv; <span class="comment">//empty</span> |
---|
398 | <a name="l00462"></a>00462 <span class="keywordtype">int</span> td=ml._rvc().<a class="code" href="classbdm_1_1RV.html#a9a5c5aeeaf39299d07763377b05a8241" title="Minimum time-offset.">mint</a>(); |
---|
399 | <a name="l00463"></a>00463 <span class="comment">// assuming strictly proper function!!!</span> |
---|
400 | <a name="l00464"></a>00464 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> t=-1;t>=td;t--){ |
---|
401 | <a name="l00465"></a>00465 xrv.add(yrv.<a class="code" href="classbdm_1_1RV.html#a627222f49abc5d07e5e8aecac7708ee2" title="create new RV from the current one with time shifted by given value">copy_t</a>(t)); |
---|
402 | <a name="l00466"></a>00466 Crv.<a class="code" href="classbdm_1_1RV.html#a87841b5ee43997b79789c0c22047e224" title="Add (concat) another variable to the current one,.">add</a>(urv.<a class="code" href="classbdm_1_1RV.html#a627222f49abc5d07e5e8aecac7708ee2" title="create new RV from the current one with time shifted by given value">copy_t</a>(t)); |
---|
403 | <a name="l00467"></a>00467 } |
---|
404 | <a name="l00468"></a>00468 |
---|
405 | <a name="l00469"></a>00469 this-><a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a> = xrv._dsize(); |
---|
406 | <a name="l00470"></a>00470 this-><a class="code" href="classbdm_1_1StateSpace.html#a3b784d85ca911866225a79193ae1441f" title="cache of rvy.count()">dimy</a> = yrv.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>(); |
---|
407 | <a name="l00471"></a>00471 this-><a class="code" href="classbdm_1_1StateSpace.html#a95bb59ffbfd34c55d03d4d7a2a9b4faf" title="cache of rvu.count()">dimu</a> = urv.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>(); |
---|
408 | <a name="l00472"></a>00472 |
---|
409 | <a name="l00473"></a>00473 <span class="comment">// get mapp</span> |
---|
410 | <a name="l00474"></a>00474 <a class="code" href="classbdm_1_1StateCanonical.html#a4e6a4771f9444f9b55ddc0b6e65cb5d1" title="remember connection from theta -&gt;A">th2A</a>.<a class="code" href="classbdm_1_1datalink__part.html#a6cef1083755c27e4476501abe6f49dce" title="set connection, rv must be fully present in rv_up">set_connection</a>(xrv, ml._rvc()); |
---|
411 | <a name="l00475"></a>00475 <a class="code" href="classbdm_1_1StateCanonical.html#ab7c7aed9b66be7a24cc8ca43cea3123d" title="remember connection from theta -&gt;C">th2C</a>.<a class="code" href="classbdm_1_1datalink__part.html#a6cef1083755c27e4476501abe6f49dce" title="set connection, rv must be fully present in rv_up">set_connection</a>(Crv, ml._rvc()); |
---|
412 | <a name="l00476"></a>00476 <a class="code" href="classbdm_1_1StateCanonical.html#adf03b4d4c48d94f2f0510e086c651c89" title="remember connection from theta -&gt;D">th2D</a>.<a class="code" href="classbdm_1_1datalink__part.html#a6cef1083755c27e4476501abe6f49dce" title="set connection, rv must be fully present in rv_up">set_connection</a>(urv, ml._rvc()); |
---|
413 | <a name="l00477"></a>00477 |
---|
414 | <a name="l00478"></a>00478 <span class="comment">//set matrix sizes</span> |
---|
415 | <a name="l00479"></a>00479 this-><a class="code" href="classbdm_1_1StateSpace.html#ade7d828a8d06cbbd5ac45afeaf9f0c7b" title="Matrix A.">A</a>=zeros(<a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a>,<a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a>); |
---|
416 | <a name="l00480"></a>00480 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j=1; j<<a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a>; j++){<a class="code" href="classbdm_1_1StateSpace.html#ade7d828a8d06cbbd5ac45afeaf9f0c7b" title="Matrix A.">A</a>(j,j-1)=1.0;} <span class="comment">// off diagonal</span> |
---|
417 | <a name="l00481"></a>00481 this-><a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a>=zeros(dimx,1); |
---|
418 | <a name="l00482"></a>00482 this-><a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a>(0) = 1.0; |
---|
419 | <a name="l00483"></a>00483 this-><a class="code" href="classbdm_1_1StateSpace.html#ac7ec82d2200c956cff6dff559bd32ff9" title="Matrix C.">C</a>=zeros(1,dimx); |
---|
420 | <a name="l00484"></a>00484 this-><a class="code" href="classbdm_1_1StateSpace.html#ad5769a41b34eb518716120cf04dbc23f" title="Matrix D.">D</a>=zeros(1,urv.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>()); |
---|
421 | <a name="l00485"></a>00485 this-><a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f" title="Matrix Q in square-root form.">Q</a> = zeros(dimx,dimx); |
---|
422 | <a name="l00486"></a>00486 <span class="comment">// R is set by update</span> |
---|
423 | <a name="l00487"></a>00487 |
---|
424 | <a name="l00488"></a>00488 <span class="comment">//set cache</span> |
---|
425 | <a name="l00489"></a>00489 this-><a class="code" href="classbdm_1_1StateCanonical.html#a770b84ff706d4888236096a96ef51730" title="cached first row of A">A1row</a> = zeros(xrv._dsize()); |
---|
426 | <a name="l00490"></a>00490 this-><a class="code" href="classbdm_1_1StateCanonical.html#a665df0310519066e7adbbd490baf157d" title="cached first row of C">C1row</a> = zeros(xrv._dsize()); |
---|
427 | <a name="l00491"></a>00491 this-><a class="code" href="classbdm_1_1StateCanonical.html#a8e890a7aee1e6c1d06074f6604609eb6" title="cached first row of D">D1row</a> = zeros(urv.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>()); |
---|
428 | <a name="l00492"></a>00492 |
---|
429 | <a name="l00493"></a>00493 <a class="code" href="classbdm_1_1StateCanonical.html#a25f55da4899112f210ade6d322c78b7e" title="fast function to update parameters from ml - not checked for compatibility!!">update_from</a>(ml); |
---|
430 | <a name="l00494"></a>00494 validate(); |
---|
431 | <a name="l00495"></a>00495 }; |
---|
432 | <a name="l00497"></a><a class="code" href="classbdm_1_1StateCanonical.html#a25f55da4899112f210ade6d322c78b7e">00497</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1StateCanonical.html#a25f55da4899112f210ade6d322c78b7e" title="fast function to update parameters from ml - not checked for compatibility!!">update_from</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<fsqmat></a> &ml){ |
---|
433 | <a name="l00498"></a>00498 |
---|
434 | <a name="l00499"></a>00499 vec theta = ml.<a class="code" href="classbdm_1_1mlnorm.html#a55e1bd7fa70b852bd7fe50ce72fb8f23" title="access function">_A</a>().get_row(0); <span class="comment">// this </span> |
---|
435 | <a name="l00500"></a>00500 |
---|
436 | <a name="l00501"></a>00501 <a class="code" href="classbdm_1_1StateCanonical.html#a4e6a4771f9444f9b55ddc0b6e65cb5d1" title="remember connection from theta -&gt;A">th2A</a>.<a class="code" href="classbdm_1_1datalink__part.html#aaba9b673ef82584e1bc06cc7a32b0a59" title="Get val for vector val_down from val of &quot;Up&quot;.">filldown</a>(theta,<a class="code" href="classbdm_1_1StateCanonical.html#a770b84ff706d4888236096a96ef51730" title="cached first row of A">A1row</a>); |
---|
437 | <a name="l00502"></a>00502 <a class="code" href="classbdm_1_1StateCanonical.html#ab7c7aed9b66be7a24cc8ca43cea3123d" title="remember connection from theta -&gt;C">th2C</a>.<a class="code" href="classbdm_1_1datalink__part.html#aaba9b673ef82584e1bc06cc7a32b0a59" title="Get val for vector val_down from val of &quot;Up&quot;.">filldown</a>(theta,<a class="code" href="classbdm_1_1StateCanonical.html#a665df0310519066e7adbbd490baf157d" title="cached first row of C">C1row</a>); |
---|
438 | <a name="l00503"></a>00503 <a class="code" href="classbdm_1_1StateCanonical.html#adf03b4d4c48d94f2f0510e086c651c89" title="remember connection from theta -&gt;D">th2D</a>.<a class="code" href="classbdm_1_1datalink__part.html#aaba9b673ef82584e1bc06cc7a32b0a59" title="Get val for vector val_down from val of &quot;Up&quot;.">filldown</a>(theta,<a class="code" href="classbdm_1_1StateCanonical.html#a8e890a7aee1e6c1d06074f6604609eb6" title="cached first row of D">D1row</a>); |
---|
439 | <a name="l00504"></a>00504 |
---|
440 | <a name="l00505"></a>00505 <a class="code" href="classbdm_1_1StateSpace.html#a11dd3493d62ec9329860386adb3e6084" title="Matrix R in square-root form.">R</a> = ml.<a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a>(); |
---|
441 | <a name="l00506"></a>00506 |
---|
442 | <a name="l00507"></a>00507 <a class="code" href="classbdm_1_1StateSpace.html#ade7d828a8d06cbbd5ac45afeaf9f0c7b" title="Matrix A.">A</a>.set_row(0,<a class="code" href="classbdm_1_1StateCanonical.html#a770b84ff706d4888236096a96ef51730" title="cached first row of A">A1row</a>); |
---|
443 | <a name="l00508"></a>00508 <a class="code" href="classbdm_1_1StateSpace.html#ac7ec82d2200c956cff6dff559bd32ff9" title="Matrix C.">C</a>.set_row(0,<a class="code" href="classbdm_1_1StateCanonical.html#a665df0310519066e7adbbd490baf157d" title="cached first row of C">C1row</a>+<a class="code" href="classbdm_1_1StateCanonical.html#a8e890a7aee1e6c1d06074f6604609eb6" title="cached first row of D">D1row</a>*<a class="code" href="classbdm_1_1StateCanonical.html#a770b84ff706d4888236096a96ef51730" title="cached first row of A">A1row</a>); |
---|
444 | <a name="l00509"></a>00509 <a class="code" href="classbdm_1_1StateSpace.html#ad5769a41b34eb518716120cf04dbc23f" title="Matrix D.">D</a>.set_row(0,<a class="code" href="classbdm_1_1StateCanonical.html#a8e890a7aee1e6c1d06074f6604609eb6" title="cached first row of D">D1row</a>); |
---|
445 | <a name="l00510"></a>00510 |
---|
446 | <a name="l00511"></a>00511 } |
---|
447 | <a name="l00512"></a>00512 }; |
---|
448 | <a name="l00513"></a>00513 |
---|
449 | <a name="l00515"></a>00515 |
---|
450 | <a name="l00516"></a>00516 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
---|
451 | <a name="l00517"></a>00517 <span class="keywordtype">void</span> StateSpace<sq_T>::set_parameters (<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) |
---|
452 | <a name="l00518"></a>00518 { |
---|
453 | <a name="l00519"></a>00519 |
---|
454 | <a name="l00520"></a>00520 <a class="code" href="classbdm_1_1StateSpace.html#ade7d828a8d06cbbd5ac45afeaf9f0c7b" title="Matrix A.">A</a> = A0; |
---|
455 | <a name="l00521"></a>00521 <a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a> = B0; |
---|
456 | <a name="l00522"></a>00522 <a class="code" href="classbdm_1_1StateSpace.html#ac7ec82d2200c956cff6dff559bd32ff9" title="Matrix C.">C</a> = C0; |
---|
457 | <a name="l00523"></a>00523 <a class="code" href="classbdm_1_1StateSpace.html#ad5769a41b34eb518716120cf04dbc23f" title="Matrix D.">D</a> = D0; |
---|
458 | <a name="l00524"></a>00524 <a class="code" href="classbdm_1_1StateSpace.html#a11dd3493d62ec9329860386adb3e6084" title="Matrix R in square-root form.">R</a> = R0; |
---|
459 | <a name="l00525"></a>00525 <a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f" title="Matrix Q in square-root form.">Q</a> = Q0; |
---|
460 | <a name="l00526"></a>00526 validate(); |
---|
461 | <a name="l00527"></a>00527 } |
---|
462 | <a name="l00528"></a>00528 |
---|
463 | <a name="l00529"></a>00529 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
---|
464 | <a name="l00530"></a>00530 <span class="keywordtype">void</span> StateSpace<sq_T>::validate(){ |
---|
465 | <a name="l00531"></a>00531 <a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a> = <a class="code" href="classbdm_1_1StateSpace.html#ade7d828a8d06cbbd5ac45afeaf9f0c7b" title="Matrix A.">A</a>.rows(); |
---|
466 | <a name="l00532"></a>00532 <a class="code" href="classbdm_1_1StateSpace.html#a95bb59ffbfd34c55d03d4d7a2a9b4faf" title="cache of rvu.count()">dimu</a> = <a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a>.cols(); |
---|
467 | <a name="l00533"></a>00533 <a class="code" href="classbdm_1_1StateSpace.html#a3b784d85ca911866225a79193ae1441f" title="cache of rvy.count()">dimy</a> = <a class="code" href="classbdm_1_1StateSpace.html#ac7ec82d2200c956cff6dff559bd32ff9" title="Matrix C.">C</a>.rows(); |
---|
468 | <a name="l00534"></a>00534 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (<a class="code" href="classbdm_1_1StateSpace.html#ade7d828a8d06cbbd5ac45afeaf9f0c7b" title="Matrix A.">A</a>.cols() == <a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a>, <span class="stringliteral">"KalmanFull: A is not square"</span>); |
---|
469 | <a name="l00535"></a>00535 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (<a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a>.rows() == <a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a>, <span class="stringliteral">"KalmanFull: B is not compatible"</span>); |
---|
470 | <a name="l00536"></a>00536 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (<a class="code" href="classbdm_1_1StateSpace.html#ac7ec82d2200c956cff6dff559bd32ff9" title="Matrix C.">C</a>.cols() == <a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a>, <span class="stringliteral">"KalmanFull: C is not square"</span>); |
---|
471 | <a name="l00537"></a>00537 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> ( (<a class="code" href="classbdm_1_1StateSpace.html#ad5769a41b34eb518716120cf04dbc23f" title="Matrix D.">D</a>.rows() == <a class="code" href="classbdm_1_1StateSpace.html#a3b784d85ca911866225a79193ae1441f" title="cache of rvy.count()">dimy</a>) && (<a class="code" href="classbdm_1_1StateSpace.html#ad5769a41b34eb518716120cf04dbc23f" title="Matrix D.">D</a>.cols() == <a class="code" href="classbdm_1_1StateSpace.html#a95bb59ffbfd34c55d03d4d7a2a9b4faf" title="cache of rvu.count()">dimu</a>), <span class="stringliteral">"KalmanFull: D is not compatible"</span>); |
---|
472 | <a name="l00538"></a>00538 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> ( (<a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f" title="Matrix Q in square-root form.">Q</a>.cols() == <a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a>) && (<a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f" title="Matrix Q in square-root form.">Q</a>.rows() == <a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a>), <span class="stringliteral">"KalmanFull: Q is not compatible"</span>); |
---|
473 | <a name="l00539"></a>00539 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> ( (<a class="code" href="classbdm_1_1StateSpace.html#a11dd3493d62ec9329860386adb3e6084" title="Matrix R in square-root form.">R</a>.cols() == <a class="code" href="classbdm_1_1StateSpace.html#a3b784d85ca911866225a79193ae1441f" title="cache of rvy.count()">dimy</a>) && (<a class="code" href="classbdm_1_1StateSpace.html#a11dd3493d62ec9329860386adb3e6084" title="Matrix R in square-root form.">R</a>.rows() == <a class="code" href="classbdm_1_1StateSpace.html#a3b784d85ca911866225a79193ae1441f" title="cache of rvy.count()">dimy</a>), <span class="stringliteral">"KalmanFull: R is not compatible"</span>); |
---|
474 | <a name="l00540"></a>00540 } |
---|
475 | <a name="l00541"></a>00541 |
---|
476 | <a name="l00542"></a>00542 } |
---|
477 | <a name="l00543"></a>00543 <span class="preprocessor">#endif // KF_H</span> |
---|
478 | <a name="l00544"></a>00544 <span class="preprocessor"></span> |
---|
479 | <a name="l00545"></a>00545 |
---|
480 | </pre></div></div> |
---|
481 | <hr size="1"/><address style="text-align: right;"><small>Generated on Mon Oct 12 19:37:19 2009 for mixpp by |
---|
482 | <a href="http://www.doxygen.org/index.html"> |
---|
483 | <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address> |
---|
484 | </body> |
---|
485 | </html> |
---|