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
36inline double log1m_inv_logit(double u) {
37 using std::exp;
38 if (u > 0.0) {
39 return -u - log1p_exp(-u); // prevent underflow
40 }
41 return -log1p_exp(u);
42}
43
51inline double log1m_inv_logit(int u) {
52 return log1m_inv_logit(static_cast<double>(u));
53}
54
67 template <typename T>
68 static inline auto fun(const T& x) {
69 return log1m_inv_logit(x);
70 }
71};
72
83template <typename T, require_not_var_matrix_t<T>* = nullptr,
84 require_not_nonscalar_prim_or_rev_kernel_expression_t<T>* = nullptr>
85inline typename apply_scalar_unary<log1m_inv_logit_fun, T>::return_t
86log1m_inv_logit(const T& x) {
88}
89
90} // namespace math
91} // namespace stan
92
93#endif
fvar< T > log1p_exp(const fvar< T > &x)
Definition log1p_exp.hpp:13
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(const 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.