| 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
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
4 #include <stan/math/prim/mat/fun/Eigen.hpp>
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
Eigen.hpp
stan::math::num_elements
int num_elements(const T &x)
Returns 1, the number of elements in a primitive type.
Definition: num_elements.hpp:19

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