Automatic Differentiation
 
Loading...
Searching...
No Matches
log_rising_factorial.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUN_LOG_RISING_FACTORIAL_HPP
2#define STAN_MATH_REV_FUN_LOG_RISING_FACTORIAL_HPP
3
9
10namespace stan {
11namespace math {
12
13namespace 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
43inline var log_rising_factorial(const var& a, double b) {
44 return var(new internal::log_rising_factorial_vd_vari(a.vi_, b));
45}
46
47inline var log_rising_factorial(const var& a, const var& b) {
48 return var(new internal::log_rising_factorial_vv_vari(a.vi_, b.vi_));
49}
50
51inline var log_rising_factorial(double a, const var& b) {
52 return var(new internal::log_rising_factorial_dv_vari(a, b.vi_));
53}
54
55} // namespace math
56} // namespace stan
57#endif
fvar< T > log_rising_factorial(const fvar< T > &x, const fvar< T > &n)
var_value< double > var
Definition var.hpp:1187
fvar< T > digamma(const fvar< T > &x)
Return the derivative of the log gamma function at the specified argument.
Definition digamma.hpp:23
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...