Stan Math Library  2.15.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 
5 #include <boost/math/tools/promotion.hpp>
6 #include <cmath>
7 
8 namespace stan {
9  namespace math {
10 
34  inline double log_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 log_inv_logit(int u) {
49  return log_inv_logit(static_cast<double>(u));
50  }
51 
52  }
53 }
54 
55 #endif
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
fvar< T > log1p(const fvar< T > &x)
Definition: log1p.hpp:11
fvar< T > log_inv_logit(const fvar< T > &x)

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