Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
digamma.hpp
Go to the documentation of this file.
1 #ifndef STAN__AGRAD__REV__FUNCTIONS__DIGAMMA_HPP
2 #define STAN__AGRAD__REV__FUNCTIONS__DIGAMMA_HPP
3 
4 #include <boost/math/special_functions/digamma.hpp>
5 #include <boost/math/special_functions/zeta.hpp>
6 #include <stan/agrad/rev/var.hpp>
9 
10 namespace stan {
11  namespace agrad {
12 
13  namespace {
14  class digamma_vari : public op_v_vari {
15  public:
16  digamma_vari(vari* avi) :
17  op_v_vari(boost::math::digamma(avi->val_), avi) {
18  }
19  void chain() {
20  avi_->adj_ += adj_ * stan::math::trigamma(avi_->val_);
21  }
22  };
23  }
24 
25  inline var digamma(const stan::agrad::var& a) {
26  return var(new digamma_vari(a.vi_));
27  }
28 
29  }
30 }
31 #endif
T trigamma(T x)
Definition: trigamma.hpp:49
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:40
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:27
fvar< T > digamma(const fvar< T > &x)
Definition: digamma.hpp:16

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