From 52ca742e14e36cd37010bae9a7678dd5b1a7eaf5 Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Wed, 13 May 2015 18:56:39 +0800 Subject: branched for mem --- tools/dataProvider.h | 81 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 16 deletions(-) (limited to 'tools/dataProvider.h') diff --git a/tools/dataProvider.h b/tools/dataProvider.h index 028980e..a3f3d34 100644 --- a/tools/dataProvider.h +++ b/tools/dataProvider.h @@ -55,6 +55,70 @@ public: } }; +class RidList{ +private: + int n; + std::vector uniq; + std::vector other; +public: + void clear(){ + uniq.clear(); + other.clear(); + } + void setfSize(int fsize){n=fsize;} + int getfSize(){return n;} + void addEntry(DataEntry* d){ + int ext=false; + for (int i=0;iqid==d->qid) + { + ext = true; + d->rank = i; + } + if (ext) + other.push_back(d); + else + uniq.push_back(d); + } + int getqSize() + { + return (int)(uniq.size()+other.size()-1); + } + int getuSize() + { + return (int)uniq.size(); + } + int getSize() + { + return getuSize()*getqSize(); + } + Eigen::VectorXd getVec(int x){ + int a,b,n=getqSize(); + a=x/n; + b=x%n; + Eigen::VectorXd vec = uniq[a]->feature; + if (bfeature; + else + if (bfeature; + else + vec=vec-other[b-uniq.size()+1]->feature; + return vec.cwiseAbs(); + }; + double getL(int x){ + int a,b,n=(int)(uniq.size()+other.size()-1); + a=x/n; + b=x%n; + if (brank - a) < 1e-5) + return 1; + return -1; + }; +}; + class DataProvider //Virtual base class for data input { protected: @@ -63,22 +127,7 @@ public: DataProvider():eof(false){}; bool EOFile(){return eof;} - void getAllDataSet(DataList &out){\ - out.clear(); - DataList buf; - while (!EOFile()) - { - getDataSet(buf); - // won't work as data are discarded with every call to getDataSet - // out.getData().insert(out.getData().end(),buf.getData().begin(),buf.getData().end()); - for (int i=0;i