Changeset 178 for bdm/stat/emix.h

Show
Ignore:
Timestamp:
10/15/08 19:04:09 (16 years ago)
Author:
smidl
Message:

Changes in basic structures! new methods

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • bdm/stat/emix.h

    r176 r178  
    3636        //! Component (epdfs) 
    3737        Array<epdf*> Coms; 
     38        //!Flag if owning Coms 
     39        bool destroyComs; 
    3840public: 
    3941        //!Default constructor 
    40         emix ( RV &rv ) : epdf ( rv ) {}; 
    41         //! Set weights \c w and components \c R 
    42         void set_parameters ( const vec &w, const Array<epdf*> &Coms ); 
     42        emix (const RV &rv ) : epdf ( rv ) {}; 
     43        //! Set weights \c w and components \c Coms , Coms are not copied! 
     44        void set_parameters ( const vec &w, const Array<epdf*> &Coms, bool copy=true ); 
    4345 
    4446        vec sample() const; 
     
    5860        //! returns a pointer to the internal mean value. Use with Care! 
    5961        vec& _w() {return w;} 
     62        virtual ~emix(){if (destroyComs){for(int i=0;i<Coms.length();i++){delete Coms(i);}}} 
     63        //! Auxiliary function for taking ownership of the Coms() 
     64        void ownComs(){destroyComs=true;} 
    6065}; 
    6166 
     
    102107                ll = 0; 
    103108                for ( int i = ( n - 1 );i >= 0;i-- ) { 
    104                         if ( rvcinds ( i ).length() > 0 ) { 
    105                                 condi = zeros ( rvcsinrv.length() + rvcinds.length() ); 
     109                        if (( rvcinds ( i ).length() > 0 )||( rvcsinrv ( i ).length() > 0 )) { 
     110                                condi = zeros ( rvcsinrv(i).length() + rvcinds(i).length() ); 
    106111                                // copy data in condition 
    107112                                set_subvector ( condi,rvcinds ( i ), cond ); 
    108113                                // copy data in already generated sample 
    109                                 set_subvector ( condi,rvcsinrv ( i ), smp ); 
     114                                set_subvector ( condi,rvinrvcs ( i ), get_vec(smp,rvcsinrv(i)) ); 
    110115 
    111116                                mpdfs ( i )->condition ( condi );