root/library/doc/html/kalman_8h_source.html @ 616

Revision 616, 74.1 kB (checked in by smidl, 15 years ago)

doc, sorted related pages

Line 
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<!--
13function 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}
25function 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}
49window.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&nbsp;Page</span></a></li>
56      <li><a href="pages.html"><span>Related&nbsp;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&nbsp;List</span></a></li>
64      <li><a href="globals.html"><span>File&nbsp;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 &quot;../math/functions.h&quot;</span>
73<a name="l00018"></a>00018 <span class="preprocessor">#include &quot;../stat/exp_family.h&quot;</span>
74<a name="l00019"></a>00019 <span class="preprocessor">#include &quot;../math/chmat.h&quot;</span>
75<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;../base/user_info.h&quot;</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>&lt;<span class="keyword">class</span> sq_T&gt;
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                 <span class="keywordtype">void</span> set_parameters (<span class="keyword">const</span> mat &amp;A0, <span class="keyword">const</span>  mat &amp;B0, <span class="keyword">const</span>  mat &amp;C0, <span class="keyword">const</span>  mat &amp;D0, <span class="keyword">const</span>  sq_T &amp;Q0, <span class="keyword">const</span> sq_T &amp;R0);
96<a name="l00057"></a>00057                 <span class="keywordtype">void</span> validate();
97<a name="l00059"></a><a class="code" href="classbdm_1_1StateSpace.html#a02470085bbf3c41fe8e36544813eecbd">00059</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 &amp;<span class="keyword">set</span>) {
98<a name="l00060"></a>00060                         <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">&quot;A&quot;</span>, UI::compulsory);
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#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a>, <span class="keyword">set</span>, <span class="stringliteral">&quot;B&quot;</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#ac7ec82d2200c956cff6dff559bd32ff9" title="Matrix C.">C</a>, <span class="keyword">set</span>, <span class="stringliteral">&quot;C&quot;</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#ad5769a41b34eb518716120cf04dbc23f" title="Matrix D.">D</a>, <span class="keyword">set</span>, <span class="stringliteral">&quot;D&quot;</span>, UI::compulsory);
102<a name="l00064"></a>00064                         mat Qtm, Rtm;
103<a name="l00065"></a>00065                         <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">&quot;Q&quot;</span>, UI::optional)){
104<a name="l00066"></a>00066                                 vec dq;
105<a name="l00067"></a>00067                                 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a>(dq, <span class="keyword">set</span>, <span class="stringliteral">&quot;dQ&quot;</span>, UI::compulsory);
106<a name="l00068"></a>00068                                 Qtm=diag(dq);
107<a name="l00069"></a>00069                         }
108<a name="l00070"></a>00070                         <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">&quot;R&quot;</span>, UI::optional)){
109<a name="l00071"></a>00071                                 vec dr;
110<a name="l00072"></a>00072                                 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a>(dr, <span class="keyword">set</span>, <span class="stringliteral">&quot;dQ&quot;</span>, UI::compulsory);
111<a name="l00073"></a>00073                                 Rtm=diag(dr);
112<a name="l00074"></a>00074                         }
113<a name="l00075"></a>00075                         <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>
114<a name="l00076"></a>00076                         <a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f" title="Matrix Q in square-root form.">Q</a>=Qtm;
115<a name="l00077"></a>00077                         
116<a name="l00078"></a>00078                         validate();
117<a name="l00079"></a>00079                 }               
118<a name="l00081"></a><a class="code" href="classbdm_1_1StateSpace.html#ab1972e00d9b9dd22a0f983c7cb0b8b40">00081</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>;}
119<a name="l00083"></a><a class="code" href="classbdm_1_1StateSpace.html#af3d83a4b39e05df9fb4246fd6ddc2a60">00083</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>;}
120<a name="l00085"></a><a class="code" href="classbdm_1_1StateSpace.html#aa238842025a0eaade26d5d79a0e9000e">00085</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>;}
121<a name="l00087"></a><a class="code" href="classbdm_1_1StateSpace.html#aae0dd610bf28f52c4c7acec87e39ed5e">00087</a>                 <span class="keyword">const</span> mat&amp; <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>;}
122<a name="l00089"></a><a class="code" href="classbdm_1_1StateSpace.html#a19cabf296793357c130778fe74df54a4">00089</a>                 <span class="keyword">const</span> mat&amp; <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>;}
123<a name="l00091"></a><a class="code" href="classbdm_1_1StateSpace.html#a5731f429df4a70dc0d0d1e6ea8e35125">00091</a>                 <span class="keyword">const</span> mat&amp; <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>;}
124<a name="l00093"></a><a class="code" href="classbdm_1_1StateSpace.html#a286286acb308f9ee596cab9af503b252">00093</a>                 <span class="keyword">const</span> mat&amp; <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>;}
125<a name="l00095"></a><a class="code" href="classbdm_1_1StateSpace.html#a38a71e31f22f5459d10c3cbee1e4d977">00095</a>                 <span class="keyword">const</span> sq_T&amp; <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>;}
126<a name="l00097"></a><a class="code" href="classbdm_1_1StateSpace.html#a69ddac45b7a4efbf83b2232d0d5595ba">00097</a>                 <span class="keyword">const</span> sq_T&amp; <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>;}
127<a name="l00098"></a>00098 };
128<a name="l00099"></a>00099
129<a name="l00101"></a>00101 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt;
130<a name="l00102"></a><a class="code" href="classbdm_1_1Kalman.html">00102</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>&lt;sq_T&gt;
131<a name="l00103"></a>00103 {
132<a name="l00104"></a>00104         <span class="keyword">protected</span>:
133<a name="l00106"></a><a class="code" href="classbdm_1_1Kalman.html#aaac28e226fe6cbff5a9ae38d8d025d7a">00106</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>;
134<a name="l00108"></a><a class="code" href="classbdm_1_1Kalman.html#a44d4a8ab05d5311286e1da78b831633e">00108</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>;
135<a name="l00110"></a><a class="code" href="classbdm_1_1Kalman.html#abd69dfb802465f22dd84d73a180d5c92">00110</a>                 mat  <a class="code" href="classbdm_1_1Kalman.html#abd69dfb802465f22dd84d73a180d5c92" title="Kalman gain.">_K</a>;
136<a name="l00112"></a><a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43">00112</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&lt;enorm&lt;sq_T&gt;</a> &gt; <a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>;
137<a name="l00114"></a><a class="code" href="classbdm_1_1Kalman.html#aba555c394c429f6831c9bbabfa2c944c">00114</a>                 <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm&lt;sq_T&gt;</a>  <a class="code" href="classbdm_1_1Kalman.html#aba555c394c429f6831c9bbabfa2c944c" title="marginal on data f(y|y)">fy</a>;
138<a name="l00115"></a>00115         <span class="keyword">public</span>:
139<a name="l00116"></a>00116                 <a class="code" href="classbdm_1_1Kalman.html" title="Common abstract base for Kalman filters.">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>(), <a class="code" href="classbdm_1_1StateSpace.html" title="Basic elements of linear state-space model.">StateSpace</a>&lt;sq_T&gt;(), <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>(new <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm</a>&lt;sq_T&gt;){}
140<a name="l00117"></a>00117                 <span class="keywordtype">void</span> set_statistics (<span class="keyword">const</span> vec &amp;mu0, <span class="keyword">const</span> mat &amp;P0) {<a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>-&gt;set_parameters (mu0, P0); };
141<a name="l00118"></a>00118                 <span class="keywordtype">void</span> set_statistics (<span class="keyword">const</span> vec &amp;mu0, <span class="keyword">const</span> sq_T &amp;P0) {<a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>-&gt;set_parameters (mu0, P0); };
142<a name="l00120"></a><a class="code" href="classbdm_1_1Kalman.html#a8b0c3db41eb292edb20b826832c9b5fa">00120</a>                 <span class="keyword">const</span> <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm&lt;sq_T&gt;</a>&amp; <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>();}
143<a name="l00122"></a><a class="code" href="classbdm_1_1Kalman.html#a4da2fdd01e9b335b133def9814eb0620">00122</a>                 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr&lt;epdf&gt;</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>;}
144<a name="l00124"></a><a class="code" href="classbdm_1_1Kalman.html#a7fe88fc3471cab1911707bcdb6b4690a">00124</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 &amp;<span class="keyword">set</span>) {
145<a name="l00125"></a>00125                         <a class="code" href="classbdm_1_1Kalman.html#a7fe88fc3471cab1911707bcdb6b4690a" title="load basic elements of Kalman from structure">StateSpace&lt;sq_T&gt;::from_setting</a>(<span class="keyword">set</span>);
146<a name="l00126"></a>00126                                                 
147<a name="l00127"></a>00127                         mat P0; vec mu0;
148<a name="l00128"></a>00128                         <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a>(mu0, <span class="keyword">set</span>, <span class="stringliteral">&quot;mu0&quot;</span>, UI::optional);
149<a name="l00129"></a>00129                         <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a>(P0, <span class="keyword">set</span><span class="stringliteral">&quot;P0&quot;</span>, UI::optional);
150<a name="l00130"></a>00130                         set_statistics(mu0,P0);
151<a name="l00131"></a>00131                         <span class="comment">// Initial values</span>
152<a name="l00132"></a>00132                         <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">&quot;yrv&quot;</span>, UI::optional);
153<a name="l00133"></a>00133                         <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">&quot;urv&quot;</span>, UI::optional);
154<a name="l00134"></a>00134                         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>));
155<a name="l00135"></a>00135                         
156<a name="l00136"></a>00136                         validate();
157<a name="l00137"></a>00137                 }
158<a name="l00138"></a>00138                 <span class="keywordtype">void</span> validate() {
159<a name="l00139"></a>00139                         <a class="code" href="classbdm_1_1StateSpace.html" title="Basic elements of linear state-space model.">StateSpace&lt;sq_T&gt;::validate</a>();
160<a name="l00140"></a>00140                         <a class="code" href="bdmerror_8h.html#a89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</a>(<a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>-&gt;dimension(), <span class="stringliteral">&quot;Statistics and model parameters mismatch&quot;</span>);
161<a name="l00141"></a>00141                 }
162<a name="l00142"></a>00142 };
163<a name="l00147"></a><a class="code" href="classbdm_1_1KalmanFull.html">00147</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>&lt;fsqmat&gt;
164<a name="l00148"></a>00148 {
165<a name="l00149"></a>00149         <span class="keyword">public</span>:
166<a name="l00151"></a><a class="code" href="classbdm_1_1KalmanFull.html#abdcc98c8b18c1cbdebdf218ae838fd11">00151</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>&lt;<a class="code" href="classbdm_1_1fsqmat.html" title="Fake sqmat. This class maps sqmat operations to operations on full matrix.">fsqmat</a>&gt;(){};
167<a name="l00153"></a>00153                 <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 &amp;dt);
168<a name="l00154"></a>00154 };
169<a name="l00155"></a>00155 <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);
170<a name="l00156"></a>00156
171<a name="l00157"></a>00157
172<a name="l00165"></a><a class="code" href="classbdm_1_1KalmanCh.html">00165</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>&lt;chmat&gt;
173<a name="l00166"></a>00166 {
174<a name="l00167"></a>00167         <span class="keyword">protected</span>:
175<a name="l00170"></a>00170                 mat preA;
176<a name="l00172"></a><a class="code" href="classbdm_1_1KalmanCh.html#abcbd68f51d4b57246e7784ca5900171f">00172</a>                 mat <a class="code" href="classbdm_1_1KalmanCh.html#abcbd68f51d4b57246e7784ca5900171f" title="post array (triangular matrix)">postA</a>;
177<a name="l00174"></a>00174         <span class="keyword">public</span>:
178<a name="l00176"></a><a class="code" href="classbdm_1_1KalmanCh.html#a24ce65bdaa538d4d5153d709a929b996">00176</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>{
179<a name="l00177"></a>00177                         <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>;
180<a name="l00178"></a>00178                         K-&gt;<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>);
181<a name="l00179"></a>00179                         K-&gt;set_statistics (<a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>-&gt;_mu(), <a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>-&gt;_R());
182<a name="l00180"></a>00180                         <span class="keywordflow">return</span> K;
183<a name="l00181"></a>00181                 }
184<a name="l00183"></a>00183                 <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 &amp;A0, <span class="keyword">const</span> mat &amp;B0, <span class="keyword">const</span> mat &amp;C0, <span class="keyword">const</span> mat &amp;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> &amp;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> &amp;R0);
185<a name="l00185"></a>00185                 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1KalmanCh.html#ac983b1a2687312ab733d4c859cf83c1e" title="initialize internal parametetrs">initialize</a>();
186<a name="l00186"></a>00186
187<a name="l00200"></a>00200                 <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 &amp;dt);
188<a name="l00201"></a>00201                 
189<a name="l00202"></a><a class="code" href="classbdm_1_1KalmanCh.html#a13f68cef5b14c8753012ad3ed695689d">00202</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 &amp;<span class="keyword">set</span>){
190<a name="l00203"></a>00203                         <a class="code" href="classbdm_1_1KalmanCh.html#a13f68cef5b14c8753012ad3ed695689d" title="load basic elements of Kalman from structure">Kalman&lt;chmat&gt;::from_setting</a>(<span class="keyword">set</span>);
191<a name="l00204"></a>00204                         <a class="code" href="classbdm_1_1KalmanCh.html#ac983b1a2687312ab733d4c859cf83c1e" title="initialize internal parametetrs">initialize</a>();
192<a name="l00205"></a>00205                 }
193<a name="l00206"></a>00206 };
194<a name="l00207"></a>00207 <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);
195<a name="l00208"></a>00208
196<a name="l00214"></a><a class="code" href="classbdm_1_1EKFfull.html">00214</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>
197<a name="l00215"></a>00215 {
198<a name="l00216"></a>00216         <span class="keyword">protected</span>:
199<a name="l00218"></a><a class="code" href="classbdm_1_1EKFfull.html#aee5bfb3f09dfa994596c5bc68306f7d6">00218</a>                 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr&lt;diffbifn&gt;</a> <a class="code" href="classbdm_1_1EKFfull.html#aee5bfb3f09dfa994596c5bc68306f7d6" title="Internal Model f(x,u).">pfxu</a>;
200<a name="l00219"></a>00219
201<a name="l00221"></a><a class="code" href="classbdm_1_1EKFfull.html#a6432c675b1a9b83898b4ff19eab9b45c">00221</a>                 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr&lt;diffbifn&gt;</a> <a class="code" href="classbdm_1_1EKFfull.html#a6432c675b1a9b83898b4ff19eab9b45c" title="Observation Model h(x,u).">phxu</a>;
202<a name="l00222"></a>00222
203<a name="l00223"></a>00223         <span class="keyword">public</span>:
204<a name="l00225"></a>00225                 <a class="code" href="classbdm_1_1EKFfull.html#a6939c345389abb8b2481457b4cfe1165" title="Default constructor.">EKFfull</a> ();
205<a name="l00226"></a>00226
206<a name="l00228"></a>00228                 <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&lt;diffbifn&gt;</a> &amp;<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&lt;diffbifn&gt;</a> &amp;<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);
207<a name="l00229"></a>00229
208<a name="l00231"></a>00231                 <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 &amp;dt);
209<a name="l00233"></a><a class="code" href="classbdm_1_1EKFfull.html#a44986d667c19bcf7708495a4a5afc841">00233</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 &amp;mu0, <span class="keyword">const</span> mat &amp;P0) {
210<a name="l00234"></a>00234                         <a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>-&gt;set_parameters (mu0, P0);
211<a name="l00235"></a>00235                 };
212<a name="l00236"></a>00236                 <span class="keyword">const</span> mat _R() {
213<a name="l00237"></a>00237                         <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>-&gt;_R().to_mat();
214<a name="l00238"></a>00238                 }
215<a name="l00239"></a>00239 };
216<a name="l00240"></a>00240 <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);
217<a name="l00241"></a>00241
218<a name="l00242"></a>00242
219<a name="l00249"></a><a class="code" href="classbdm_1_1EKFCh.html">00249</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>
220<a name="l00250"></a>00250 {
221<a name="l00251"></a>00251         <span class="keyword">protected</span>:
222<a name="l00253"></a><a class="code" href="classbdm_1_1EKFCh.html#a5dc1964a6058057c9e17ea3c2f33bd2a">00253</a>                 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr&lt;diffbifn&gt;</a> <a class="code" href="classbdm_1_1EKFCh.html#a5dc1964a6058057c9e17ea3c2f33bd2a" title="Internal Model f(x,u).">pfxu</a>;
223<a name="l00254"></a>00254
224<a name="l00256"></a><a class="code" href="classbdm_1_1EKFCh.html#a27c29351b2cc8248c011af506208e8d1">00256</a>                 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr&lt;diffbifn&gt;</a> <a class="code" href="classbdm_1_1EKFCh.html#a27c29351b2cc8248c011af506208e8d1" title="Observation Model h(x,u).">phxu</a>;
225<a name="l00257"></a>00257         <span class="keyword">public</span>:
226<a name="l00259"></a><a class="code" href="classbdm_1_1EKFCh.html#a1d1d91400e3f177de9fe7962ea17adc4">00259</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>{
227<a name="l00260"></a>00260                         <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>;
228<a name="l00261"></a>00261                         E-&gt;<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>);
229<a name="l00262"></a>00262                         E-&gt;set_statistics (<a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>-&gt;_mu(), <a class="code" href="classbdm_1_1Kalman.html#ac83599f2541eb01de329f7b0bb35bf43" title="posterior">est</a>-&gt;_R());
230<a name="l00263"></a>00263                         <span class="keywordflow">return</span> E;
231<a name="l00264"></a>00264                 }
232<a name="l00266"></a>00266                 <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&lt;diffbifn&gt;</a> &amp;<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&lt;diffbifn&gt;</a> &amp;<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);
233<a name="l00267"></a>00267
234<a name="l00269"></a>00269                 <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 &amp;dt);
235<a name="l00270"></a>00270
236<a name="l00271"></a>00271                 <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 &amp;<span class="keyword">set</span>);
237<a name="l00272"></a>00272
238<a name="l00273"></a>00273                 <span class="comment">// TODO dodelat void to_setting( Setting &amp;set ) const;</span>
239<a name="l00274"></a>00274
240<a name="l00275"></a>00275 };
241<a name="l00276"></a>00276
242<a name="l00277"></a>00277 <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);
243<a name="l00278"></a>00278 SHAREDPTR (EKFCh);
244<a name="l00279"></a>00279
245<a name="l00280"></a>00280
246<a name="l00282"></a>00282
247<a name="l00290"></a><a class="code" href="classbdm_1_1MultiModel.html">00290</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>
248<a name="l00291"></a>00291 {
249<a name="l00292"></a>00292         <span class="keyword">protected</span>:
250<a name="l00294"></a><a class="code" href="classbdm_1_1MultiModel.html#a33de5d07ee774070632de8963b5d4c93">00294</a>                 Array&lt;EKFCh*&gt; <a class="code" href="classbdm_1_1MultiModel.html#a33de5d07ee774070632de8963b5d4c93" title="List of models between which we switch.">Models</a>;
251<a name="l00296"></a><a class="code" href="classbdm_1_1MultiModel.html#aef85ea61575bffa8beac8040869ee47a">00296</a>                 vec <a class="code" href="classbdm_1_1MultiModel.html#aef85ea61575bffa8beac8040869ee47a" title="vector of model weights">w</a>;
252<a name="l00298"></a><a class="code" href="classbdm_1_1MultiModel.html#a7b4012fc2208ce4ddd5c0d1fe69d7634">00298</a>                 vec <a class="code" href="classbdm_1_1MultiModel.html#a7b4012fc2208ce4ddd5c0d1fe69d7634" title="cache of model lls">_lls</a>;
253<a name="l00300"></a><a class="code" href="classbdm_1_1MultiModel.html#a9b56bcde4664bd53f8995d7ee7ed415c">00300</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>;
254<a name="l00302"></a><a class="code" href="classbdm_1_1MultiModel.html#ad665551d045b1a1055eeb9185558ff0b">00302</a>                 <a class="code" href="classbdm_1_1enorm.html">enorm&lt;chmat&gt;</a> <a class="code" href="classbdm_1_1MultiModel.html#ad665551d045b1a1055eeb9185558ff0b" title="internal statistics">est</a>;
255<a name="l00303"></a>00303         <span class="keyword">public</span>:
256<a name="l00304"></a>00304                 <span class="keywordtype">void</span> set_parameters (Array&lt;EKFCh*&gt; A, <span class="keywordtype">int</span> pol0 = 1) {
257<a name="l00305"></a>00305                         <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>
258<a name="l00306"></a>00306                         <a class="code" href="classbdm_1_1MultiModel.html#aef85ea61575bffa8beac8040869ee47a" title="vector of model weights">w</a>.set_length (A.length());
259<a name="l00307"></a>00307                         <a class="code" href="classbdm_1_1MultiModel.html#a7b4012fc2208ce4ddd5c0d1fe69d7634" title="cache of model lls">_lls</a>.set_length (A.length());
260<a name="l00308"></a>00308                         <a class="code" href="classbdm_1_1MultiModel.html#a9b56bcde4664bd53f8995d7ee7ed415c" title="type of switching policy [1=maximum,2=...]">policy</a> = pol0;
261<a name="l00309"></a>00309
262<a name="l00310"></a>00310                         <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">&quot;MM&quot;</span>, A (0)-&gt;<a class="code" href="classbdm_1_1MultiModel.html#a2af3f8dc10dfdae0ddc8160a9f36aaee" title="posterior density">posterior</a>().dimension(), 0));
263<a name="l00311"></a>00311                         <a class="code" href="classbdm_1_1MultiModel.html#ad665551d045b1a1055eeb9185558ff0b" title="internal statistics">est</a>.set_parameters (A (0)-&gt;<a class="code" href="classbdm_1_1MultiModel.html#a2af3f8dc10dfdae0ddc8160a9f36aaee" title="posterior density">posterior</a>().mean(), A (0)-&gt;<a class="code" href="classbdm_1_1MultiModel.html#a2af3f8dc10dfdae0ddc8160a9f36aaee" title="posterior density">posterior</a>()._R());
264<a name="l00312"></a>00312                 }
265<a name="l00313"></a><a class="code" href="classbdm_1_1MultiModel.html#aa915deeddb0e94c337d02ebc0abe535e">00313</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 &amp;dt) {
266<a name="l00314"></a>00314                         <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();
267<a name="l00315"></a>00315                         <span class="keywordtype">int</span> i;
268<a name="l00316"></a>00316                         <span class="keywordflow">for</span> (i = 0; i &lt; n; i++) {
269<a name="l00317"></a>00317                                 <a class="code" href="classbdm_1_1MultiModel.html#a33de5d07ee774070632de8963b5d4c93" title="List of models between which we switch.">Models</a> (i)-&gt;bayes (dt);
270<a name="l00318"></a>00318                                 <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)-&gt;_ll();
271<a name="l00319"></a>00319                         }
272<a name="l00320"></a>00320                         <span class="keywordtype">double</span> mlls = max (<a class="code" href="classbdm_1_1MultiModel.html#a7b4012fc2208ce4ddd5c0d1fe69d7634" title="cache of model lls">_lls</a>);
273<a name="l00321"></a>00321                         <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);
274<a name="l00322"></a>00322                         <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>
275<a name="l00323"></a>00323                         <span class="comment">//set statistics</span>
276<a name="l00324"></a>00324                         <span class="keywordflow">switch</span> (<a class="code" href="classbdm_1_1MultiModel.html#a9b56bcde4664bd53f8995d7ee7ed415c" title="type of switching policy [1=maximum,2=...]">policy</a>) {
277<a name="l00325"></a>00325                                 <span class="keywordflow">case</span> 1: {
278<a name="l00326"></a>00326                                         <span class="keywordtype">int</span> mi = max_index (<a class="code" href="classbdm_1_1MultiModel.html#aef85ea61575bffa8beac8040869ee47a" title="vector of model weights">w</a>);
279<a name="l00327"></a>00327                                         <span class="keyword">const</span> <a class="code" href="classbdm_1_1enorm.html">enorm&lt;chmat&gt;</a> &amp;st = <a class="code" href="classbdm_1_1MultiModel.html#a33de5d07ee774070632de8963b5d4c93" title="List of models between which we switch.">Models</a> (mi)-&gt;posterior() ;
280<a name="l00328"></a>00328                                         <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());
281<a name="l00329"></a>00329                                 }
282<a name="l00330"></a>00330                                 <span class="keywordflow">break</span>;
283<a name="l00331"></a>00331                                 <span class="keywordflow">default</span>:
284<a name="l00332"></a>00332                                         <a class="code" href="bdmerror_8h.html#a7c43f3a72afe68ab0c85663a1bb3521a" title="Unconditionally throw std::runtime_error.">bdm_error</a> (<span class="stringliteral">&quot;unknown policy&quot;</span>);
285<a name="l00333"></a>00333                         }
286<a name="l00334"></a>00334                         <span class="comment">// copy result to all models</span>
287<a name="l00335"></a>00335                         <span class="keywordflow">for</span> (i = 0; i &lt; n; i++) {
288<a name="l00336"></a>00336                                 <a class="code" href="classbdm_1_1MultiModel.html#a33de5d07ee774070632de8963b5d4c93" title="List of models between which we switch.">Models</a> (i)-&gt;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());
289<a name="l00337"></a>00337                         }
290<a name="l00338"></a>00338                 }
291<a name="l00340"></a><a class="code" href="classbdm_1_1MultiModel.html#a2af3f8dc10dfdae0ddc8160a9f36aaee">00340</a>                 <span class="keyword">const</span> <a class="code" href="classbdm_1_1enorm.html">enorm&lt;chmat&gt;</a>&amp; <a class="code" href="classbdm_1_1MultiModel.html#a2af3f8dc10dfdae0ddc8160a9f36aaee" title="posterior density">posterior</a>()<span class="keyword"> const </span>{
292<a name="l00341"></a>00341                         <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1MultiModel.html#ad665551d045b1a1055eeb9185558ff0b" title="internal statistics">est</a>;
293<a name="l00342"></a>00342                 }
294<a name="l00343"></a>00343
295<a name="l00344"></a>00344                 <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 &amp;<span class="keyword">set</span>);
296<a name="l00345"></a>00345
297<a name="l00346"></a>00346                 <span class="comment">// TODO dodelat void to_setting( Setting &amp;set ) const;</span>
298<a name="l00347"></a>00347
299<a name="l00348"></a>00348 };
300<a name="l00349"></a>00349
301<a name="l00350"></a>00350 <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);
302<a name="l00351"></a>00351 SHAREDPTR (MultiModel);
303<a name="l00352"></a>00352
304<a name="l00354"></a>00354
305<a name="l00362"></a>00362 <span class="comment">//template&lt;class sq_T&gt;</span>
306<a name="l00363"></a><a class="code" href="classbdm_1_1StateCanonical.html">00363</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>&lt;fsqmat&gt;{
307<a name="l00364"></a>00364         <span class="keyword">protected</span>:
308<a name="l00366"></a><a class="code" href="classbdm_1_1StateCanonical.html#a4e6a4771f9444f9b55ddc0b6e65cb5d1">00366</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 -&amp;gt;A">th2A</a>;
309<a name="l00368"></a><a class="code" href="classbdm_1_1StateCanonical.html#ab7c7aed9b66be7a24cc8ca43cea3123d">00368</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 -&amp;gt;C">th2C</a>;
310<a name="l00370"></a><a class="code" href="classbdm_1_1StateCanonical.html#adf03b4d4c48d94f2f0510e086c651c89">00370</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 -&amp;gt;D">th2D</a>;
311<a name="l00372"></a><a class="code" href="classbdm_1_1StateCanonical.html#a770b84ff706d4888236096a96ef51730">00372</a>                 vec <a class="code" href="classbdm_1_1StateCanonical.html#a770b84ff706d4888236096a96ef51730" title="cached first row of A">A1row</a>;
312<a name="l00374"></a><a class="code" href="classbdm_1_1StateCanonical.html#a665df0310519066e7adbbd490baf157d">00374</a>                 vec <a class="code" href="classbdm_1_1StateCanonical.html#a665df0310519066e7adbbd490baf157d" title="cached first row of C">C1row</a>;
313<a name="l00376"></a><a class="code" href="classbdm_1_1StateCanonical.html#a8e890a7aee1e6c1d06074f6604609eb6">00376</a>                 vec <a class="code" href="classbdm_1_1StateCanonical.html#a8e890a7aee1e6c1d06074f6604609eb6" title="cached first row of D">D1row</a>;
314<a name="l00377"></a>00377                 
315<a name="l00378"></a>00378         <span class="keyword">public</span>:
316<a name="l00380"></a><a class="code" href="classbdm_1_1StateCanonical.html#ad3ad57524c2af597b36ab1592fddc26c">00380</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&lt;fsqmat &gt;</a> &amp;ml){
317<a name="l00381"></a>00381         <span class="comment">//get ids of yrv                                </span>
318<a name="l00382"></a>00382                         <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &amp;yrv = ml._rv();
319<a name="l00383"></a>00383                         <span class="comment">//need to determine u_t - it is all in _rvc that is not in ml._rv()</span>
320<a name="l00384"></a>00384                         <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rgr0 = ml._rvc().remove_time();
321<a name="l00385"></a>00385                         <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);
322<a name="l00386"></a>00386                         
323<a name="l00387"></a>00387                         <span class="comment">//We can do only 1d now... :(</span>
324<a name="l00388"></a>00388                         <a class="code" href="bdmerror_8h.html#a89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</a>(yrv.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>()==1, <span class="stringliteral">&quot;Only for SISO so far...&quot;</span> );
325<a name="l00389"></a>00389
326<a name="l00390"></a>00390                         <span class="comment">// create names for </span>
327<a name="l00391"></a>00391                         <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> xrv; <span class="comment">//empty</span>
328<a name="l00392"></a>00392                         <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> Crv; <span class="comment">//empty</span>
329<a name="l00393"></a>00393                         <span class="keywordtype">int</span> td=ml._rvc().<a class="code" href="classbdm_1_1RV.html#a9a5c5aeeaf39299d07763377b05a8241" title="Minimum time-offset.">mint</a>();
330<a name="l00394"></a>00394                         <span class="comment">// assuming strictly proper function!!!</span>
331<a name="l00395"></a>00395                         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> t=-1;t&gt;=td;t--){
332<a name="l00396"></a>00396                                 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));
333<a name="l00397"></a>00397                                 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));
334<a name="l00398"></a>00398                         }
335<a name="l00399"></a>00399                         
336<a name="l00400"></a>00400                         this-&gt;<a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a> = xrv._dsize();
337<a name="l00401"></a>00401                         this-&gt;<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>();
338<a name="l00402"></a>00402                         this-&gt;<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>();
339<a name="l00403"></a>00403                         
340<a name="l00404"></a>00404                         <span class="comment">// get mapp</span>
341<a name="l00405"></a>00405                         <a class="code" href="classbdm_1_1StateCanonical.html#a4e6a4771f9444f9b55ddc0b6e65cb5d1" title="remember connection from theta -&amp;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());
342<a name="l00406"></a>00406                         <a class="code" href="classbdm_1_1StateCanonical.html#ab7c7aed9b66be7a24cc8ca43cea3123d" title="remember connection from theta -&amp;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());
343<a name="l00407"></a>00407                         <a class="code" href="classbdm_1_1StateCanonical.html#adf03b4d4c48d94f2f0510e086c651c89" title="remember connection from theta -&amp;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());
344<a name="l00408"></a>00408
345<a name="l00409"></a>00409                         <span class="comment">//set matrix sizes</span>
346<a name="l00410"></a>00410                         this-&gt;<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>);
347<a name="l00411"></a>00411                         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j=1; j&lt;<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>
348<a name="l00412"></a>00412                                 this-&gt;<a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a>=zeros(dimx,1);
349<a name="l00413"></a>00413                                 this-&gt;<a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a>(0) = 1.0;
350<a name="l00414"></a>00414                                 this-&gt;<a class="code" href="classbdm_1_1StateSpace.html#ac7ec82d2200c956cff6dff559bd32ff9" title="Matrix C.">C</a>=zeros(1,dimx);
351<a name="l00415"></a>00415                                 this-&gt;<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>());
352<a name="l00416"></a>00416                                 this-&gt;<a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f" title="Matrix Q in square-root form.">Q</a> = zeros(dimx,dimx);
353<a name="l00417"></a>00417                         <span class="comment">// R is set by update</span>
354<a name="l00418"></a>00418                         
355<a name="l00419"></a>00419                         <span class="comment">//set cache</span>
356<a name="l00420"></a>00420                         this-&gt;<a class="code" href="classbdm_1_1StateCanonical.html#a770b84ff706d4888236096a96ef51730" title="cached first row of A">A1row</a> = zeros(xrv._dsize());
357<a name="l00421"></a>00421                         this-&gt;<a class="code" href="classbdm_1_1StateCanonical.html#a665df0310519066e7adbbd490baf157d" title="cached first row of C">C1row</a> = zeros(xrv._dsize());
358<a name="l00422"></a>00422                         this-&gt;<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>());
359<a name="l00423"></a>00423                         
360<a name="l00424"></a>00424                         <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);
361<a name="l00425"></a>00425                         validate();
362<a name="l00426"></a>00426                 };
363<a name="l00428"></a><a class="code" href="classbdm_1_1StateCanonical.html#a25f55da4899112f210ade6d322c78b7e">00428</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&lt;fsqmat&gt;</a> &amp;ml){
364<a name="l00429"></a>00429                         
365<a name="l00430"></a>00430                         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>
366<a name="l00431"></a>00431                         
367<a name="l00432"></a>00432                         <a class="code" href="classbdm_1_1StateCanonical.html#a4e6a4771f9444f9b55ddc0b6e65cb5d1" title="remember connection from theta -&amp;gt;A">th2A</a>.<a class="code" href="classbdm_1_1datalink__part.html#aaba9b673ef82584e1bc06cc7a32b0a59" title="Get val for vector val_down from val of &amp;quot;Up&amp;quot;.">filldown</a>(theta,<a class="code" href="classbdm_1_1StateCanonical.html#a770b84ff706d4888236096a96ef51730" title="cached first row of A">A1row</a>);
368<a name="l00433"></a>00433                         <a class="code" href="classbdm_1_1StateCanonical.html#ab7c7aed9b66be7a24cc8ca43cea3123d" title="remember connection from theta -&amp;gt;C">th2C</a>.<a class="code" href="classbdm_1_1datalink__part.html#aaba9b673ef82584e1bc06cc7a32b0a59" title="Get val for vector val_down from val of &amp;quot;Up&amp;quot;.">filldown</a>(theta,<a class="code" href="classbdm_1_1StateCanonical.html#a665df0310519066e7adbbd490baf157d" title="cached first row of C">C1row</a>);
369<a name="l00434"></a>00434                         <a class="code" href="classbdm_1_1StateCanonical.html#adf03b4d4c48d94f2f0510e086c651c89" title="remember connection from theta -&amp;gt;D">th2D</a>.<a class="code" href="classbdm_1_1datalink__part.html#aaba9b673ef82584e1bc06cc7a32b0a59" title="Get val for vector val_down from val of &amp;quot;Up&amp;quot;.">filldown</a>(theta,<a class="code" href="classbdm_1_1StateCanonical.html#a8e890a7aee1e6c1d06074f6604609eb6" title="cached first row of D">D1row</a>);
370<a name="l00435"></a>00435
371<a name="l00436"></a>00436                         <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>();
372<a name="l00437"></a>00437
373<a name="l00438"></a>00438                         <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>);
374<a name="l00439"></a>00439                         <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>);
375<a name="l00440"></a>00440                         <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>);
376<a name="l00441"></a>00441                         
377<a name="l00442"></a>00442                 }
378<a name="l00443"></a>00443 };
379<a name="l00444"></a>00444
380<a name="l00446"></a>00446
381<a name="l00447"></a>00447 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt;
382<a name="l00448"></a>00448 <span class="keywordtype">void</span> StateSpace&lt;sq_T&gt;::set_parameters (<span class="keyword">const</span> mat &amp;A0, <span class="keyword">const</span>  mat &amp;B0, <span class="keyword">const</span>  mat &amp;C0, <span class="keyword">const</span>  mat &amp;D0, <span class="keyword">const</span>  sq_T &amp;Q0, <span class="keyword">const</span> sq_T &amp;R0)
383<a name="l00449"></a>00449 {
384<a name="l00450"></a>00450         <a class="code" href="classbdm_1_1StateSpace.html#ac3120f1c9cd7c3a0ba9944e4a2381f21" title="cache of rv.count()">dimx</a> = A0.rows();
385<a name="l00451"></a>00451         <a class="code" href="classbdm_1_1StateSpace.html#a95bb59ffbfd34c55d03d4d7a2a9b4faf" title="cache of rvu.count()">dimu</a> = B0.cols();
386<a name="l00452"></a>00452         <a class="code" href="classbdm_1_1StateSpace.html#a3b784d85ca911866225a79193ae1441f" title="cache of rvy.count()">dimy</a> = C0.rows();
387<a name="l00453"></a>00453
388<a name="l00454"></a>00454         <a class="code" href="classbdm_1_1StateSpace.html#ade7d828a8d06cbbd5ac45afeaf9f0c7b" title="Matrix A.">A</a> = A0;
389<a name="l00455"></a>00455         <a class="code" href="classbdm_1_1StateSpace.html#a0cdaa906550290b759a1584d02b3ca51" title="Matrix B.">B</a> = B0;
390<a name="l00456"></a>00456         <a class="code" href="classbdm_1_1StateSpace.html#ac7ec82d2200c956cff6dff559bd32ff9" title="Matrix C.">C</a> = C0;
391<a name="l00457"></a>00457         <a class="code" href="classbdm_1_1StateSpace.html#ad5769a41b34eb518716120cf04dbc23f" title="Matrix D.">D</a> = D0;
392<a name="l00458"></a>00458         <a class="code" href="classbdm_1_1StateSpace.html#a11dd3493d62ec9329860386adb3e6084" title="Matrix R in square-root form.">R</a> = R0;
393<a name="l00459"></a>00459         <a class="code" href="classbdm_1_1StateSpace.html#a66248c83836424f1cd7c1b5b9a92cf1f" title="Matrix Q in square-root form.">Q</a> = Q0;
394<a name="l00460"></a>00460         validate();
395<a name="l00461"></a>00461 }
396<a name="l00462"></a>00462
397<a name="l00463"></a>00463 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt;
398<a name="l00464"></a>00464 <span class="keywordtype">void</span> StateSpace&lt;sq_T&gt;::validate(){
399<a name="l00465"></a>00465         <a class="code" href="bdmerror_8h.html#a89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</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">&quot;KalmanFull: A is not square&quot;</span>);
400<a name="l00466"></a>00466         <a class="code" href="bdmerror_8h.html#a89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</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">&quot;KalmanFull: B is not compatible&quot;</span>);
401<a name="l00467"></a>00467         <a class="code" href="bdmerror_8h.html#a89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</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">&quot;KalmanFull: C is not square&quot;</span>);
402<a name="l00468"></a>00468         <a class="code" href="bdmerror_8h.html#a89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</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">&quot;KalmanFull: D is not compatible&quot;</span>);
403<a name="l00469"></a>00469         <a class="code" href="bdmerror_8h.html#a89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</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">&quot;KalmanFull: Q is not compatible&quot;</span>);
404<a name="l00470"></a>00470         <a class="code" href="bdmerror_8h.html#a89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</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">&quot;KalmanFull: R is not compatible&quot;</span>);
405<a name="l00471"></a>00471 }
406<a name="l00472"></a>00472
407<a name="l00473"></a>00473 }
408<a name="l00474"></a>00474 <span class="preprocessor">#endif // KF_H</span>
409<a name="l00475"></a>00475 <span class="preprocessor"></span>
410<a name="l00476"></a>00476
411</pre></div></div>
412<hr size="1"/><address style="text-align: right;"><small>Generated on Sun Sep 13 23:08:55 2009 for mixpp by&nbsp;
413<a href="http://www.doxygen.org/index.html">
414<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
415</body>
416</html>
Note: See TracBrowser for help on using the browser.