10 M
read_csv(std::string name,
bool comma =
true) {
11 using namespace Eigen;
13 std::ifstream input(name);
16 std::vector<typename M::Scalar> values;
18 while(std::getline(input, line)) {
19 std::stringstream lineStream(line);
21 typename M::Scalar value;
24 while(std::getline<char>(lineStream, cell,
','))
25 values.push_back(std::stod(cell));
27 while(lineStream >> value)
28 values.push_back(value);
32 return Map<const Matrix<typename M::Scalar, M::RowsAtCompileTime, M::ColsAtCompileTime, ColMajor>>(
33 values.data(), values.size() / rows, rows);
M read_csv(std::string name, bool comma=true)