From e500bb4cdb32b13cc022b6dc5d221de7ad97a73e Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Sun, 8 Mar 2015 16:02:15 +0800 Subject: added commandline parser --- tools/dataProvider.h | 4 ++-- tools/fileDataProvider.h | 12 ++++++++---- tools/matrixIO.h | 30 ++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 tools/matrixIO.h (limited to 'tools') diff --git a/tools/dataProvider.h b/tools/dataProvider.h index d598f3f..b2384c9 100644 --- a/tools/dataProvider.h +++ b/tools/dataProvider.h @@ -19,8 +19,8 @@ public: virtual Eigen::MatrixXd* getAttr() = 0; virtual Eigen::VectorXd* getPref() = 0; - virtual int open(); - virtual bool EOFile(); + virtual int open()=0; + virtual bool EOFile()=0; }; #endif \ No newline at end of file diff --git a/tools/fileDataProvider.h b/tools/fileDataProvider.h index 3cfb3f9..7937866 100644 --- a/tools/fileDataProvider.h +++ b/tools/fileDataProvider.h @@ -11,10 +11,14 @@ private: public: FileDP(){}; FileDP(std::string fn):fname(fn){}; - virtual Eigen::MatrixXd* getNextAttr(); - virtual Eigen::VectorXd* getNextPref(); - virtual int open(); - virtual bool EOFile(); + virtual Eigen::MatrixXd* getAttr(){ + return new Eigen::MatrixXd(3,3); + } + virtual Eigen::VectorXd* getPref(){ + return new Eigen::VectorXd(3); + }; + virtual int open(){return 0;}; + virtual bool EOFile(){return true;}; }; #endif \ No newline at end of file diff --git a/tools/matrixIO.h b/tools/matrixIO.h new file mode 100644 index 0000000..88cd419 --- /dev/null +++ b/tools/matrixIO.h @@ -0,0 +1,30 @@ +#ifndef MATIO_H +#define MATIO_H + +#include + +namespace Eigen{ + template + void write_stream(std::ostream &ostr, const Matrix& matrix){ + typename Matrix::Index rows=matrix.rows(), cols=matrix.cols(); + ostr< + void read_stream(std::istream &istr, Matrix& matrix){ + typename Matrix::Index rows=0, cols=0; + istr>>rows>>cols; + matrix.resize(rows, cols); + for (int r=0;r>matrix(r,c); + } +} // Eigen:: + + +#endif \ No newline at end of file -- cgit v1.2.3-70-g09d2