From fa6818b7ddaf951f2b2ec79eeedddffca7116b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 6 Apr 2021 19:43:42 +0200 Subject: [PATCH 1/7] Fix approximate_sqrt return types --- Algebraic_foundations/include/CGAL/number_utils.h | 10 ++++++---- Number_types/include/CGAL/mpq_class.h | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Algebraic_foundations/include/CGAL/number_utils.h b/Algebraic_foundations/include/CGAL/number_utils.h index d29434ad603..3b7a1154cc8 100644 --- a/Algebraic_foundations/include/CGAL/number_utils.h +++ b/Algebraic_foundations/include/CGAL/number_utils.h @@ -302,19 +302,21 @@ to_interval( const Real_embeddable& x) { } template -NT approximate_sqrt(const NT& nt, CGAL::Null_functor) +typename Coercion_traits::Type +approximate_sqrt(const NT& x, CGAL::Null_functor) { - return NT(sqrt(CGAL::to_double(nt))); + return sqrt(CGAL::to_double(x)); } template -NT approximate_sqrt(const NT& nt, Sqrt sqrt) +typename Sqrt::result_type +approximate_sqrt(const NT& nt, Sqrt sqrt) { return sqrt(nt); } template -NT approximate_sqrt(const NT& nt) +decltype(auto) approximate_sqrt(const NT& nt) { // the initial version of this function was using Algebraic_category // for the dispatch but some ring type (like Gmpz) provides a Sqrt diff --git a/Number_types/include/CGAL/mpq_class.h b/Number_types/include/CGAL/mpq_class.h index 6250ea95e3a..76611b93cf9 100644 --- a/Number_types/include/CGAL/mpq_class.h +++ b/Number_types/include/CGAL/mpq_class.h @@ -40,7 +40,6 @@ namespace CGAL { - // AST for mpq_class template<> class Algebraic_structure_traits< mpq_class > From b0b38dade8739c434fe1bb09eca3921d70cfac86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 7 Apr 2021 12:38:24 +0200 Subject: [PATCH 2/7] Add a simple test for approximate_sqrt(NT) for most NTs --- Number_types/test/Number_types/Gmpzf_new.cpp | 2 +- .../test/Number_types/include/CGAL/_test_utilities.h | 4 ++++ Number_types/test/Number_types/utilities.cpp | 5 ----- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Number_types/test/Number_types/Gmpzf_new.cpp b/Number_types/test/Number_types/Gmpzf_new.cpp index 95ea8c2de4f..f2ae93fe287 100644 --- a/Number_types/test/Number_types/Gmpzf_new.cpp +++ b/Number_types/test/Number_types/Gmpzf_new.cpp @@ -31,7 +31,7 @@ int main() { CGAL::test_algebraic_structure(); CGAL::test_real_embeddable(); - // assert(CGAL::approximate_sqrt(NT(4)) == NT(2)); + assert(CGAL::approximate_sqrt(NT(4)) == NT(2)); } return 0; diff --git a/Number_types/test/Number_types/include/CGAL/_test_utilities.h b/Number_types/test/Number_types/include/CGAL/_test_utilities.h index 49a0d8e5224..dff2b016e08 100644 --- a/Number_types/test/Number_types/include/CGAL/_test_utilities.h +++ b/Number_types/test/Number_types/include/CGAL/_test_utilities.h @@ -366,6 +366,10 @@ test_utilities(const NT& x) if (!test_gcd(x,typename AST::Algebraic_category())) return false; if (!test_sqrt(x,typename AST::Sqrt())) return false; + // approximate_sqrt + std::cout << " approximate_sqrt()" << std::endl; + if(CGAL::approximate_sqrt(zero + one) != one) return false; + return true; } diff --git a/Number_types/test/Number_types/utilities.cpp b/Number_types/test/Number_types/utilities.cpp index b4e3e22c81f..22958e4ee67 100644 --- a/Number_types/test/Number_types/utilities.cpp +++ b/Number_types/test/Number_types/utilities.cpp @@ -1,10 +1,5 @@ #include -// TODO: solve conflict of CORE with GMPXX -#ifdef CGAL_USE_CORE -#undef CGAL_USE_GMPXX -#endif - #include #include #include From ee58c89f7a078d7ae8124ff2f0aeef1d16d71c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 7 Apr 2021 12:38:52 +0200 Subject: [PATCH 3/7] Add a note about why MP_Float is not tested --- Number_types/test/Number_types/utilities.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Number_types/test/Number_types/utilities.cpp b/Number_types/test/Number_types/utilities.cpp index 22958e4ee67..32e7fb13573 100644 --- a/Number_types/test/Number_types/utilities.cpp +++ b/Number_types/test/Number_types/utilities.cpp @@ -72,7 +72,7 @@ int main() TESTIT(long double, "long double") // CGAL number types - //TESTIT(CGAL::MP_Float, "MP_Float") + //TESTIT(CGAL::MP_Float, "MP_Float") // CGAL::div(MP_Float, MP_Float) does not implement _integer_ division TESTIT(CGAL::Quotient, "Quotient") TESTIT(QMPF, "Quotient") TESTIT(CGAL::Lazy_exact_nt, "Lazy_exact_nt >") From 3a26ede3a0480e15ecc7091c581c3e125703261e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 9 Apr 2021 16:32:38 +0200 Subject: [PATCH 4/7] Simplify test to avoid issue with boost mp Issue is fixed, see https://github.com/boostorg/multiprecision/pull/320 --- Number_types/test/Number_types/include/CGAL/_test_utilities.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Number_types/test/Number_types/include/CGAL/_test_utilities.h b/Number_types/test/Number_types/include/CGAL/_test_utilities.h index dff2b016e08..f82e59f3604 100644 --- a/Number_types/test/Number_types/include/CGAL/_test_utilities.h +++ b/Number_types/test/Number_types/include/CGAL/_test_utilities.h @@ -368,7 +368,7 @@ test_utilities(const NT& x) // approximate_sqrt std::cout << " approximate_sqrt()" << std::endl; - if(CGAL::approximate_sqrt(zero + one) != one) return false; + if(CGAL::approximate_sqrt(one) != one) return false; return true; } From c489b7ffa5c6a9b09740ec13fb7fc935f55f0d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 20 Apr 2021 15:59:29 +0200 Subject: [PATCH 5/7] Add missing Coercion_traits specialization for custom FT in PMP test --- .../Polygon_mesh_processing/test_pmp_distance.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_distance.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_distance.cpp index dbcbce4db8a..70251cd00ed 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_distance.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_distance.cpp @@ -1,11 +1,11 @@ #include #include + #include #include - - #include - +#include +#include #include #include @@ -194,6 +194,14 @@ struct Custom_traits_Hausdorff }; namespace CGAL{ + +CGAL_DEFINE_COERCION_TRAITS_FOR_SELF(Custom_traits_Hausdorff::FT) +CGAL_DEFINE_COERCION_TRAITS_FROM_TO(short, Custom_traits_Hausdorff::FT) +CGAL_DEFINE_COERCION_TRAITS_FROM_TO(int, Custom_traits_Hausdorff::FT) +CGAL_DEFINE_COERCION_TRAITS_FROM_TO(long, Custom_traits_Hausdorff::FT) +CGAL_DEFINE_COERCION_TRAITS_FROM_TO(float, Custom_traits_Hausdorff::FT) +CGAL_DEFINE_COERCION_TRAITS_FROM_TO(double, Custom_traits_Hausdorff::FT) + template<>struct Kernel_traits { typedef Custom_traits_Hausdorff Kernel; From 0d7eb2a9336671a37fca90382c28c80f63d51ddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 30 Apr 2021 17:37:05 +0200 Subject: [PATCH 6/7] Avoid a conversion warning --- Number_types/test/Number_types/include/CGAL/_test_utilities.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Number_types/test/Number_types/include/CGAL/_test_utilities.h b/Number_types/test/Number_types/include/CGAL/_test_utilities.h index f82e59f3604..a53184e65c5 100644 --- a/Number_types/test/Number_types/include/CGAL/_test_utilities.h +++ b/Number_types/test/Number_types/include/CGAL/_test_utilities.h @@ -368,7 +368,7 @@ test_utilities(const NT& x) // approximate_sqrt std::cout << " approximate_sqrt()" << std::endl; - if(CGAL::approximate_sqrt(one) != one) return false; + if(NT(CGAL::approximate_sqrt(one)) != one) return false; return true; } From 181cc4ebb8dedc222e60fbaff17c1439651b3f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 30 Apr 2021 17:37:31 +0200 Subject: [PATCH 7/7] Tiny logging fix --- Number_types/test/Number_types/utilities.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Number_types/test/Number_types/utilities.cpp b/Number_types/test/Number_types/utilities.cpp index 32e7fb13573..f8028bf59d6 100644 --- a/Number_types/test/Number_types/utilities.cpp +++ b/Number_types/test/Number_types/utilities.cpp @@ -124,7 +124,7 @@ int main() // TEST Sqrt_extension #ifdef CGAL_USE_GMP typedef CGAL::Sqrt_extension Ext_int; - TESTIT(Ext_int , "CGAL::Sqrt_extension"); + TESTIT(Ext_int , "CGAL::Sqrt_extension"); typedef CGAL::Sqrt_extension Ext_int_int; TESTIT(Ext_int_int , "CGAL::Sqrt_extension"); typedef CGAL::Sqrt_extension Ext_rat_int;