mirror of https://github.com/CGAL/cgal
Merge pull request #5589 from MaelRL/Number_types-Fix_approx_sqrt_mpq-GF
Fix approximate_sqrt return types # Conflicts: # Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_distance.cpp
This commit is contained in:
commit
e222e772f1
|
|
@ -303,19 +303,21 @@ to_interval( const Real_embeddable& x) {
|
|||
}
|
||||
|
||||
template <typename NT>
|
||||
NT approximate_sqrt(const NT& nt, CGAL::Null_functor)
|
||||
typename Coercion_traits<double, NT>::Type
|
||||
approximate_sqrt(const NT& x, CGAL::Null_functor)
|
||||
{
|
||||
return NT(sqrt(CGAL::to_double(nt)));
|
||||
return sqrt(CGAL::to_double(x));
|
||||
}
|
||||
|
||||
template <typename NT, typename Sqrt>
|
||||
NT approximate_sqrt(const NT& nt, Sqrt sqrt)
|
||||
typename Sqrt::result_type
|
||||
approximate_sqrt(const NT& nt, Sqrt sqrt)
|
||||
{
|
||||
return sqrt(nt);
|
||||
}
|
||||
|
||||
template <typename NT>
|
||||
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
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@
|
|||
|
||||
namespace CGAL {
|
||||
|
||||
|
||||
// AST for mpq_class
|
||||
template<>
|
||||
class Algebraic_structure_traits< mpq_class >
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ int main() {
|
|||
CGAL::test_algebraic_structure<NT,Tag, Is_exact>();
|
||||
CGAL::test_real_embeddable<NT>();
|
||||
|
||||
// assert(CGAL::approximate_sqrt(NT(4)) == NT(2));
|
||||
assert(CGAL::approximate_sqrt(NT(4)) == NT(2));
|
||||
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -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(NT(CGAL::approximate_sqrt(one)) != one) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,5 @@
|
|||
#include <CGAL/config.h>
|
||||
|
||||
// TODO: solve conflict of CORE with GMPXX
|
||||
#ifdef CGAL_USE_CORE
|
||||
#undef CGAL_USE_GMPXX
|
||||
#endif
|
||||
|
||||
#include <CGAL/Quotient.h>
|
||||
#include <CGAL/MP_Float.h>
|
||||
#include <CGAL/Lazy_exact_nt.h>
|
||||
|
|
@ -77,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<int>, "Quotient<int>")
|
||||
TESTIT(QMPF, "Quotient<MP_Float>")
|
||||
TESTIT(CGAL::Lazy_exact_nt<QMPF>, "Lazy_exact_nt<Quotient<MP_Float> >")
|
||||
|
|
@ -129,7 +124,7 @@ int main()
|
|||
// TEST Sqrt_extension
|
||||
#ifdef CGAL_USE_GMP
|
||||
typedef CGAL::Sqrt_extension<int,int> Ext_int;
|
||||
TESTIT(Ext_int , "CGAL::Sqrt_extension<CGAL::Gmpz,CGAL::Gmpz>");
|
||||
TESTIT(Ext_int , "CGAL::Sqrt_extension<int,int>");
|
||||
typedef CGAL::Sqrt_extension<CGAL::Gmpz,CGAL::Gmpz> Ext_int_int;
|
||||
TESTIT(Ext_int_int , "CGAL::Sqrt_extension<CGAL::Gmpz,CGAL::Gmpz>");
|
||||
typedef CGAL::Sqrt_extension<CGAL::Gmpq,CGAL::Gmpz> Ext_rat_int;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/Real_timer.h>
|
||||
#include <CGAL/IO/OFF.h>
|
||||
|
||||
|
||||
#include <CGAL/boost/graph/property_maps.h>
|
||||
|
||||
#include <CGAL/number_utils.h>
|
||||
#include <CGAL/Coercion_traits.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <ostream>
|
||||
|
|
@ -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<Custom_traits_Hausdorff::Point_3>
|
||||
{
|
||||
typedef Custom_traits_Hausdorff Kernel;
|
||||
|
|
|
|||
Loading…
Reference in New Issue