Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
log1m_exp.hpp
Go to the documentation of this file.
1 #ifndef STAN__AGRAD__FWD__FUNCTIONS__LOG1M_EXP_HPP
2 #define STAN__AGRAD__FWD__FUNCTIONS__LOG1M_EXP_HPP
3 
5 #include <stan/meta/traits.hpp>
7 #include <boost/math/special_functions/expm1.hpp>
9 
10 namespace stan{
11 
12  namespace agrad{
13 
14  template <typename T>
15  inline
16  fvar<T>
17  log1m_exp(const fvar<T>& x) {
19  using boost::math::expm1;
21  using std::exp;
22  if (x.val_ >= 0)
23  return fvar<T>(NOT_A_NUMBER);
24  return fvar<T>(log1m_exp(x.val_), x.d_ / -expm1(-x.val_));
25  }
26  }
27 }
28 #endif
const double NOT_A_NUMBER
(Quiet) not-a-number value.
Definition: constants.hpp:53
fvar< T > expm1(const fvar< T > &x)
Definition: expm1.hpp:15
fvar< T > log1m_exp(const fvar< T > &x)
Definition: log1m_exp.hpp:17
boost::math::tools::promote_args< T >::type log1m_exp(const T a)
Calculates the log of 1 minus the exponential of the specified value without overflow log1m_exp(x) = ...
Definition: log1m_exp.hpp:40
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:16

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