root/doc/html/libFN_8h-source.html @ 23

Revision 23, 16.2 kB (checked in by smidl, 16 years ago)

doxy

Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3<title>mixpp: work/mixpp/bdm/stat/libFN.h Source File</title>
4<link href="doxygen.css" rel="stylesheet" type="text/css">
5<link href="tabs.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.5.3 -->
8<div class="tabs">
9  <ul>
10    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
11    <li><a href="annotated.html"><span>Classes</span></a></li>
12    <li class="current"><a href="files.html"><span>Files</span></a></li>
13  </ul>
14</div>
15<h1>work/mixpp/bdm/stat/libFN.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//</span>
16<a name="l00002"></a>00002 <span class="comment">// C++ Interface: itpp_ext</span>
17<a name="l00003"></a>00003 <span class="comment">//</span>
18<a name="l00004"></a>00004 <span class="comment">// Description:</span>
19<a name="l00005"></a>00005 <span class="comment">//</span>
20<a name="l00006"></a>00006 <span class="comment">//</span>
21<a name="l00007"></a>00007 <span class="comment">// Author: smidl &lt;smidl@utia.cas.cz&gt;, (C) 2008</span>
22<a name="l00008"></a>00008 <span class="comment">//</span>
23<a name="l00009"></a>00009 <span class="comment">// Copyright: See COPYING file that comes with this distribution</span>
24<a name="l00010"></a>00010 <span class="comment">//</span>
25<a name="l00011"></a>00011 <span class="comment">//</span>
26<a name="l00012"></a>00012 <span class="preprocessor">#include &lt;itpp/itbase.h&gt;</span>
27<a name="l00013"></a>00013 <span class="preprocessor">#include "<a class="code" href="libBM_8h.html" title="Bayesian Models (bm) that use Bayes rule to learn from observations.">libBM.h</a>"</span>
28<a name="l00014"></a>00014
29<a name="l00015"></a>00015 <span class="keyword">using namespace </span>itpp;
30<a name="l00016"></a>00016
31<a name="l00018"></a><a class="code" href="classconstfn.html">00018</a> <span class="keyword">class </span><a class="code" href="classconstfn.html" title="class representing function $f(x) = a$, here rv is empty">constfn</a> : <span class="keyword">public</span> <a class="code" href="classfnc.html" title="Class representing function $f(x)$ of variable $x$ represented by rv.">fnc</a>
32<a name="l00019"></a>00019 {
33<a name="l00020"></a>00020                 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rv;
34<a name="l00021"></a>00021                 vec val;
35<a name="l00022"></a>00022
36<a name="l00023"></a>00023
37<a name="l00024"></a>00024         <span class="keyword">public</span>:
38<a name="l00025"></a>00025                 vec eval() {<span class="keywordflow">return</span> val;};
39<a name="l00026"></a>00026                 vec eval ( vec &amp;cond ) {<span class="keywordflow">return</span> val;};
40<a name="l00028"></a><a class="code" href="classconstfn.html#d08acd7fac0ef3edfa59bbe48403f2bc">00028</a>                 <a class="code" href="classconstfn.html#d08acd7fac0ef3edfa59bbe48403f2bc" title="Default constructor.">constfn</a> ( <span class="keyword">const</span> vec &amp;val0 ) :rv(),val ( val0 ) {};
41<a name="l00029"></a>00029 };
42<a name="l00030"></a>00030
43<a name="l00032"></a><a class="code" href="classlinfn.html">00032</a> <span class="keyword">class </span><a class="code" href="classlinfn.html" title="Class representing function $f(x) = Ax+B$.">linfn</a>: <span class="keyword">public</span> <a class="code" href="classfnc.html" title="Class representing function $f(x)$ of variable $x$ represented by rv.">fnc</a>
44<a name="l00033"></a>00033 {
45<a name="l00034"></a>00034                 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rv;
46<a name="l00035"></a>00035                 ivec indexlist; <span class="comment">// needed by evalsome</span>
47<a name="l00036"></a>00036                 mat A;
48<a name="l00037"></a>00037                 vec B;
49<a name="l00038"></a>00038         <span class="keyword">public</span> :
50<a name="l00039"></a>00039                 vec eval ( vec &amp;cond ) {it_assert_debug ( cond.length() ==rv.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return length (number of scalars) of the RV.">count</a>(), <span class="stringliteral">"linfn::eval Wrong cond."</span> );<span class="keywordflow">return</span> A*cond+B;};
51<a name="l00040"></a>00040
52<a name="l00041"></a>00041                 <a class="code" href="classlinfn.html" title="Class representing function $f(x) = Ax+B$.">linfn</a> evalsome ( ivec &amp;rvind );
53<a name="l00042"></a>00042                 <a class="code" href="classlinfn.html" title="Class representing function $f(x) = Ax+B$.">linfn</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rv0 ) :rv ( rv0 ),A ( eye ( rv0.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return length (number of scalars) of the RV.">count</a>() ) ),B ( zeros ( rv0.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return length (number of scalars) of the RV.">count</a>() ) ) { indexlist=rv.<a class="code" href="classRV.html#8470cf53be6e7bdba78ad0efbd203ee7" title="generate a list of indeces, i.e. which">indexlist</a>();};
54<a name="l00043"></a>00043                 <a class="code" href="classlinfn.html" title="Class representing function $f(x) = Ax+B$.">linfn</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rv0, <span class="keyword">const</span> mat &amp;A0 ) : rv ( rv0 ), A ( A0 ), B ( zeros ( rv0.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return length (number of scalars) of the RV.">count</a>() ) ) { indexlist=rv.<a class="code" href="classRV.html#8470cf53be6e7bdba78ad0efbd203ee7" title="generate a list of indeces, i.e. which">indexlist</a>();};
55<a name="l00044"></a>00044                 <a class="code" href="classlinfn.html" title="Class representing function $f(x) = Ax+B$.">linfn</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rv0, <span class="keyword">const</span> mat &amp;A0, <span class="keyword">const</span> vec &amp;B0 ) :rv ( rv0 ), A ( A0 ), B ( B0 ) { indexlist=rv.<a class="code" href="classRV.html#8470cf53be6e7bdba78ad0efbd203ee7" title="generate a list of indeces, i.e. which">indexlist</a>();};
56<a name="l00045"></a>00045 };
57<a name="l00046"></a>00046
58<a name="l00047"></a>00047
59<a name="l00057"></a><a class="code" href="classdiffbifn.html">00057</a> <span class="keyword">class </span><a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables $f(x,u)$.">diffbifn</a>: <span class="keyword">public</span> <a class="code" href="classfnc.html" title="Class representing function $f(x)$ of variable $x$ represented by rv.">fnc</a>
60<a name="l00058"></a>00058 {
61<a name="l00059"></a>00059         <span class="keyword">protected</span>:
62<a name="l00060"></a>00060                 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx,rvu;
63<a name="l00061"></a>00061                 <span class="keywordtype">int</span> dimx;
64<a name="l00062"></a>00062                 <span class="keywordtype">int</span> dimu;
65<a name="l00063"></a>00063                 <span class="keywordtype">int</span> dimy;
66<a name="l00064"></a>00064         <span class="keyword">public</span>:
67<a name="l00066"></a><a class="code" href="classdiffbifn.html#ad7673e16aa1a046b131b24c731c4632">00066</a>                 vec <a class="code" href="classdiffbifn.html#ad7673e16aa1a046b131b24c731c4632" title="Evaluates $f(x0,u0)$ (VS: Do we really need common eval? ).">eval</a> ( <span class="keyword">const</span> vec &amp;cond )
68<a name="l00067"></a>00067                 {
69<a name="l00068"></a>00068                         it_assert_debug ( cond.length() == ( dimx+dimu ), <span class="stringliteral">"linfn::eval Wrong cond."</span> );
70<a name="l00069"></a>00069                         <span class="keywordflow">return</span> <a class="code" href="classdiffbifn.html#ad7673e16aa1a046b131b24c731c4632" title="Evaluates $f(x0,u0)$ (VS: Do we really need common eval? ).">eval</a> ( cond ( 0,dimx-1 ),cond ( dimx,dimx+dimu ) );<span class="comment">//-1 = end (in matlab)</span>
71<a name="l00070"></a>00070                 };
72<a name="l00071"></a>00071
73<a name="l00073"></a><a class="code" href="classdiffbifn.html#40d8a7eee45acc55cda33d43282faa03">00073</a>                 <span class="keyword">virtual</span> vec <a class="code" href="classdiffbifn.html#ad7673e16aa1a046b131b24c731c4632" title="Evaluates $f(x0,u0)$ (VS: Do we really need common eval? ).">eval</a> ( <span class="keyword">const</span> vec &amp;x0, <span class="keyword">const</span> vec &amp;u0 ) {<span class="keywordflow">return</span> zeros ( dimy );};
74<a name="l00075"></a><a class="code" href="classdiffbifn.html#6d217a02d4fa13931258d4bebdd0feb4">00075</a>                 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classdiffbifn.html#6d217a02d4fa13931258d4bebdd0feb4" title="Evaluates  and writes result into A .">dfdx_cond</a> ( <span class="keyword">const</span> vec &amp;x0, <span class="keyword">const</span> vec &amp;u0, mat &amp;A , <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) {};
75<a name="l00077"></a><a class="code" href="classdiffbifn.html#1978bafd7909d15c139a08c495c24aa0">00077</a>                 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classdiffbifn.html#1978bafd7909d15c139a08c495c24aa0" title="Evaluates  and writes result into A .">dfdu_cond</a> ( <span class="keyword">const</span> vec &amp;x0, <span class="keyword">const</span> vec &amp;u0, mat &amp;A, <span class="keywordtype">bool</span> full=<span class="keyword">true</span> ) {};
76<a name="l00079"></a><a class="code" href="classdiffbifn.html#0b33e1bfa23be5ed234d172eb4c0e4b5">00079</a>                 <a class="code" href="classdiffbifn.html#0b33e1bfa23be5ed234d172eb4c0e4b5" title="Default constructor (dimy is not set!).">diffbifn</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvx0, <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvu0 ) : rvx ( rvx0 ),rvu ( rvu0 ) {dimx=rvx.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return length (number of scalars) of the RV.">count</a>();dimu=rvu.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return length (number of scalars) of the RV.">count</a>();};
77<a name="l00081"></a><a class="code" href="classdiffbifn.html#436de7a7301ea9eac7d6081b893bbf57">00081</a>                 <span class="keywordtype">int</span> <a class="code" href="classdiffbifn.html#436de7a7301ea9eac7d6081b893bbf57" title="access function">_dimx</a>()<span class="keyword"> const</span>{<span class="keywordflow">return</span> dimx;}
78<a name="l00083"></a><a class="code" href="classdiffbifn.html#fc8779acbff170611aff0ee70cee3879">00083</a>                 <span class="keywordtype">int</span> <a class="code" href="classdiffbifn.html#fc8779acbff170611aff0ee70cee3879" title="access function">_dimu</a>()<span class="keyword"> const</span>{<span class="keywordflow">return</span> dimu;}
79<a name="l00084"></a>00084 };
80<a name="l00085"></a>00085
81<a name="l00087"></a>00087 <span class="comment">//TODO can be generalized into multilinear form!</span>
82<a name="l00088"></a><a class="code" href="classbilinfn.html">00088</a> <span class="keyword">class </span><a class="code" href="classbilinfn.html" title="Class representing function $f(x,u) = Ax+Bu$.">bilinfn</a>: <span class="keyword">public</span> <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables $f(x,u)$.">diffbifn</a>
83<a name="l00089"></a>00089 {
84<a name="l00090"></a>00090                 mat A;
85<a name="l00091"></a>00091                 mat B;
86<a name="l00092"></a>00092         <span class="keyword">public</span> :
87<a name="l00093"></a>00093                 vec <a class="code" href="classbilinfn.html#e36a16e72e7f9fedf3cb18d2d5505a24" title="Evaluates $f(x0,u0)$.">eval</a> ( <span class="keyword">const</span>  vec &amp;x0, <span class="keyword">const</span> vec &amp;u0 );
88<a name="l00094"></a>00094
89<a name="l00096"></a><a class="code" href="classbilinfn.html#af9f36282730d910a41b95f4d1fb8221">00096</a>                 <a class="code" href="classbilinfn.html#af9f36282730d910a41b95f4d1fb8221" title="Default constructor.">bilinfn</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rvx0, <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rvu0 ) : <a class="code" href="classdiffbifn.html" title="Class representing a differentiable function of two variables $f(x,u)$.">diffbifn</a> ( rvx0,rvu0 ) ,A ( eye ( dimx ) ),B ( zeros ( dimx,dimu ) )       {};
90<a name="l00097"></a>00097                 <span class="comment">//</span>
91<a name="l00098"></a>00098                 <a class="code" href="classbilinfn.html#af9f36282730d910a41b95f4d1fb8221" title="Default constructor.">bilinfn</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rvx0, <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rvu0, <span class="keyword">const</span> mat &amp;A0, <span class="keyword">const</span> mat &amp;B0 );
92<a name="l00099"></a>00099                 <span class="comment">//</span>
93<a name="l00100"></a><a class="code" href="classbilinfn.html#79c022de8dbe2b054bb9cc49345f3ef5">00100</a>                 <span class="keywordtype">void</span> <a class="code" href="classbilinfn.html#79c022de8dbe2b054bb9cc49345f3ef5" title="Evaluates  and writes result into A .">dfdx_cond</a> ( <span class="keyword">const</span> vec &amp;x0, <span class="keyword">const</span> vec &amp;u0, mat &amp;F, <span class="keywordtype">bool</span> full )
94<a name="l00101"></a>00101                 {
95<a name="l00102"></a>00102                         it_assert_debug ( ( F.cols() ==A.cols() ) &amp; ( F.rows() ==A.rows() ),<span class="stringliteral">"Allocated F is not compatible."</span> );
96<a name="l00103"></a>00103                         <span class="keywordflow">if</span> ( full ) F=A;        <span class="comment">//else : nothing has changed no need to regenerate</span>
97<a name="l00104"></a>00104                 }
98<a name="l00105"></a>00105                 <span class="comment">//</span>
99<a name="l00106"></a><a class="code" href="classbilinfn.html#90f2b15612b14883d6ed2b0e295cb82b">00106</a>                 <span class="keywordtype">void</span> <a class="code" href="classbilinfn.html#90f2b15612b14883d6ed2b0e295cb82b" title="Evaluates  and writes result into A .">dfdu_cond</a> ( <span class="keyword">const</span> vec &amp;x0, <span class="keyword">const</span> vec &amp;u0, mat &amp;F,  <span class="keywordtype">bool</span> full=<span class="keyword">true</span> )
100<a name="l00107"></a>00107                 {
101<a name="l00108"></a>00108                         it_assert_debug ( ( F.cols() ==B.cols() ) &amp; ( F.rows() ==B.rows() ),<span class="stringliteral">"Allocated F is not compatible."</span> );
102<a name="l00109"></a>00109                         <span class="keywordflow">if</span> ( full ) F=B;        <span class="comment">//else : nothing has changed no need to regenerate</span>
103<a name="l00110"></a>00110                 }
104<a name="l00111"></a>00111 };
105</pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Sun Feb 17 16:14:14 2008 for mixpp by&nbsp;
106<a href="http://www.doxygen.org/index.html">
107<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
108</body>
109</html>
Note: See TracBrowser for help on using the browser.