root/library/doc/html/discrete_8h_source.html @ 651

Revision 651, 19.6 kB (checked in by mido, 15 years ago)

\doc directory cleaned a bit

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: discrete.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.9 -->
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>discrete.h</h1><a href="discrete_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
65<a name="l00013"></a>00013 <span class="preprocessor">#ifndef DISCR_H</span>
66<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define DISCR_H</span>
67<a name="l00015"></a>00015 <span class="preprocessor"></span>
68<a name="l00016"></a>00016 <span class="preprocessor">#include "../shared_ptr.h"</span>
69<a name="l00017"></a>00017 <span class="preprocessor">#include "../base/bdmbase.h"</span>
70<a name="l00018"></a>00018 <span class="preprocessor">#include "../math/chmat.h"</span>
71<a name="l00019"></a>00019
72<a name="l00020"></a>00020 <span class="keyword">namespace </span>bdm {
73<a name="l00021"></a>00021
74<a name="l00022"></a>00022 <span class="comment">// Abstract support - pokus, jen diskretni.. takze jmeno discrete support je lepci:)</span>
75<a name="l00023"></a>00023 <span class="comment">// ale jediny, co by umel, je first_vec a next_vec, hmm:(</span>
76<a name="l00024"></a>00024 <span class="comment">// class support : public root {</span>
77<a name="l00025"></a>00025
78<a name="l00029"></a><a class="code" href="classbdm_1_1rectangular__support.html">00029</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1rectangular__support.html">rectangular_support</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> {
79<a name="l00030"></a>00030 <span class="keyword">private</span>:
80<a name="l00032"></a>00032         <span class="keywordtype">void</span> initialize();
81<a name="l00033"></a>00033 <span class="keyword">protected</span>:
82<a name="l00035"></a><a class="code" href="classbdm_1_1rectangular__support.html#b63e1190a8a22031d110624a8fc64b14">00035</a>         Array&lt;vec&gt; <a class="code" href="classbdm_1_1rectangular__support.html#b63e1190a8a22031d110624a8fc64b14" title="Array of boundaries (2D vectors: [begining,end]) for each dimension.">ranges</a>;
83<a name="l00037"></a><a class="code" href="classbdm_1_1rectangular__support.html#efe08427f4bf66191e10b727b57e4b31">00037</a>         ivec <a class="code" href="classbdm_1_1rectangular__support.html#efe08427f4bf66191e10b727b57e4b31" title="Number of support points in each dimension.">gridsizes</a>;
84<a name="l00039"></a><a class="code" href="classbdm_1_1rectangular__support.html#442ae2e1881d6bcdccf0cabbef769e79">00039</a>         <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1rectangular__support.html#442ae2e1881d6bcdccf0cabbef769e79" title="dimension">dim</a>;
85<a name="l00041"></a><a class="code" href="classbdm_1_1rectangular__support.html#6e55e6243f3a3e451f8bed149d948319">00041</a>         <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1rectangular__support.html#6e55e6243f3a3e451f8bed149d948319" title="Number of data points.">Npoints</a>;
86<a name="l00043"></a><a class="code" href="classbdm_1_1rectangular__support.html#e1aa9a4e91c248a29e4e432f4b448197">00043</a>         vec <a class="code" href="classbdm_1_1rectangular__support.html#e1aa9a4e91c248a29e4e432f4b448197" title="active vector for first_vec and next_vec">actvec</a>;
87<a name="l00045"></a><a class="code" href="classbdm_1_1rectangular__support.html#744688479a1ab8cf9f80d6f3021d762b">00045</a>         vec <a class="code" href="classbdm_1_1rectangular__support.html#744688479a1ab8cf9f80d6f3021d762b" title="indeces of active vector">actvec_ind</a>;
88<a name="l00047"></a><a class="code" href="classbdm_1_1rectangular__support.html#967bfe2eb868409e3e0e6e41dcd63a6a">00047</a>         vec <a class="code" href="classbdm_1_1rectangular__support.html#967bfe2eb868409e3e0e6e41dcd63a6a" title="length of steps in each dimension">steps</a>;
89<a name="l00048"></a>00048 <span class="keyword">public</span>:
90<a name="l00050"></a><a class="code" href="classbdm_1_1rectangular__support.html#9929645efe5eff3a6b87da8b81e114c4">00050</a>         <a class="code" href="classbdm_1_1rectangular__support.html#9929645efe5eff3a6b87da8b81e114c4" title="default constructor">rectangular_support</a>() : <a class="code" href="classbdm_1_1rectangular__support.html#442ae2e1881d6bcdccf0cabbef769e79" title="dimension">dim</a> ( 0 ), <a class="code" href="classbdm_1_1rectangular__support.html#6e55e6243f3a3e451f8bed149d948319" title="Number of data points.">Npoints</a> ( 0 ) {
91<a name="l00051"></a>00051         }
92<a name="l00052"></a>00052
93<a name="l00054"></a>00054         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1rectangular__support.html#a18272405534f914ee3798f1c4034e51" title="set parameters">set_parameters</a> ( <span class="keyword">const</span> Array&lt;vec&gt; &amp;ranges0, <span class="keyword">const</span> ivec &amp;gridsize0 );
94<a name="l00055"></a>00055
95<a name="l00057"></a>00057         vec <a class="code" href="classbdm_1_1rectangular__support.html#2fd69b881ff077e6d3da3e453d7dc418" title="return vector at position given by vector of indeces">get_vec</a> ( <span class="keyword">const</span> ivec &amp;inds );
96<a name="l00058"></a>00058
97<a name="l00060"></a>00060         <span class="keywordtype">long</span> <a class="code" href="classbdm_1_1rectangular__support.html#2ae8ed78cba8e14b5dcc570b51d7d3f0" title="convert dimension indeces into linear index, the indexing is in the same way as in...">linear_index</a> ( <span class="keyword">const</span> ivec inds );
98<a name="l00061"></a>00061
99<a name="l00063"></a>00063         <span class="keyword">const</span> vec&amp; <a class="code" href="classbdm_1_1rectangular__support.html#6a1d6c127b468b772fd0a7206e2880a3" title="set the first vector to corner and store result in actvec">first_vec</a>();
100<a name="l00064"></a>00064
101<a name="l00066"></a>00066         <span class="keyword">const</span> vec&amp; <a class="code" href="classbdm_1_1rectangular__support.html#80f33e406ba1799376537c39fdf7cc97" title="Get next active vector, call ONLY after first_vector()!">next_vec</a>();
102<a name="l00067"></a>00067
103<a name="l00069"></a>00069         ivec <a class="code" href="classbdm_1_1rectangular__support.html#0ea90fd6ba65251683c04599b6d094b7">nearest_point</a> ( <span class="keyword">const</span> vec &amp;val );
104<a name="l00070"></a>00070
105<a name="l00072"></a><a class="code" href="classbdm_1_1rectangular__support.html#a2cc3a7250b969675bc8f9034aa2a7d2">00072</a>         <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1rectangular__support.html#a2cc3a7250b969675bc8f9034aa2a7d2" title="Access function.">points</a>()<span class="keyword"> const </span>{
106<a name="l00073"></a>00073                 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1rectangular__support.html#6e55e6243f3a3e451f8bed149d948319" title="Number of data points.">Npoints</a>;
107<a name="l00074"></a>00074         }
108<a name="l00075"></a>00075
109<a name="l00078"></a><a class="code" href="classbdm_1_1rectangular__support.html#cfd542382bc959fce9c117b8df5f6e9f">00078</a>         <span class="keyword">const</span> vec&amp; <a class="code" href="classbdm_1_1rectangular__support.html#cfd542382bc959fce9c117b8df5f6e9f">_steps</a>()<span class="keyword"> const </span>{
110<a name="l00079"></a>00079                 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1rectangular__support.html#967bfe2eb868409e3e0e6e41dcd63a6a" title="length of steps in each dimension">steps</a>;
111<a name="l00080"></a>00080         }
112<a name="l00081"></a>00081
113<a name="l00082"></a>00082         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1rectangular__support.html#c8d82bd237cdd4dc50d5fbcc285d80ee" 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> );
114<a name="l00083"></a>00083 };
115<a name="l00084"></a>00084 <a class="code" href="user__info_8h.html#4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> ( rectangular_support );
116<a name="l00085"></a>00085
117<a name="l00087"></a><a class="code" href="classbdm_1_1discrete__support.html">00087</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1discrete__support.html" title="Discrete support with stored support points.">discrete_support</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> {
118<a name="l00088"></a>00088 <span class="keyword">protected</span>:
119<a name="l00090"></a><a class="code" href="classbdm_1_1discrete__support.html#c0cbdb61727406b52ca22332507a9a7c">00090</a>         Array&lt;vec&gt; <a class="code" href="classbdm_1_1discrete__support.html#c0cbdb61727406b52ca22332507a9a7c" title="storage of support points">Spoints</a>;
120<a name="l00092"></a><a class="code" href="classbdm_1_1discrete__support.html#505284848af521fea33e65368de4845e">00092</a>         <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1discrete__support.html#505284848af521fea33e65368de4845e" title="index in iterators">idx</a>;
121<a name="l00093"></a>00093 <span class="keyword">public</span>:
122<a name="l00095"></a><a class="code" href="classbdm_1_1discrete__support.html#58d652a1f149a7698f1fee9acd1a78b5">00095</a>         <a class="code" href="classbdm_1_1discrete__support.html#58d652a1f149a7698f1fee9acd1a78b5" title="Default constructor.">discrete_support</a>() : <a class="code" href="classbdm_1_1discrete__support.html#c0cbdb61727406b52ca22332507a9a7c" title="storage of support points">Spoints</a> ( 0 ), <a class="code" href="classbdm_1_1discrete__support.html#505284848af521fea33e65368de4845e" title="index in iterators">idx</a> ( 0 ) {}
123<a name="l00097"></a><a class="code" href="classbdm_1_1discrete__support.html#dc3d175266b65168ba3f3a5f568078a1">00097</a>         <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1discrete__support.html#dc3d175266b65168ba3f3a5f568078a1" title="Access function.">points</a>()<span class="keyword"> const </span>{
124<a name="l00098"></a>00098                 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1discrete__support.html#c0cbdb61727406b52ca22332507a9a7c" title="storage of support points">Spoints</a>.length();
125<a name="l00099"></a>00099         }
126<a name="l00101"></a><a class="code" href="classbdm_1_1discrete__support.html#26c803791b63916adf301a4a186f01ba">00101</a>         <span class="keyword">const</span> vec&amp; <a class="code" href="classbdm_1_1discrete__support.html#26c803791b63916adf301a4a186f01ba" title="set the first vector to corner and store result in actvec">first_vec</a>() {
127<a name="l00102"></a>00102                 <a class="code" href="bdmerror_8h.html#89a0f906b242b79c5d3d342291b2cab4" 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_1discrete__support.html#c0cbdb61727406b52ca22332507a9a7c" title="storage of support points">Spoints</a>.length() &gt; 0, <span class="stringliteral">"Empty support"</span> );
128<a name="l00103"></a>00103                 <a class="code" href="classbdm_1_1discrete__support.html#505284848af521fea33e65368de4845e" title="index in iterators">idx</a> = 0;
129<a name="l00104"></a>00104                 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1discrete__support.html#c0cbdb61727406b52ca22332507a9a7c" title="storage of support points">Spoints</a> ( idx );
130<a name="l00105"></a>00105         }
131<a name="l00107"></a><a class="code" href="classbdm_1_1discrete__support.html#368f10fd45443dee5296cc0febb240fb">00107</a>         <span class="keyword">const</span> vec&amp; <a class="code" href="classbdm_1_1discrete__support.html#368f10fd45443dee5296cc0febb240fb" title="set next vector after calling first_vec()">next_vec</a>() {
132<a name="l00108"></a>00108                 <a class="code" href="bdmerror_8h.html#89a0f906b242b79c5d3d342291b2cab4" 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_1discrete__support.html#c0cbdb61727406b52ca22332507a9a7c" title="storage of support points">Spoints</a>.length() &gt; <a class="code" href="classbdm_1_1discrete__support.html#505284848af521fea33e65368de4845e" title="index in iterators">idx</a> - 1, <span class="stringliteral">"Out of support points"</span> );
133<a name="l00109"></a>00109                 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1discrete__support.html#c0cbdb61727406b52ca22332507a9a7c" title="storage of support points">Spoints</a> ( ++<a class="code" href="classbdm_1_1discrete__support.html#505284848af521fea33e65368de4845e" title="index in iterators">idx</a> );
134<a name="l00110"></a>00110         }
135<a name="l00111"></a>00111
136<a name="l00121"></a>00121         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1discrete__support.html#0c405889b7b76f0852c1b2a222f07aab">from_setting</a> ( <span class="keyword">const</span> Setting &amp;<span class="keyword">set</span> );
137<a name="l00122"></a>00122
138<a name="l00124"></a><a class="code" href="classbdm_1_1discrete__support.html#1e9af8da7fa2ac2c03b3cec1d4407b1d">00124</a>         Array&lt;vec&gt; &amp; <a class="code" href="classbdm_1_1discrete__support.html#1e9af8da7fa2ac2c03b3cec1d4407b1d" title="access function">_Spoints</a>() {
139<a name="l00125"></a>00125                 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1discrete__support.html#c0cbdb61727406b52ca22332507a9a7c" title="storage of support points">Spoints</a>;
140<a name="l00126"></a>00126         }
141<a name="l00127"></a>00127 };
142<a name="l00128"></a>00128 <a class="code" href="user__info_8h.html#4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> ( discrete_support );
143<a name="l00129"></a>00129
144<a name="l00130"></a>00130 <span class="keyword">class </span>grid_fnc: <span class="keyword">public</span> fnc {
145<a name="l00131"></a>00131 <span class="keyword">protected</span>:
146<a name="l00132"></a>00132         rectangular_support sup;
147<a name="l00133"></a>00133         vec values;
148<a name="l00134"></a>00134 <span class="keyword">public</span>:
149<a name="l00136"></a>00136         <span class="keywordtype">void</span> set_support ( rectangular_support &amp;sup0 ) {
150<a name="l00137"></a>00137                 sup = sup0;
151<a name="l00138"></a>00138                 values = zeros ( sup.points() );
152<a name="l00139"></a>00139         }
153<a name="l00141"></a>00141         <span class="keywordtype">void</span> set_values ( <span class="keywordtype">double</span> ( *evalptr ) ( <span class="keyword">const</span> vec&amp; ) );
154<a name="l00142"></a>00142
155<a name="l00144"></a>00144         <span class="keywordtype">double</span> nearest_val ( <span class="keyword">const</span> vec &amp;val ) {
156<a name="l00145"></a>00145                 <span class="keywordflow">return</span> values ( sup.linear_index ( sup.nearest_point ( val ) ) );
157<a name="l00146"></a>00146         }
158<a name="l00147"></a>00147
159<a name="l00148"></a>00148         vec eval ( <span class="keyword">const</span> vec &amp;val ) {
160<a name="l00149"></a>00149                 <span class="keywordflow">return</span> vec_1 ( nearest_val ( val ) );
161<a name="l00150"></a>00150         }
162<a name="l00151"></a>00151 };
163<a name="l00152"></a>00152 <a class="code" href="user__info_8h.html#4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> ( grid_fnc );
164<a name="l00153"></a>00153
165<a name="l00157"></a><a class="code" href="classbdm_1_1egrid.html">00157</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1egrid.html">egrid</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> {
166<a name="l00158"></a>00158 <span class="keyword">protected</span>:
167<a name="l00159"></a>00159         <a class="code" href="classbdm_1_1rectangular__support.html">rectangular_support</a> sup;
168<a name="l00160"></a>00160         vec values;
169<a name="l00161"></a>00161 <span class="keyword">public</span>:
170<a name="l00163"></a><a class="code" href="classbdm_1_1egrid.html#3a9f0d4f725b189b08990c5997aa57ae">00163</a>         <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egrid.html#3a9f0d4f725b189b08990c5997aa57ae" title="we assume that evallog is not called too often otherwise we should cache log(values)...">evallog</a> ( <span class="keyword">const</span> vec &amp;val ) {
171<a name="l00164"></a>00164                 <span class="keywordflow">return</span> log ( values ( sup.<a class="code" href="classbdm_1_1rectangular__support.html#2ae8ed78cba8e14b5dcc570b51d7d3f0" title="convert dimension indeces into linear index, the indexing is in the same way as in...">linear_index</a> ( sup.<a class="code" href="classbdm_1_1rectangular__support.html#0ea90fd6ba65251683c04599b6d094b7">nearest_point</a> ( val ) ) ) );
172<a name="l00165"></a>00165         }
173<a name="l00166"></a>00166
174<a name="l00167"></a>00167 };
175<a name="l00168"></a>00168 }
176<a name="l00169"></a>00169 <span class="preprocessor">#endif //DISCR_H</span>
177</pre></div></div>
178<hr size="1"><address style="text-align: right;"><small>Generated on Wed Oct 7 17:34:43 2009 for mixpp by&nbsp;
179<a href="http://www.doxygen.org/index.html">
180<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
181</body>
182</html>
Note: See TracBrowser for help on using the browser.