Stan Math Library  2.20.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 
8 #include <cmath>
9 #include <limits>
10 
11 namespace stan {
12 namespace math {
13 
46 inline double log1m_exp(double a) {
47  using std::exp;
48  using std::log;
49  if (a >= 0)
50  return NOT_A_NUMBER;
51  else if (a > -0.693147)
52  return log(-expm1(a)); // 0.693147 ~= log(2)
53  else
54  return log1m(exp(a));
55 }
56 
57 } // namespace math
58 } // namespace stan
59 
60 #endif
const double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition: constants.hpp:58
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:12
fvar< T > expm1(const fvar< T > &x)
Definition: expm1.hpp:13
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:11
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:12

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