mirror of https://github.com/CGAL/cgal
Merge pull request #1609 from mglisse/Number_types-gmpxx_AK-glisse
New GMPXX_arithmetic_kernel.
This commit is contained in:
commit
79741e4581
|
|
@ -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 <marc.glisse@inria.fr>
|
||||
|
||||
#ifndef CGAL_GMPXX_ARITHMETIC_KERNEL_H
|
||||
#define CGAL_GMPXX_ARITHMETIC_KERNEL_H
|
||||
|
||||
#include <CGAL/config.h>
|
||||
|
||||
#ifdef CGAL_USE_GMPXX
|
||||
|
||||
#include <CGAL/Arithmetic_kernel/Arithmetic_kernel_base.h>
|
||||
#include <CGAL/Get_arithmetic_kernel.h>
|
||||
|
||||
#include <CGAL/gmpxx.h>
|
||||
|
||||
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 <class T, class U>
|
||||
struct Get_arithmetic_kernel<__gmp_expr<T, U> > {
|
||||
typedef GMPXX_arithmetic_kernel Arithmetic_kernel;
|
||||
};
|
||||
} //namespace CGAL
|
||||
#endif //CGAL_USE_GMPXX
|
||||
#endif
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#include <iostream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/GMPXX_arithmetic_kernel.h>
|
||||
|
||||
#ifdef CGAL_USE_GMPXX
|
||||
|
||||
#include <CGAL/Test/_test_arithmetic_kernel.h>
|
||||
|
||||
int main() {
|
||||
std::cout << "TEST GMPXX_arithmetic_kernel" << std::endl;
|
||||
typedef CGAL::GMPXX_arithmetic_kernel AK;
|
||||
CGAL::test_arithmetic_kernel<AK>();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
int main() { return 0; }
|
||||
#endif
|
||||
|
|
@ -195,9 +195,10 @@ public:
|
|||
> >::type* = 0 )
|
||||
{
|
||||
typename Fraction_traits<NT>::Compose compose_nt;
|
||||
typename Fraction_traits<ROOT>::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 {
|
||||
|
|
|
|||
|
|
@ -61,4 +61,6 @@ class Real_embeddable_traits< ::__gmp_expr<T,U> >
|
|||
|
||||
} //namespace CGAL
|
||||
|
||||
#include <CGAL/GMPXX_arithmetic_kernel.h>
|
||||
|
||||
#endif // CGAL_GMPXX_H
|
||||
|
|
|
|||
|
|
@ -127,8 +127,8 @@ CGAL::Sqrt_extension<double,double,Tag1,Tag2> create_root_helper(RT a, RT b,CGAL
|
|||
template < class T, class RT,class Tag1, class Tag2 >
|
||||
CGAL::Sqrt_extension<T,T,Tag1,Tag2> create_root_helper(RT a, RT b, CGAL::Sqrt_extension<T,T,Tag1,Tag2> *)
|
||||
{
|
||||
T t(a,b);
|
||||
return CGAL::Sqrt_extension<T,T,Tag1,Tag2>( t );
|
||||
typename CGAL::Fraction_traits<T>::Compose comp;
|
||||
return CGAL::Sqrt_extension<T,T,Tag1,Tag2>( 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::Sqrt_extension<CGAL::Quotient<mpz_class>,CGAL::Quotient<mpz_class>,CGAL::Tag_true,CGAL::Tag_true >,mpz_class,CGAL::Quotient<mpz_class> >();
|
||||
std::cout << "Testing Sqrt_extension with mpq_class" << std::endl;
|
||||
result = result && test_root_of<CGAL::Sqrt_extension<mpq_class,mpq_class,CGAL::Tag_true,CGAL::Tag_true > >();
|
||||
#endif
|
||||
|
||||
if (result) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue