Changeset 7
- Timestamp:
- 01/22/08 15:13:55 (17 years ago)
- Files:
-
- 9 added
- 18 modified
Legend:
- Unmodified
- Added
- Removed
-
Makefile
r5 r7 2 2 CPPFLAGS=-g 3 3 4 all: test 04 all: testKF 5 5 6 6 test: test0 … … 8 8 9 9 clean: 10 rm *.o test0 10 rm *.o test0 testKF 11 11 12 12 test0: test0.cpp libBM.o libDC.o itpp_ext.o 13 13 testKF: testKF.o libKF.o libBM.o libDC.o itpp_ext.o 14 g++ -o $@ testKF.o libKF.o libBM.o libDC.o itpp_ext.o $(LDFLAGS) -
doc/html/annotated.html
r5 r7 16 16 <ul> 17 17 <li class="current"><a href="annotated.html"><span>Class List</span></a></li> 18 <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> 18 19 <li><a href="functions.html"><span>Class Members</span></a></li> 19 20 </ul> … … 23 24 <tr><td class="indexkey"><a class="el" href="classepdf.html">epdf</a></td><td class="indexvalue">Probability density function with numerical statistics, e.g. posterior density </td></tr> 24 25 <tr><td class="indexkey"><a class="el" href="classfnc.html">fnc</a></td><td class="indexvalue">Class representing function of variables </td></tr> 26 <tr><td class="indexkey"><a class="el" href="classKalman.html">Kalman</a></td><td class="indexvalue"><a class="el" href="classKalman.html" title="Kalman filter with covaraince matrices in square root form.">Kalman</a> filter with covaraince matrices in square root form </td></tr> 27 <tr><td class="indexkey"><a class="el" href="classKalmanFull.html">KalmanFull</a></td><td class="indexvalue">Basic <a class="el" href="classKalman.html" title="Kalman filter with covaraince matrices in square root form.">Kalman</a> filter with full matrices (education purpose only)! </td></tr> 25 28 <tr><td class="indexkey"><a class="el" href="classmpdf.html">mpdf</a></td><td class="indexvalue">Conditional probability density, e.g. modeling some dependencies </td></tr> 26 29 <tr><td class="indexkey"><a class="el" href="classRV.html">RV</a></td><td class="indexvalue">Class representing variables, most often random variables </td></tr> 27 30 </table> 28 <hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 18 09:57:402008 for mixpp by 31 <hr size="1"><address style="text-align: right;"><small>Generated on Sun Jan 20 12:47:33 2008 for mixpp by 29 32 <a href="http://www.doxygen.org/index.html"> 30 33 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address> -
doc/html/classfnc-members.html
r5 r7 16 16 <ul> 17 17 <li><a href="annotated.html"><span>Class List</span></a></li> 18 <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> 18 19 <li><a href="functions.html"><span>Class Members</span></a></li> 19 20 </ul> 20 21 </div> 21 22 <h1>fnc Member List</h1>This is the complete list of members for <a class="el" href="classfnc.html">fnc</a>, including all inherited members.<p><table> 22 </table><hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 18 09:57:402008 for mixpp by 23 </table><hr size="1"><address style="text-align: right;"><small>Generated on Sun Jan 20 12:47:34 2008 for mixpp by 23 24 <a href="http://www.doxygen.org/index.html"> 24 25 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address> -
doc/html/classfnc.html
r5 r7 16 16 <ul> 17 17 <li><a href="annotated.html"><span>Class List</span></a></li> 18 <li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li> 18 19 <li><a href="functions.html"><span>Class Members</span></a></li> 19 20 </ul> … … 32 33 Class representing function of variables. <hr>The documentation for this class was generated from the following file:<ul> 33 34 <li>work/mixpp/<a class="el" href="libBM_8h-source.html">libBM.h</a></ul> 34 <hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 18 09:57:402008 for mixpp by 35 <hr size="1"><address style="text-align: right;"><small>Generated on Sun Jan 20 12:47:34 2008 for mixpp by 35 36 <a href="http://www.doxygen.org/index.html"> 36 37 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address> -
doc/html/files.html
r5 r7 14 14 </div> 15 15 <h1>mixpp File List</h1>Here is a list of all documented files with brief descriptions:<table> 16 <tr><td class="indexkey">work/mixpp/<b>itpp_ext.h</b> <a href="itpp__ext_8h-source.html">[code]</a></td><td class="indexvalue"></td></tr> 16 17 <tr><td class="indexkey">work/mixpp/<a class="el" href="libBM_8h.html">libBM.h</a> <a href="libBM_8h-source.html">[code]</a></td><td class="indexvalue">Bayesian Models (bm) that use Bayes rule to learn from observations </td></tr> 17 <tr><td class="indexkey">work/mixpp/<a class="el" href="libDC_8cpp.html">libDC.cpp</a></td><td class="indexvalue">Matrices in decomposed forms (LDL', LU, UDU', etc) </td></tr> 18 <tr><td class="indexkey">work/mixpp/<a class="el" href="libDC_8h.html">libDC.h</a> <a href="libDC_8h-source.html">[code]</a></td><td class="indexvalue">Matrices in decomposed forms (LDL', LU, UDU', etc) </td></tr> 19 <tr><td class="indexkey">work/mixpp/<a class="el" href="libKF_8h.html">libKF.h</a> <a href="libKF_8h-source.html">[code]</a></td><td class="indexvalue">Bayesian Filtering for linear Gaussian models (<a class="el" href="classKalman.html" title="Kalman filter with covaraince matrices in square root form.">Kalman</a> Filter) and extensions </td></tr> 18 20 </table> 19 <hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 18 09:57:402008 for mixpp by 21 <hr size="1"><address style="text-align: right;"><small>Generated on Sun Jan 20 12:47:34 2008 for mixpp by 20 22 <a href="http://www.doxygen.org/index.html"> 21 23 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address> -
doc/html/index.html
r5 r7 15 15 <h1>mixpp Documentation</h1> 16 16 <p> 17 <h3 align="center">1 </h3><hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 18 09:57:402008 for mixpp by 17 <h3 align="center">1 </h3><hr size="1"><address style="text-align: right;"><small>Generated on Sun Jan 20 12:47:33 2008 for mixpp by 18 18 <a href="http://www.doxygen.org/index.html"> 19 19 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address> -
doc/html/libBM_8h-source.html
r5 r7 22 22 <a name="l00019"></a>00019 <span class="keyword">using namespace </span>itpp; 23 23 <a name="l00020"></a>00020 24 <a name="l00026"></a><a class="code" href="classRV.html">00026</a> <span class="keyword">class </span><a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> 25 <a name="l00027"></a>00027 { 26 <a name="l00028"></a>00028 <span class="keywordtype">int</span> len; 27 <a name="l00029"></a>00029 ivec ids; 28 <a name="l00030"></a>00030 ivec sizes; 29 <a name="l00031"></a>00031 ivec times; 30 <a name="l00032"></a>00032 ivec obs; 31 <a name="l00033"></a>00033 Array<std::string> names; 32 <a name="l00034"></a>00034 33 <a name="l00035"></a>00035 <span class="keyword">public</span>: 34 <a name="l00037"></a>00037 <a class="code" href="classRV.html#e46882dec2c30b12be282d34b03417b2" title="Full constructor which is called by the others.">RV</a> ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times, ivec in_obs ); 35 <a name="l00039"></a>00039 <a class="code" href="classRV.html#e46882dec2c30b12be282d34b03417b2" title="Full constructor which is called by the others.">RV</a> ( ivec ids ); 36 <a name="l00040"></a>00040 <span class="keyword">friend</span> std::ostream &operator<< ( std::ostream &os, <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv ); 37 <a name="l00041"></a>00041 }; 38 <a name="l00042"></a>00042 24 <a name="l00026"></a><a class="code" href="classRV.html">00026</a> <span class="keyword">class </span><a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> { 25 <a name="l00027"></a>00027 <span class="keywordtype">int</span> len; 26 <a name="l00028"></a>00028 ivec ids; 27 <a name="l00029"></a>00029 ivec sizes; 28 <a name="l00030"></a>00030 ivec times; 29 <a name="l00031"></a>00031 ivec obs; 30 <a name="l00032"></a>00032 Array<std::string> names; 31 <a name="l00033"></a>00033 32 <a name="l00034"></a>00034 <span class="keyword">private</span>: 33 <a name="l00035"></a>00035 <span class="keywordtype">void</span> init ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times, ivec in_obs ); 34 <a name="l00036"></a>00036 <span class="keyword">public</span>: 35 <a name="l00038"></a>00038 <a class="code" href="classRV.html#e46882dec2c30b12be282d34b03417b2" title="Full constructor which is called by the others.">RV</a> ( ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times, ivec in_obs ); 36 <a name="l00040"></a>00040 <a class="code" href="classRV.html#e46882dec2c30b12be282d34b03417b2" title="Full constructor which is called by the others.">RV</a> ( ivec ids ); 37 <a name="l00042"></a>00042 <span class="keyword">friend</span> std::ostream &<a class="code" href="classRV.html#cad6f15535d10437f6690cb4492176a8" title="Printing output e.g. for debugging.">operator<< </a>( std::ostream &os, <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv ); 39 38 <a name="l00043"></a>00043 40 <a name="l00044"></a>00044 41 <a name="l00045"></a>00045 42 <a name="l00047"></a><a class="code" href="classfnc.html">00047</a> <span class="keyword">class </span><a class="code" href="classfnc.html" title="Class representing function of variables.">fnc</a> 43 <a name="l00048"></a>00048 { 44 <a name="l00049"></a>00049 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rv; 45 <a name="l00050"></a>00050 }; 46 <a name="l00051"></a>00051 47 <a name="l00053"></a><a class="code" href="classBM.html">00053</a> <span class="keyword">class </span><a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> 48 <a name="l00054"></a>00054 { 49 <a name="l00055"></a>00055 <span class="keyword">public</span>: 50 <a name="l00057"></a>00057 <span class="keywordtype">void</span> <a class="code" href="classBM.html#c1b46da4abb4302ed57858558c90d641" title="Incremental Bayes rule.">bayes</a> ( vec dt ); 51 <a name="l00059"></a>00059 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classBM.html#c1b46da4abb4302ed57858558c90d641" title="Incremental Bayes rule.">bayes</a> ( mat Dt ); 52 <a name="l00060"></a>00060 }; 53 <a name="l00061"></a>00061 54 <a name="l00063"></a><a class="code" href="classepdf.html">00063</a> <span class="keyword">class </span><a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> 55 <a name="l00064"></a>00064 { 56 <a name="l00065"></a>00065 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rv; 57 <a name="l00066"></a>00066 <span class="keyword">public</span>: 58 <a name="l00068"></a>00068 <span class="keyword">virtual</span> vec <a class="code" href="classepdf.html#545555f9d561555603911f7d3989611f" title="Returns the required moment of the epdf.">moment</a> ( <span class="keyword">const</span> <span class="keywordtype">int</span> order = 1 ); 59 <a name="l00069"></a>00069 }; 60 <a name="l00070"></a>00070 61 <a name="l00072"></a><a class="code" href="classmpdf.html">00072</a> <span class="keyword">class </span><a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> 62 <a name="l00073"></a>00073 { 63 <a name="l00075"></a>00075 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rv; 64 <a name="l00077"></a>00077 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvc; 65 <a name="l00078"></a>00078 <span class="keyword">public</span>: 66 <a name="l00079"></a>00079 67 <a name="l00081"></a>00081 <span class="keyword">virtual</span> <a class="code" href="classfnc.html" title="Class representing function of variables.">fnc</a> <a class="code" href="classmpdf.html#0863640c439869e8fbbbeb2bd8ea1fc0" title="Returns the required moment of the epdf.">moment</a> ( <span class="keyword">const</span> <span class="keywordtype">int</span> order = 1 ); 39 <a name="l00045"></a>00045 ivec <a class="code" href="classRV.html#45b869bced40dc3fa0df584aaf8228c0" title="Find indexes of another rv in self.">rvfind</a>(<a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rv2); 40 <a name="l00047"></a>00047 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classRV.html#f47ab0015ebac822da3b2e00f42a8fc6" title="Add (concat) another variable to the current one.">rvadd</a>(<a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rv2); 41 <a name="l00049"></a>00049 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classRV.html#269023ac4d41b21c4e1f7f17db1603b9" title="Subtract another variable from the current one.">rvsubt</a>(<a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rv2); 42 <a name="l00051"></a>00051 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classRV.html#70a53f2bc37929bae899b0b24cda9d8e" title="Select only variables at indeces ind.">rvsubselect</a>(ivec ind); 43 <a name="l00053"></a>00053 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classRV.html#28bbcb8873bafdac317bafb7b481cc45" title="Select only variables at indeces ind.">operator()</a>(ivec ind); 44 <a name="l00054"></a>00054 }; 45 <a name="l00055"></a>00055 46 <a name="l00056"></a>00056 47 <a name="l00057"></a>00057 48 <a name="l00058"></a>00058 49 <a name="l00060"></a><a class="code" href="classfnc.html">00060</a> <span class="keyword">class </span><a class="code" href="classfnc.html" title="Class representing function of variables.">fnc</a> { 50 <a name="l00061"></a>00061 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rv; 51 <a name="l00062"></a>00062 }; 52 <a name="l00063"></a>00063 53 <a name="l00065"></a><a class="code" href="classBM.html">00065</a> <span class="keyword">class </span><a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> { 54 <a name="l00066"></a>00066 <span class="keyword">public</span>: 55 <a name="l00071"></a>00071 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classBM.html#c52edf4ad6e1dff9bf64b9e1e0cfb1f0" title="Incremental Bayes rule.">bayes</a> ( <span class="keyword">const</span> vec &dt, <span class="keywordtype">bool</span> evall=<span class="keyword">true</span> ) = 0; 56 <a name="l00073"></a>00073 <span class="keywordtype">void</span> <a class="code" href="classBM.html#c52edf4ad6e1dff9bf64b9e1e0cfb1f0" title="Incremental Bayes rule.">bayes</a> ( mat Dt ); 57 <a name="l00074"></a>00074 }; 58 <a name="l00075"></a>00075 59 <a name="l00077"></a><a class="code" href="classepdf.html">00077</a> <span class="keyword">class </span><a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> { 60 <a name="l00078"></a>00078 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rv; 61 <a name="l00079"></a>00079 <span class="keyword">public</span>: 62 <a name="l00081"></a>00081 <span class="keyword">virtual</span> vec <a class="code" href="classepdf.html#545555f9d561555603911f7d3989611f" title="Returns the required moment of the epdf.">moment</a> ( <span class="keyword">const</span> <span class="keywordtype">int</span> order = 1 ); 68 63 <a name="l00082"></a>00082 }; 69 64 <a name="l00083"></a>00083 70 <a name="l00084"></a>00084 <span class="preprocessor">#endif // BM_H</span> 71 </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 18 09:57:40 2008 for mixpp by 65 <a name="l00085"></a><a class="code" href="classmpdf.html">00085</a> <span class="keyword">class </span><a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> { 66 <a name="l00087"></a>00087 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rv; 67 <a name="l00089"></a>00089 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvc; 68 <a name="l00090"></a>00090 <span class="keyword">public</span>: 69 <a name="l00091"></a>00091 70 <a name="l00093"></a>00093 <span class="keyword">virtual</span> <a class="code" href="classfnc.html" title="Class representing function of variables.">fnc</a> <a class="code" href="classmpdf.html#0863640c439869e8fbbbeb2bd8ea1fc0" title="Returns the required moment of the epdf.">moment</a> ( <span class="keyword">const</span> <span class="keywordtype">int</span> order = 1 ); 71 <a name="l00094"></a>00094 }; 72 <a name="l00095"></a>00095 73 <a name="l00096"></a>00096 <span class="preprocessor">#endif // BM_H</span> 74 </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Sun Jan 20 12:47:33 2008 for mixpp by 72 75 <a href="http://www.doxygen.org/index.html"> 73 76 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address> -
doc/html/libBM_8h.html
r5 r7 42 42 <dl class="author" compact><dt><b>Author:</b></dt><dd>Vaclav Smidl.</dd></dl> 43 43 ----------------------------------- BDM++ - C++ library for Bayesian Decision Making under Uncertainty<p> 44 Using IT++ for numerical operations ----------------------------------- <hr size="1"><address style="text-align: right;"><small>Generated on Fri Jan 18 09:57:402008 for mixpp by 44 Using IT++ for numerical operations ----------------------------------- <hr size="1"><address style="text-align: right;"><small>Generated on Sun Jan 20 12:47:33 2008 for mixpp by 45 45 <a href="http://www.doxygen.org/index.html"> 46 46 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address> -
doc/latex/annotated.tex
r4 r7 4 4 \item\contentsline{section}{{\bf epdf} (Probability density function with numerical statistics, e.g. posterior density )}{\pageref{classepdf}}{} 5 5 \item\contentsline{section}{{\bf fnc} (Class representing function of variables )}{\pageref{classfnc}}{} 6 \item\contentsline{section}{{\bf Kalman} (\doxyref{Kalman}{p.}{classKalman} filter with covaraince matrices in square root form )}{\pageref{classKalman}}{} 7 \item\contentsline{section}{{\bf KalmanFull} (Basic \doxyref{Kalman}{p.}{classKalman} filter with full matrices (education purpose only)! )}{\pageref{classKalmanFull}}{} 6 8 \item\contentsline{section}{{\bf mpdf} (Conditional probability density, e.g. modeling some dependencies )}{\pageref{classmpdf}}{} 7 9 \item\contentsline{section}{{\bf RV} (Class representing variables, most often random variables )}{\pageref{classRV}}{} -
doc/latex/doxygen.sty
r5 r7 11 11 \rhead[\fancyplain{}{\bfseries\leftmark}] 12 12 {\fancyplain{}{\bfseries\thepage}} 13 \rfoot[\fancyplain{}{\bfseries\scriptsize Generated on Fri Jan 18 09:57:402008 for mixpp by Doxygen }]{}14 \lfoot[]{\fancyplain{}{\bfseries\scriptsize Generated on Fri Jan 18 09:57:402008 for mixpp by Doxygen }}13 \rfoot[\fancyplain{}{\bfseries\scriptsize Generated on Sun Jan 20 12:47:33 2008 for mixpp by Doxygen }]{} 14 \lfoot[]{\fancyplain{}{\bfseries\scriptsize Generated on Sun Jan 20 12:47:33 2008 for mixpp by Doxygen }} 15 15 \cfoot{} 16 16 \newenvironment{Code} -
doc/latex/files.tex
r3 r7 1 1 \section{mixpp File List} 2 2 Here is a list of all documented files with brief descriptions:\begin{CompactList} 3 \item\contentsline{section}{work/mixpp/\textbf{itpp\_\-ext.h} }{\pageref{itpp__ext_8h}}{} 3 4 \item\contentsline{section}{work/mixpp/{\bf libBM.h} (Bayesian Models (bm) that use Bayes rule to learn from observations )}{\pageref{libBM_8h}}{} 4 \item\contentsline{section}{work/mixpp/{\bf libDC.cpp} (Matrices in decomposed forms (LDL', LU, UDU', etc) )}{\pageref{libDC_8cpp}}{} 5 \item\contentsline{section}{work/mixpp/{\bf libDC.h} (Matrices in decomposed forms (LDL', LU, UDU', etc) )}{\pageref{libDC_8h}}{} 6 \item\contentsline{section}{work/mixpp/{\bf libKF.h} (Bayesian Filtering for linear Gaussian models (\doxyref{Kalman}{p.}{classKalman} Filter) and extensions )}{\pageref{libKF_8h}}{} 5 7 \end{CompactList} -
doc/latex/refman.tex
r5 r7 21 21 {\large Generated by Doxygen 1.5.3}\\ 22 22 \vspace*{0.5cm} 23 {\small Fri Jan 18 09:57:402008}\\23 {\small Sun Jan 20 12:47:33 2008}\\ 24 24 \end{center} 25 25 \end{titlepage} … … 29 29 \clearemptydoublepage 30 30 \pagenumbering{arabic} 31 \chapter{mixpp Hierarchical Index} 32 \input{hierarchy} 31 33 \chapter{mixpp Class Index} 32 34 \input{annotated} … … 37 39 \include{classepdf} 38 40 \include{classfnc} 41 \include{classKalman} 42 \include{classKalmanFull} 39 43 \include{classmpdf} 40 44 \include{classRV} 41 45 \chapter{mixpp File Documentation} 42 46 \input{libBM_8h} 43 \include{libDC_8cpp} 47 \include{libDC_8h} 48 \include{libKF_8h} 44 49 \printindex 45 50 \end{document} -
libBM.h
r5 r7 65 65 class BM { 66 66 public: 67 //! Incremental Bayes rule 68 void bayes ( vec dt ); 67 //!Logarithm of marginalized data likelihood. 68 double ll; 69 70 /*! \brief Incremental Bayes rule 71 @param dt vector of input data 72 @param evall If true, the filter will compute likelihood of the data record and store it in \c ll 73 */ 74 virtual void bayes ( const vec &dt, bool evall=true ) = 0; 69 75 //! Batch Bayes rule (columns of Dt are observations) 70 v irtual void bayes ( mat Dt );76 void bayes ( mat Dt ); 71 77 }; 72 78 -
libDC.cpp
r5 r7 1 /*!2 * \file3 * \brief Matrices in decomposed forms (LDL', LU, UDU', etc).4 * \author Vaclav Smidl.5 *6 * -----------------------------------7 * BDM++ - C++ library for Bayesian Decision Making under Uncertainty8 *9 * Using IT++ for numerical operations10 * -----------------------------------11 */12 13 1 #include <itpp/itbase.h> 2 #include "libDC.h" 14 3 15 4 using namespace itpp; 16 5 17 class LD 18 { 19 public: 20 21 /** 22 * Perfroms a dyadic update $V = V + w v v'$ 23 * @param v Vector forming the dyad to be added 24 * @param w weight of the updating dysad 25 */ 26 void ldupdt ( vec v, double w = 1.0 ); 27 28 //! Construct by copy of L and D. 29 LD ( mat L, vec D ); 30 //! Construct by decomposition of full matrix V. 31 LD ( mat V ); 32 33 protected: 34 vec D; 35 mat L; 36 37 }; 38 39 LD::LD ( const mat exL, const vec exD ) 40 { 6 using std::endl; 7 8 //! Auxiliary function dydr; dyadic reduction 9 void dydr( double * r, double *f, double *Dr, double *Df, double *R, int jl, int jh, double *kr, int m, int mx ); 10 11 //! Auxiliary function ltuinv; inversion of a triangular matrix; 12 //TODO can be done via: dtrtri.f from lapack 13 mat ltuinv( const mat &L ); 14 15 16 17 ldmat::ldmat( const mat &exL, const vec &exD ) { 41 18 D = exD; 42 19 L = exL; 43 20 } 44 21 45 LD::LD ( const mat V ) 22 ldmat::ldmat() { 23 vec D ; 24 mat L; 25 } 26 27 ldmat::ldmat( const mat V ) { 28 //TODO check if correct!! Based on heuristic observation of lu() 29 30 int dim = V.cols(); 31 it_assert_debug( dim == V.rows(),"ldmat::ldmat matrix V is not square!" ); 32 33 mat U( dim,dim ); 34 35 L = V; //Allocate space for L 36 ivec p = ivec( dim ); //not clear why? 37 38 lu( V,L,U,p ); 39 40 //Now, if V is symmetric, L is what we seek and D is on diagonal of U 41 D = diag( U ); 42 43 //check if V was symmetric 44 //TODO How? norm of L-U'? 45 //it_assert_debug(); 46 } 47 48 void ldmat::opupdt( const vec &v, double w ) { 49 int dim = D.length(); 50 double kr; 51 vec r = v; 52 //beware! it is potentionally dangerous, if ITpp change _behaviour of _data()! 53 double *Lraw = L._data(); 54 double *Draw = D._data(); 55 double *rraw = r._data(); 56 57 it_assert_debug( v.length() == dim, "LD::ldupdt vector v is not compatible with this ld." ); 58 59 for ( int i = dim - 1; i >= 0; i-- ) { 60 dydr( rraw, Lraw + i, &w, Draw + i, rraw + i, 0, i, &kr, 1, dim ); 61 } 62 } 63 64 std::ostream &operator<< ( std::ostream &os, sqmat &sq ) { 65 os << sq.to_mat() << endl; 66 } 67 68 mat ldmat::to_mat() { 69 int dim = D.length(); 70 mat V( dim, dim ); 71 double sum; 72 int r, c, cc; 73 74 for ( r = 0;r < dim;r++ ) { //row cycle 75 for ( c = r;c < dim;c++ ) { 76 //column cycle, using symmetricity => c=r! 77 sum = 0.0; 78 for ( cc = c;cc < dim;cc++ ) { //cycle over the remaining part of the vector 79 sum += L( cc, r ) * D( cc ) * L( cc, c ); 80 //here L(cc,r) = L(r,cc)'; 81 } 82 V( r, c ) = sum; 83 // symmetricity 84 if ( r != c ) {V( c, r ) = sum;}; 85 } 86 } 87 return V; 88 } 89 90 91 void ldmat::add( const ldmat &ld2, double w ) { 92 int dim = D.length(); 93 94 it_assert_debug( ld2.D.length() == dim, "LD.add() incompatible sizes of LDs;" ); 95 96 //Fixme can be done more efficiently either via dydr or ldform 97 for ( int r = 0; r < dim; r++ ) { 98 // Add columns of ld2.L' (i.e. rows of ld2.L) as dyads weighted by ld2.D 99 this->opupdt( ld2.L.get_row( r ), w*ld2.D( r ) ); 100 } 101 } 102 103 void ldmat::clear(){L.clear(); for ( int i=0;i<L.cols();i++ ){L( i,i )=1;}; D.clear();} 104 105 void ldmat::inv( ldmat &Inv ) { 106 int dim = D.length(); 107 Inv.clear(); //Inv = zero in LD 108 mat U = ltuinv( L ); 109 110 //Fixme can be done more efficiently either via dydr or ldform 111 for ( int r = 0; r < dim; r++ ) { 112 // Add columns of U as dyads weighted by 1/D 113 Inv.opupdt( U.get_col( r ), 1.0 / D( r ) ); 114 } 115 } 116 117 void ldmat::mult_qform( const mat &C, bool trans ) { 118 119 //TODO better 120 121 it_assert_debug( C.cols()==L.cols(), "ldmat::mult_qform wrong input argument" ); 122 mat Ct=C; 123 124 if ( trans==false ) { // return C*this*C' 125 Ct *= this->to_mat(); 126 Ct *= C.transpose(); 127 } else { // return C'*this*C 128 Ct = C.transpose(); 129 Ct *= this->to_mat(); 130 Ct *= C; 131 } 132 133 ldmat Lnew=ldmat( Ct ); 134 L = Lnew.L; 135 D = Lnew.D; 136 } 137 138 double ldmat::logdet() { 139 double ldet = 0.0; 140 int i; 141 // sum logarithms of diagobal elements 142 for ( i=0; i<D.length(); i++ ){ldet+=log( D( i ) );}; 143 } 144 145 double ldmat::qform( vec &v ) { 146 double x = 0.0, sum; 147 int i,j; 148 149 for ( i=0; i<D.length(); i++ ) { //rows of L 150 sum = 0.0; 151 for ( j=0; j<=i; j++ ){sum+=L( i,j )*v( j );} 152 x +=D( i )*sum*sum; 153 }; 154 return x; 155 } 156 157 ldmat& ldmat::operator *= (double x){ 158 int i; 159 for(i=0;i<D.length();i++){D(i)*=x;}; 160 } 161 162 163 //////// Auxiliary Functions 164 165 mat ltuinv( const mat &L ) { 166 int dim = L.cols(); 167 mat Il = eye( dim ); 168 int i, j, k, m; 169 double s; 170 171 //Fixme blind transcription of ltuinv.m 172 for ( k = 1; k < ( dim );k++ ) { 173 for ( i = 0; i < ( dim - k );i++ ) { 174 j = i + k; //change in .m 1+1=2, here 0+0+1=1 175 s = L( j, i ); 176 for ( m = i + 1; m < ( j - 1 ); m++ ) { 177 s += L( m, i ) * Il( j, m ); 178 } 179 Il( j, i ) = -s; 180 } 181 } 182 183 return Il; 184 } 185 186 void dydr( double * r, double *f, double *Dr, double *Df, double *R, int jl, int jh, double *kr, int m, int mx ) 187 /******************************************************************** 188 189 dydr = dyadic reduction, performs transformation of sum of 190 2 dyads r*Dr*r'+ f*Df*f' so that the element of r pointed 191 by R is zeroed. This version allows Dr to be NEGATIVE. Hence the name negdydr or dydr_withneg. 192 193 Parameters : 194 r ... pointer to reduced dyad 195 f ... pointer to reducing dyad 196 Dr .. pointer to the weight of reduced dyad 197 Df .. pointer to the weight of reducing dyad 198 R ... pointer to the element of r, which is to be reduced to 199 zero; the corresponding element of f is assumed to be 1. 200 jl .. lower index of the range within which the dyads are 201 modified 202 ju .. upper index of the range within which the dyads are 203 modified 204 kr .. pointer to the coefficient used in the transformation of r 205 rnew = r + kr*f 206 m .. number of rows of modified matrix (part of which is r) 207 Remark : Constant mzero means machine zero and should be modified 208 according to the precision of particular machine 209 210 V. Peterka 17-7-89 211 212 Added: 213 mx .. number of rows of modified matrix (part of which is f) -PN 214 215 ********************************************************************/ 46 216 { 47 ; //not implemneted yet 48 } 49 50 void LD::ldupdt ( vec v, double w ) 51 { 52 printf ( "not implemented" ); //TODO: VS 53 } 217 int j, jm; 218 double kD, r0; 219 double mzero = 2.2e-16; 220 double threshold = 1e-4; 221 222 if ( fabs( *Dr ) < mzero ) *Dr = 0; 223 r0 = *R; 224 *R = 0.0; 225 kD = *Df; 226 *kr = r0 * *Dr; 227 *Df = kD + r0 * ( *kr ); 228 if ( *Df > mzero ) { 229 kD /= *Df; 230 *kr /= *Df; 231 } else { 232 kD = 1.0; 233 *kr = 0.0; 234 if ( *Df < -threshold ) it_warning( "Problem in dydr: subraction of dyad results in negative definitness. Likely mistake in calling function." ); 235 *Df = 0.0; 236 } 237 *Dr *= kD; 238 jm = mx * jl; 239 for ( j = m * jl; j < m*jh; j += m ) { 240 r[j] -= r0 * f[jm]; 241 f[jm] += *kr * r[j]; 242 jm += mx; 243 } 244 } 245 246 -
mixpp.kdevelop
r6 r7 11 11 <projectdirectory>.</projectdirectory> 12 12 <absoluteprojectpath>false</absoluteprojectpath> 13 <description/> 14 <defaultencoding/> 13 <description></description> 14 <defaultencoding></defaultencoding> 15 <versioncontrol>kdevsubversion</versioncontrol> 15 16 </general> 16 17 <kdevcustomproject> 17 18 <run> 18 19 <directoryradio>executable</directoryradio> 19 <mainprogram> /home/smidl/work/mixpp/test0</mainprogram>20 <programargs />21 <globaldebugarguments />20 <mainprogram>./testKF</mainprogram> 21 <programargs></programargs> 22 <globaldebugarguments></globaldebugarguments> 22 23 <globalcwd>/home/smidl/work/mixpp</globalcwd> 23 24 <useglobalprogram>false</useglobalprogram> … … 47 48 <path>lib0a.cpp</path> 48 49 <path>lib0.c</path> 50 <path>extern</path> 51 <path>extern/lt_ldfil</path> 52 <path>extern/lt_ldfil/ldredneg.c</path> 53 <path>extern/lt_ldfil/negdydr.c</path> 49 54 </blacklist> 50 55 <build> 51 56 <buildtool>make</buildtool> 52 <builddir />57 <builddir></builddir> 53 58 </build> 54 59 <other> 55 60 <prio>0</prio> 56 <otherbin />57 <defaulttarget />58 <otheroptions />61 <otherbin></otherbin> 62 <defaulttarget></defaulttarget> 63 <otheroptions></otheroptions> 59 64 <selectedenvironment>default</selectedenvironment> 60 65 <environments> … … 67 72 <prio>0</prio> 68 73 <dontact>false</dontact> 69 <makebin />70 <defaulttarget />71 <makeoptions />74 <makebin></makebin> 75 <defaulttarget></defaulttarget> 76 <makeoptions></makeoptions> 72 77 <selectedenvironment>default</selectedenvironment> 73 78 <environments> … … 78 83 <kdevdebugger> 79 84 <general> 80 <dbgshell />81 <gdbpath />82 <configGdbScript />83 <runShellScript />84 <runGdbScript />85 <dbgshell></dbgshell> 86 <gdbpath></gdbpath> 87 <configGdbScript></configGdbScript> 88 <runShellScript></runShellScript> 89 <runGdbScript></runGdbScript> 85 90 <breakonloadinglibs>true</breakonloadinglibs> 86 91 <separatetty>false</separatetty> … … 183 188 </codecompletion> 184 189 <creategettersetter> 185 <prefixGet />190 <prefixGet></prefixGet> 186 191 <prefixSet>set</prefixSet> 187 192 <prefixVariable>m_,_</prefixVariable> … … 195 200 <orientation>Vertical</orientation> 196 201 </splitheadersource> 197 <references/>198 202 </kdevcppsupport> 199 203 <cppsupportpart> … … 211 215 </kdevdocumentation> 212 216 <kdevfileview> 213 <groups> 214 <hidenonprojectfiles>false</hidenonprojectfiles> 215 <hidenonlocation>false</hidenonlocation> 216 </groups> 217 <tree> 218 <hidepatterns>*.o,*.lo,CVS</hidepatterns> 219 <hidenonprojectfiles>false</hidenonprojectfiles> 220 </tree> 217 <groups/> 221 218 </kdevfileview> 219 <ctagspart> 220 <customArguments></customArguments> 221 <customTagfilePath>/home/smidl/work/mixpp/tags</customTagfilePath> 222 <activeTagsFiles/> 223 </ctagspart> 222 224 </kdevelop> -
mixpp.kdevelop.filelist
r5 r7 6 6 itpp_ext.cpp 7 7 itpp_ext.h 8 doc 9 doc/latex 10 doc/latex/Makefile 8 11 libBM.cpp 9 12 libBM.h -
mixpp.tag
r4 r7 12 12 </compound> 13 13 <compound kind="file"> 14 <name>libDC. cpp</name>14 <name>libDC.h</name> 15 15 <path>/home/smidl/work/mixpp/</path> 16 <filename>libDC_8 cpp</filename>16 <filename>libDC_8h</filename> 17 17 <class kind="class">LD</class> 18 </compound> 19 <compound kind="file"> 20 <name>libKF.h</name> 21 <path>/home/smidl/work/mixpp/</path> 22 <filename>libKF_8h</filename> 23 <includes id="libBM_8h" name="libBM.h" local="yes" imported="no">libBM.h</includes> 24 <includes id="libDC_8h" name="libDC.h" local="yes" imported="no">libDC.h</includes> 25 <class kind="class">KalmanFull</class> 26 <class kind="class">Kalman</class> 18 27 </compound> 19 28 <compound kind="class"> 20 29 <name>BM</name> 21 30 <filename>classBM.html</filename> 31 <member kind="function" virtualness="pure"> 32 <type>virtual void</type> 33 <name>bayes</name> 34 <anchorfile>classBM.html</anchorfile> 35 <anchor>c52edf4ad6e1dff9bf64b9e1e0cfb1f0</anchor> 36 <arglist>(const vec &dt, bool evall=true)=0</arglist> 37 </member> 22 38 <member kind="function"> 23 39 <type>void</type> 24 40 <name>bayes</name> 25 41 <anchorfile>classBM.html</anchorfile> 26 <anchor>c1b46da4abb4302ed57858558c90d641</anchor> 27 <arglist>(vec dt)</arglist> 28 </member> 29 <member kind="function" virtualness="virtual"> 30 <type>virtual void</type> 31 <name>bayes</name> 32 <anchorfile>classBM.html</anchorfile> 33 <anchor>2f7092405a831a6e84de32209037aeac</anchor> 42 <anchor>87b07867fd4c133aa89a18543f68d9f9</anchor> 34 43 <arglist>(mat Dt)</arglist> 35 44 </member> … … 51 60 </compound> 52 61 <compound kind="class"> 62 <name>Kalman</name> 63 <filename>classKalman.html</filename> 64 <base>BM</base> 65 <member kind="function"> 66 <type></type> 67 <name>Kalman</name> 68 <anchorfile>classKalman.html</anchorfile> 69 <anchor>04e31a807dae4dea4aef3f0a47ec191a</anchor> 70 <arglist>(mat A, mat B, mat C, mat D, mat R, mat Q, mat P0, vec mu0)</arglist> 71 </member> 72 <member kind="function"> 73 <type>void</type> 74 <name>bayes</name> 75 <anchorfile>classKalman.html</anchorfile> 76 <anchor>398ecc4378c139ef3dabdd210452fd54</anchor> 77 <arglist>(const vec &dt, bool evalll=true)</arglist> 78 </member> 79 <member kind="variable"> 80 <type>vec</type> 81 <name>mu</name> 82 <anchorfile>classKalman.html</anchorfile> 83 <anchor>950f5196f688fc0e4e58640d07b11e5d</anchor> 84 <arglist></arglist> 85 </member> 86 <member kind="variable"> 87 <type>mat</type> 88 <name>P</name> 89 <anchorfile>classKalman.html</anchorfile> 90 <anchor>4b09f16863a10e0fa17f5106432c6da4</anchor> 91 <arglist></arglist> 92 </member> 93 <member kind="friend"> 94 <type>friend std::ostream &</type> 95 <name>operator<<</name> 96 <anchorfile>classKalman.html</anchorfile> 97 <anchor>86ba216243ed95bb46d80d88775d16af</anchor> 98 <arglist>(std::ostream &os, const KalmanFull &kf)</arglist> 99 </member> 100 </compound> 101 <compound kind="class"> 102 <name>KalmanFull</name> 103 <filename>classKalmanFull.html</filename> 104 <base>BM</base> 105 <member kind="function"> 106 <type></type> 107 <name>KalmanFull</name> 108 <anchorfile>classKalmanFull.html</anchorfile> 109 <anchor>7197ab6e7380790006394eabd3b97043</anchor> 110 <arglist>(mat A, mat B, mat C, mat D, mat R, mat Q, mat P0, vec mu0)</arglist> 111 </member> 112 <member kind="function"> 113 <type>void</type> 114 <name>bayes</name> 115 <anchorfile>classKalmanFull.html</anchorfile> 116 <anchor>13a041cd98ff157703766be275a657bb</anchor> 117 <arglist>(const vec &dt)</arglist> 118 </member> 119 <member kind="variable"> 120 <type>vec</type> 121 <name>mu</name> 122 <anchorfile>classKalmanFull.html</anchorfile> 123 <anchor>fb5aec635e2720cc5ac31bc01c18a68a</anchor> 124 <arglist></arglist> 125 </member> 126 <member kind="variable"> 127 <type>mat</type> 128 <name>P</name> 129 <anchorfile>classKalmanFull.html</anchorfile> 130 <anchor>b75dc059e84fa8ffc076203b30f926cc</anchor> 131 <arglist></arglist> 132 </member> 133 <member kind="variable"> 134 <type>double</type> 135 <name>ll</name> 136 <anchorfile>classKalmanFull.html</anchorfile> 137 <anchor>3aa4bf6128980d0627413dcf9cd07308</anchor> 138 <arglist></arglist> 139 </member> 140 <member kind="friend"> 141 <type>friend std::ostream &</type> 142 <name>operator<<</name> 143 <anchorfile>classKalmanFull.html</anchorfile> 144 <anchor>86ba216243ed95bb46d80d88775d16af</anchor> 145 <arglist>(std::ostream &os, const KalmanFull &kf)</arglist> 146 </member> 147 </compound> 148 <compound kind="class"> 53 149 <name>mpdf</name> 54 150 <filename>classmpdf.html</filename> … … 78 174 <arglist>(ivec ids)</arglist> 79 175 </member> 176 <member kind="function"> 177 <type>ivec</type> 178 <name>rvfind</name> 179 <anchorfile>classRV.html</anchorfile> 180 <anchor>45b869bced40dc3fa0df584aaf8228c0</anchor> 181 <arglist>(RV rv2)</arglist> 182 </member> 183 <member kind="function"> 184 <type>RV</type> 185 <name>rvadd</name> 186 <anchorfile>classRV.html</anchorfile> 187 <anchor>f47ab0015ebac822da3b2e00f42a8fc6</anchor> 188 <arglist>(RV rv2)</arglist> 189 </member> 190 <member kind="function"> 191 <type>RV</type> 192 <name>rvsubt</name> 193 <anchorfile>classRV.html</anchorfile> 194 <anchor>269023ac4d41b21c4e1f7f17db1603b9</anchor> 195 <arglist>(RV rv2)</arglist> 196 </member> 197 <member kind="function"> 198 <type>RV</type> 199 <name>rvsubselect</name> 200 <anchorfile>classRV.html</anchorfile> 201 <anchor>70a53f2bc37929bae899b0b24cda9d8e</anchor> 202 <arglist>(ivec ind)</arglist> 203 </member> 204 <member kind="function"> 205 <type>RV</type> 206 <name>operator()</name> 207 <anchorfile>classRV.html</anchorfile> 208 <anchor>28bbcb8873bafdac317bafb7b481cc45</anchor> 209 <arglist>(ivec ind)</arglist> 210 </member> 80 211 <member kind="friend"> 81 212 <type>friend std::ostream &</type> -
test0.cpp
r5 r7 1 1 #include <itpp/itbase.h> 2 2 #include "libBM.h" 3 #include "libDC.h" 3 4 4 5 using namespace itpp; … … 12 13 13 14 RV th = RV ( "1 2","{a b }","1 1","0 0","0 0" ); 14 RV r = RV ("3 4");15 RV r = RV ( "3 4" ); 15 16 int i =0; 16 17 17 cout << th << r << th(ivec(&1,1)) << endl; 18 cout << th << r << endl; 19 20 ldmat ld = ldmat("1 0;-0.1 1","1.1 1.3"); 21 vec v = "1 -0.1"; 22 23 cout << "Test to_mat"<<endl; 24 // cout << ld << endl; 25 cout << ld.to_mat()<<endl; 26 27 cout << "Test opupdt" <<endl; 28 ldmat ldup = ld; 29 ldup.opupdt(v,1); 30 cout << ldup.to_mat()<<endl; 31 32 cout << "Test +="<<endl; 33 ldmat ld2x = ld; 34 ld2x+=ld; 35 cout << ld.to_mat() << ld2x.to_mat() <<endl; 36 37 cout << "Test ldinv()"<<endl; 38 ldmat Il = ld; 39 ld.inv(Il); // 40 mat I = Il.to_mat()*ld.to_mat(); 41 cout << "ld:"<<Il.to_mat() << "eye:"<< I <<endl; 42 18 43 19 44 //Exit program: