Stan Math Library  2.20.0
reverse mode automatic differentiation
log1m_inv_logit.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_LOG1M_INV_LOGIT_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_LOG1M_INV_LOGIT_HPP
3 
6 #include <cmath>
7 
8 namespace stan {
9 namespace math {
10 
35 inline double log1m_inv_logit(double u) {
36  using std::exp;
37  if (u > 0.0)
38  return -u - log1p(exp(-u)); // prevent underflow
39  return -log1p(exp(u));
40 }
41 
49 inline double log1m_inv_logit(int u) {
50  return log1m_inv_logit(static_cast<double>(u));
51 }
52 
53 } // namespace math
54 } // namespace stan
55 #endif
fvar< T > log1m_inv_logit(const fvar< T > &x)
Return the natural logarithm of one minus the inverse logit of the specified argument.
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:11
fvar< T > log1p(const fvar< T > &x)
Definition: log1p.hpp:12

     [ Stan Home Page ] © 2011–2018, Stan Development Team.