diff --git a/src/run.cpp b/src/run.cpp index 9bf4158..e336284 100644 --- a/src/run.cpp +++ b/src/run.cpp @@ -20,6 +20,21 @@ using TugType = double; using RowMajorMat = Eigen::Matrix; +static inline std::vector +eigenMatrix_to_vector(const Eigen::MatrixX &mat) { + if (mat.IsRowMajor) { + return std::vector(mat.data(), mat.data() + mat.size()); + } else { + std::vector out_vec(mat.size()); + for (int i = 0; i < mat.rows(); i++) { + for (int j = 0; j < mat.cols(); j++) { + out_vec[i * mat.cols() + j] = mat(i, j); + } + } + return out_vec; + } +} + double run_bench(const bench_input &input, const std::string &output_file) { std::vector> raw_data = read_conc_csv(input.csv_file, input.ncols, input.nrows); @@ -77,8 +92,7 @@ double run_bench(const bench_input &input, const std::string &output_file) { const auto &result = grid.getConcentrations(); - raw_data[i] = - std::vector(result.data(), result.data() + result.size()); + raw_data[i] = eigenMatrix_to_vector(result); } const auto end_t = std::chrono::high_resolution_clock::now();