Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
log_diff_exp.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__FUNCTIONS__LOG_DIFF_EXP_HPP
2 #define STAN__MATH__FUNCTIONS__LOG_DIFF_EXP_HPP
3 
4 #include <boost/math/tools/promotion.hpp>
5 #include <stdexcept>
6 #include <boost/throw_exception.hpp>
8 
9 namespace stan {
10  namespace math {
11 
47  template <typename T1, typename T2>
48  inline typename boost::math::tools::promote_args<T1,T2>::type
49  log_diff_exp(const T1 x, const T2 y) {
50  if (x <= y)
51  return std::numeric_limits<double>::quiet_NaN();
52  return x + log1m_exp(y - x);
53  }
54 
55  }
56 }
57 
58 #endif
boost::math::tools::promote_args< T1, T2 >::type log_diff_exp(const T1 x, const T2 y)
The natural logarithm of the difference of the natural exponentiation of x1 and the natural exponenti...
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

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