1 #ifndef STAN_MATH_PRIM_MAT_FUN_CUMULATIVE_SUM_HPP 2 #define STAN_MATH_PRIM_MAT_FUN_CUMULATIVE_SUM_HPP 25 std::vector<T> result(x.size());
28 std::partial_sum(x.begin(), x.end(), result.begin(), std::plus<T>());
46 template <
typename T,
int R,
int C>
47 inline Eigen::Matrix<T, R, C>
cumulative_sum(
const Eigen::Matrix<T, R, C>& m) {
48 Eigen::Matrix<T, R, C> result(m.rows(), m.cols());
51 std::partial_sum(m.data(), m.data() + m.size(), result.data(),
std::vector< T > cumulative_sum(const std::vector< T > &x)
Return the cumulative sum of the specified vector.