mirror of https://github.com/CGAL/cgal
*** empty log message ***
This commit is contained in:
parent
8e0b01f88a
commit
637f44f617
|
|
@ -1,5 +1,6 @@
|
|||
// example using nearest_neighbour_iterator for L2
|
||||
// benchmark example using 10000 data points and 2000 query points
|
||||
// bucketsize=1
|
||||
// both generated with Random_points_in_cube_3<Point_3>
|
||||
// comparing ASPAS to brute force method
|
||||
|
||||
|
|
@ -33,7 +34,8 @@ typedef K::FT NT;
|
|||
|
||||
typedef CGAL::Plane_separator<NT> Separator;
|
||||
typedef CGAL::Kd_tree_traits_point<Separator,Point> Traits;
|
||||
typedef CGAL::Nearest_neighbour_L2<Traits,CGAL::Search_nearest_neighbour>::iterator NNN_Iterator;
|
||||
typedef CGAL::Nearest_neighbour_L2<Traits,
|
||||
CGAL::Search_nearest_neighbour>::iterator NNN_Iterator;
|
||||
|
||||
|
||||
|
||||
|
|
@ -53,8 +55,10 @@ NT The_squared_distance(Point P, Point Q) {
|
|||
int bucket_size=1;
|
||||
NT eps=0.0;
|
||||
|
||||
std::cout << "test parameters: d=" << dim << " point_number=" << point_number << std::endl;
|
||||
std::cout << "query_point_number=" << query_point_number << " bucket_size="
|
||||
std::cout << "test parameters: d=" << dim << " point_number="
|
||||
<< point_number << std::endl;
|
||||
std::cout << "query_point_number=" << query_point_number
|
||||
<< " bucket_size="
|
||||
<< bucket_size << " eps=" << eps << std::endl;
|
||||
|
||||
// generate 10000 data points
|
||||
|
|
@ -88,13 +92,15 @@ NT The_squared_distance(Point P, Point Q) {
|
|||
t.stop();
|
||||
|
||||
std::cout << "created binary search tree containing" << std::endl
|
||||
<< point_number << " random points in the 3-dim unit cube in time " << t.time() <<
|
||||
<< point_number << " random points in the 3-dim unit cube in time "
|
||||
<< t.time() <<
|
||||
" seconds " << std::endl;
|
||||
d.statistics();
|
||||
|
||||
// end of building binary search tree
|
||||
|
||||
std::vector<Traits::Item_with_distance> nearest_neighbours(query_point_number);
|
||||
std::vector<Traits::Item_with_distance>
|
||||
nearest_neighbours(query_point_number);
|
||||
|
||||
t.reset(); t.start();
|
||||
for (int i=0; i < query_point_number; i++) {
|
||||
|
|
@ -114,7 +120,8 @@ NT The_squared_distance(Point P, Point Q) {
|
|||
// copy data points from vector to list
|
||||
Vector the_data_points;
|
||||
the_data_points.reserve(point_number);
|
||||
std::copy(data_points.begin(),data_points.end(),std::back_inserter(the_data_points));
|
||||
std::copy(data_points.begin(),data_points.end(),
|
||||
std::back_inserter(the_data_points));
|
||||
|
||||
std::vector<int>
|
||||
nearest_neighbours_brute_force_index(query_point_number);
|
||||
|
|
@ -146,7 +153,8 @@ NT The_squared_distance(Point P, Point Q) {
|
|||
if (!(*(nearest_neighbours[i].first)==the_data_points[
|
||||
nearest_neighbours_brute_force_index[i]])) {
|
||||
assert(
|
||||
The_squared_distance(query_points[i],*(nearest_neighbours[i]).first)==
|
||||
The_squared_distance(query_points[i],
|
||||
*(nearest_neighbours[i]).first)==
|
||||
The_squared_distance(query_points[i],
|
||||
the_data_points[nearest_neighbours_brute_force_index[i]]));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// example using nearest_neighbour_iterator for Linf
|
||||
// benchmark example using 10000 data points and 2000 query points
|
||||
// benchmark example using 10000 data points and 2000 query points,
|
||||
// bucketsize=1
|
||||
// both generated with Random_points_in_cube_3<Point_3>
|
||||
// comparing to brute force method
|
||||
|
||||
|
|
@ -34,7 +35,8 @@ typedef K::FT NT;
|
|||
|
||||
typedef CGAL::Plane_separator<NT> Separator;
|
||||
typedef CGAL::Kd_tree_traits_point<Separator,Point> Traits;
|
||||
typedef CGAL::Nearest_neighbour_Linf<Traits,CGAL::Search_nearest_neighbour>::iterator NNN_Iterator;
|
||||
typedef CGAL::Nearest_neighbour_Linf<Traits,
|
||||
CGAL::Search_nearest_neighbour>::iterator NNN_Iterator;
|
||||
|
||||
NT The_Linf_distance(Point P, Point Q) {
|
||||
NT dist=fabs(P.x()-Q.x());
|
||||
|
|
@ -54,8 +56,10 @@ NT The_Linf_distance(Point P, Point Q) {
|
|||
int bucket_size=1;
|
||||
NT eps=0.0;
|
||||
|
||||
std::cout << "test parameters: d=" << dim << " point_number=" << point_number << std::endl;
|
||||
std::cout << "query_point_number=" << query_point_number << " bucket_size="
|
||||
std::cout << "test parameters: d=" << dim << " point_number="
|
||||
<< point_number << std::endl;
|
||||
std::cout << "query_point_number=" << query_point_number
|
||||
<< " bucket_size="
|
||||
<< bucket_size << " eps=" << eps << std::endl;
|
||||
|
||||
// generate 10000 data points
|
||||
|
|
@ -89,13 +93,14 @@ NT The_Linf_distance(Point P, Point Q) {
|
|||
t.stop();
|
||||
|
||||
std::cout << "created binary search tree containing" << std::endl
|
||||
<< point_number << " random points in the 3-dim unit cube in time " << t.time() <<
|
||||
" seconds " << std::endl;
|
||||
<< point_number << " random points in the 3-dim unit cube in time "
|
||||
<< t.time() << " seconds " << std::endl;
|
||||
d.statistics();
|
||||
|
||||
// end of building binary search tree
|
||||
|
||||
std::vector<Traits::Item_with_distance> nearest_neighbours(query_point_number);
|
||||
std::vector<Traits::Item_with_distance>
|
||||
nearest_neighbours(query_point_number);
|
||||
|
||||
t.reset(); t.start();
|
||||
for (int i=0; i < query_point_number; i++) {
|
||||
|
|
@ -113,7 +118,8 @@ NT The_Linf_distance(Point P, Point Q) {
|
|||
// copy data points from vector to list
|
||||
Vector the_data_points;
|
||||
the_data_points.reserve(point_number);
|
||||
std::copy(data_points.begin(),data_points.end(),std::back_inserter(the_data_points));
|
||||
std::copy(data_points.begin(),data_points.end(),
|
||||
std::back_inserter(the_data_points));
|
||||
|
||||
std::vector<int>
|
||||
nearest_neighbours_brute_force_index(query_point_number);
|
||||
|
|
@ -145,7 +151,8 @@ NT The_Linf_distance(Point P, Point Q) {
|
|||
if (!(*(nearest_neighbours[i].first)==the_data_points[
|
||||
nearest_neighbours_brute_force_index[i]])) {
|
||||
assert(
|
||||
The_Linf_distance(query_points[i],*(nearest_neighbours[i]).first)==
|
||||
The_Linf_distance(query_points[i],
|
||||
*(nearest_neighbours[i]).first)==
|
||||
The_Linf_distance(query_points[i],
|
||||
the_data_points[nearest_neighbours_brute_force_index[i]]));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// example using nearest_neighbour_iterator for Minkowski_norm
|
||||
// benchmark example using 10000 data points and 2000 query points, bucketsize=10
|
||||
// benchmark example using 10000 data points and 2000 query points,
|
||||
// bucketsize=10
|
||||
// both generated with Random_points_in_cube_3<Point_3>
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
|
|
@ -48,9 +49,10 @@ NNN_Iterator;
|
|||
std::vector<double> my_weights(dim);
|
||||
my_weights[0]=0.0; my_weights[1]=2.0; my_weights[2]=5;
|
||||
|
||||
std::cout << "test parameters: d=" << dim << " point_number=" << point_number << std::endl;
|
||||
std::cout << "query_point_number=" << query_point_number << " bucket_size="
|
||||
<< bucket_size << " eps=" << eps << std::endl;
|
||||
std::cout << "test parameters: d=" << dim << " point_number="
|
||||
<< point_number << std::endl;
|
||||
std::cout << "query_point_number=" << query_point_number
|
||||
<< " bucket_size=" << bucket_size << " eps=" << eps << std::endl;
|
||||
|
||||
// generate 10000 data points
|
||||
// Prepare a vector for 10000 points.
|
||||
|
|
@ -73,7 +75,8 @@ NNN_Iterator;
|
|||
query_points.reserve(2000);
|
||||
|
||||
// Create 2000 query points within the same cube.
|
||||
CGAL::copy_n( g, query_point_number, std::back_inserter(query_points));
|
||||
CGAL::copy_n( g, query_point_number,
|
||||
std::back_inserter(query_points));
|
||||
|
||||
t.reset(); t.start();
|
||||
|
||||
|
|
@ -85,13 +88,14 @@ NNN_Iterator;
|
|||
t.stop();
|
||||
|
||||
std::cout << "created binary search tree containing" << std::endl
|
||||
<< point_number << " random points in the 3-dim unit cube in time " << t.time() <<
|
||||
" seconds " << std::endl;
|
||||
<< point_number << " random points in the 3-dim unit cube in time "
|
||||
<< t.time() << " seconds " << std::endl;
|
||||
d.statistics();
|
||||
|
||||
// end of building binary search tree
|
||||
|
||||
std::vector<Traits::Item_with_distance> nearest_neighbours(query_point_number);
|
||||
std::vector<Traits::Item_with_distance>
|
||||
nearest_neighbours(query_point_number);
|
||||
Distance_traits tr_dist(the_power,dim,my_weights);
|
||||
|
||||
t.reset(); t.start();
|
||||
|
|
@ -110,7 +114,8 @@ NNN_Iterator;
|
|||
// copy data points from vector to list
|
||||
Vector the_data_points;
|
||||
the_data_points.reserve(point_number);
|
||||
std::copy(data_points.begin(),data_points.end(),std::back_inserter(the_data_points));
|
||||
std::copy(data_points.begin(),data_points.end(),
|
||||
std::back_inserter(the_data_points));
|
||||
|
||||
std::vector<int>
|
||||
nearest_neighbours_brute_force_index(query_point_number);
|
||||
|
|
@ -142,7 +147,8 @@ NNN_Iterator;
|
|||
if (!(*(nearest_neighbours[i].first)==the_data_points[
|
||||
nearest_neighbours_brute_force_index[i]])) {
|
||||
assert(
|
||||
tr_dist.distance(query_points[i],*(nearest_neighbours[i]).first)==
|
||||
tr_dist.distance(query_points[i],
|
||||
*(nearest_neighbours[i]).first)==
|
||||
tr_dist.distance(query_points[i],
|
||||
the_data_points[nearest_neighbours_brute_force_index[i]]));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// example using nearest_neighbour_iterator for Minkowski_norm with general_distance
|
||||
// benchmark example using 10000 data points and 2000 query points, bucketsize=10
|
||||
// example using nearest_neighbour_iterator for Minkowski_norm
|
||||
// with general_distance
|
||||
// benchmark example using 10000 data points and 2000 query points,
|
||||
// bucketsize=10
|
||||
// both generated with Random_points_in_cube_3<Point_3>
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
|
|
@ -48,7 +50,8 @@ NNN_Iterator;
|
|||
std::vector<double> my_weights(dim);
|
||||
my_weights[0]=0.0; my_weights[1]=2.0; my_weights[2]=5;
|
||||
|
||||
std::cout << "test parameters: d=" << dim << " point_number=" << point_number << std::endl;
|
||||
std::cout << "test parameters: d=" << dim << " point_number="
|
||||
<< point_number << std::endl;
|
||||
std::cout << "query_point_number=" << query_point_number << " bucket_size="
|
||||
<< bucket_size << " eps=" << eps << std::endl;
|
||||
|
||||
|
|
@ -85,13 +88,14 @@ NNN_Iterator;
|
|||
t.stop();
|
||||
|
||||
std::cout << "created binary search tree containing" << std::endl
|
||||
<< point_number << " random points in the 3-dim unit cube in time " << t.time() <<
|
||||
" seconds " << std::endl;
|
||||
<< point_number << " random points in the 3-dim unit cube in time "
|
||||
<< t.time() << " seconds " << std::endl;
|
||||
d.statistics();
|
||||
|
||||
// end of building binary search tree
|
||||
|
||||
std::vector<Traits::Item_with_distance> nearest_neighbours(query_point_number);
|
||||
std::vector<Traits::Item_with_distance>
|
||||
nearest_neighbours(query_point_number);
|
||||
Distance_traits tr_dist(the_power,dim,my_weights);
|
||||
|
||||
t.reset(); t.start();
|
||||
|
|
@ -110,7 +114,8 @@ NNN_Iterator;
|
|||
// copy data points from vector to list
|
||||
Vector the_data_points;
|
||||
the_data_points.reserve(point_number);
|
||||
std::copy(data_points.begin(),data_points.end(),std::back_inserter(the_data_points));
|
||||
std::copy(data_points.begin(),data_points.end(),
|
||||
std::back_inserter(the_data_points));
|
||||
|
||||
std::vector<int>
|
||||
nearest_neighbours_brute_force_index(query_point_number);
|
||||
|
|
@ -142,7 +147,8 @@ NNN_Iterator;
|
|||
if (!(*(nearest_neighbours[i].first)==the_data_points[
|
||||
nearest_neighbours_brute_force_index[i]])) {
|
||||
assert(
|
||||
tr_dist.distance(query_points[i],*(nearest_neighbours[i]).first)==
|
||||
tr_dist.distance(query_points[i],
|
||||
*(nearest_neighbours[i]).first)==
|
||||
tr_dist.distance(query_points[i],
|
||||
the_data_points[nearest_neighbours_brute_force_index[i]]));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class Priority_higher
|
|||
search_nearest = s.Search_nearest();
|
||||
}
|
||||
//highest priority is smallest distance
|
||||
bool operator() (Node_with_distance* n1, Node_with_distance* n2) const
|
||||
bool operator() (Node_with_distance* n1, Node_with_distance* n2) const
|
||||
{
|
||||
if (search_nearest) { return (n1->second > n2->second);}
|
||||
else {return (n2->second > n1->second);}
|
||||
|
|
@ -78,7 +78,7 @@ class Distance_smaller
|
|||
}
|
||||
|
||||
//highest priority is smallest distance
|
||||
bool operator() (Item_with_distance* p1, Item_with_distance* p2) const
|
||||
bool operator() (Item_with_distance* p1, Item_with_distance* p2) const
|
||||
{
|
||||
if (search_nearest) {return (p1->second > p2->second);}
|
||||
else {return (p2->second > p1->second);}
|
||||
|
|
@ -97,8 +97,8 @@ class Distance_smaller
|
|||
public:
|
||||
|
||||
// constructor
|
||||
Nearest_neighbour_Minkowski_norm(Tree& tree, Item& q, Orthogonal_Distance& tr,
|
||||
NT Eps=0.0)
|
||||
Nearest_neighbour_Minkowski_norm(Tree& tree, Item& q,
|
||||
Orthogonal_Distance& tr, NT Eps=0.0)
|
||||
{
|
||||
start = new iterator(tree,q,tr,Eps);
|
||||
past_the_end = new iterator();
|
||||
|
|
|
|||
Loading…
Reference in New Issue