Changeset 504 for library/bdm/stat/emix.h
- Timestamp:
- 08/12/09 09:27:40 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/stat/emix.h
r503 r504 39 39 //! Nominator in the form of mpdf 40 40 const epdf* nom; 41 41 42 //!Denominator in the form of epdf 42 epdf* den; 43 shared_ptr<epdf> den; 44 43 45 //!flag for destructor 44 46 bool destroynom; … … 85 87 //! Default destructor 86 88 ~mratio() { 87 delete den;88 89 if ( destroynom ) { 89 90 delete nom; … … 107 108 vec w; 108 109 //! Component (epdfs) 109 Array<epdf*> Coms; 110 //!Flag if owning Coms 111 bool destroyComs; 110 Array<shared_ptr<epdf> > Coms; 111 112 112 public: 113 113 //!Default constructor … … 115 115 //! Set weights \c w and components \c Coms 116 116 //!By default Coms are copied inside. Parameter \c copy can be set to false if Coms live externally. Use method ownComs() if Coms should be destroyed by the destructor. 117 void set_parameters ( const vec &w, const Array< epdf*> &Coms, bool copy = false);117 void set_parameters ( const vec &w, const Array<shared_ptr<epdf> > &Coms ); 118 118 119 119 vec sample() const; … … 164 164 }; 165 165 166 emix* marginal ( const RV &rv ) const; 167 mratio* condition ( const RV &rv ) const; //why not mratio!! 166 shared_ptr<epdf> marginal ( const RV &rv ) const; 167 void marginal ( const RV &rv, emix &target ) const; 168 shared_ptr<mpdf> condition ( const RV &rv ) const; 168 169 169 170 //Access methods … … 172 173 return w; 173 174 } 174 virtual ~emix() {175 if ( destroyComs ) {176 for ( int i = 0; i < Coms.length(); i++ ) {177 delete Coms ( i );178 }179 }180 }181 //! Auxiliary function for taking ownership of the Coms()182 void ownComs() {183 destroyComs = true;184 }185 175 186 176 //!access function 187 epdf*_Coms ( int i ) {177 shared_ptr<epdf> _Coms ( int i ) { 188 178 return Coms ( i ); 189 179 } 180 190 181 void set_rv ( const RV &rv ) { 191 182 epdf::set_rv ( rv ); … … 233 224 double lognc () const { 234 225 return 0; 235 }; 236 emix* marginal ( const RV &rv ) const; 226 } 227 228 shared_ptr<epdf> marginal ( const RV &rv ) const; 229 void marginal ( const RV &rv, emix &target ) const; 237 230 238 231 //Access methods