1 #ifndef STAN__MATH__MATRIX__CUMULATIVE_SUM_HPP
2 #define STAN__MATH__MATRIX__CUMULATIVE_SUM_HPP
24 std::vector<T> result(x.size());
28 for (
size_t i = 1; i < result.size(); ++i)
29 result[i] = x[i] + result[i-1];
47 template <
typename T,
int R,
int C>
48 inline Eigen::Matrix<T,R,C>
50 Eigen::Matrix<T,R,C> result(m.rows(),m.cols());
54 for (
int i = 1; i < result.size(); ++i)
55 result(i) = m(i) + result(i-1);
std::vector< T > cumulative_sum(const std::vector< T > &x)
Return the cumulative sum of the specified vector.