Stan Math Library  2.20.0
reverse mode automatic differentiation
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 
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)
19  return 1;
20  Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, 1>> m(&v[0], v.size());
21  return m.prod();
22 }
23 
30 template <typename T, int R, int C>
31 inline T prod(const Eigen::Matrix<T, R, C>& v) {
32  if (v.size() == 0)
33  return 1.0;
34  return v.prod();
35 }
36 
37 } // namespace math
38 } // namespace stan
39 #endif
T prod(const std::vector< T > &v)
Returns the product of the coefficients of the specified standard vector.
Definition: prod.hpp:17

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