Automatic Differentiation
 
Loading...
Searching...
No Matches
log1m_inv_logit.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_LOG1M_INV_LOGIT_HPP
2#define STAN_MATH_PRIM_FUN_LOG1M_INV_LOGIT_HPP
3
8#include <cmath>
9
10namespace stan {
11namespace math {
12
37template <typename T, require_arithmetic_t<T>* = nullptr>
38inline double log1m_inv_logit(T&& uu) {
39 const auto u = static_cast<double>(uu);
40 if (u > 0.0) {
41 return -u - log1p_exp(-u); // prevent underflow
42 }
43 return -log1p_exp(u);
44}
45
58 template <typename T>
59 static inline auto fun(T&& x) {
60 return log1m_inv_logit(std::forward<T>(x));
61 }
62};
63
74template <typename T, require_not_var_matrix_t<T>* = nullptr,
75 require_not_nonscalar_prim_or_rev_kernel_expression_t<T>* = nullptr,
76 require_container_t<T>* = nullptr>
77inline auto log1m_inv_logit(T&& x) {
79}
80
81} // namespace math
82} // namespace stan
83
84#endif
fvar< T > log1p_exp(const fvar< T > &x)
Definition log1p_exp.hpp:14
fvar< T > log1m_inv_logit(const fvar< T > &x)
Return the natural logarithm of one minus the inverse logit of the specified argument.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Base template class for vectorization of unary scalar functions defined by a template class F to a sc...
static auto fun(T &&x)
Return the natural logarithm of one minus the inverse logit of the specified argument.
Structure to wrap log1m_inv_logit() so it can be vectorized.