Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs 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

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