1 #ifndef STAN_MATH_FWD_MAT_FUN_LOG_SUM_EXP_HPP 2 #define STAN_MATH_FWD_MAT_FUN_LOG_SUM_EXP_HPP 11 template <
typename T,
int R,
int C>
13 Eigen::Matrix<T, R, C> vals = v.val();
14 Eigen::Matrix<T, R, C> exp_vals = vals.array().exp();
17 v.d().cwiseProduct(exp_vals).sum() / exp_vals.sum());
fvar< T > log_sum_exp(const std::vector< fvar< T > > &v)
This template class represents scalars used in forward-mode automatic differentiation, which consist of values and directional derivatives of the specified template type.