From b15766bef024f086c51e56aa9af17783d3c1ff68 Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Wed, 20 May 2015 16:59:50 +0800 Subject: speedup, internalize libop --- tools/dataProvider.h | 73 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 17 deletions(-) (limited to 'tools/dataProvider.h') diff --git a/tools/dataProvider.h b/tools/dataProvider.h index 348d15c..4dc9c41 100644 --- a/tools/dataProvider.h +++ b/tools/dataProvider.h @@ -4,6 +4,7 @@ #include #include "../tools/easylogging++.h" #include +#include // TODO decide how to construct training data // One possible way for training data: @@ -93,8 +94,8 @@ public: } inline std::string getQid(int x) { - int a,b,n=getqSize(); - a=x/n; + int a,b,q=getqSize(); + a=x/q; return getU(a)->qid; } inline int getqSize() @@ -112,25 +113,63 @@ public: return getuSize()*getqSize(); } inline Eigen::VectorXd getVec(int x){ - int a,b,n=getqSize(); - a=x/n; - b=x%n; - Eigen::VectorXd vec; + int a,b,q=getqSize(); + a=x/q; + b=x%q; + Eigen::VectorXd *id,*oth; + id = &(uniq[a]->feature); if (single) - return (uniq[a]->feature-other[b]->feature).cwiseAbs(); - if (bfeature-uniq[b]->feature; + oth = &(other[b]->feature); + else if (bfeature); + else if (bfeature); else - if (bfeature-uniq[b+1]->feature; - else - vec=uniq[a]->feature-other[b-uniq.size()+1]->feature; - return vec.cwiseAbs(); + oth = &(other[b-uniq.size()+1]->feature); + return (*id-*oth).cwiseAbs(); }; + inline double getVecDot(int x,const Eigen::VectorXd &w) + { + int a,b,q=getqSize(); + a=x/q; + b=x%q; + double res = 0; + Eigen::VectorXd *id,*oth; + id = &(uniq[a]->feature); + if (single) + oth = &(other[b]->feature); + else if (bfeature); + else if (bfeature); + else + oth = &(other[b-uniq.size()+1]->feature); + for (int i=0;ifeature); + if (single) + oth = &(other[b]->feature); + else if (bfeature); + else if (bfeature); + else + oth = &(other[b-uniq.size()+1]->feature); + for (int i=0;irank - a) < 1e-5) -- cgit v1.2.3-70-g09d2