From 6877bbb4a9d162d0d4336bca8f74c35ca062a347 Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Mon, 25 May 2015 12:21:57 +0800 Subject: full pairs --- tools/dataProvider.h | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/tools/dataProvider.h b/tools/dataProvider.h index 4dc9c41..390432e 100644 --- a/tools/dataProvider.h +++ b/tools/dataProvider.h @@ -61,11 +61,13 @@ private: int n; std::vector uniq; std::vector other; + std::vector all; public: static bool single; void clear(){ uniq.clear(); other.clear(); + all.clear(); } void setfSize(int fsize){n=fsize;} inline int getfSize(){return n;} @@ -83,6 +85,7 @@ public: other.push_back(d); else uniq.push_back(d); + all.push_back(d); } inline DataEntry* getU(int x) { @@ -92,21 +95,29 @@ public: { return other[x]; } + inline DataEntry* getAll(int x) + { + return all[x]; + } inline std::string getQid(int x) { int a,b,q=getqSize(); a=x/q; - return getU(a)->qid; + if (single) + return getU(a)->qid; + return getAll(a)->qid; } inline int getqSize() { if (single) return (int)other.size(); - return (int)(uniq.size()+other.size()-1); + return (int)(all.size()-1); } inline int getuSize() { - return (int)uniq.size(); + if (single) + return (int)uniq.size(); + return (int)all.size(); } inline int getSize() { @@ -121,11 +132,9 @@ public: if (single) oth = &(other[b]->feature); else if (bfeature); - else if (bfeature); + oth = &(all[b]->feature); else - oth = &(other[b-uniq.size()+1]->feature); + oth = &(all[b+1]->feature); return (*id-*oth).cwiseAbs(); }; inline double getVecDot(int x,const Eigen::VectorXd &w) @@ -139,11 +148,9 @@ public: if (single) oth = &(other[b]->feature); else if (bfeature); - else if (bfeature); + oth = &(all[b]->feature); else - oth = &(other[b-uniq.size()+1]->feature); + oth = &(all[b+1]->feature); for (int i=0;ifeature); else if (bfeature); - else if (bfeature); + oth = &(all[b]->feature); else - oth = &(other[b-uniq.size()+1]->feature); + oth = &(all[b+1]->feature); for (int i=0;irank; + if (brank; else - if (std::fabs(other[b-uniq.size()+1]->rank - a) < 1e-5) + oth = all[b+1]->rank; + if (fabs(oth - id) < 1e-5) return 1; return -1; }; -- cgit v1.2.3-70-g09d2