1#ifndef STAN_MATH_FWD_FUN_SUM_HPP
2#define STAN_MATH_FWD_FUN_SUM_HPP
22template <
typename T, require_fvar_t<T>* =
nullptr>
23inline auto sum(
const std::vector<T>& m) {
27 std::vector<partials_type_t<T>> vals(m.size());
28 std::vector<partials_type_t<T>> tans(m.size());
29 for (
size_t i = 0; i < m.size(); ++i) {
33 return T(
sum(vals),
sum(tans));
44template <
typename T, require_eigen_vt<is_fvar, T>* =
nullptr>
49 const Eigen::Ref<const plain_type_t<T>>& m_ref = m;
50 return {
sum(m_ref.val()),
sum(m_ref.d())};
typename value_type< T >::type value_type_t
Helper function for accessing underlying type.
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...