Changeset 568

Show
Ignore:
Timestamp:
08/20/09 00:54:44 (15 years ago)
Author:
smidl
Message:

bdmtoolbox adapted to shared_ptr, merger_grid (partially) working,

Location:
applications/bdmtoolbox
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • applications/bdmtoolbox/mex/config2mxstruct.cpp

    r411 r568  
    1313                } 
    1414                catch(exception e){ 
    15                         cout <<e.what() <<endl; 
     15                        cout <<"Error: " << e.what() <<endl; 
    1616                } 
    1717        } 
  • applications/bdmtoolbox/mex/estimator.cpp

    r490 r568  
    109109#endif 
    110110         
    111         logger* L = UI::build<logger>( Cfg, "logger"); 
    112         ArxDS * DS = UI::build<ArxDS>( Cfg, "system" ); 
    113         Array<BM*> Es;  UI::get(Es,Cfg, "estimators" ); 
     111        shared_ptr<logger> L = UI::build<logger>( Cfg, "logger"); 
     112        shared_ptr<ArxDS> DS = UI::build<ArxDS>( Cfg, "system" ); 
     113        Array<shared_ptr<BM> > Es;      UI::get(Es,Cfg, "estimators" ); 
    114114        int Ndat; 
    115115        Cfg.lookupValue ( "experiment.ndat",Ndat ); 
     
    151151 
    152152#ifdef MEX 
    153         mexlog* mL=dynamic_cast<mexlog*>(L); 
     153        mexlog* mL=dynamic_cast<mexlog*>(L.get()); 
    154154 
    155155        if (mL) { // user wants output!! 
     
    158158        } 
    159159#endif 
    160         /////// 
    161         delete L; 
    162         delete DS; 
    163         for (int i;i<Es.length();i++){delete Es(i);delete Dls(i);} 
    164160} 
  • applications/bdmtoolbox/mex/merger.cpp

    r490 r568  
    5959#endif 
    6060        // Sources 
    61         Array<mpdf*> Sources; 
     61        Array<shared_ptr<mpdf> > Sources; 
    6262        //abuse Mer to store sources 
    6363        Setting& _Sources = Cfg.lookup ("Sources"); 
     
    6666        for (int i = 0; i < Slen; i++) { 
    6767                try { 
    68                         mpdf* mtmp = UI::build<mpdf> (_Sources, i); 
     68                        shared_ptr<mpdf> mtmp = UI::build<mpdf> (_Sources, i); 
    6969                        Sources (i) = mtmp; 
    7070                } catch (UIException) { 
     
    7373                                shared_ptr<epdf> etmp = UI::build<epdf> (_Sources, i); 
    7474                                if (etmp) { 
    75                                         Sources (i) = new mepdf (etmp); 
     75                                        Sources (i) = new mepdf (etmp); // hopefully OK 
    7676                                } 
    77                         } catch (UIException e) { 
     77                        } catch (UIException &e) { 
    7878                                it_error ("No mpdfs or epdfs found! " + string (e.what())); 
    7979                        } catch (std::exception e) { 
    8080                                it_error ("Error in UI at " + _Sources[i].getPath()); 
    8181                        } 
    82                 } catch (std::exception e) { 
     82                } catch (std::exception &e) { 
    8383                        it_error ("Error in UI at " + _Sources[i].getPath()); 
    8484                } 
    8585        } 
    8686 
    87         merger_base* Merger = UI::build<merger_base> (Cfg, "Merger"); 
     87        shared_ptr<merger_base> Merger = UI::build<merger_base> (Cfg, "Merger"); 
    8888 
    8989        // Support 
    90         Setting & _Supp = Cfg.lookup ("Support"); 
    91  
    92         if (_Supp.exists ("grid") &&  _Supp.exists ("nbins")) { 
    93                 Array<vec> bounds (0); 
    94                 UI::get (bounds, _Supp, "grid"); 
    95                 ivec nbins (0); 
    96                 UI::get (nbins, _Supp, "nbins"); 
    97                 Merger->set_support (bounds, nbins); 
    98  
    99         } else { 
    100                 if (_Supp.exists ("pdf") &&  _Supp.exists ("nsamples")) { 
    101                         epdf *g0 = UI::build<epdf> (_Supp, "pdf"); 
    102                         int npoints = 100; 
    103                         _Supp.lookupValue ("nsamples", npoints); 
    104                         Merger->set_support (*g0, npoints); 
    105                         delete g0; 
    106                 } else it_error ("Use either [grid,nbins] or [pdf,nsamples]."); 
     90        try { 
     91                shared_ptr<rectangular_support> RecSup = UI::build<rectangular_support> (Cfg, "Support"); 
     92                Merger->set_support(*RecSup); 
     93        } 
     94        catch (UIException &e) { 
     95                shared_ptr<epdf> g0 = UI::build<epdf> (Cfg, "Support"); 
     96                Merger->set_support (*g0, 100); 
    10797        } 
    10898// COMPUTE RESULTS 
    109         Merger->set_sources (Sources, true); // takes care of deletion of sources 
     99        Merger->set_sources (Sources);  
    110100        Merger->merge(); 
    111101 
     
    128118        } 
    129119 
    130         merger_mix* MerMix=dynamic_cast<merger_mix*>(Merger); 
     120        merger_mix* MerMix=dynamic_cast<merger_mix*>(Merger.get()); 
    131121        vec mix_val; 
    132122                         
  • applications/bdmtoolbox/tutorial/arx_mex_test.cfg

    r357 r568  
    1919 
    2020        //optional fields 
    21         dV0 = [1e-3, 1e-5, 1e-5, 1e-5, 1e-5]; //default: 1e-3 for y, 1e-5 for rgr 
     21        dV0 = matrix(5,1,[1e-3, 1e-5, 1e-5, 1e-5, 1e-5]); //default: 1e-3 for y, 1e-5 for rgr 
    2222        //nu0 = 8.;      //default: rgrlen + 2 
    2323        frg = .9991;    // forgetting, default frg=1.0 
  • applications/bdmtoolbox/tutorial/merging/merge_grid.m

    r409 r568  
    1010 
    1111% support 
    12 support.grid={[-5,5]}; 
    13 support.nbins=[100]; 
     12support.class='rectangular_support'; 
     13support.ranges={[-5,5]}; 
     14support.gridsizes=[100]; 
    1415 
    1516% 1D 
     
    4950type=0; 
    5051if type==0 
    51     support2.grid={[-5,5],[0.001,5]}; 
    52     support2.nbins=[10,10]; 
     52    support2.class='rectangular_support'; 
     53    support2.ranges={[-5,5],[0.001,5]}; 
     54    support2.gridsizes=[10,10]; 
    5355else 
    5456    support2=struct('pdf',... 
  • applications/bdmtoolbox/tutorial/merging/pdfs.m

    r409 r568  
    4040Ga_ =struct('class','mepdf','epdf',Ga); % convert f(a) to f(a|) 
    4141Gba = struct('class','mprod',  'mpdfs',{{Gb_a,Ga_}}); 
     42 
     43pd.Ga=Ga; 
     44pd.N1a=N1a; 
     45pd.N1b=N1b; 
     46pd.N2a=N2a; 
     47pd.Nab=Nab; 
     48pd.GiW=GiW; 
     49pd.Gba=Gba; 
     50