root/library/doc/html/functions_8h-source.html @ 541

Revision 538, 20.1 kB (checked in by smidl, 15 years ago)

Documentation regenerated

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: functions.h Source File</title>
4<link href="tabs.css" rel="stylesheet" type="text/css">
5<link href="doxygen.css" rel="stylesheet" type="text/css">
6</head><body>
7<!-- Generated by Doxygen 1.5.8 -->
8<script type="text/javascript">
9<!--
10function changeDisplayState (e){
11  var num=this.id.replace(/[^[0-9]/g,'');
12  var button=this.firstChild;
13  var sectionDiv=document.getElementById('dynsection'+num);
14  if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
15    sectionDiv.style.display='block';
16    button.src='open.gif';
17  }else{
18    sectionDiv.style.display='none';
19    button.src='closed.gif';
20  }
21}
22function initDynSections(){
23  var divs=document.getElementsByTagName('div');
24  var sectionCounter=1;
25  for(var i=0;i<divs.length-1;i++){
26    if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
27      var header=divs[i];
28      var section=divs[i+1];
29      var button=header.firstChild;
30      if (button!='IMG'){
31        divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
32        button=document.createElement('img');
33        divs[i].insertBefore(button,divs[i].firstChild);
34      }
35      header.style.cursor='pointer';
36      header.onclick=changeDisplayState;
37      header.id='dynheader'+sectionCounter;
38      button.src='closed.gif';
39      section.id='dynsection'+sectionCounter;
40      section.style.display='none';
41      section.style.marginLeft='14px';
42      sectionCounter++;
43    }
44  }
45}
46window.onload = initDynSections;
47-->
48</script>
49<div class="navigation" id="top">
50  <div class="tabs">
51    <ul>
52      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
53      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
54      <li><a href="annotated.html"><span>Classes</span></a></li>
55      <li class="current"><a href="files.html"><span>Files</span></a></li>
56    </ul>
57  </div>
58  <div class="tabs">
59    <ul>
60      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
61      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
62    </ul>
63  </div>
64<h1>functions.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//</span>
65<a name="l00002"></a>00002 <span class="comment">// C++ Interface: itpp_ext</span>
66<a name="l00003"></a>00003 <span class="comment">//</span>
67<a name="l00004"></a>00004 <span class="comment">// Description:</span>
68<a name="l00005"></a>00005 <span class="comment">//</span>
69<a name="l00006"></a>00006 <span class="comment">//</span>
70<a name="l00007"></a>00007 <span class="comment">// Author: smidl &lt;smidl@utia.cas.cz&gt;, (C) 2008</span>
71<a name="l00008"></a>00008 <span class="comment">//</span>
72<a name="l00009"></a>00009 <span class="comment">// Copyright: See COPYING file that comes with this distribution</span>
73<a name="l00010"></a>00010 <span class="comment">//</span>
74<a name="l00011"></a>00011 <span class="comment">//</span>
75<a name="l00012"></a>00012 <span class="preprocessor">#ifndef FN_H</span>
76<a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor">#define FN_H</span>
77<a name="l00014"></a>00014 <span class="preprocessor"></span>
78<a name="l00015"></a>00015 <span class="preprocessor">#include "../base/bdmbase.h"</span>
79<a name="l00016"></a>00016
80<a name="l00017"></a>00017 <span class="keyword">namespace </span>bdm {
81<a name="l00018"></a>00018
82<a name="l00020"></a><a class="code" href="classbdm_1_1constfn.html">00020</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1constfn.html" title="class representing function , here rv is empty">constfn</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1fnc.html" title="Class representing function  of variable  represented by rv.">fnc</a> {
83<a name="l00022"></a>00022         vec val;
84<a name="l00023"></a>00023
85<a name="l00024"></a>00024 <span class="keyword">public</span>:
86<a name="l00025"></a>00025         <span class="comment">//vec eval() {return val;};</span>
87<a name="l00027"></a><a class="code" href="classbdm_1_1constfn.html#33c2631ddcad9e81ef4b743d83eed4d4">00027</a> <span class="comment"></span>        vec <a class="code" href="classbdm_1_1constfn.html#33c2631ddcad9e81ef4b743d83eed4d4" title="inherited">eval</a> ( <span class="keyword">const</span> vec &amp;cond ) {
88<a name="l00028"></a>00028                 <span class="keywordflow">return</span> val;
89<a name="l00029"></a>00029         };
90<a name="l00031"></a><a class="code" href="classbdm_1_1constfn.html#7df0693d3ef4f1d2a52a5a3c3fce44af">00031</a>         <a class="code" href="classbdm_1_1constfn.html#7df0693d3ef4f1d2a52a5a3c3fce44af" title="Default constructor.">constfn</a> ( <span class="keyword">const</span> vec &amp;val0 ) : <a class="code" href="classbdm_1_1fnc.html" title="Class representing function  of variable  represented by rv.">fnc</a>(), val ( val0 ) {
91<a name="l00032"></a>00032                 <a class="code" href="classbdm_1_1fnc.html#52156cb4a52a62d51fc7455985797a62" title="Length of the output vector.">dimy</a> = val.length();
92<a name="l00033"></a>00033         };
93<a name="l00034"></a>00034 };
94<a name="l00035"></a>00035
95<a name="l00037"></a><a class="code" href="classbdm_1_1linfn.html">00037</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1linfn.html" title="Class representing function .">linfn</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1fnc.html" title="Class representing function  of variable  represented by rv.">fnc</a> {
96<a name="l00039"></a>00039         <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rv;
97<a name="l00041"></a>00041         mat A;
98<a name="l00043"></a>00043         vec B;
99<a name="l00044"></a>00044 <span class="keyword">public</span> :
100<a name="l00045"></a><a class="code" href="classbdm_1_1linfn.html#b8063094a2aa210dcf7ae73e2b85e09c">00045</a>         vec <a class="code" href="classbdm_1_1linfn.html#b8063094a2aa210dcf7ae73e2b85e09c" title="function evaluates numerical value of  at  cond ">eval</a> ( <span class="keyword">const</span> vec &amp;cond ) {
101<a name="l00046"></a>00046                 it_assert_debug ( cond.length() == A.cols(), <span class="stringliteral">"linfn::eval Wrong cond."</span> );
102<a name="l00047"></a>00047                 <span class="keywordflow">return</span> A*cond + B;
103<a name="l00048"></a>00048         };
104<a name="l00049"></a>00049
105<a name="l00050"></a>00050 <span class="comment">//              linfn evalsome ( ivec &amp;rvind );</span>
106<a name="l00052"></a><a class="code" href="classbdm_1_1linfn.html#b39c494c12863c031eb2acf86c0bc429">00052</a> <span class="comment"></span>        <a class="code" href="classbdm_1_1linfn.html#b39c494c12863c031eb2acf86c0bc429" title="default constructor">linfn</a> ( ) : <a class="code" href="classbdm_1_1fnc.html" title="Class representing function  of variable  represented by rv.">fnc</a>(), A ( ), B () { };
107<a name="l00054"></a><a class="code" href="classbdm_1_1linfn.html#7e0e714b814532fc3e38daede24c5e68">00054</a>         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1linfn.html#7e0e714b814532fc3e38daede24c5e68" title="Set values of A and B.">set_parameters</a> ( <span class="keyword">const</span> mat &amp;A0 , <span class="keyword">const</span> vec &amp;B0 ) {
108<a name="l00055"></a>00055                 A = A0;
109<a name="l00056"></a>00056                 B = B0;
110<a name="l00057"></a>00057                 <a class="code" href="classbdm_1_1fnc.html#52156cb4a52a62d51fc7455985797a62" title="Length of the output vector.">dimy</a> = A.rows();
111<a name="l00058"></a>00058         };
112<a name="l00059"></a>00059 };
113<a name="l00060"></a>00060
114<a name="l00061"></a>00061
115<a name="l00071"></a><a class="code" href="classbdm_1_1diffbifn.html">00071</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1fnc.html" title="Class representing function  of variable  represented by rv.">fnc</a> {
116<a name="l00072"></a>00072 <span class="keyword">protected</span>:
117<a name="l00074"></a><a class="code" href="classbdm_1_1diffbifn.html#5f56547d8e9378b669d3cc19d7831cbb">00074</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_1diffbifn.html#5f56547d8e9378b669d3cc19d7831cbb" title="Indentifier of the first rv.">rvx</a>;
118<a name="l00076"></a><a class="code" href="classbdm_1_1diffbifn.html#a8e3e861d5ec2a7ae9524e6338e58320">00076</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_1diffbifn.html#a8e3e861d5ec2a7ae9524e6338e58320" title="Indentifier of the second rv.">rvu</a>;
119<a name="l00078"></a><a class="code" href="classbdm_1_1diffbifn.html#a193aa2c4a500139c0c4b669691e588e">00078</a>         <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1diffbifn.html#a193aa2c4a500139c0c4b669691e588e" title="cache for rvx.count()">dimx</a>;
120<a name="l00080"></a><a class="code" href="classbdm_1_1diffbifn.html#30c45617eec89adeb4ebaa763d093fb0">00080</a>         <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1diffbifn.html#30c45617eec89adeb4ebaa763d093fb0" title="cache for rvu.count()">dimu</a>;
121<a name="l00081"></a>00081 <span class="keyword">public</span>:
122<a name="l00083"></a><a class="code" href="classbdm_1_1diffbifn.html#188f31066bd72e1bf0ddacd1eb0e6af3">00083</a>         vec <a class="code" href="classbdm_1_1diffbifn.html#188f31066bd72e1bf0ddacd1eb0e6af3" title="Evaluates  (VS: Do we really need common eval? ).">eval</a> ( <span class="keyword">const</span> vec &amp;cond ) {
123<a name="l00084"></a>00084                 it_assert_debug ( cond.length() == ( <a class="code" href="classbdm_1_1diffbifn.html#a193aa2c4a500139c0c4b669691e588e" title="cache for rvx.count()">dimx</a> + <a class="code" href="classbdm_1_1diffbifn.html#30c45617eec89adeb4ebaa763d093fb0" title="cache for rvu.count()">dimu</a> ), <span class="stringliteral">"linfn::eval Wrong cond."</span> );
124<a name="l00085"></a>00085                 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1diffbifn.html#188f31066bd72e1bf0ddacd1eb0e6af3" title="Evaluates  (VS: Do we really need common eval? ).">eval</a> ( cond ( 0, <a class="code" href="classbdm_1_1diffbifn.html#a193aa2c4a500139c0c4b669691e588e" title="cache for rvx.count()">dimx</a> - 1 ), cond ( <a class="code" href="classbdm_1_1diffbifn.html#a193aa2c4a500139c0c4b669691e588e" title="cache for rvx.count()">dimx</a>, <a class="code" href="classbdm_1_1diffbifn.html#a193aa2c4a500139c0c4b669691e588e" title="cache for rvx.count()">dimx</a> + <a class="code" href="classbdm_1_1diffbifn.html#30c45617eec89adeb4ebaa763d093fb0" title="cache for rvu.count()">dimu</a> - 1 ) );<span class="comment">//-1 = end (in matlab)</span>
125<a name="l00086"></a>00086         };
126<a name="l00087"></a>00087
127<a name="l00089"></a><a class="code" href="classbdm_1_1diffbifn.html#b5462c05b58cd38367ff946836bb82d3">00089</a>         <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1diffbifn.html#b5462c05b58cd38367ff946836bb82d3" title="Evaluates .">eval</a> ( <span class="keyword">const</span> vec &amp;x0, <span class="keyword">const</span> vec &amp;u0 ) {
128<a name="l00090"></a>00090                 <span class="keywordflow">return</span> zeros ( <a class="code" href="classbdm_1_1fnc.html#52156cb4a52a62d51fc7455985797a62" title="Length of the output vector.">dimy</a> );
129<a name="l00091"></a>00091         };
130<a name="l00093"></a><a class="code" href="classbdm_1_1diffbifn.html#651184f808a35f236dbfea21aca1b6ac">00093</a>         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1diffbifn.html#651184f808a35f236dbfea21aca1b6ac" 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> ) {};
131<a name="l00095"></a><a class="code" href="classbdm_1_1diffbifn.html#6ea1dc7a482601b29c5ba36a52d20d07">00095</a>         <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1diffbifn.html#6ea1dc7a482601b29c5ba36a52d20d07" 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> ) {};
132<a name="l00097"></a><a class="code" href="classbdm_1_1diffbifn.html#92ff29d748e445b440453a38d0b09681">00097</a>         <a class="code" href="classbdm_1_1diffbifn.html#92ff29d748e445b440453a38d0b09681" title="Default constructor (dimy is not set!).">diffbifn</a> () : <a class="code" href="classbdm_1_1fnc.html" title="Class representing function  of variable  represented by rv.">fnc</a>() {};
133<a name="l00099"></a><a class="code" href="classbdm_1_1diffbifn.html#1b3c8f5949f13d86d2661e191d4b369b">00099</a>         <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1diffbifn.html#1b3c8f5949f13d86d2661e191d4b369b" title="access function">_dimx</a>()<span class="keyword"> const </span>{
134<a name="l00100"></a>00100                 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1diffbifn.html#a193aa2c4a500139c0c4b669691e588e" title="cache for rvx.count()">dimx</a>;
135<a name="l00101"></a>00101         }
136<a name="l00103"></a><a class="code" href="classbdm_1_1diffbifn.html#031458f38c97cdb3aecde16f6a06dced">00103</a>         <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1diffbifn.html#031458f38c97cdb3aecde16f6a06dced" title="access function">_dimu</a>()<span class="keyword"> const </span>{
137<a name="l00104"></a>00104                 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1diffbifn.html#30c45617eec89adeb4ebaa763d093fb0" title="cache for rvu.count()">dimu</a>;
138<a name="l00105"></a>00105         }
139<a name="l00106"></a>00106 };
140<a name="l00107"></a>00107
141<a name="l00109"></a>00109 <span class="comment">//TODO can be generalized into multilinear form!</span>
142<a name="l00110"></a><a class="code" href="classbdm_1_1bilinfn.html">00110</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1bilinfn.html" title="Class representing function .">bilinfn</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1diffbifn.html" title="Class representing a differentiable function of two variables .">diffbifn</a> {
143<a name="l00111"></a>00111         mat A;
144<a name="l00112"></a>00112         mat B;
145<a name="l00113"></a>00113 <span class="keyword">public</span> :
146<a name="l00116"></a>00116
147<a name="l00117"></a>00117         <a class="code" href="classbdm_1_1bilinfn.html" title="Class representing function .">bilinfn</a> () : <a class="code" href="classbdm_1_1diffbifn.html#92ff29d748e445b440453a38d0b09681" title="Default constructor (dimy is not set!).">diffbifn</a> () , A() , B()    {};
148<a name="l00118"></a>00118         <a class="code" href="classbdm_1_1bilinfn.html" title="Class representing function .">bilinfn</a> ( <span class="keyword">const</span> mat A0, <span class="keyword">const</span> mat B0 ) {
149<a name="l00119"></a>00119                 <a class="code" href="classbdm_1_1bilinfn.html#5a508fbb5fc013904d9b62b2231442de" title="Alternative constructor.">set_parameters</a> ( A0, B0 );
150<a name="l00120"></a>00120         };
151<a name="l00122"></a><a class="code" href="classbdm_1_1bilinfn.html#5a508fbb5fc013904d9b62b2231442de">00122</a>         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1bilinfn.html#5a508fbb5fc013904d9b62b2231442de" title="Alternative constructor.">set_parameters</a> ( <span class="keyword">const</span> mat A0, <span class="keyword">const</span> mat B0 ) {
152<a name="l00123"></a>00123                 it_assert_debug ( A0.rows() == B0.rows(), <span class="stringliteral">""</span> );
153<a name="l00124"></a>00124                 A = A0;
154<a name="l00125"></a>00125                 B = B0;
155<a name="l00126"></a>00126                 <a class="code" href="classbdm_1_1fnc.html#52156cb4a52a62d51fc7455985797a62" title="Length of the output vector.">dimy</a> = A.rows();
156<a name="l00127"></a>00127                 <a class="code" href="classbdm_1_1diffbifn.html#a193aa2c4a500139c0c4b669691e588e" title="cache for rvx.count()">dimx</a> = A.cols();
157<a name="l00128"></a>00128                 <a class="code" href="classbdm_1_1diffbifn.html#30c45617eec89adeb4ebaa763d093fb0" title="cache for rvu.count()">dimu</a> = B.cols();
158<a name="l00129"></a>00129         }
159<a name="l00131"></a>00131
160<a name="l00134"></a><a class="code" href="classbdm_1_1bilinfn.html#846c21e8e8d41555eb7c075f5ff86ffd">00134</a>         <span class="keyword">inline</span> vec <a class="code" href="classbdm_1_1bilinfn.html#846c21e8e8d41555eb7c075f5ff86ffd" title="Evaluates .">eval</a> ( <span class="keyword">const</span>  vec &amp;x0, <span class="keyword">const</span> vec &amp;u0 ) {
161<a name="l00135"></a>00135                 it_assert_debug ( x0.length() == <a class="code" href="classbdm_1_1diffbifn.html#a193aa2c4a500139c0c4b669691e588e" title="cache for rvx.count()">dimx</a>, <span class="stringliteral">"linfn::eval Wrong xcond."</span> );
162<a name="l00136"></a>00136                 it_assert_debug ( u0.length() == <a class="code" href="classbdm_1_1diffbifn.html#30c45617eec89adeb4ebaa763d093fb0" title="cache for rvu.count()">dimu</a>, <span class="stringliteral">"linfn::eval Wrong ucond."</span> );
163<a name="l00137"></a>00137                 <span class="keywordflow">return</span> A*x0 + B*u0;
164<a name="l00138"></a>00138         }
165<a name="l00139"></a>00139
166<a name="l00140"></a><a class="code" href="classbdm_1_1bilinfn.html#33066f1054dd259df2ec5fafae4b46e6">00140</a>         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1bilinfn.html#33066f1054dd259df2ec5fafae4b46e6" 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 ) {
167<a name="l00141"></a>00141                 it_assert_debug ( ( F.cols() == A.cols() ) &amp; ( F.rows() == A.rows() ), <span class="stringliteral">"Allocated F is not compatible."</span> );
168<a name="l00142"></a>00142                 <span class="keywordflow">if</span> ( full ) F = A;      <span class="comment">//else : nothing has changed no need to regenerate</span>
169<a name="l00143"></a>00143         }
170<a name="l00145"></a><a class="code" href="classbdm_1_1bilinfn.html#9cfe2f1c115ba7c3c75849a10a4f2c08">00145</a>         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1bilinfn.html#9cfe2f1c115ba7c3c75849a10a4f2c08" 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> ) {
171<a name="l00146"></a>00146                 it_assert_debug ( ( F.cols() == B.cols() ) &amp; ( F.rows() == B.rows() ), <span class="stringliteral">"Allocated F is not compatible."</span> );
172<a name="l00147"></a>00147                 <span class="keywordflow">if</span> ( full ) F = B;      <span class="comment">//else : nothing has changed no need to regenerate</span>
173<a name="l00148"></a>00148         }
174<a name="l00150"></a>00150 };
175<a name="l00151"></a>00151
176<a name="l00152"></a>00152 } <span class="comment">//namespace</span>
177<a name="l00153"></a>00153 <span class="preprocessor">#endif // FN_H</span>
178</pre></div></div>
179<hr size="1"><address style="text-align: right;"><small>Generated on Sun Aug 16 17:58:18 2009 for mixpp by&nbsp;
180<a href="http://www.doxygen.org/index.html">
181<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
182</body>
183</html>
Note: See TracBrowser for help on using the browser.