Changeset 395 for library/bdm/base/bdmbase.h
- Timestamp:
- 06/22/09 13:17:49 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/bdm/base/bdmbase.h
r392 r395 268 268 //! Compute log-probability of multiple values argument \c val 269 269 virtual vec evallog_m(const mat &Val) const { 270 vec x(Val.cols()); 271 for (int i = 0; i < Val.cols(); i++) {x(i) = evallog(Val.get_col(i)) ;} 272 return x; 270 vec x(Val.cols()); 271 for (int i = 0; i < Val.cols(); i++) {x(i) = evallog(Val.get_col(i)) ;} 272 return x; 273 } 274 //! Compute log-probability of multiple values argument \c val 275 virtual vec evallog_m(const Array<vec> &Avec) const { 276 vec x(Avec.size()); 277 for (int i = 0; i < Avec.size(); i++) {x(i) = evallog(Avec(i)) ;} 278 return x; 273 279 } 274 280 //! Return conditional density on the given RV, the remaining rvs will be in conditioning … … 311 317 //! Size of the random variable 312 318 int dimension() const {return dim;} 313 //!@} 319 //! Load from structure with elements: 320 //! \code 321 //! { rv = {class="RV", names=(...),}; // RV describing meaning of random variable 322 //! // elements of offsprings 323 //! } 324 //! \endcode 325 //!@} 326 void from_setting(const Setting &set){ 327 if (set.exists("rv")){ 328 RV* r = UI::build<RV>(set,"rv"); 329 set_rv(*r); 330 delete r; 331 } 332 } 314 333 315 334 }; … … 368 387 //! Matrix version of evallogcond 369 388 virtual vec evallogcond_m(const mat &Dt, const vec &cond) {this->condition(cond); return ep->evallog_m(Dt);}; 389 //! Array<vec> version of evallogcond 390 virtual vec evallogcond_m(const Array<vec> &Dt, const vec &cond) {this->condition(cond); return ep->evallog_m(Dt);}; 370 391 371 392 //! \name Access to attributes … … 378 399 epdf& _epdf() {return *ep;} 379 400 epdf* _e() {return ep;} 401 //! Load from structure with elements: 402 //! \code 403 //! { rv = {class="RV", names=(...),}; // RV describing meaning of random variable 404 //! rvc= {class="RV", names=(...),}; // RV describing meaning of random variable in condition 405 //! // elements of offsprings 406 //! } 407 //! \endcode 408 //!@} 409 void from_setting(const Setting &set){ 410 if (set.exists("rv")){ 411 RV* r = UI::build<RV>(set,"rv"); 412 set_rv(*r); 413 delete r; 414 } 415 if (set.exists("rvc")){ 416 RV* r = UI::build<RV>(set,"rvc"); 417 set_rvc(*r); 418 delete r; 419 } 420 } 380 421 //!@} 381 422 … … 570 611 public: 571 612 //!Default constructor 613 mepdf(){}; 572 614 mepdf ( epdf* em, bool owning_ep0=false ) :mpdf ( ) {ep= em ;owning_ep=owning_ep0;dimc=0;}; 573 615 mepdf (const epdf* em ) :mpdf ( ) {ep=const_cast<epdf*>( em );}; 574 616 void condition ( const vec &cond ) {} 575 617 ~mepdf(){if (owning_ep) delete ep;} 576 }; 618 //! Load from structure with elements: 619 //! \code 620 //! { class = "mepdf", 621 //! epdfs = {class="epdfs",...} 622 //! } 623 //! \endcode 624 //!@} 625 void from_setting(const Setting &set){ 626 epdf* e = UI::build<epdf>(set,"epdf"); 627 ep= e; 628 owning_ep=true; 629 } 630 }; 631 UIREGISTER(mepdf); 577 632 578 633 //!\brief Chain rule of pdfs - abstract part common for mprod and merger.