BCPositiveDefinitePrior.cxx
1 /*
2  * Copyright (C) 2007-2018, the BAT core developer team
3  * All rights reserved.
4  *
5  * For the licensing terms see doc/COPYING.
6  * For documentation see http://mpp.mpg.de/bat
7  */
8 
9 #include "BCPositiveDefinitePrior.h"
10 
11 // ---------------------------------------------------------
13  : BCPrior(),
14  fPrior(prior)
15 {
16 }
17 
18 // ---------------------------------------------------------
20  : BCPrior(other),
21  fPrior(other.fPrior->Clone())
22 {
23 }
24 
25 // ---------------------------------------------------------
27 {
28  delete fPrior;
29 }
30 
31 // ---------------------------------------------------------
33 {
34  swap(*this, other);
35  return *this;
36 }
37 
38 // ---------------------------------------------------------
40 {
41  swap(static_cast<BCPrior&>(A), static_cast<BCPrior&>(B));
42  std::swap(A.fPrior, B.fPrior);
43 }
44 
45 // ---------------------------------------------------------
46 double BCPositiveDefinitePrior::GetRandomValue(double xmin, double xmax, TRandom* const R)
47 {
48  xmin = std::max<double>(xmin, 0);
49  xmax = std::max<double>(xmax, 0);
50  if (xmin == xmax)
51  return std::numeric_limits<double>::quiet_NaN();
52  return fPrior->GetRandomValue(xmin, xmax, R);
53 }
A class to represent the prior of a parameter.
Definition: BCPrior.h:49
BCPositiveDefinitePrior(BCPrior *prior)
Constructor.
BCPrior * fPrior
Prior that is cut to positive values.
BCPositiveDefinitePrior & operator=(BCPositiveDefinitePrior other)
assignment operator
virtual BCPrior * Clone() const
Clone function.
A class to wrap around a BCPrior to make it positive definite.
virtual double GetRandomValue(double xmin, double xmax, TRandom *const R=NULL)
Definition: BCPrior.cxx:126
friend void swap(BCPositiveDefinitePrior &A, BCPositiveDefinitePrior &B)
swap
virtual double GetRandomValue(double xmin, double xmax, TRandom *const R=NULL)
virtual ~BCPositiveDefinitePrior()
Destructor.