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 --- model/ranksvm.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'model/ranksvm.cpp') diff --git a/model/ranksvm.cpp b/model/ranksvm.cpp index b15d2ef..58a097a 100644 --- a/model/ranksvm.cpp +++ b/model/ranksvm.cpp @@ -1,21 +1,23 @@ #include"ranksvm.h" -#include"ranksvmtron.h" +#include"ranksvmtn.h" +#include"../tools/matrixIO.h" #include #include #include using namespace Eigen; +using namespace std; -int RSVM::saveModel(string fname){ +int RSVM::saveModel(const string fname){ - std::ofstream fout(fname); + std::ofstream fout(fname.c_str()); fout<getName()<model; return 0; } -static RSVM* RSVM::loadModel(string fname){ - std::ifstream fin(fname); +RSVM* RSVM::loadModel(const string fname){ + std::ifstream fin(fname.c_str()); std::string type; int fsize; fin>>type; @@ -25,17 +27,17 @@ static RSVM* RSVM::loadModel(string fname){ // TODO multiplex type if (type=="TN") - RSVM = new RSVMTN(); + rsvm = new RSVMTN(); rsvm->fsize=fsize; VectorXd model; - fin>>model; + Eigen::read_stream(fin, model); rsvm->setModel(model); return rsvm; } -int RSVM::setModel(Eigen::VectorXd model) { +int RSVM::setModel(const Eigen::VectorXd &model) { if (model.cols()!=fsize) LOG(FATAL) << "Feature size mismatch";; this->model=model; -- cgit v1.2.3-70-g09d2