Stan Math Library  2.8.0
reverse mode automatic differentiation
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
num_elements.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_NUM_ELEMENTS_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_NUM_ELEMENTS_HPP
3 
5 #include <vector>
6 
7 namespace stan {
8 
9  namespace math {
10 
17  template <typename T>
18  inline int
19  num_elements(const T& x) {
20  return 1;
21  }
22 
29  template <typename T, int R, int C>
30  inline int
31  num_elements(const Eigen::Matrix<T, R, C>& m) {
32  return m.size();
33  }
34 
43  template <typename T>
44  inline int
45  num_elements(const std::vector<T>& v) {
46  if (v.size() == 0)
47  return 0;
48  return v.size() * num_elements(v[0]);
49  }
50 
51  }
52 }
53 #endif
int num_elements(const T &x)
Returns 1, the number of elements in a primitive type.

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