Automatic Differentiation
 
Loading...
Searching...
No Matches
log_inv_logit_diff.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUN_LOG_INV_LOGIT_DIFF_HPP
2#define STAN_MATH_REV_FUN_LOG_INV_LOGIT_DIFF_HPP
3
10
11namespace stan {
12namespace math {
13
38namespace internal {
40 public:
42 : op_vv_vari(log_inv_logit_diff(avi->val_, bvi->val_), avi, bvi) {}
43 void chain() {
44 avi_->adj_
45 -= adj_ * (inv(expm1(bvi_->val_ - avi_->val_)) + inv_logit(avi_->val_));
46
47 bvi_->adj_
48 -= adj_ * (inv(expm1(avi_->val_ - bvi_->val_)) + inv_logit(bvi_->val_));
49 }
50};
51
53 public:
55 : op_vd_vari(log_inv_logit_diff(avi->val_, b), avi, b) {}
56 void chain() {
57 avi_->adj_ -= adj_ * (inv(expm1(bd_ - avi_->val_)) + inv_logit(avi_->val_));
58 }
59};
60
62 public:
64 : op_dv_vari(log_inv_logit_diff(a, bvi->val_), a, bvi) {}
65 void chain() {
66 bvi_->adj_ -= adj_ * (inv(expm1(ad_ - bvi_->val_)) + inv_logit(bvi_->val_));
67 }
68};
69} // namespace internal
70
71inline var log_inv_logit_diff(const var& a, double b) {
72 return var(new internal::log_inv_logit_diff_vd_vari(a.vi_, b));
73}
74
75inline var log_inv_logit_diff(const var& a, const var& b) {
76 return var(new internal::log_inv_logit_diff_vv_vari(a.vi_, b.vi_));
77}
78
79inline var log_inv_logit_diff(double a, const var& b) {
80 return var(new internal::log_inv_logit_diff_dv_vari(a, b.vi_));
81}
82
83} // namespace math
84} // namespace stan
85#endif
fvar< T > expm1(const fvar< T > &x)
Definition expm1.hpp:13
fvar< T > log_inv_logit_diff(const fvar< T > &x, const fvar< T > &y)
Returns fvar with the natural logarithm of the difference of the inverse logits of the specified argu...
var_value< double > var
Definition var.hpp:1187
fvar< T > inv_logit(const fvar< T > &x)
Returns the inverse logit function applied to the argument.
Definition inv_logit.hpp:20
fvar< T > inv(const fvar< T > &x)
Definition inv.hpp:12
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...