1 #ifndef STAN_MATH_PRIM_MAT_FUN_LOG_SUM_EXP_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_LOG_SUM_EXP_HPP
6 #include <boost/math/tools/promotion.hpp>
27 template <
int R,
int C>
29 using std::numeric_limits;
32 double max = -numeric_limits<double>::infinity();
33 for (
int i = 0; i < x.size(); i++)
38 for (
int i = 0; i < x.size(); i++)
39 if (x(i) != -numeric_limits<double>::infinity())
42 return max +
log(sum);
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
fvar< T > log(const fvar< T > &x)
fvar< T > log_sum_exp(const std::vector< fvar< T > > &v)
fvar< T > exp(const fvar< T > &x)
int max(const std::vector< int > &x)
Returns the maximum coefficient in the specified column vector.