| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
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
digamma.hpp
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:32
stan::math::var::vi_
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:44
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–2015, Stan Development Team.