Stan Math Library  2.15.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 
5 #include <cmath>
6 
7 namespace stan {
8  namespace math {
9 
34  inline double log1m_inv_logit(double u) {
35  using std::exp;
36  if (u > 0.0)
37  return -u - log1p(exp(-u)); // prevent underflow
38  return -log1p(exp(u));
39  }
40 
48  inline double log1m_inv_logit(int u) {
49  return log1m_inv_logit(static_cast<double>(u));
50  }
51 
52 
53 
54  }
55 }
56 #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:10
fvar< T > log1p(const fvar< T > &x)
Definition: log1p.hpp:11

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