Automatic Differentiation
 
Loading...
Searching...
No Matches
dims.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_DIMS_HPP
2#define STAN_MATH_PRIM_FUN_DIMS_HPP
3
6#include <vector>
7
8namespace stan {
9namespace math {
10
19template <typename T, require_stan_scalar_t<T>* = nullptr>
20inline void dims(const T& x, std::vector<int>& result) {}
21
29template <typename T, require_matrix_t<T>* = nullptr>
30inline void dims(const T& x, std::vector<int>& result) {
31 result.push_back(x.rows());
32 result.push_back(x.cols());
33}
34
44template <typename T, typename Alloc>
45inline void dims(const std::vector<T, Alloc>& x, std::vector<int>& result) {
46 result.push_back(x.size());
47 if (x.size() > 0) {
48 dims(x[0], result);
49 }
50}
51
57template <typename T>
58inline std::vector<int> dims(const T& x) {
59 std::vector<int> result;
60 dims(x, result);
61 return result;
62}
63
64} // namespace math
65} // namespace stan
66#endif
void dims(const T_x &x, std::vector< int > &result)
matrix_cl overload of the dims helper function in prim/fun/dims.hpp.
Definition dims.hpp:21
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...