| Stan Math Library 2.11.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

log_sum_exp.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_LOG_SUM_EXP_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_LOG_SUM_EXP_HPP
3
4 #include <stan/math/prim/scal/fun/log1p_exp.hpp>
5 #include <boost/math/tools/promotion.hpp>
6 #include <limits>
7
8 namespace stan {
9 namespace math {
10
46 template <typename T1, typename T2>
47 inline typename boost::math::tools::promote_args<T1, T2>::type
48 log_sum_exp(const T2& a, const T1& b) {
49 using std::exp;
50 if (a > b)
51 return a + log1p_exp(b - a);
52 return b + log1p_exp(a - b);
53 }
54
55 }
56 }
57
58 #endif
stan
Definition: log_sum_exp.hpp:8
stan::math::log_sum_exp
fvar< T > log_sum_exp(const std::vector< fvar< T > > &v)
Definition: log_sum_exp.hpp:14
stan::math::exp
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
log1p_exp.hpp
stan::math::log1p_exp
fvar< T > log1p_exp(const fvar< T > &x)
Definition: log1p_exp.hpp:13

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