root/doc/html/gmm_8h-source.html @ 353

Revision 353, 11.0 kB (checked in by smidl, 16 years ago)

doc

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: gmm.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="modules.html"><span>Modules</span></a></li>
55      <li><a href="annotated.html"><span>Classes</span></a></li>
56      <li class="current"><a href="files.html"><span>Files</span></a></li>
57    </ul>
58  </div>
59  <div class="tabs">
60    <ul>
61      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
62      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
63    </ul>
64  </div>
65<h1>gmm.h</h1><a href="gmm_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
66<a name="l00029"></a>00029 <span class="preprocessor">#ifndef GMM_H</span>
67<a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#define GMM_H</span>
68<a name="l00031"></a>00031 <span class="preprocessor"></span>
69<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;<a class="code" href="mat_8h.html" title="Matrix Class Definitions.">itpp/base/mat.h</a>&gt;</span>
70<a name="l00033"></a>00033
71<a name="l00034"></a>00034
72<a name="l00035"></a>00035 <span class="keyword">namespace </span>itpp
73<a name="l00036"></a>00036 {
74<a name="l00037"></a>00037
75<a name="l00039"></a>00039
76<a name="l00045"></a>00045 <span class="keyword">class </span>GMM
77<a name="l00046"></a>00046 {
78<a name="l00047"></a>00047 <span class="keyword">public</span>:
79<a name="l00048"></a>00048   GMM();
80<a name="l00049"></a>00049   GMM(<span class="keywordtype">int</span> nomix, <span class="keywordtype">int</span> dim);
81<a name="l00050"></a>00050   GMM(std::string filename);
82<a name="l00051"></a>00051   <span class="keywordtype">void</span> init_from_vq(<span class="keyword">const</span> vec &amp;codebook, <span class="keywordtype">int</span> dim);
83<a name="l00052"></a>00052   <span class="comment">// void init(const vec &amp;w_in, const vec &amp;m_in, const vec &amp;sigma_in);</span>
84<a name="l00053"></a>00053   <span class="keywordtype">void</span> init(<span class="keyword">const</span> vec &amp;w_in, <span class="keyword">const</span> mat &amp;m_in, <span class="keyword">const</span> mat &amp;sigma_in);
85<a name="l00054"></a>00054   <span class="keywordtype">void</span> load(std::string filename);
86<a name="l00055"></a>00055   <span class="keywordtype">void</span> save(std::string filename);
87<a name="l00056"></a>00056   <span class="keywordtype">void</span> set_weight(<span class="keyword">const</span> vec &amp;weights, <span class="keywordtype">bool</span> compflag = <span class="keyword">true</span>);
88<a name="l00057"></a>00057   <span class="keywordtype">void</span> set_weight(<span class="keywordtype">int</span> i, <span class="keywordtype">double</span> <a class="code" href="group__misccommfunc.html#g1661dfd39dc7327de562d3eca3d113aa" title="Calculate the Hamming weight of a.">weight</a>, <span class="keywordtype">bool</span> compflag = <span class="keyword">true</span>);
89<a name="l00058"></a>00058   <span class="keywordtype">void</span> set_mean(<span class="keyword">const</span> mat &amp;m_in);
90<a name="l00059"></a>00059   <span class="keywordtype">void</span> set_mean(<span class="keyword">const</span> vec &amp;means, <span class="keywordtype">bool</span> compflag = <span class="keyword">true</span>);
91<a name="l00060"></a>00060   <span class="keywordtype">void</span> set_mean(<span class="keywordtype">int</span> i, <span class="keyword">const</span> vec &amp;means, <span class="keywordtype">bool</span> compflag = <span class="keyword">true</span>);
92<a name="l00061"></a>00061   <span class="keywordtype">void</span> set_covariance(<span class="keyword">const</span> mat &amp;sigma_in);
93<a name="l00062"></a>00062   <span class="keywordtype">void</span> set_covariance(<span class="keyword">const</span> vec &amp;covariances, <span class="keywordtype">bool</span> compflag = <span class="keyword">true</span>);
94<a name="l00063"></a>00063   <span class="keywordtype">void</span> set_covariance(<span class="keywordtype">int</span> i, <span class="keyword">const</span> vec &amp;covariances, <span class="keywordtype">bool</span> compflag = <span class="keyword">true</span>);
95<a name="l00064"></a>00064   <span class="keywordtype">int</span> get_no_mixtures();
96<a name="l00065"></a>00065   <span class="keywordtype">int</span> get_no_gaussians()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> M; }
97<a name="l00066"></a>00066   <span class="keywordtype">int</span> get_dimension();
98<a name="l00067"></a>00067   vec get_weight();
99<a name="l00068"></a>00068   <span class="keywordtype">double</span> get_weight(<span class="keywordtype">int</span> i);
100<a name="l00069"></a>00069   vec get_mean();
101<a name="l00070"></a>00070   vec get_mean(<span class="keywordtype">int</span> i);
102<a name="l00071"></a>00071   vec get_covariance();
103<a name="l00072"></a>00072   vec get_covariance(<span class="keywordtype">int</span> i);
104<a name="l00073"></a>00073   <span class="keywordtype">void</span> marginalize(<span class="keywordtype">int</span> d_new);
105<a name="l00074"></a>00074   <span class="keywordtype">void</span> join(<span class="keyword">const</span> GMM &amp;newgmm);
106<a name="l00075"></a>00075   <span class="keywordtype">void</span> clear();
107<a name="l00076"></a>00076   <span class="keywordtype">double</span> likelihood(<span class="keyword">const</span> vec &amp;x);
108<a name="l00077"></a>00077   <span class="keywordtype">double</span> likelihood_aposteriori(<span class="keyword">const</span> vec &amp;x, <span class="keywordtype">int</span> mixture);
109<a name="l00078"></a>00078   vec likelihood_aposteriori(<span class="keyword">const</span> vec &amp;x);
110<a name="l00079"></a>00079   vec draw_sample();
111<a name="l00080"></a>00080 <span class="keyword">protected</span>:
112<a name="l00081"></a>00081   vec   m, sigma, w;
113<a name="l00082"></a>00082   <span class="keywordtype">int</span>   M, d;
114<a name="l00083"></a>00083 <span class="keyword">private</span>:
115<a name="l00084"></a>00084   <span class="keywordtype">void</span>  compute_internals();
116<a name="l00085"></a>00085   vec   normweight, normexp;
117<a name="l00086"></a>00086 };
118<a name="l00087"></a>00087
119<a name="l00088"></a>00088 <span class="keyword">inline</span> <span class="keywordtype">void</span> GMM::set_weight(<span class="keyword">const</span> vec &amp;weights, <span class="keywordtype">bool</span> compflag) {w = weights; <span class="keywordflow">if</span> (compflag) compute_internals(); }
120<a name="l00089"></a>00089 <span class="keyword">inline</span> <span class="keywordtype">void</span> GMM::set_weight(<span class="keywordtype">int</span> i, <span class="keywordtype">double</span> <a class="code" href="group__misccommfunc.html#g1661dfd39dc7327de562d3eca3d113aa" title="Calculate the Hamming weight of a.">weight</a>, <span class="keywordtype">bool</span> compflag) {w(i) = weight; <span class="keywordflow">if</span> (compflag) compute_internals(); }
121<a name="l00090"></a>00090 <span class="keyword">inline</span> <span class="keywordtype">void</span> GMM::set_mean(<span class="keyword">const</span> vec &amp;means, <span class="keywordtype">bool</span> compflag) {m = means; <span class="keywordflow">if</span> (compflag) compute_internals(); }
122<a name="l00091"></a>00091 <span class="keyword">inline</span> <span class="keywordtype">void</span> GMM::set_covariance(<span class="keyword">const</span> vec &amp;covariances, <span class="keywordtype">bool</span> compflag) {sigma = covariances; <span class="keywordflow">if</span> (compflag) compute_internals(); }
123<a name="l00092"></a>00092 <span class="keyword">inline</span> <span class="keywordtype">int</span> GMM::get_dimension() {<span class="keywordflow">return</span> d;}
124<a name="l00093"></a>00093 <span class="keyword">inline</span> vec GMM::get_weight() {<span class="keywordflow">return</span> w;}
125<a name="l00094"></a>00094 <span class="keyword">inline</span> <span class="keywordtype">double</span> GMM::get_weight(<span class="keywordtype">int</span> i) {<span class="keywordflow">return</span> w(i);}
126<a name="l00095"></a>00095 <span class="keyword">inline</span> vec GMM::get_mean() {<span class="keywordflow">return</span> m;}
127<a name="l00096"></a>00096 <span class="keyword">inline</span> vec GMM::get_mean(<span class="keywordtype">int</span> i) {<span class="keywordflow">return</span> m.mid(i*d, d);}
128<a name="l00097"></a>00097 <span class="keyword">inline</span> vec GMM::get_covariance() {<span class="keywordflow">return</span> sigma;}
129<a name="l00098"></a>00098 <span class="keyword">inline</span> vec GMM::get_covariance(<span class="keywordtype">int</span> i) {<span class="keywordflow">return</span> sigma.mid(i*d, d);}
130<a name="l00099"></a>00099
131<a name="l00100"></a>00100 GMM gmmtrain(Array&lt;vec&gt; &amp;TrainingData, <span class="keywordtype">int</span> M, <span class="keywordtype">int</span> NOITER = 30, <span class="keywordtype">bool</span> VERBOSE = <span class="keyword">true</span>);
132<a name="l00101"></a>00101
133<a name="l00103"></a>00103
134<a name="l00104"></a>00104 } <span class="comment">// namespace itpp</span>
135<a name="l00105"></a>00105
136<a name="l00106"></a>00106 <span class="preprocessor">#endif // #ifndef GMM_H</span>
137</pre></div></div>
138<hr size="1"><address style="text-align: right;"><small>Generated on Tue Jun 2 10:02:11 2009 for mixpp by&nbsp;
139<a href="http://www.doxygen.org/index.html">
140<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
141</body>
142</html>
Note: See TracBrowser for help on using the browser.