All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Groups
num_elements.hpp
Go to the documentation of this file.
#ifndef STAN_MATH_PRIM_MAT_FUN_NUM_ELEMENTS_HPP
#define STAN_MATH_PRIM_MAT_FUN_NUM_ELEMENTS_HPP
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <vector>
namespace stan {
namespace math {
template <typename T>
inline int
num_elements(const T& x) {
return 1;
}
template <typename T, int R, int C>
inline int
num_elements(const Eigen::Matrix<T, R, C>& m) {
return m.size();
}
template <typename T>
inline int
num_elements(const std::vector<T>& v) {
if (v.size() == 0)
return 0;
return v.size() * num_elements(v[0]);
}
}
}
#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.