Stan Math Library
2.20.0
reverse mode automatic differentiation
stan
math
prim
scal
fun
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
4
#include <
stan/math/prim/meta.hpp
>
5
#include <
stan/math/prim/scal/fun/log1p.hpp
>
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
stan
Definition:
log_sum_exp.hpp:8
meta.hpp
stan::math::exp
fvar< T > exp(const fvar< T > &x)
Definition:
exp.hpp:11
stan::math::log1p
fvar< T > log1p(const fvar< T > &x)
Definition:
log1p.hpp:12
log1p.hpp
stan::math::log_inv_logit
fvar< T > log_inv_logit(const fvar< T > &x)
Definition:
log_inv_logit.hpp:12
[
Stan Home Page
]
© 2011–2018, Stan Development Team.