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
8
9namespace stan {
10namespace math {
11
12namespace internal {
13
15 public:
17 : op_vv_vari(log_rising_factorial(avi->val_, bvi->val_), avi, bvi) {}
18 void chain() {
19 avi_->adj_
20 += adj_ * (digamma(avi_->val_ + bvi_->val_) - digamma(avi_->val_));
21 bvi_->adj_ += adj_ * digamma(avi_->val_ + bvi_->val_);
22 }
23};
24
26 public:
28 : op_vd_vari(log_rising_factorial(avi->val_, b), avi, b) {}
29 void chain() {
30 avi_->adj_ += adj_ * (digamma(avi_->val_ + bd_) - digamma(avi_->val_));
31 }
32};
33
35 public:
37 : op_dv_vari(log_rising_factorial(a, bvi->val_), a, bvi) {}
38 void chain() { bvi_->adj_ += adj_ * digamma(bvi_->val_ + ad_); }
39};
40} // namespace internal
41
42inline var log_rising_factorial(const var& a, double b) {
43 return var(new internal::log_rising_factorial_vd_vari(a.vi_, b));
44}
45
46inline var log_rising_factorial(const var& a, const var& b) {
47 return var(new internal::log_rising_factorial_vv_vari(a.vi_, b.vi_));
48}
49
50inline var log_rising_factorial(double a, const var& b) {
51 return var(new internal::log_rising_factorial_dv_vari(a, b.vi_));
52}
53
54} // namespace math
55} // namespace stan
56#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 ...