Automatic Differentiation
 
Loading...
Searching...
No Matches
log_inv_logit.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUN_LOG_INV_LOGIT_HPP
2#define STAN_MATH_REV_FUN_LOG_INV_LOGIT_HPP
3
8
9namespace stan {
10namespace math {
11
20template <typename T, require_arithmetic_t<T>* = nullptr>
21inline auto log_inv_logit(const var_value<T>& u) {
22 return make_callback_var(log_inv_logit(u.val()), [u](auto& vi) mutable {
23 u.adj() += vi.adj() * inv_logit(-u.val());
24 });
25}
26
35template <typename T, require_eigen_t<T>* = nullptr>
36inline auto log_inv_logit(const var_value<T>& u) {
37 return make_callback_var(log_inv_logit(u.val()), [u](auto& vi) mutable {
38 u.adj().array() += vi.adj().array() * inv_logit(-u.val()).array();
39 });
40}
41
42} // namespace math
43} // namespace stan
44#endif
var_value< plain_type_t< T > > make_callback_var(T &&value, F &&functor)
Creates a new var initialized with a callback_vari with a given value and reverse-pass callback funct...
fvar< T > log_inv_logit(const fvar< T > &x)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...