Stan Math Library  2.20.0
reverse mode automatic differentiation
log_rising_factorial.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_SCAL_FUN_LOG_RISING_FACTORIAL_HPP
2 #define STAN_MATH_REV_SCAL_FUN_LOG_RISING_FACTORIAL_HPP
3 
4 #include <stan/math/rev/meta.hpp>
5 #include <stan/math/rev/core.hpp>
9 
10 namespace stan {
11 namespace math {
12 
13 namespace internal {
14 
16  public:
18  : op_vv_vari(log_rising_factorial(avi->val_, bvi->val_), avi, bvi) {}
19  void chain() {
20  avi_->adj_
21  += adj_ * (digamma(avi_->val_ + bvi_->val_) - digamma(avi_->val_));
22  bvi_->adj_ += adj_ * digamma(avi_->val_ + bvi_->val_);
23  }
24 };
25 
27  public:
29  : op_vd_vari(log_rising_factorial(avi->val_, b), avi, b) {}
30  void chain() {
31  avi_->adj_ += adj_ * (digamma(avi_->val_ + bd_) - digamma(avi_->val_));
32  }
33 };
34 
36  public:
38  : op_dv_vari(log_rising_factorial(a, bvi->val_), a, bvi) {}
39  void chain() { bvi_->adj_ += adj_ * digamma(bvi_->val_ + ad_); }
40 };
41 } // namespace internal
42 
43 inline var log_rising_factorial(const var& a, double b) {
45 }
46 
47 inline var log_rising_factorial(const var& a, const var& b) {
49 }
50 
51 inline var log_rising_factorial(double a, const var& b) {
53 }
54 
55 } // namespace math
56 } // namespace stan
57 #endif
The variable implementation base class.
Definition: vari.hpp:30
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:33
friend class var
Definition: vari.hpp:32
const double val_
The value of this variable.
Definition: vari.hpp:38
void chain()
Apply the chain rule to this variable based on the variables on which it depends. ...
vari * vi_
Pointer to the implementation of this variable.
Definition: var.hpp:45
void chain()
Apply the chain rule to this variable based on the variables on which it depends. ...
fvar< T > log_rising_factorial(const fvar< T > &x, const fvar< T > &n)
void chain()
Apply the chain rule to this variable based on the variables on which it depends. ...
double adj_
The adjoint of this variable, which is the partial derivative of this variable with respect to the ro...
Definition: vari.hpp:44
fvar< T > digamma(const fvar< T > &x)
Return the derivative of the log gamma function at the specified argument.
Definition: digamma.hpp:23

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