78 | | Example of a mexfile: <div class="fragment"><pre class="fragment"></pre></div> </div> |
79 | | <hr size="1"><address style="text-align: right;"><small>Generated on Fri Mar 6 15:01:37 2009 for mixpp by |
| 78 | Example of a mexfile: <div class="fragment"><pre class="fragment"><span class="preprocessor">#include <itpp/itmex.h></span> |
| 79 | <span class="preprocessor">#include <<a class="code" href="arx_8h.html" title="Bayesian Filtering for generalized autoregressive (ARX) model.">estim/arx.h</a>></span> |
| 80 | |
| 81 | <span class="keyword">using namespace </span>bdm; |
| 82 | |
| 83 | <span class="keywordtype">void</span> mexFunction(<span class="keywordtype">int</span> n_output, mxArray *output[], <span class="keywordtype">int</span> n_input, <span class="keyword">const</span> mxArray *input[]) |
| 84 | { |
| 85 | <span class="comment">// Check the number of inputs and output arguments</span> |
| 86 | <span class="keywordflow">if</span>(n_output!=1) mexErrMsgTxt(<span class="stringliteral">"Wrong number of output variables!"</span>); |
| 87 | <span class="keywordflow">if</span>(n_input!=2) mexErrMsgTxt(<span class="stringliteral">"Usage: arx1d(ysize, Data)!"</span>); |
| 88 | |
| 89 | <span class="comment">// Convert input variables to IT++ format</span> |
| 90 | <span class="keywordtype">int</span> ysize = mxArray2int(input[0]); |
| 91 | mat Data = mxArray2mat(input[1]); |
| 92 | |
| 93 | <span class="comment">// ------------------ Start of routine ---------------------------</span> |
| 94 | ARX Ar; |
| 95 | Ar.set_statistics(ysize, 1e-5*eye(Data.rows()) ); |
| 96 | Ar.bayesB(Data); |
| 97 | <span class="comment">// ------------------ End of routine -----------------------------</span> |
| 98 | |
| 99 | <span class="comment">// Create output vectors</span> |
| 100 | output[0] = mxCreateDoubleMatrix(1,Data.rows(), mxREAL); |
| 101 | |
| 102 | <span class="comment">// Convert the IT++ format to Matlab format for output</span> |
| 103 | vec2mxArray(Ar.posterior().mean(), output[0]); |
| 104 | } |
| 105 | </pre></div> </div> |
| 106 | <hr size="1"><address style="text-align: right;"><small>Generated on Tue Mar 17 13:51:49 2009 for mixpp by |