diff options
Diffstat (limited to 'model/ranksvm.cpp')
-rw-r--r-- | model/ranksvm.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
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<iostream> #include<fstream> #include<string> 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<<this->getName()<<endl; fout<<this->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; |