#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <set>
#include <tuple>
#include <math.h>
#include <Eigen/Dense>
#include <gsl/gsl>
#include <cosan/base/CosanBO.h>
Go to the source code of this file.
|
| template<Numeric NumericType> |
| NumericType | Cosan::StringToNum (const std::string &arg, std::size_t *pos=0) |
| | General string to number conversion function. More...
|
| |
| template<typename Matrix > |
| Matrix | load_csv1 (const std::string &path) |
| |
| template<typename Matrix > |
| void | save_csv (const std::string &path, const Matrix &matrix) |
| |
◆ load_csv1()
template<typename Matrix >
| Matrix load_csv1 |
( |
const std::string & |
path | ) |
|
Definition at line 55 of file utils.h.
60 std::vector<double> values;
62 while (std::getline(indata, line)) {
63 std::stringstream lineStream(line);
65 while (getline(lineStream, cell,
',')) {
66 values.push_back(stod(cell));
71 return Eigen::Map<const Eigen::Matrix<typename Matrix::Scalar, Matrix::RowsAtCompileTime, Matrix::ColsAtCompileTime, Eigen::RowMajor> >(values.data(), rows, values.size()/rows);
◆ save_csv()
template<typename Matrix >
| void save_csv |
( |
const std::string & |
path, |
|
|
const Matrix & |
matrix |
|
) |
| |
Definition at line 76 of file utils.h.
80 std::ofstream file(path,std::ios::out);
82 Eigen::IOFormat csvFmt(Eigen::FullPrecision,0,
",");
83 file<<matrix.format(csvFmt);