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> 26 template <
int R,
int C>
28 using std::numeric_limits;
31 double max = -numeric_limits<double>::infinity();
32 for (
int i = 0; i < x.size(); i++)
37 for (
int i = 0; i < x.size(); i++)
38 if (x(i) != -numeric_limits<double>::infinity())
41 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.