Point newRandomPoint(T Min, T Max) { double d; double e; double f; Point a; double max, min; max = (double) Max; min = (double) Min; for(unsigned int i=0;i < Point::__DIM;++i) { d = __drand48__(); if(min > 0) { e = (d*max)-(d*min); f = min; } else { e = (d*max)+min; f = -(d*min); } a[i] = (T) (e+f); } return a; }
void init(std::vector<Point> &points, int sample_size=128) { samples.resize(sample_size); __srand48__(time(0)); for(int i=0;i < sample_size;++i) { size_type s = __drand48__() * (double) points.size(); samples[i] = points.begin() + s; } sort(samples.begin(), samples.end(), lt); }
WspIter findPivot(WspIter begin, WspIter end) { double range = (double) (end-begin); for(unsigned int i=0; i < samples.size(); ++i) { samples[i] = (begin+((size_type) (__drand48__()*range))); } sort(samples.begin(), samples.end(), bccp); return samples[pivot_index]; };