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

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

lmgamma.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_SCAL_FUN_LMGAMMA_HPP
2 #define STAN_MATH_REV_SCAL_FUN_LMGAMMA_HPP
3
4 #include <stan/math/rev/core.hpp>
5 #include <stan/math/prim/scal/fun/constants.hpp>
6 #include <stan/math/prim/scal/fun/lmgamma.hpp>
7 #include <stan/math/prim/scal/fun/digamma.hpp>
8 #include <valarray>
9
10 namespace stan {
11 namespace math {
12
13 namespace {
14 class lmgamma_dv_vari : public op_dv_vari {
15 public:
16 lmgamma_dv_vari(int a, vari* bvi) :
17 op_dv_vari(stan::math::lmgamma(a, bvi->val_), a, bvi) {
18 }
19 void chain() {
20 double deriv = 0;
21 for (int i = 1; i < ad_ + 1; i++)
22 deriv += stan::math::digamma(bvi_->val_ + (1.0 - i) / 2.0);
23 bvi_->adj_ += adj_ * deriv;
24 }
25 };
26 }
27
28 inline var lmgamma(int a, const stan::math::var& b) {
29 return var(new lmgamma_dv_vari(a, b.vi_));
30 }
31
32 }
33 }
34 #endif
core.hpp
stan
Definition: log_sum_exp.hpp:8
digamma.hpp
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:31
stan::math::var::vi_
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:43
constants.hpp
lmgamma.hpp
stan::math::lmgamma
fvar< typename stan::return_type< T, int >::type > lmgamma(int x1, const fvar< T > &x2)
Definition: lmgamma.hpp:16
stan::math::digamma
fvar< T > digamma(const fvar< T > &x)
Definition: digamma.hpp:16

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