root/applications/bdmtoolbox/mex/bm_bayes.cpp @ 978

Revision 978, 1.6 kB (checked in by smidl, 14 years ago)

wrapper for bm.bayes

Line 
1/*!
2\file
3\brief wrapper function for BM.bayes()
4
5
6 */
7
8#include <stat/emix.h>
9
10using namespace bdm;
11
12#ifdef MEX
13#include <estim/arx_ext.h>
14#include <estim/kalman.h>
15#include <estim/particles.h>
16#include <mex/mex_BM.h>
17
18void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) {
19        // Check the number of inputs and output arguments
20        if ( n_input<1 ) mexErrMsgTxt ( "Usage:\n"
21                                                "bm_struct=bm_bayes(BM_struct, yt, cond)\n"
22                                                "  bm_struct = struct('class','BM_offspring',...);    % description of Bayesian Model (BM)\n"
23                                                "  yt = [...];                                        % vector of observed data\n"
24                                                "  cond = [...];                                      % vector of conditioning variables\n"
25                                                "output:\n"
26                                                "  bm_struct = struct('class','BM_offsprin',...);     % description of BM afret update." );
27
28        RV::clear_all();
29        //CONFIG
30        if (n_input<2){                 bdm_error("no observed data entered"); }
31       
32        UImxArray Cfg(input[0]);
33        Cfg.writeFile("BM_bayes.cfg");
34
35        shared_ptr<BM> bm=UI::build<BM>(Cfg);
36       
37        if (bm){       
38                vec yt;
39                vec cond;
40                if (n_input<2){
41                } else {
42                        yt=mxArray2vec(input[1]);
43                        if (n_input>2){
44                                cond =mxArray2vec(input[2]);
45                        }
46                }
47                //if ( n_output<1 ) mexErrMsgTxt ( "No output - nothing to do!" );
48                bm->bayes(yt,cond);
49                UImxArray Out;
50                UI::save(bm.get(), Out);
51                output[0]=UImxArray::create_mxArray(Out);
52        } else { 
53                mexErrMsgTxt ( "Given object is not BM" );
54        }
55}
56#endif
Note: See TracBrowser for help on using the browser.