using epsilon tolerance for Simple_cartesian<double> instead of exact comparison

This commit is contained in:
Sven Oesau 2022-10-01 16:09:30 +02:00
parent cd3d7528ec
commit 9611c8f3c0
2 changed files with 12 additions and 8 deletions

View File

@ -71,21 +71,21 @@ void run()
typename K_search::iterator it = oins.begin();
typename K_search::Point_with_transformed_distance pd = *it;
points2.push_back(get_point(pd.first));
if(CGAL::squared_distance(query,get_point(pd.first)) != pd.second){
if(abs(CGAL::squared_distance(query, get_point(pd.first)) - pd.second) >= 0.000000001){
std::cout << "different distances: " << CGAL::squared_distance(query,get_point(pd.first)) << " != " << pd.second << std::endl;
}
assert(CGAL_IA_FORCE_TO_DOUBLE(CGAL::squared_distance(query,get_point(pd.first))) == pd.second);
assert(abs(CGAL::squared_distance(query, get_point(pd.first)) - pd.second) < 0.000000001);
it++;
for(; it != oins.end();it++){
typename K_search::Point_with_transformed_distance qd = *it;
assert(pd.second <= qd.second);
pd = qd;
points2.push_back(get_point(pd.first));
if(CGAL_IA_FORCE_TO_DOUBLE(CGAL::squared_distance(query,get_point(pd.first))) != pd.second){
if(abs(CGAL::squared_distance(query, get_point(pd.first)) - pd.second) >= 0.000000001){
std::cout << "different distances: " << CGAL::squared_distance(query,get_point(pd.first)) << " != " << pd.second << std::endl;
}
assert(CGAL_IA_FORCE_TO_DOUBLE(CGAL::squared_distance(query,get_point(pd.first))) == pd.second);
assert(abs(CGAL::squared_distance(query, get_point(pd.first)) - pd.second) < 0.000000001);
}
@ -176,6 +176,7 @@ bool search(bool nearest)
int
main() {
std::cout << std::setprecision(17);
bool OK=true;
std::cout << "Testing Incremental_neighbor_search\n";
run<Incremental_neighbor_search>();

View File

@ -60,20 +60,23 @@ struct Splitter_test {
typename Orthogonal_incremental_neighbor_search::iterator it = oins.begin();
Point_with_transformed_distance pd = *it;
points2.push_back(get_point(pd.first));
if(CGAL::squared_distance(query,get_point(pd.first)) != pd.second){
std::cout << std::setprecision(17);
if(abs(CGAL::squared_distance(query, get_point(pd.first)) - pd.second) >= 0.000000001){
std::cout << CGAL::squared_distance(query,get_point(pd.first)) << " != " << pd.second << std::endl;
}
assert(CGAL_IA_FORCE_TO_DOUBLE(CGAL::squared_distance(query,get_point(pd.first))) == pd.second);
assert(abs(CGAL::squared_distance(query,get_point(pd.first)) - pd.second) < 0.000000001);
it++;
for(; it != oins.end();it++){
Point_with_transformed_distance qd = *it;
assert(pd.second <= qd.second);
pd = qd;
points2.push_back(get_point(pd.first));
if(CGAL_IA_FORCE_TO_DOUBLE(CGAL::squared_distance(query,get_point(pd.first))) != pd.second){
if(abs(CGAL::squared_distance(query, get_point(pd.first)) - pd.second) >= 0.000000001){
std::cout << CGAL::squared_distance(query,get_point(pd.first)) << " != " << pd.second << std::endl;
}
assert(CGAL_IA_FORCE_TO_DOUBLE(CGAL::squared_distance(query,get_point(pd.first))) == pd.second);
assert(abs(CGAL::squared_distance(query, get_point(pd.first)) - pd.second) < 0.000000001);
}
std::sort(points.begin(),points.end());
std::sort(points2.begin(),points2.end());