Automatic Differentiation
 
Loading...
Searching...
No Matches
log_inv_logit_diff.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_FWD_FUN_LOG_INV_LOGIT_DIFF_HPP
2#define STAN_MATH_FWD_FUN_LOG_INV_LOGIT_DIFF_HPP
3
10
11namespace stan {
12namespace math {
13
37template <typename T>
38inline fvar<T> log_inv_logit_diff(const fvar<T>& x, const fvar<T>& y) {
39 return fvar<T>(
41 -x.d_ * (inv(expm1(y.val_ - x.val_)) + inv_logit(x.val_))
42 - y.d_ * (inv(expm1(x.val_ - y.val_)) + inv_logit(y.val_)));
43}
44
45template <typename T>
46inline fvar<T> log_inv_logit_diff(const fvar<T>& x, double y) {
47 return fvar<T>(log_inv_logit_diff(x.val_, y),
48 -x.d_ * (inv(expm1(y - x.val_)) + inv_logit(x.val_)));
49}
50
51template <typename T>
52inline fvar<T> log_inv_logit_diff(double x, const fvar<T>& y) {
53 return fvar<T>(log_inv_logit_diff(x, y.val_),
54 -y.d_ * (inv(expm1(x - y.val_)) + inv_logit(y.val_)));
55}
56
57} // namespace math
58} // namespace stan
59#endif
fvar< T > expm1(const fvar< T > &x)
Definition expm1.hpp:14
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...
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:13
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Scalar val_
The value of this variable.
Definition fvar.hpp:49
Scalar d_
The tangent (derivative) of this variable.
Definition fvar.hpp:61
This template class represents scalars used in forward-mode automatic differentiation,...
Definition fvar.hpp:40