| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

sum.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_ARR_FUN_SUM_HPP
2 #define STAN_MATH_PRIM_ARR_FUN_SUM_HPP
3
4 #include <cstddef>
5 #include <vector>
6
7 namespace stan {
8 namespace math {
9
17 template <typename T>
18 inline T sum(const std::vector<T>& xs) {
19 if (xs.size() == 0) return 0;
20 T sum(xs[0]);
21 for (size_t i = 1; i < xs.size(); ++i)
22 sum += xs[i];
23 return sum;
24 }
25
26 }
27 }
28 #endif
stan::math::sum
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
Definition: sum.hpp:20
stan
Definition: log_sum_exp.hpp:8

[ Stan Home Page ] © 2011–2016, Stan Development Team.