Changeset 1002

Show
Ignore:
Timestamp:
05/27/10 13:08:31 (14 years ago)
Author:
smidl
Message:

new mexes + cleanup

Location:
applications/bdmtoolbox/mex
Files:
2 added
5 modified

Legend:

Unmodified
Added
Removed
  • applications/bdmtoolbox/mex/CMakeLists.txt

    r995 r1002  
    3333 
    3434MEX(bm_bayes) 
     35MEX(bm_bayesweighted) 
     36MEX(bm_epredictor) 
    3537 
    3638MEX(arx_structure_reduction) 
  • applications/bdmtoolbox/mex/arx_structure_reduction.cpp

    r995 r1002  
    3636        shared_ptr<ARX> Apri=UI::build<ARX>(Cfgpri); 
    3737         
    38         if (ARX) && (ARXpri){    
     38        if ((A1) && (Apri)){     
    3939                 
    4040                //if ( n_output<1 ) mexErrMsgTxt ( "No output - nothing to do!" ); 
    41                 ivec strnew=A1->structure_est_LT(Apri); 
     41                ivec strnew=A1->structure_est_LT(Apri->posterior()); 
    4242                UImxArray Out; 
    4343                A1->reduce_structure(strnew); 
  • applications/bdmtoolbox/mex/bm_bayes.cpp

    r978 r1002  
    1414#include <estim/kalman.h> 
    1515#include <estim/particles.h> 
     16#include <estim/mixtures.h> 
    1617#include <mex/mex_BM.h> 
    1718 
    1819void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) { 
    1920        // 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." ); 
     21        if ( n_input<1 ) mexErrMsgTxt (  
     22                "Usage:\n" 
     23                "[bm_struct,logevidence]=bm_bayes(BM_struct, yt, cond)\n" 
     24                "  BM_struct = struct('class','BM_offspring',...);    % description of Bayesian Model (BM)\n" 
     25                "  yt = [...];                                        % vector of observed data\n" 
     26                "  cond = [...];                                      % vector of conditioning variables\n" 
     27                "output:\n" 
     28                "  bm_struct = struct('class','BM_offsprin',...);     % description of BM afret update.\n" 
     29                "  logevidence  = 0.0;                                % logarithm of normalizing constant f(yt|cond)" 
     30                ); 
    2731 
    2832        RV::clear_all(); 
     
    5054                UI::save(bm.get(), Out); 
    5155                output[0]=UImxArray::create_mxArray(Out); 
     56                if (n_output>1){ 
     57                        mxArray *le=mxCreateDoubleScalar(mxREAL); 
     58                        double2mxArray(bm->_ll(), le); 
     59                        output[1]=le; 
     60                } 
    5261        } else {  
    5362                mexErrMsgTxt ( "Given object is not BM" ); 
  • applications/bdmtoolbox/mex/enorm_bhattacharyya.cpp

    r809 r1002  
    2424        //CONFIG 
    2525        UImxArray E1(input[0]); 
    26         UImxArray E2(input[0]); 
     26        UImxArray E2(input[1]); 
    2727//      Cfg.writeFile("epdf_mean.cfg"); 
    2828 
  • applications/bdmtoolbox/mex/mixef_init.cpp

    r801 r1002  
    2121                                                "  Data = [];                                 % matrix of data \n" 
    2222                                                "  Com1 = struct('class','BMEF_offspring');   % A typical component \n" 
     23                                                "  no_com = [10];                             % requested numbebr of component \n" 
    2324                                                "output:\n" 
    2425                                                "  structure with description of mixture." ); 
     
    3738         
    3839        UImxArray Cfg(input[1]); 
    39 //      Cfg.writeFile("mixef_init.cfg"); 
     40        Cfg.writeFile("mixef_init.cfg"); 
    4041 
     42        int no_com=10; 
     43        if (n_input>2){ 
     44                no_com = mxArray2double(input[2]); 
     45        } 
    4146#else 
    4247int main() { 
    4348        UIFile Cfg ( "mixef_init.cfg" ); 
    4449        mat Data=randn(2,100); // <<<<<<<<< ============== beware!!! 
     50        int no_com =10; 
    4551#endif 
    4652         
    4753        shared_ptr<BMEF> com1=UI::build<BMEF>(Cfg.getRoot()); 
    4854        MixEF mix; 
    49         mix.init(&(*com1),Data,10); 
     55        mix.init(&(*com1),Data,no_com); 
    5056        mix.bayes_batch(Data,zeros(0,Data.cols()),ones(Data.cols())); 
    51          
     57        shared_ptr<epdf> p=mix.epredictor(vec(0)); 
     58        UIFile prf; 
     59        UI::save(p.get(), prf.getRoot(),"predictor"); 
     60        prf.writeFile("mix_pred.cfg"); 
     61                 
    5262#ifdef MEX       
    5363        UImxArray out; 
    5464        UI::save( &mix, out ); 
    5565        output[0]= out.create_mxArray(); 
     66        if (n_output>1){ 
     67                UImxArray ep; 
     68                shared_ptr<epdf> p=mix.epredictor(vec(0)); 
     69                UI::save( p.get(), ep ); 
     70                output[1] = ep.create_mxArray(); 
     71        } 
     72         
    5673#else 
    5774        UIFile out;