naive_ortho_range_search.h
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00040 #ifndef NAIVE_ORTHO_RANGE_SEARCH_H
00041 #define NAIVE_ORTHO_RANGE_SEARCH_H
00042 
00043 #include "fastlib/fastlib.h"
00044 
00045 
00059 template<typename T>
00060 class NaiveOrthoRangeSearch {
00061   
00062   
00063   FORBID_ACCIDENTAL_COPIES(NaiveOrthoRangeSearch);
00064 
00065  private:
00066 
00069   GenMatrix<T> data_;
00070   
00071  public:
00072   
00074 
00077   NaiveOrthoRangeSearch() {}
00078 
00081   ~NaiveOrthoRangeSearch() {}
00082 
00084 
00089   void Init(const GenMatrix<T> &data) {
00090 
00091     
00092     data_.StaticCopy(data);
00093   }
00094 
00102   void Compute(const GenMatrix<T> &low_coord_limits, 
00103                const GenMatrix<T> &high_coord_limits,
00104                GenMatrix<bool> *search_results) {
00105 
00106     
00107     search_results->Init(data_.n_cols(), low_coord_limits.n_cols());
00108 
00109     
00110     fx_timer_start(NULL, "naive_search");
00111     for(index_t j = 0; j < low_coord_limits.n_cols(); j++) {
00112       for(index_t i = 0; i < data_.n_cols(); i++) {     
00113         GenVector<T> pt;
00114         bool flag = true;
00115         data_.MakeColumnVector(i, &pt);
00116         
00117         
00118         
00119         
00120         
00121         for(index_t d = 0; d < data_.n_rows(); d++) {
00122           if(pt[d] < low_coord_limits.get(d, j) || 
00123              pt[d] > high_coord_limits.get(d, j)) {
00124             flag = false;
00125             break;
00126           }
00127         }
00128         (*search_results).set(i, j, flag);
00129       }
00130     }
00131     fx_timer_stop(NULL, "naive_search");
00132     
00133     
00134     
00135   }
00136 
00137 };
00138 
00139 
00140 #endif