Stan
2.5.0
probability, sampling & optimization
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
stan
math
matrix
num_elements.hpp
Go to the documentation of this file.
1
#ifndef STAN__MATH__MATRIX__NUM_ELEMENTS_HPP
2
#define STAN__MATH__MATRIX__NUM_ELEMENTS_HPP
3
4
#include <vector>
5
#include <
stan/math/matrix/Eigen.hpp
>
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–2014, Stan Development Team.