Stan Math Library  2.15.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 
6 #include <cmath>
7 #include <limits>
8 
9 namespace stan {
10  namespace math {
11 
44  inline double log1m_exp(double a) {
45  using std::log;
46  using std::exp;
47  if (a >= 0)
48  return std::numeric_limits<double>::quiet_NaN();
49  else if (a > -0.693147)
50  return log(-expm1(a)); // 0.693147 ~= log(2)
51  else
52  return log1m(exp(a));
53  }
54 
55  }
56 }
57 
58 #endif
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:14
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)
Return the natural logarithm of one minus the exponentiation of the specified argument.
Definition: log1m_exp.hpp:23
fvar< T > log1m(const fvar< T > &x)
Definition: log1m.hpp:13

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