Medusa  1.1
Coordinate Free Mehless Method implementation
CSV_fwd.hpp
Go to the documentation of this file.
1 #ifndef MEDUSA_BITS_IO_CSV_FWD_HPP_
2 #define MEDUSA_BITS_IO_CSV_FWD_HPP_
3 
12 #include <medusa/Config.hpp>
14 
16 namespace Eigen {
17 template <typename Derived>
18 class MatrixBase;
19 
20 template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
21 class Matrix;
22 }
24 
25 namespace mm {
26 
35 class CSV {
36  public:
43  static std::vector<double> read(const std::string& filename);
44 
51  static std::vector<std::vector<double>> read2d(const std::string& filename,
52  char separator = ',');
53 
61  static Eigen::Matrix<double, -1, -1, 0, -1, -1> readEigen(
62  const std::string& filename, char separator = ',');
63 
70  template <typename arr_t>
71  static void write(const std::string& filename, const arr_t& array);
72 
81  template <typename arr_t>
82  static void write2d(const std::string& filename, const arr_t& array, char separator = ',');
83 
84 
92  template <typename Derived>
93  static void writeEigen(const std::string& filename, const Eigen::MatrixBase<Derived>& expr,
94  char separator = ',');
95 
96  private:
104  static std::vector<std::string> split(const std::string& str, char separator);
105 };
106 
107 } // namespace mm
108 #endif // MEDUSA_BITS_IO_CSV_FWD_HPP_
mm
Root namespace for the whole library.
Definition: Gaussian.hpp:14
mm::CSV::writeEigen
static void writeEigen(const std::string &filename, const Eigen::MatrixBase< Derived > &expr, char separator=',')
Writes given Eigen matrix to a CSV file.
Definition: CSV_Eigen.hpp:44
mm::sh::str
std::string str(shape_flags f)
Convert shape flags to a string representation.
Definition: shape_flags.hpp:32
mm::CSV::read2d
static std::vector< std::vector< double > > read2d(const std::string &filename, char separator=',')
Reads a CSV file to a vector of vectors of doubles.
Definition: CSV.cpp:26
mm::CSV
Implements support for basic CSV I/O.
Definition: CSV_fwd.hpp:35
mm::CSV::readEigen
static Eigen::Matrix< double, -1, -1, 0, -1, -1 > readEigen(const std::string &filename, char separator=',')
Reads a CSV file to an Eigen matrix.
Definition: CSV_Eigen.hpp:14
Config.hpp
mm::CSV::write
static void write(const std::string &filename, const arr_t &array)
Writes given array to a CSV file (as a column).
Definition: CSV.hpp:19
assert.hpp
mm::CSV::split
static std::vector< std::string > split(const std::string &str, char separator)
Splits given string into a vector of strings on the given separator.
Definition: CSV.cpp:55
Matrix
Matrix(const Scalar &s)
Construct matrix from scalar. Enabled only for fixed size matrices.
Definition: MatrixAddons.hpp:21
mm::CSV::write2d
static void write2d(const std::string &filename, const arr_t &array, char separator=',')
Writes given 2d array to a CSV file.
Definition: CSV.hpp:29
mm::CSV::read
static std::vector< double > read(const std::string &filename)
Reads a CSV file to a vector of doubles.
Definition: CSV.cpp:10