Show
Ignore:
Timestamp:
01/11/10 22:55:57 (14 years ago)
Author:
mido
Message:

abstract methods restored wherever they are meaningful
macros NOT_IMPLEMENTED and NOT_IMPLEMENTED_VOID defined to make sources shorter
emix::set_parameters and mmix::set_parameters removed, corresponding acces methods created and the corresponding validate methods improved appropriately
some compilator warnings were avoided
and also a few other things cleaned up

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/bdm/stat/emix.h

    r750 r766  
    5353                // adjust rv and rvc 
    5454 
    55                 set_rv ( rv ); // TODO co kdyby tohle samo uz nastavovalo dimension?!?! 
     55                set_rv ( rv );  
    5656                dim = rv._dsize(); 
    5757 
     
    8181                return tmp; 
    8282        } 
     83 
     84        //! Returns a sample from the density conditioned on \c cond, \f$x \sim epdf(rv|cond)\f$. \param cond is numeric value of \c rv 
     85        virtual vec samplecond ( const vec &cond ) NOT_IMPLEMENTED(0); 
     86 
    8387        //! Object takes ownership of nom and will destroy it 
    8488        void ownnom() { 
     
    9195                } 
    9296        } 
     97 
     98 
     99 
    93100 
    94101private: 
     
    120127        emix ( ) : epdf ( ) { } 
    121128 
    122         /*! 
    123           \brief Set weights \c w and components \c Coms 
    124  
    125           Shared pointers in Coms are kept inside this instance and 
    126           shouldn't be modified after being passed to this method. 
    127         */ 
    128         void set_parameters ( const vec &w, const Array<shared_ptr<epdf> > &Coms ); 
    129      
    130129        virtual void validate (); 
    131130 
     
    148147        shared_ptr<pdf> condition ( const RV &rv ) const; 
    149148 
    150         //Access methods 
    151         //! returns a pointer to the internal mean value. Use with Care! 
     149        //Access methods         
     150        //! returns a reference to the internal weights. Use with Care! 
    152151        vec& _w() { 
    153152                return w; 
    154153        } 
    155154 
    156         //!access function 
     155        /*! 
     156          \brief returns a reference to the internal array of components. Use with Care! Set components \c Coms 
     157 
     158          Shared pointers in Coms are kept inside this instance and 
     159          shouldn't be modified after being passed to this method. 
     160        */ 
     161        Array<shared_ptr<epdf>>& _Coms ( ) { 
     162                return Coms; 
     163        } 
     164 
     165        //! returns a reference to the internal components specified by index i. Use with Care! 
    157166        shared_ptr<epdf> _Coms ( int i ) { 
    158167                return Coms ( i ); 
     
    174183        //! \endcode 
    175184        //!@} 
    176         void from_setting ( const Setting &set ) { 
    177  
    178                 vec w0; 
    179                 Array<shared_ptr<epdf> > Coms0; 
    180  
    181                 UI::get ( Coms0, set, "pdfs", UI::compulsory ); 
    182  
    183                 if ( !UI::get ( w0, set, "weights", UI::optional ) ) { 
    184                         int len = Coms.length(); 
    185                         w0.set_length ( len ); 
    186                         w0 = 1.0 / len; 
    187                 } 
    188  
    189                 // TODO asi lze nacitat primocare do w a coms, jen co bude hotovy validate() 
    190                 set_parameters ( w0, Coms0 ); 
    191                 validate(); 
    192         } 
     185        void from_setting ( const Setting &set ); 
    193186}; 
    194187SHAREDPTR ( emix ); 
     
    284277        //! Data link for each pdfs 
    285278        Array<shared_ptr<datalink_m2m> > dls; 
    286  
    287 protected: 
    288         //! dummy epdf used only as storage for RV and dim 
    289         epdf iepdf; 
    290279 
    291280public: 
     
    330319        //!@} 
    331320        void from_setting ( const Setting &set ) { 
    332                 Array<shared_ptr<pdf> > atmp; //temporary Array 
    333                 UI::get ( atmp, set, "pdfs", UI::compulsory ); 
    334                 set_elements ( atmp ); 
     321                Array<shared_ptr<pdf> > temp_array;  
     322                UI::get ( temp_array, set, "pdfs", UI::compulsory ); 
     323                set_elements ( temp_array ); 
    335324        } 
    336325}; 
     
    418407        mmix() : Coms ( 0 ) { } 
    419408 
    420         //! Set weights \c w and components \c R 
    421         void set_parameters ( const vec &w0, const Array<shared_ptr<pdf> > &Coms0 ) { 
    422                 //!\todo check if all components are OK 
    423                 Coms = Coms0; 
    424                 w = w0; 
    425  
    426                 if ( Coms0.length() > 0 ) { 
    427                         set_rv ( Coms ( 0 )->_rv() ); 
    428                         dim = rv._dsize(); 
    429                         set_rvc ( Coms ( 0 )->_rvc() ); 
    430                         dimc = rvc._dsize(); 
    431                 } 
    432         } 
    433409        double evallogcond ( const vec &dt, const vec &cond ) { 
    434410                double ll = 0.0; 
     
    449425        //! \endcode 
    450426        //!@} 
    451         void from_setting ( const Setting &set ) { 
    452                 UI::get ( Coms, set, "pdfs", UI::compulsory ); 
    453  
    454                 // TODO ma byt zde, ci ve validate()? 
    455                 if ( Coms.length() > 0 ) { 
    456                         set_rv ( Coms ( 0 )->_rv() ); 
    457                         dim = rv._dsize(); 
    458                         set_rvc ( Coms ( 0 )->_rvc() ); 
    459                         dimc = rvc._dsize(); 
    460                 } 
    461  
    462                 if ( !UI::get ( w, set, "weights", UI::optional ) ) { 
    463                         int len = Coms.length(); 
    464                         w.set_length ( len ); 
    465                         w = 1.0 / len; 
    466                 } 
    467         } 
     427        void from_setting ( const Setting &set ); 
     428 
     429        virtual void validate(); 
    468430}; 
    469431SHAREDPTR ( mmix );