Stan Math Library  2.15.0
reverse mode automatic differentiation
lgamma.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_SCAL_FUN_LGAMMA_HPP
2 #define STAN_MATH_REV_SCAL_FUN_LGAMMA_HPP
3 
4 #include <stan/math/rev/core.hpp>
8 
9 namespace stan {
10  namespace math {
11 
12  namespace {
13  class lgamma_vari : public op_v_vari {
14  public:
15  lgamma_vari(double value, vari* avi) :
16  op_v_vari(value, avi) {
17  }
18  void chain() {
19  avi_->adj_ += adj_ * digamma(avi_->val_);
20  }
21  };
22  }
23 
34  inline var lgamma(const var& a) {
35  return var(new lgamma_vari(lgamma(a.val()), a.vi_));
36  }
37 
38  }
39 }
40 #endif
fvar< T > lgamma(const fvar< T > &x)
Return the natural logarithm of the gamma function applied to the specified argument.
Definition: lgamma.hpp:20
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:30
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:42
double val() const
Return the value of this variable.
Definition: var.hpp:230
fvar< T > digamma(const fvar< T > &x)
Return the derivative of the log gamma function at the specified argument.
Definition: digamma.hpp:22

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