Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
log1p_exp.hpp
Go to the documentation of this file.
1 #ifndef __STAN__MATH__FUNCTIONS__LOG1P_EXP_HPP__
2 #define __STAN__MATH__FUNCTIONS__LOG1P_EXP_HPP__
3 
4 #include <boost/math/tools/promotion.hpp>
6 
7 namespace stan {
8  namespace math {
9 
24  template <typename T>
25  inline typename boost::math::tools::promote_args<T>::type
26  log1p_exp(const T a) {
27  using std::exp;
28  // like log_sum_exp below with b=0.0; prevents underflow
29  if (a > 0.0)
30  return a + log1p(exp(-a));
31  return log1p(exp(a));
32  }
33 
34  }
35 }
36 
37 #endif

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