1#ifndef STAN_MATH_PRIM_FUN_TO_ARRAY_2D_HPP
2#define STAN_MATH_PRIM_FUN_TO_ARRAY_2D_HPP
12template <
typename EigMat, require_eigen_t<EigMat>* =
nullptr>
13inline std::vector<std::vector<value_type_t<EigMat>>>
to_array_2d(
14 const EigMat& matrix) {
17 const Eigen::Ref<
const Eigen::Matrix<T, EigMat::RowsAtCompileTime,
18 EigMat::ColsAtCompileTime>>& mat_ref
20 int C = matrix.cols();
21 int R = matrix.rows();
22 vector<vector<T>> result(R, vector<T>(C));
23 for (
int i = 0, ij = 0; i < C; i++) {
24 for (
int j = 0; j < R; j++, ij++) {
25 result[j][i] = mat_ref.data()[ij];
T_x to_array_2d(T_x &&x)
Returns input matrix converted into a nested std vector.
typename value_type< T >::type value_type_t
Helper function for accessing underlying type.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...