mirror of https://github.com/CGAL/cgal
bug for very high dim
This commit is contained in:
parent
afa6a9fc80
commit
ba2d4c67ad
|
|
@ -23,7 +23,7 @@ to be able to combine the good randomized complexity and the
|
||||||
good effects of locality \cite{acr-icb-03}.
|
good effects of locality \cite{acr-icb-03}.
|
||||||
|
|
||||||
|
|
||||||
The only predicates used by this package are comparisons between coordinates,
|
The predicates used by this package are comparisons between coordinates,
|
||||||
thus there is no robustness issues involved here, for example to choose the
|
thus there is no robustness issues involved here, for example to choose the
|
||||||
arithmetic of the kernel.
|
arithmetic of the kernel.
|
||||||
|
|
||||||
|
|
@ -129,10 +129,16 @@ similar manner and we get also a suitable ordering of the points
|
||||||
\cgal\ provides Hilbert sorting for points in 2D, 3D and higher dimensions,
|
\cgal\ provides Hilbert sorting for points in 2D, 3D and higher dimensions,
|
||||||
in the middle and the median policies.
|
in the middle and the median policies.
|
||||||
|
|
||||||
The median policy seems interesting in practice and his invariant to
|
The middle policy is easier to analyze, and is interesting in practice
|
||||||
scaling, while the middle policy is easier to analyze. Most
|
for well distributed set of points in small dimension (if the number
|
||||||
theoretical results are using the middle policy
|
of points is really smaller than $2^d$).
|
||||||
\cite{acr-icb-03,other-references}..
|
The median policy should be prefered for high dimension or if
|
||||||
|
the point set distribution is not regular (or unknown).
|
||||||
|
Since the median policy cannot be much worse than the middle
|
||||||
|
policy, while the converse can happen, the median policy is the
|
||||||
|
default behavior.
|
||||||
|
Most theoretical results are using the middle policy
|
||||||
|
\cite{acr-icb-03,other-references}.
|
||||||
|
|
||||||
|
|
||||||
This other example illustrates the use of the two different policies
|
This other example illustrates the use of the two different policies
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<RandomAccessIterator> places(nb_splits +1);
|
std::vector<RandomAccessIterator> places(nb_splits +1);
|
||||||
std::vector<int> dir (nb_splits +1);
|
std::vector<int> dir (nb_splits +1);
|
||||||
places[0]=begin;
|
places[0]=begin;
|
||||||
|
|
@ -144,16 +143,15 @@ public:
|
||||||
two_to_dim = 1;
|
two_to_dim = 1;
|
||||||
Starting_position start(_dimension);
|
Starting_position start(_dimension);
|
||||||
|
|
||||||
|
int N=end-begin;N*=2;
|
||||||
|
for (int i=0; i<_dimension; ++i) start[i]=false; // we start below in all coordinates
|
||||||
for (int i=0; i<_dimension; ++i) {
|
for (int i=0; i<_dimension; ++i) {
|
||||||
start[i]=false; // we start below in all coordinates
|
|
||||||
two_to_dim *= 2; // compute 2^_dimension
|
two_to_dim *= 2; // compute 2^_dimension
|
||||||
if (two_to_dim*2 <= 0) {
|
N/=2;
|
||||||
CGAL_assertion(end-begin < two_to_dim);//too many points in such dim
|
if (N==0) break; // not many points, this number of dimension is enough
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// we start with direction 0;
|
// we start with direction 0;
|
||||||
sort (begin, end, start, 0);
|
sort (begin, end, start, 0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -342,6 +342,39 @@ int main ()
|
||||||
|
|
||||||
std::cout << "no points lost." << std::endl;
|
std::cout << "no points lost." << std::endl;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
int dim = 10;
|
||||||
|
std::cout << "Testing "<<dim<<"D (middle policy): Generating "<<nb_points_d<<" random points... " << std::flush;
|
||||||
|
|
||||||
|
std::vector<Point> v;
|
||||||
|
v.reserve (nb_points_d);
|
||||||
|
|
||||||
|
CGAL::Random_points_in_cube_d<Point> gen (dim, 1.0, random);
|
||||||
|
|
||||||
|
for (int i = 0; i < nb_points_d; ++i)
|
||||||
|
v.push_back (*gen++);
|
||||||
|
|
||||||
|
std::cout << "done." << std::endl;
|
||||||
|
|
||||||
|
std::vector<Point> v2 (v);
|
||||||
|
|
||||||
|
std::cout << " Sorting points ... " << std::flush;
|
||||||
|
|
||||||
|
cost.reset();cost.start();
|
||||||
|
CGAL::hilbert_sort (v.begin(), v.end(),
|
||||||
|
CGAL::Hilbert_sort_middle_policy());
|
||||||
|
cost.stop();
|
||||||
|
|
||||||
|
std::cout << "done in "<<cost.time()<<"seconds." << std::endl;
|
||||||
|
|
||||||
|
std::cout << " Checking... " << std::flush;
|
||||||
|
|
||||||
|
std::sort (v.begin(), v.end(), Kd().less_lexicographically_d_object());
|
||||||
|
std::sort (v2.begin(), v2.end(),Kd().less_lexicographically_d_object());
|
||||||
|
assert(v == v2);
|
||||||
|
|
||||||
|
std::cout << "no points lost." << std::endl;
|
||||||
|
}
|
||||||
{
|
{
|
||||||
int dim=5;
|
int dim=5;
|
||||||
std::cout << "Testing "<<dim<<"D: Generating "<<small_nb_points_d<<" random points... " << std::flush;
|
std::cout << "Testing "<<dim<<"D: Generating "<<small_nb_points_d<<" random points... " << std::flush;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue