Stan Math Library  2.14.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
12  void
13  dims(const T& x, std::vector<int>& result) {
14  /* no op */
15  }
16  template <typename T, int R, int C>
17  inline void
18  dims(const Eigen::Matrix<T, R, C>& x,
19  std::vector<int>& result) {
20  result.push_back(x.rows());
21  result.push_back(x.cols());
22  }
23  template <typename T>
24  inline void
25  dims(const std::vector<T>& x,
26  std::vector<int>& result) {
27  result.push_back(x.size());
28  if (x.size() > 0)
29  dims(x[0], result);
30  }
31 
32  template <typename T>
33  inline std::vector<int>
34  dims(const T& x) {
35  std::vector<int> result;
36  dims(x, result);
37  return result;
38  }
39 
40  }
41 }
42 #endif
void dims(const T &x, std::vector< int > &result)
Definition: dims.hpp:13

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