Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sum.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__MATRIX__SUM_HPP
2 #define STAN__MATH__MATRIX__SUM_HPP
3 
4 #include <vector>
6 
7 namespace stan {
8  namespace math {
9 
18  template <typename T>
19  inline T sum(const std::vector<T>& xs) {
20  if (xs.size() == 0) return 0;
21  T sum(xs[0]);
22  for (size_t i = 1; i < xs.size(); ++i)
23  sum += xs[i];
24  return sum;
25  }
26 
33  template <typename T, int R, int C>
34  inline double sum(const Eigen::Matrix<T,R,C>& v) {
35  return v.sum();
36  }
37 
38  }
39 }
40 #endif
double sum(std::vector< double > &x)
Definition: sum.hpp:10

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