1 | /*! |
---|
2 | \file |
---|
3 | \brief wrapper function for arx.structure_est_LT() |
---|
4 | |
---|
5 | |
---|
6 | */ |
---|
7 | |
---|
8 | #include <stat/emix.h> |
---|
9 | |
---|
10 | using 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 | #include <estim/arx.h> |
---|
18 | |
---|
19 | void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) { |
---|
20 | // Check the number of inputs and output arguments |
---|
21 | if ( n_input<1 ) mexErrMsgTxt ( "Usage:\n" |
---|
22 | "arx_struct=arx_structure_reduction(ARX_struct, ARX_prior)\n" |
---|
23 | " ARX_struct = struct('class','ARX',...); % posterior ARX\n" |
---|
24 | " ARX_prior = struct('class','ARX',...); % prior ARX\n" |
---|
25 | "output:\n" |
---|
26 | " ARX_struct = struct('class','ARX',...); % best reduced structure of ARX class." ); |
---|
27 | |
---|
28 | RV::clear_all(); |
---|
29 | //CONFIG |
---|
30 | if (n_input<2){ bdm_error("no prior entered"); } |
---|
31 | |
---|
32 | UImxArray Cfg(input[0]); |
---|
33 | UImxArray Cfgpri(input[1]); |
---|
34 | |
---|
35 | shared_ptr<ARX> A1=UI::build<ARX>(Cfg); |
---|
36 | shared_ptr<ARX> Apri=UI::build<ARX>(Cfgpri); |
---|
37 | |
---|
38 | if ((A1) && (Apri)){ |
---|
39 | bdm_assert(A1->posterior()._dimx()==1, "First ARX is not one-dimensional"); |
---|
40 | bdm_assert(Apri->posterior()._dimx()==1, "Prior ARX is not one-dimensional"); |
---|
41 | bdm_assert(A1->_rgr().length()==A1->_rgrlen(), "First ARX is not properly described: rgr="+A1->_rgr().to_string()+ |
---|
42 | " expected scalar descriptors of total length "+num2str(A1->_rgrlen())); |
---|
43 | //if ( n_output<1 ) mexErrMsgTxt ( "No output - nothing to do!" ); |
---|
44 | ivec strnew=A1->structure_est_LT(Apri->posterior()); |
---|
45 | UImxArray Out; |
---|
46 | A1->reduce_structure(strnew); |
---|
47 | UI::save(A1, Out); |
---|
48 | output[0]=UImxArray::create_mxArray(Out); |
---|
49 | } else { |
---|
50 | mexErrMsgTxt ( "Given objects are not ARX" ); |
---|
51 | } |
---|
52 | } |
---|
53 | #endif |
---|