Automatic Differentiation
 
Loading...
Searching...
No Matches
to_row_vector_array.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_TO_ROW_VECTOR_ARRAY_HPP
2#define STAN_MATH_PRIM_FUN_TO_ROW_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>, 1, Eigen::Dynamic>>
21to_row_vector_array(const EigMat& matrix) {
22 using T = value_type_t<EigMat>;
23 std::vector<Eigen::Matrix<T, 1, Eigen::Dynamic>> result;
24 result.reserve(matrix.rows());
25 for (int i = 0; i < matrix.rows(); ++i) {
26 result.push_back(matrix.row(i));
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 >, 1, Eigen::Dynamic > > to_row_vector_array(const EigMat &matrix)
Returns a standard vector of Eigen row vectors from the rows of the input matrix.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...