Stan Math Library: stan/math/rev/scal/fun/lgamma.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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>
5 #include <stan/math/prim/scal/fun/constants.hpp>
6 #include <boost/math/special_functions/digamma.hpp>
7 #include <boost/math/special_functions/gamma.hpp>
8 #include <valarray>
9
10 namespace stan {
11 namespace math {
12
13 namespace {
14 class lgamma_vari : public op_v_vari {
15 public:
16 lgamma_vari(double value, vari* avi) :
17 op_v_vari(value, avi) {
18 }
19 void chain() {
20 avi_->adj_ += adj_ * boost::math::digamma(avi_->val_);
21 }
22 };
23 }
24
35 inline var lgamma(const stan::math::var& a) {
36 double lgamma_a = boost::math::lgamma(a.val());
37 return var(new lgamma_vari(lgamma_a, a.vi_));
38 }
39
40 }
41 }
42 #endif
core.hpp
stan::math::lgamma
fvar< T > lgamma(const fvar< T > &x)
Definition: lgamma.hpp:15
stan
Definition: log_sum_exp.hpp:8
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:31
stan::math::lgamma
var lgamma(const stan::math::var &a)
The log gamma function for variables (C99).
Definition: lgamma.hpp:35
stan::math::var::vi_
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:43
constants.hpp
stan::math::var::val
double val() const
Return the value of this variable.
Definition: var.hpp:233
stan::math::digamma
fvar< T > digamma(const fvar< T > &x)
Definition: digamma.hpp:16

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