diff --git a/Arithmetic_kernel/include/CGAL/GMPXX_arithmetic_kernel.h b/Arithmetic_kernel/include/CGAL/GMPXX_arithmetic_kernel.h new file mode 100644 index 00000000000..9c05981e0a6 --- /dev/null +++ b/Arithmetic_kernel/include/CGAL/GMPXX_arithmetic_kernel.h @@ -0,0 +1,44 @@ +// Copyright (c) 2016 Inria. +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org); you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation; either version 3 of the License, +// or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Author: Marc Glisse + +#ifndef CGAL_GMPXX_ARITHMETIC_KERNEL_H +#define CGAL_GMPXX_ARITHMETIC_KERNEL_H + +#include + +#ifdef CGAL_USE_GMPXX + +#include +#include + +#include + +namespace CGAL { +/** \ingroup CGAL_Arithmetic_kernel + * \brief The GMPXX set of exact number types + */ +struct GMPXX_arithmetic_kernel : internal::Arithmetic_kernel_base { + typedef mpz_class Integer; + typedef mpq_class Rational; +}; + +template +struct Get_arithmetic_kernel<__gmp_expr > { + typedef GMPXX_arithmetic_kernel Arithmetic_kernel; +}; +} //namespace CGAL +#endif //CGAL_USE_GMPXX +#endif diff --git a/Arithmetic_kernel/test/Arithmetic_kernel/GMPXX_arithmetic_kernel.cpp b/Arithmetic_kernel/test/Arithmetic_kernel/GMPXX_arithmetic_kernel.cpp new file mode 100644 index 00000000000..b51a5d6de00 --- /dev/null +++ b/Arithmetic_kernel/test/Arithmetic_kernel/GMPXX_arithmetic_kernel.cpp @@ -0,0 +1,18 @@ +#include +#include +#include + +#ifdef CGAL_USE_GMPXX + +#include + +int main() { + std::cout << "TEST GMPXX_arithmetic_kernel" << std::endl; + typedef CGAL::GMPXX_arithmetic_kernel AK; + CGAL::test_arithmetic_kernel(); + return 0; +} + +#else +int main() { return 0; } +#endif diff --git a/Number_types/include/CGAL/Sqrt_extension/Sqrt_extension_type.h b/Number_types/include/CGAL/Sqrt_extension/Sqrt_extension_type.h index b7290aec11e..e49109e2421 100644 --- a/Number_types/include/CGAL/Sqrt_extension/Sqrt_extension_type.h +++ b/Number_types/include/CGAL/Sqrt_extension/Sqrt_extension_type.h @@ -195,9 +195,10 @@ public: > >::type* = 0 ) { typename Fraction_traits::Compose compose_nt; + typename Fraction_traits::Compose compose_root; if ( a != 0 ) { a0_ = compose_nt(-b,2*a); - root_ = CGAL_NTS square(a0_) - ROOT(c,a); + root_ = CGAL_NTS square(a0_) - compose_root(c,a); if(CGAL_NTS is_zero(root_)) { is_extended_ = false; } else { diff --git a/Number_types/include/CGAL/gmpxx.h b/Number_types/include/CGAL/gmpxx.h index 5f65e85abff..429bf1b710e 100644 --- a/Number_types/include/CGAL/gmpxx.h +++ b/Number_types/include/CGAL/gmpxx.h @@ -61,4 +61,6 @@ class Real_embeddable_traits< ::__gmp_expr > } //namespace CGAL +#include + #endif // CGAL_GMPXX_H diff --git a/Number_types/test/Number_types/root_of_2.cpp b/Number_types/test/Number_types/root_of_2.cpp index 32d6ac39be7..0b221b7d5e2 100644 --- a/Number_types/test/Number_types/root_of_2.cpp +++ b/Number_types/test/Number_types/root_of_2.cpp @@ -127,8 +127,8 @@ CGAL::Sqrt_extension create_root_helper(RT a, RT b,CGAL template < class T, class RT,class Tag1, class Tag2 > CGAL::Sqrt_extension create_root_helper(RT a, RT b, CGAL::Sqrt_extension *) { - T t(a,b); - return CGAL::Sqrt_extension( t ); + typename CGAL::Fraction_traits::Compose comp; + return CGAL::Sqrt_extension( comp(a, b) ); } template < class Root, class RT > @@ -597,10 +597,8 @@ int main(int argc, char **argv) { #endif #ifdef CGAL_USE_GMPXX - std::cout << "Testing Sqrt_extension with Quotient mpz_class" << std::endl; - //no specialization of Get_arithmetic_kernel of mpz_class is available, the default is to suppose it is - //a ring type and make a field type using CGAL::Quotient. - result = result && test_root_of_g,CGAL::Quotient,CGAL::Tag_true,CGAL::Tag_true >,mpz_class,CGAL::Quotient >(); + std::cout << "Testing Sqrt_extension with mpq_class" << std::endl; + result = result && test_root_of >(); #endif if (result) {