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

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