| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
prod.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_PROD_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_PROD_HPP
3
4 #include <stan/math/prim/mat/fun/Eigen.hpp>
5 #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::math::prod
T prod(const std::vector< T > &v)
Returns the product of the coefficients of the specified standard vector.
Definition: prod.hpp:17
Eigen.hpp

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