diff options
| -rw-r--r-- | tools/dataProvider.h | 44 | 
1 files 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<DataEntry*> uniq;      std::vector<DataEntry*> other; +    std::vector<DataEntry*> 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 (b<a) -            oth = &(uniq[b]->feature); -        else if (b<uniq.size()-1) -            oth = &(uniq[b+1]->feature); +            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 (b<a) -            oth = &(uniq[b]->feature); -        else if (b<uniq.size()-1) -            oth = &(uniq[b+1]->feature); +            oth = &(all[b]->feature);          else -            oth = &(other[b-uniq.size()+1]->feature); +            oth = &(all[b+1]->feature);          for (int i=0;i<n;++i)              res += fabs((*id)[i] - (*oth)[i])*w[i];          return res; @@ -158,11 +165,9 @@ public:          if (single)              oth = &(other[b]->feature);          else if (b<a) -            oth = &(uniq[b]->feature); -        else if (b<uniq.size()-1) -            oth = &(uniq[b+1]->feature); +            oth = &(all[b]->feature);          else -            oth = &(other[b-uniq.size()+1]->feature); +            oth = &(all[b+1]->feature);          for (int i=0;i<n;++i)              X[i] += fabs((*id)[i] - (*oth)[i])*w;      } @@ -176,10 +181,13 @@ public:                  return 1;              return -1;          } -        if (b<uniq.size()-1) -            return -1; +        double id,oth; +        id = all[a]->rank; +        if (b<a) +            oth = all[b]->rank;          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;      };  | 
