Stan Math Library: stan/math/prim/scal/fun/log1m_exp.hpp Source File

| Stan Math Library 2.10.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/math/tools/promotion.hpp>
6 #include <boost/throw_exception.hpp>
7 #include <cmath>
8 #include <limits>
9 #include <stdexcept>
10
11 namespace stan {
12 namespace math {
13
39 template <typename T>
40 inline typename boost::math::tools::promote_args<T>::type
41 log1m_exp(const T a) {
42 using std::log;
43 using std::exp;
44 using ::expm1;
45
46 if (a >= 0)
47 return std::numeric_limits<double>::quiet_NaN();
48 else if (a > -0.693147)
49 return log(-expm1(a)); // 0.693147 ~= log(2)
50 else
51 return log1m(exp(a));
52 }
53
54 }
55 }
56
57 #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.