Automatic Differentiation
 
Loading...
Searching...
No Matches
to_vector_array.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_TO_VECTOR_ARRAY_HPP
2#define STAN_MATH_PRIM_FUN_TO_VECTOR_ARRAY_HPP
3
6#include <vector>
7
8namespace stan {
9namespace math {
10
19template <typename EigMat, require_eigen_t<EigMat>* = nullptr>
20inline std::vector<Eigen::Matrix<value_type_t<EigMat>, Eigen::Dynamic, 1>>
21to_vector_array(const EigMat& matrix) {
22 using T = value_type_t<EigMat>;
23 std::vector<Eigen::Matrix<T, Eigen::Dynamic, 1>> result;
24 result.reserve(matrix.cols());
25 for (int j = 0; j < matrix.cols(); ++j) {
26 result.push_back(matrix.col(j));
27 }
28 return result;
29}
30
31} // namespace math
32} // namespace stan
33#endif
typename value_type< T >::type value_type_t
Helper function for accessing underlying type.
std::vector< Eigen::Matrix< value_type_t< EigMat >, Eigen::Dynamic, 1 > > to_vector_array(const EigMat &matrix)
Returns a standard vector of Eigen column vectors from the columns of the input matrix.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...