Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lgamma.hpp
Go to the documentation of this file.
1 #ifndef STAN__AGRAD__REV__FUNCTIONS__LGAMMA_HPP
2 #define STAN__AGRAD__REV__FUNCTIONS__LGAMMA_HPP
3 
4 #include <valarray>
5 #include <stan/agrad/rev/var.hpp>
8 #include <boost/math/special_functions/digamma.hpp>
9 #include <boost/math/special_functions/gamma.hpp>
10 
11 namespace stan {
12  namespace agrad {
13 
14  namespace {
15  class lgamma_vari : public op_v_vari {
16  public:
17  lgamma_vari(double value, vari* avi) :
18  op_v_vari(value, avi) {
19  }
20  void chain() {
21  avi_->adj_ += adj_ * boost::math::digamma(avi_->val_);
22  }
23  };
24  }
25 
36  inline var lgamma(const stan::agrad::var& a) {
37  double lgamma_a = boost::math::lgamma(a.val());
38  return var(new lgamma_vari(lgamma_a, a.vi_));
39  }
40 
41  }
42 }
43 #endif
double val() const
Return the value of this variable.
Definition: var.hpp:209
fvar< T > lgamma(const fvar< T > &x)
Definition: lgamma.hpp:15
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:40
double lgamma(double x)
Definition: lgamma.hpp:31
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:27
fvar< T > digamma(const fvar< T > &x)
Definition: digamma.hpp:16

     [ Stan Home Page ] © 2011–2014, Stan Development Team.