chore: Move content from source to header
This commit is contained in:
parent
fac2c07a3e
commit
42b6ed40fe
22
src/run.cpp
22
src/run.cpp
@ -15,26 +15,6 @@
|
|||||||
|
|
||||||
#include <Eigen/Eigen>
|
#include <Eigen/Eigen>
|
||||||
|
|
||||||
using TugType = double;
|
|
||||||
|
|
||||||
using RowMajorMat =
|
|
||||||
Eigen::Matrix<TugType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
|
|
||||||
|
|
||||||
static inline std::vector<TugType>
|
|
||||||
eigenMatrix_to_vector(const Eigen::MatrixX<TugType> &mat) {
|
|
||||||
if (mat.IsRowMajor) {
|
|
||||||
return std::vector<TugType>(mat.data(), mat.data() + mat.size());
|
|
||||||
} else {
|
|
||||||
std::vector<TugType> 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) {
|
double run_bench(const bench_input &input, const std::string &output_file) {
|
||||||
std::vector<std::vector<double>> raw_data =
|
std::vector<std::vector<double>> raw_data =
|
||||||
read_conc_csv<double>(input.csv_file_init, input.ncols, input.nrows);
|
read_conc_csv<double>(input.csv_file_init, input.ncols, input.nrows);
|
||||||
@ -89,7 +69,7 @@ double run_bench(const bench_input &input, const std::string &output_file) {
|
|||||||
int ompNumThreads = std::stoi(out, NULL);
|
int ompNumThreads = std::stoi(out, NULL);
|
||||||
sim.setNumberThreads(ompNumThreads);
|
sim.setNumberThreads(ompNumThreads);
|
||||||
}
|
}
|
||||||
|
|
||||||
sim.setTimestep(input.timestep);
|
sim.setTimestep(input.timestep);
|
||||||
sim.setIterations(input.iterations);
|
sim.setIterations(input.iterations);
|
||||||
|
|
||||||
|
|||||||
21
src/run.hpp
21
src/run.hpp
@ -1,8 +1,29 @@
|
|||||||
#ifndef _RUN_HPP
|
#ifndef _RUN_HPP
|
||||||
#define _RUN_HPP
|
#define _RUN_HPP
|
||||||
|
|
||||||
|
#include <Eigen/Eigen>
|
||||||
#include <bench_defs.hpp>
|
#include <bench_defs.hpp>
|
||||||
|
|
||||||
|
using TugType = double;
|
||||||
|
|
||||||
|
using RowMajorMat =
|
||||||
|
Eigen::Matrix<TugType, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>;
|
||||||
|
|
||||||
double run_bench(const bench_input &input, const std::string &output_file = "");
|
double run_bench(const bench_input &input, const std::string &output_file = "");
|
||||||
|
|
||||||
|
static inline std::vector<TugType>
|
||||||
|
eigenMatrix_to_vector(const Eigen::MatrixX<TugType> &mat) {
|
||||||
|
if (mat.IsRowMajor) {
|
||||||
|
return std::vector<TugType>(mat.data(), mat.data() + mat.size());
|
||||||
|
} else {
|
||||||
|
std::vector<TugType> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // _RUN_HPP
|
#endif // _RUN_HPP
|
||||||
Loading…
x
Reference in New Issue
Block a user