Stan Math Library  2.11.0
reverse mode automatic differentiation
log1m_exp.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_LOG1M_EXP_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_LOG1M_EXP_HPP
3 
5 #include <boost/throw_exception.hpp>
6 #include <cmath>
7 #include <limits>
8 #include <stdexcept>
9 
10 namespace stan {
11  namespace math {
12 
38  inline double log1m_exp(const double a) {
39  using std::log;
40  using std::exp;
42 
43  if (a >= 0)
44  return std::numeric_limits<double>::quiet_NaN();
45  else if (a > -0.693147)
46  return log(-expm1(a)); // 0.693147 ~= log(2)
47  else
48  return log1m(exp(a));
49  }
50 
51  }
52 }
53 
54 #endif
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:15
fvar< T > expm1(const fvar< T > &x)
Definition: expm1.hpp:12
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
fvar< T > log1m_exp(const fvar< T > &x)
Definition: log1m_exp.hpp:16
fvar< T > log1m(const fvar< T > &x)
Definition: log1m.hpp:16

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