29 using namespace Eigen;
35 template <
class EigenMatrix>
36 void drwnReadMatrix(EigenMatrix& m, istream& is,
const char *filename = NULL)
38 for (
int y = 0; y < m.rows(); y++) {
39 for (
int x = 0; x < m.cols(); x++) {
41 DRWN_ASSERT_MSG(!is.fail(),
"row/col " << y <<
"/" << x
42 <<
" of " << m.rows() <<
"/" << m.cols() <<
" ("
43 << (filename != NULL ? filename :
"unknown file") <<
")");
49 template <
class EigenMatrix>
52 DRWN_ASSERT(filename != NULL);
53 ifstream ifs(filename);
54 DRWN_ASSERT_MSG(!ifs.fail(), filename);
60 template <
class EigenMatrix>
63 DRWN_ASSERT(filename != NULL);
66 ifstream ifs(filename);
67 DRWN_ASSERT_MSG(!ifs.fail(), filename);
70 m.resize(nRows, nCols);
int drwnCountLines(const char *filename)
counts the number of non-empty lines in a text file
Definition: drwnFileUtils.cpp:298
void drwnReadUnknownMatrix(EigenMatrix &m, const char *filename)
Read an Eigen::Matrix of unknown size from a text file.
Definition: drwnIOUtils.h:61
int drwnCountFields(ifstream *ifs, char delimiter= ' ', bool bSkipRepeated=true)
counts the number of fields per line (separated by a single character delimiter)
Definition: drwnFileUtils.cpp:214
void drwnReadMatrix(EigenMatrix &m, istream &is, const char *filename=NULL)
Read an Eigen::Matrix from an input stream (the filename argument is only used for reporting errors a...
Definition: drwnIOUtils.h:36