Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lmgamma.hpp
Go to the documentation of this file.
1 #ifndef STAN__AGRAD__REV__FUNCTIONS__LMGAMMA_HPP
2 #define STAN__AGRAD__REV__FUNCTIONS__LMGAMMA_HPP
3 
4 #include <valarray>
5 #include <stan/agrad/rev/var.hpp>
10 
11 namespace stan {
12  namespace agrad {
13 
14  namespace {
15  class lmgamma_dv_vari : public op_dv_vari {
16  public:
17  lmgamma_dv_vari(int a, vari* bvi) :
18  op_dv_vari(stan::math::lmgamma(a, bvi->val_),a,bvi) {
19  }
20  void chain() {
21  double deriv = 0;
22  for (int i = 1; i < ad_ + 1; i++)
23  deriv += stan::math::digamma(bvi_->val_ + (1.0 - i) / 2.0);
24  bvi_->adj_ += adj_ * deriv;
25  }
26  };
27  }
28 
29  inline var lmgamma(int a, const stan::agrad::var& b) {
30  return var(new lmgamma_dv_vari(a, b.vi_));
31  }
32 
33  }
34 }
35 #endif
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:40
double digamma(double x)
Definition: digamma.hpp:39
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:27
fvar< typename stan::return_type< T, int >::type > lmgamma(int x1, const fvar< T > &x2)
Definition: lmgamma.hpp:16

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