Stan Math Library
2.12.0
reverse mode automatic differentiation
Main Page
Modules
Namespaces
Classes
Files
File List
File Members
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
18
num_elements
(
const
T& x) {
19
return
1;
20
}
21
28
template
<
typename
T,
int
R,
int
C>
29
inline
int
30
num_elements
(
const
Eigen::Matrix<T, R, C>& m) {
31
return
m.size();
32
}
33
42
template
<
typename
T>
43
inline
int
44
num_elements
(
const
std::vector<T>& v) {
45
if
(v.size() == 0)
46
return
0;
47
return
v.size() *
num_elements
(v[0]);
48
}
49
50
}
51
}
52
#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:18
[
Stan Home Page
]
© 2011–2016, Stan Development Team.