|
| 1 | +#include <stan/math/prim.hpp> |
| 2 | +#include <test/unit/math/prim/fun/expect_matrix_eq.hpp> |
| 3 | +#include <gtest/gtest.h> |
| 4 | +#include <vector> |
| 5 | +#include <stdexcept> |
| 6 | + |
| 7 | +using stan::math::to_array_1d; |
| 8 | + |
| 9 | +TEST(MathMatrix, to_array_1d_matrix){ |
| 10 | + Eigen::MatrixXd a(3,3); |
| 11 | + a << 1,2,3,4,5,6,7,8,9; |
| 12 | + std::vector<double> a_correct{1,4,7,2,5,8,3,6,9}; |
| 13 | + std::vector<double> a_res = to_array_1d(a); |
| 14 | + expect_std_vector_eq(a_res, a_correct); |
| 15 | +} |
| 16 | + |
| 17 | +TEST(MathMatrix, to_array_1d_matrix_block){ |
| 18 | + Eigen::MatrixXd a(3,3); |
| 19 | + a << 1,2,3,4,5,6,7,8,9; |
| 20 | + std::vector<double> a_correct{2,5,3,6}; |
| 21 | + std::vector<double> a_res = to_array_1d(a.block(0,1,2,2)); |
| 22 | + expect_std_vector_eq(a_res, a_correct); |
| 23 | +} |
0 commit comments