root/applications/bdmtoolbox/mex/mixef_init.cpp @ 801

Revision 801, 1.7 kB (checked in by smidl, 14 years ago)

disable debug write to disc

Line 
1/*!
2\file
3\brief wrapper function for MixEF.init() + MixEF.bayes_batch()
4
5
6 */
7
8#include <estim/mixtures.h>
9#include <estim/arx.h>
10
11using namespace bdm;
12
13#ifdef MEX
14#include <mex/mex_parser.h>
15#include <mex/mex_function.h>
16
17void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) {
18        // Check the number of inputs and output arguments
19        if ( n_input<1 ) mexErrMsgTxt ( "Usage:\n"
20                                                "Mix=mixef_init(Data, Com1)\n"
21                                                "  Data = [];                                 % matrix of data \n"
22                                                "  Com1 = struct('class','BMEF_offspring');   % A typical component \n"
23                                                "output:\n"
24                                                "  structure with description of mixture." );
25
26        //input check
27        if (!mxIsNumeric(input[0])) mexErrMsgTxt("Given input #1 is not a data matrix.");
28        if (n_input<2) mexErrMsgTxt("No initial component, dont know what type of mixture to fit.");
29        if (!mxIsStruct(input[1])) mexErrMsgTxt("Given input #2 is not a struct.");
30        //output check
31        if ( n_output<1 ) mexErrMsgTxt ( "No output - nothing to do!" );
32
33        // act
34        RV::clear_all();
35
36        mat Data=mxArray2mat(input[0]);
37       
38        UImxArray Cfg(input[1]);
39//      Cfg.writeFile("mixef_init.cfg");
40
41#else
42int main() {
43        UIFile Cfg ( "mixef_init.cfg" );
44        mat Data=randn(2,100); // <<<<<<<<< ============== beware!!!
45#endif
46       
47        shared_ptr<BMEF> com1=UI::build<BMEF>(Cfg.getRoot());
48        MixEF mix;
49        mix.init(&(*com1),Data,10);
50        mix.bayes_batch(Data,zeros(0,Data.cols()),ones(Data.cols()));
51       
52#ifdef MEX     
53        UImxArray out;
54        UI::save( &mix, out );
55        output[0]= out.create_mxArray();
56#else
57        UIFile out;
58        UI::save ( &mix, out, "test" );
59        out.save ( "mixef_init.out" );
60#endif
61}
Note: See TracBrowser for help on using the browser.