Stan Math Library  2.20.0
reverse mode automatic differentiation
log_inv_logit.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_LOG_INV_LOGIT_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_LOG_INV_LOGIT_HPP
3 
6 #include <cmath>
7 
8 namespace stan {
9 namespace math {
10 
32 inline double log_inv_logit(double u) {
33  using std::exp;
34  if (u < 0.0)
35  return u - log1p(exp(u)); // prevent underflow
36  return -log1p(exp(-u));
37 }
38 
46 inline double log_inv_logit(int u) {
47  return log_inv_logit(static_cast<double>(u));
48 }
49 
50 } // namespace math
51 } // namespace stan
52 
53 #endif
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:11
fvar< T > log1p(const fvar< T > &x)
Definition: log1p.hpp:12
fvar< T > log_inv_logit(const fvar< T > &x)

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