Stan Math Library
2.20.0
reverse mode automatic differentiation
stan
math
prim
mat
fun
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
namespace
math {
9
16
template
<
typename
T>
17
inline
int
num_elements
(
const
T& x) {
18
return
1;
19
}
20
27
template
<
typename
T,
int
R,
int
C>
28
inline
int
num_elements
(
const
Eigen::Matrix<T, R, C>& m) {
29
return
m.size();
30
}
31
40
template
<
typename
T>
41
inline
int
num_elements
(
const
std::vector<T>& v) {
42
if
(v.size() == 0)
43
return
0;
44
return
v.size() *
num_elements
(v[0]);
45
}
46
47
}
// namespace math
48
}
// namespace stan
49
#endif
stan
Definition:
log_sum_exp.hpp:8
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:17
[
Stan Home Page
]
© 2011–2018, Stan Development Team.