Show
Ignore:
Timestamp:
08/13/09 15:58:32 (15 years ago)
Author:
vbarta
Message:

using shared_ptr in UI (optionally so far; loading & saving Array<T *> still works but should be phased out); testsuite run leaks down from 8822 to 480 bytes

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/base/datasources.h

    r477 r527  
    173173        }; 
    174174        //! Set 
    175         void set_drv ( RV &yrv, RV &urv, RV &rrv ) { 
     175        void set_drv ( const RV &yrv, const RV &urv, const RV &rrv ) { 
    176176                Rrv = rrv; 
    177177                Urv = urv; 
     
    265265 
    266266class stateDS : public DS { 
     267private: 
     268        //!conditional pdf of the state evolution \f$ f(x_t|x_{t-1}) \f$ 
     269        shared_ptr<mpdf> IM; 
     270 
     271        //!conditional pdf of the observations \f$ f(d_t|x_t) \f$ 
     272        shared_ptr<mpdf> OM; 
     273 
    267274protected: 
    268         //!conditional pdf of the state evolution \f$ f(x_t|x_{t-1}) \f$ 
    269         mpdf* IM; 
    270         //!conditional pdf of the observations \f$ f(d_t|x_t) \f$ 
    271         mpdf* OM; 
    272275        //! result storage 
    273276        vec dt; 
     
    278281        //! Logger 
    279282        int L_xt; 
     283 
    280284public: 
    281285        void getdata ( vec &dt0 ) { 
     
    286290        } 
    287291 
    288         stateDS ( mpdf* IM0, mpdf* OM0, int usize ) : DS ( ), IM ( IM0 ), OM ( OM0 ), 
    289                         dt ( OM0->dimension() ), xt ( IM0->dimension() ), ut ( usize ) {} 
    290  
    291         stateDS() {} 
    292  
    293         ~stateDS() { 
    294                 delete IM; 
    295                 delete OM; 
    296         } 
     292        stateDS ( const shared_ptr<mpdf> &IM0, const shared_ptr<mpdf> &OM0, int usize ) : IM ( IM0 ), OM ( OM0 ), 
     293                dt ( OM0->dimension() ), xt ( IM0->dimension() ), 
     294                ut ( usize ), L_xt(0) { } 
     295 
     296        stateDS() : L_xt(0) { } 
     297 
    297298        virtual void step() { 
    298299                xt = IM->samplecond ( concat ( xt, ut ) ); 
    299300                dt = OM->samplecond ( concat ( xt, ut ) ); 
    300         }; 
     301        } 
    301302 
    302303        virtual void log_add ( logger &L ) {