| Stan Math Library 2.11.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/scal/fun/log1m.hpp>
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;
41 using ::expm1;
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
stan
Definition: log_sum_exp.hpp:8
stan::math::log
fvar< T > log(const fvar< T > &x)
Definition: log.hpp:15
stan::math::expm1
fvar< T > expm1(const fvar< T > &x)
Definition: expm1.hpp:12
stan::math::exp
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
stan::math::log1m_exp
fvar< T > log1m_exp(const fvar< T > &x)
Definition: log1m_exp.hpp:16
log1m.hpp
stan::math::log1m
fvar< T > log1m(const fvar< T > &x)
Definition: log1m.hpp:16

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