Stan Math Library  2.20.0
reverse mode automatic differentiation
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 
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
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:11
fvar< T > log1p_exp(const fvar< T > &x)
Definition: log1p_exp.hpp:12
fvar< T > log1p(const fvar< T > &x)
Definition: log1p.hpp:12

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