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
00032
00033
00034
00035
00036
00048 #ifndef __PREFIX_SUM_TOOLS_H__
00049 #define __PREFIX_SUM_TOOLS_H__
00050
00051 #include "prefix2d.hpp"
00052 #include "rect_list.hpp"
00053 namespace util
00054 {
00076 template <typename T, typename Pr>
00077 int extractXDim(const util::RectList<T,Pr>& currentP, int *cuts, std::vector<int> procs[]);
00097 template <typename T, typename Pr>
00098 int extractXDim(const util::RectList<T,Pr>& currentP, int *cuts);
00107 template<typename T>
00108 void prefixsum(const T *array, T *result, int length);
00109
00110
00111
00128 template <typename T, typename Pr, bool row>
00129 class Aggreg2Dto1D
00130 {
00132 const Pr& pr;
00133 const int xlow;
00134 const int xhigh;
00135 const int ylow;
00136 const int yhigh;
00137 T precomp;
00138
00139 private:
00141 Aggreg2Dto1D<T,Pr,row>& operator=(const Aggreg2Dto1D<T,Pr,row>& rhs);
00143 Aggreg2Dto1D();
00144
00145 public:
00146
00162 Aggreg2Dto1D(const Pr& p, int xl, int xh, int yl, int yh);
00167 Aggreg2Dto1D(const Aggreg2Dto1D<T,Pr,row>& o);
00168 const T operator[] (int x) const;
00179 T interval(int i1, int i2) const;
00180 };
00181
00182
00183
00184
00185 template <typename T, bool>
00186 class Prefix2D;
00187 template <typename T, typename Pr, bool row>
00188 class Aggreg2Dto1D;
00189
00206 template <typename T, typename Pr, bool row>
00207 class AggregMax2Dto1D
00208 {
00210 int lineCount;
00214 Aggreg2Dto1D<T,Pr,row> **lineSet;
00215
00216 AggregMax2Dto1D();
00217 const AggregMax2Dto1D& operator=(const AggregMax2Dto1D& a);
00218
00219 public:
00225 AggregMax2Dto1D(const AggregMax2Dto1D& a);
00226 ~AggregMax2Dto1D();
00234 AggregMax2Dto1D(const Pr& psum, int procY, int *ycuts);
00243 T interval(int left, int right) const;
00250 int getLineCount();
00251
00252 };
00253
00266 template <typename T, typename Pr>
00267 int binarySearch(const Pr & prefixSumArray, int low, int high, T prefixSumBottleneck);
00268
00290 template <typename T, typename Pr>
00291 int binarySearch_interval(const Pr& prefixSumArray, int low, int high, T prefixSumBottleneck, int base);
00292
00294
00295 template <typename T, typename Pr>
00296 int binarySearchLeft(const Pr & prefixSumArray, int low,
00297 int high, T prefixSumBottleneck);
00298
00299 }
00300 #include "prefix_sum_tools_impl.hpp"
00301
00302 #endif