Stan Math Library
2.20.0
reverse mode automatic differentiation
stan
math
prim
scal
fun
log1p_exp.hpp
Go to the documentation of this file.
1
#ifndef STAN_MATH_PRIM_SCAL_FUN_LOG1P_EXP_HPP
2
#define STAN_MATH_PRIM_SCAL_FUN_LOG1P_EXP_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
43
inline
double
log1p_exp
(
double
a) {
44
using
std::exp
;
45
// like log_sum_exp below with b=0.0; prevents underflow
46
if
(a > 0.0)
47
return
a +
log1p
(
exp
(-a));
48
return
log1p
(
exp
(a));
49
}
50
51
}
// namespace math
52
}
// namespace stan
53
54
#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_exp
fvar< T > log1p_exp(const fvar< T > &x)
Definition:
log1p_exp.hpp:12
stan::math::log1p
fvar< T > log1p(const fvar< T > &x)
Definition:
log1p.hpp:12
log1p.hpp
[
Stan Home Page
]
© 2011–2018, Stan Development Team.