Stan Math Library  2.20.0
reverse mode automatic differentiation
dims.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_DIMS_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_DIMS_HPP
3 
5 #include <vector>
6 
7 namespace stan {
8 namespace math {
9 
10 template <typename T>
11 inline void dims(const T& x, std::vector<int>& result) {
12  /* no op */
13 }
14 template <typename T, int R, int C>
15 inline void dims(const Eigen::Matrix<T, R, C>& x, std::vector<int>& result) {
16  result.push_back(x.rows());
17  result.push_back(x.cols());
18 }
19 template <typename T>
20 inline void dims(const std::vector<T>& x, std::vector<int>& result) {
21  result.push_back(x.size());
22  if (x.size() > 0)
23  dims(x[0], result);
24 }
25 
26 template <typename T>
27 inline std::vector<int> dims(const T& x) {
28  std::vector<int> result;
29  dims(x, result);
30  return result;
31 }
32 
33 } // namespace math
34 } // namespace stan
35 #endif
void dims(const T &x, std::vector< int > &result)
Definition: dims.hpp:11

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