mirror of https://github.com/CGAL/cgal
more generic Root_of_traits:
added Make_root_of_2 functor to Root_of_traits - CGAL::make_root_of_2 is now using this functor - CGAL::make_root_of_2 mv into Root_of_traits.h added new NT-support for Number_type_checker rm all *_fwd.h files
This commit is contained in:
parent
15e9b4c27a
commit
b2af681a83
|
|
@ -520,7 +520,84 @@ namespace INTERN_AST {
|
|||
|
||||
|
||||
|
||||
namespace CGALi{
|
||||
|
||||
#define CGAL_IS_SAME_OR_BASE_OF(BASE,T) \
|
||||
( \
|
||||
::boost::is_base_and_derived< BASE , T >::value || \
|
||||
::boost::is_same< BASE , T >::value \
|
||||
) \
|
||||
|
||||
|
||||
|
||||
|
||||
template<class AS>
|
||||
class Is_integral_domain_without_division {
|
||||
typedef Algebraic_structure_traits<AS> AST;
|
||||
typedef typename AST::Algebraic_structure_tag Tag;
|
||||
public :
|
||||
static const bool value
|
||||
= CGAL_IS_SAME_OR_BASE_OF(Integral_domain_without_division_tag,Tag);
|
||||
};
|
||||
|
||||
template<class AS>
|
||||
class Is_integral_domain {
|
||||
typedef Algebraic_structure_traits<AS> AST;
|
||||
typedef typename AST::Algebraic_structure_tag Tag;
|
||||
public :
|
||||
static const bool value
|
||||
= CGAL_IS_SAME_OR_BASE_OF(Integral_domain_tag,Tag);
|
||||
};
|
||||
|
||||
|
||||
template<class AS>
|
||||
class Is_unique_factorization_domain {
|
||||
typedef Algebraic_structure_traits<AS> AST;
|
||||
typedef typename AST::Algebraic_structure_tag Tag;
|
||||
public :
|
||||
static const bool value
|
||||
= CGAL_IS_SAME_OR_BASE_OF(Unique_factorization_domain_tag,Tag);
|
||||
};
|
||||
|
||||
template<class AS>
|
||||
class Is_euclidean_ring {
|
||||
typedef Algebraic_structure_traits<AS> AST;
|
||||
typedef typename AST::Algebraic_structure_tag Tag;
|
||||
public :
|
||||
static const bool value
|
||||
= CGAL_IS_SAME_OR_BASE_OF(Euclidean_ring_tag,Tag);
|
||||
};
|
||||
|
||||
|
||||
template<class AS>
|
||||
class Is_field {
|
||||
typedef Algebraic_structure_traits<AS> AST;
|
||||
typedef typename AST::Algebraic_structure_tag Tag;
|
||||
public :
|
||||
static const bool value
|
||||
= CGAL_IS_SAME_OR_BASE_OF(Field_tag,Tag);
|
||||
};
|
||||
|
||||
|
||||
template<class AS>
|
||||
class Is_field_with_sqrt {
|
||||
typedef Algebraic_structure_traits<AS> AST;
|
||||
typedef typename AST::Algebraic_structure_tag Tag;
|
||||
public :
|
||||
static const bool value
|
||||
= CGAL_IS_SAME_OR_BASE_OF(Field_with_sqrt_tag,Tag);
|
||||
};
|
||||
|
||||
template<class AS>
|
||||
class Is_field_with_root_of {
|
||||
typedef Algebraic_structure_traits<AS> AST;
|
||||
typedef typename AST::Algebraic_structure_tag Tag;
|
||||
public :
|
||||
static const bool value
|
||||
= CGAL_IS_SAME_OR_BASE_OF(Field_with_root_of_tag,Tag);
|
||||
};
|
||||
|
||||
} // namespace CGALi
|
||||
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -136,31 +136,6 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* FIX ME: this not compile
|
||||
inline
|
||||
Root_of_2< Gmpz >
|
||||
make_root_of_2(const Gmpq &a, const CGAL::Gmpq &b,
|
||||
const Gmpq &c, bool d)
|
||||
{
|
||||
return CGALi::make_root_of_2_rational< Gmpz, CGAL::Gmpq >(a,b,c,d);
|
||||
}
|
||||
*/
|
||||
|
||||
#include <CGAL/make_root_of_2.h>
|
||||
#include <CGAL/Root_of_traits.h>
|
||||
#include <CGAL/Root_of_2.h>
|
||||
// Gmpq is the same as Root_of_traits< CGAL::Gmpz >::RootOf_1
|
||||
template <>
|
||||
struct Root_of_traits< Gmpq >
|
||||
{
|
||||
typedef Gmpq RootOf_1;
|
||||
typedef Root_of_2< Gmpz > RootOf_2;
|
||||
};
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif // CGAL_GMPQ_H
|
||||
|
|
|
|||
|
|
@ -38,9 +38,6 @@
|
|||
# include <cctype>
|
||||
#endif
|
||||
|
||||
//#include <CGAL/Root_of_traits.h>
|
||||
//#include <CGAL/Root_of_2_fwd.h>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
// Algebraic structure traits
|
||||
|
|
@ -169,31 +166,4 @@ template<> class Algebraic_structure_traits< Quotient<Gmpz> >
|
|||
};
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
|
||||
|
||||
#include <CGAL/Root_of_2.h>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
class Gmpq;
|
||||
|
||||
template <>
|
||||
struct Root_of_traits< Gmpz >
|
||||
{
|
||||
typedef Gmpq RootOf_1;
|
||||
typedef Root_of_2< Gmpz > RootOf_2;
|
||||
};
|
||||
|
||||
// FIX ME: This not compile
|
||||
// inline
|
||||
// Root_of_2<Gmpz>
|
||||
// make_root_of_2(const Gmpz &a, const Gmpz &b, const Gmpz &c, bool smaller)
|
||||
// {
|
||||
// CGAL_assertion( a != 0 );
|
||||
// return Root_of_2<Gmpz>(a, b, c, smaller);
|
||||
// }
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
|
||||
#endif // CGAL_GMPZ_H
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
// Copyright (c) 1998-2005 Utrecht University (The Netherlands),
|
||||
// ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),
|
||||
// INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
|
||||
// (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),
|
||||
// and Tel-Aviv University (Israel). 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; version 2.1 of the License.
|
||||
// See the file LICENSE.LGPL distributed with CGAL.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Sylvain Pion
|
||||
|
||||
#ifndef CGAL_INTERVAL_NT_FWD_H
|
||||
#define CGAL_INTERVAL_NT_FWD_H
|
||||
|
||||
// Forward declarations of functions based on Interval_nt, required by
|
||||
// two-stage name lookup.
|
||||
|
||||
#include <CGAL/Uncertain.h>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
template <bool> class Interval_nt;
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif // CGAL_INTERVAL_NT_FWD_H
|
||||
|
|
@ -36,12 +36,9 @@
|
|||
#include <CGAL/Handle.h>
|
||||
#include <CGAL/NT_converter.h>
|
||||
|
||||
#include <CGAL/Lazy_exact_nt_fwd.h>
|
||||
|
||||
#include <CGAL/Profile_counter.h>
|
||||
|
||||
|
||||
#include <CGAL/Root_of_traits.h>
|
||||
// #include <CGAL/Root_of_traits.h> // TODO
|
||||
|
||||
/*
|
||||
* This file contains the definition of the number type Lazy_exact_nt<ET>,
|
||||
|
|
@ -91,6 +88,8 @@
|
|||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
template <class NT> class Lazy_exact_nt;
|
||||
|
||||
#ifdef CGAL_LAZY_KERNEL_DEBUG
|
||||
template <class T>
|
||||
void
|
||||
|
|
|
|||
|
|
@ -1,53 +0,0 @@
|
|||
// Copyright (c) 2006 INRIA Sophia-Antipolis (France).
|
||||
// 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; version 2.1 of the License.
|
||||
// See the file LICENSE.LGPL distributed with CGAL.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Sylvain Pion
|
||||
|
||||
#ifndef CGAL_LAZY_EXACT_NT_FWD_H
|
||||
#define CGAL_LAZY_EXACT_NT_FWD_H
|
||||
|
||||
// Forward declarations of functions on Lazy_exact_nt.
|
||||
|
||||
#include <CGAL/Root_of_traits.h>
|
||||
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
template <typename ET> class Lazy_exact_nt;
|
||||
|
||||
// template <typename ET>
|
||||
// Lazy_exact_nt<ET> min BOOST_PREVENT_MACRO_SUBSTITUTION
|
||||
// (const Lazy_exact_nt<ET> &, const Lazy_exact_nt<ET> &);
|
||||
// template <typename ET>
|
||||
// Lazy_exact_nt<ET> max BOOST_PREVENT_MACRO_SUBSTITUTION
|
||||
// (const Lazy_exact_nt<ET> &, const Lazy_exact_nt<ET> &);
|
||||
|
||||
//template <typename ET> Lazy_exact_nt<ET>
|
||||
//gcd(const Lazy_exact_nt<ET> &, const Lazy_exact_nt<ET> &);
|
||||
|
||||
#if 0 // to be finished
|
||||
template < typename ET >
|
||||
Lazy_exact_nt< typename Root_of_traits<ET>::RootOf_2 >
|
||||
make_root_of_2( const Lazy_exact_nt<ET> &a,
|
||||
const Lazy_exact_nt<ET> &b,
|
||||
const Lazy_exact_nt<ET> &c, bool d);
|
||||
#endif
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif // CGAL_LAZY_EXACT_NT_FWD_H
|
||||
|
|
@ -26,6 +26,7 @@
|
|||
#include <CGAL/Real_embeddable_traits.h>
|
||||
#include <CGAL/Coercion_traits.h>
|
||||
#include <CGAL/Quotient.h>
|
||||
#include <CGAL/Root_of_2.h>
|
||||
|
||||
#include <CGAL/utils.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include <CGAL/functional_base.h>
|
||||
|
||||
template <bool> class Interval_nt;
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
// A number type converter usable as default, using the conversion operator.
|
||||
|
|
|
|||
|
|
@ -19,13 +19,12 @@
|
|||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Sylvain Pion
|
||||
// Author(s) : Sylvain Pion, Michael Hemmer
|
||||
|
||||
#ifndef CGAL_NUMBER_TYPE_CHECKER_H
|
||||
#define CGAL_NUMBER_TYPE_CHECKER_H
|
||||
|
||||
#include <CGAL/number_type_basic.h>
|
||||
#include <CGAL/Number_type_checker_fwd.h>
|
||||
|
||||
// A number type class, parameterized by 2 number types NT1 and NT2.
|
||||
// It runs all operations on parallel over NT1 and NT2.
|
||||
|
|
@ -116,6 +115,16 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
Number_type_checker<NT1, NT2, Cmp>
|
||||
operator+(const Number_type_checker<NT1, NT2, Cmp> &a)
|
||||
{
|
||||
CGAL_NT_CHECK_DEBUG("operator+");
|
||||
return Number_type_checker<NT1, NT2, Cmp>(+ a.n1(), + a.n2() );
|
||||
}
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
Number_type_checker<NT1, NT2, Cmp>
|
||||
operator+(const Number_type_checker<NT1, NT2, Cmp> &a,
|
||||
|
|
@ -224,15 +233,8 @@ operator/(const Number_type_checker<NT1, NT2, Cmp> &a, int b)
|
|||
return Number_type_checker<NT1, NT2, Cmp>(a.n1() / b, a.n2() / b);
|
||||
}
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
Number_type_checker<NT1, NT2, Cmp>
|
||||
sqrt(const Number_type_checker<NT1, NT2, Cmp> &a)
|
||||
{
|
||||
CGAL_NT_CHECK_DEBUG("operator/");
|
||||
return Number_type_checker<NT1, NT2, Cmp>(sqrt(a.n1()),
|
||||
sqrt(a.n2()));
|
||||
}
|
||||
|
||||
// arithmetic operators end
|
||||
// compare operators begin
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
bool
|
||||
|
|
@ -420,91 +422,496 @@ operator>=(int i, const Number_type_checker<NT1, NT2, Cmp> &b)
|
|||
return b1;
|
||||
}
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
Sign
|
||||
sign(const Number_type_checker<NT1, NT2, Cmp> &a)
|
||||
{
|
||||
Sign s1 = sign(a.n1());
|
||||
Sign s2 = sign(a.n2());
|
||||
CGAL_assertion(s1 == s2);
|
||||
return s1;
|
||||
}
|
||||
// compare operators end
|
||||
// Functors Is_valid
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
Comparison_result
|
||||
compare(const Number_type_checker<NT1, NT2, Cmp> &a,
|
||||
const Number_type_checker<NT1, NT2, Cmp> &b)
|
||||
{
|
||||
Comparison_result c1 = compare(a.n1(), b.n1());
|
||||
Comparison_result c2 = compare(a.n2(), b.n2());
|
||||
CGAL_assertion(c1 == c2);
|
||||
return c1;
|
||||
}
|
||||
class Is_valid< Number_type_checker<NT1, NT2, Cmp> >
|
||||
: public Unary_function< Number_type_checker<NT1, NT2, Cmp> , bool > {
|
||||
public :
|
||||
bool operator()(const Number_type_checker<NT1, NT2, Cmp>& a ) const {
|
||||
bool b1 = is_valid(a.n1());
|
||||
bool b2 = is_valid(a.n2());
|
||||
CGAL_assertion(b1 == b2);
|
||||
// Should we also call a.is_valid() ?
|
||||
return b1;
|
||||
}
|
||||
};
|
||||
|
||||
namespace NTC_INTERN{
|
||||
// -----------------------------
|
||||
|
||||
// fwd
|
||||
template < typename Number_type_checker, typename Algebraic_structure_tag>
|
||||
class NTC_AST_base
|
||||
:public Algebraic_structure_traits_base< Number_type_checker , Null_tag>{
|
||||
};
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
Comparison_result
|
||||
compare(int a, const Number_type_checker<NT1, NT2, Cmp> &b)
|
||||
class NTC_AST_base
|
||||
< Number_type_checker<NT1, NT2, Cmp> , Integral_domain_without_division_tag>
|
||||
:public Algebraic_structure_traits_base<Number_type_checker<NT1, NT2, Cmp>, Null_tag>
|
||||
{
|
||||
Comparison_result c1 = compare(a, b.n1());
|
||||
Comparison_result c2 = compare(a, b.n2());
|
||||
CGAL_assertion(c1 == c2);
|
||||
return c1;
|
||||
}
|
||||
private:
|
||||
typedef Algebraic_structure_traits<NT1> AST1;
|
||||
typedef Algebraic_structure_traits<NT2> AST2;
|
||||
typedef Number_type_checker<NT1, NT2, Cmp> Algebraic_structure;
|
||||
|
||||
public:
|
||||
//CGAL::Algebraic_structure_traits<>::Simplify
|
||||
class Simplify
|
||||
: public Unary_function< Algebraic_structure& , void > {
|
||||
public:
|
||||
void operator()( Algebraic_structure& a) const {
|
||||
typename AST1::Simplify()(a.n1());
|
||||
typename AST2::Simplify()(a.n2());
|
||||
CGAL_assertion(a.is_valid());
|
||||
}
|
||||
};
|
||||
|
||||
//CGAL::Algebraic_structure_traits< >::Is_zero
|
||||
class Is_zero
|
||||
: public Unary_function< Algebraic_structure, bool > {
|
||||
public:
|
||||
bool operator()(const Algebraic_structure& a ) const {
|
||||
bool b1 = typename AST1::Is_zero()(a.n1());
|
||||
bool b2 = typename AST2::Is_zero()(a.n2());
|
||||
CGAL_assertion(b1 == b2 );
|
||||
CGAL_assertion(a.is_valid());
|
||||
return b1;
|
||||
}
|
||||
};
|
||||
|
||||
// CGAL::Algebraic_structure_traits< >::Is_one
|
||||
class Is_one
|
||||
: public Unary_function< Algebraic_structure, bool > {
|
||||
public:
|
||||
bool operator()(const Algebraic_structure& a) const {
|
||||
bool b1 = typename AST1::Is_one()(a.n1());
|
||||
bool b2 = typename AST2::Is_one()(a.n2());
|
||||
CGAL_assertion(b1 == b2 );
|
||||
CGAL_assertion(a.is_valid());
|
||||
return b1;
|
||||
}
|
||||
};
|
||||
// CGAL::Algebraic_structure_traits< >::Square
|
||||
class Square
|
||||
: public Unary_function< Algebraic_structure , Algebraic_structure > {
|
||||
public:
|
||||
Algebraic_structure operator()(const Algebraic_structure& a) const {
|
||||
return Algebraic_structure(
|
||||
typename AST1::Square()(a.n1()),
|
||||
typename AST2::Square()(a.n2()));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// CGAL::Algebraic_structure_traits< >::Unit_part
|
||||
class Unit_part
|
||||
: public Unary_function< Algebraic_structure , Algebraic_structure > {
|
||||
public:
|
||||
Algebraic_structure operator()(const Algebraic_structure& a) const {
|
||||
CGAL_NT_CHECK_DEBUG("AST::Unit_part");
|
||||
return Algebraic_structure(
|
||||
typename AST1::Unit_part()(a.n1()),
|
||||
typename AST2::Unit_part()(a.n2()));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
Comparison_result
|
||||
compare(const Number_type_checker<NT1, NT2, Cmp> &a, int b)
|
||||
class NTC_AST_base
|
||||
< Number_type_checker< NT1, NT2, Cmp> , Integral_domain_tag >
|
||||
:public NTC_AST_base
|
||||
< Number_type_checker< NT1, NT2, Cmp> , Integral_domain_without_division_tag >
|
||||
{
|
||||
Comparison_result c1 = compare(a.n1(), b);
|
||||
Comparison_result c2 = compare(a.n2(), b);
|
||||
CGAL_assertion(c1 == c2);
|
||||
return c1;
|
||||
}
|
||||
private:
|
||||
typedef Algebraic_structure_traits<NT1> AST1;
|
||||
typedef Algebraic_structure_traits<NT2> AST2;
|
||||
typedef Number_type_checker<NT1, NT2, Cmp> Algebraic_structure;
|
||||
|
||||
public:
|
||||
|
||||
// CGAL::Algebraic_structure_traits< >::Integral_division
|
||||
class Integral_division
|
||||
: public Binary_function< Algebraic_structure,
|
||||
Algebraic_structure,
|
||||
Algebraic_structure > {
|
||||
public:
|
||||
Algebraic_structure operator()(
|
||||
const Algebraic_structure& a,
|
||||
const Algebraic_structure& b) const {
|
||||
CGAL_NT_CHECK_DEBUG("AST::Integral_division");
|
||||
return Algebraic_structure(
|
||||
typename AST1::Integral_division()(a.n1(),b.n1()),
|
||||
typename AST2::Integral_division()(a.n2(),b.n2()));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
bool
|
||||
is_finite(const Number_type_checker<NT1, NT2, Cmp> &a)
|
||||
class NTC_AST_base
|
||||
< Number_type_checker< NT1, NT2, Cmp> , Unique_factorization_domain_tag >
|
||||
:public NTC_AST_base
|
||||
< Number_type_checker< NT1, NT2, Cmp> , Integral_domain_tag >
|
||||
{
|
||||
bool b1 = is_finite(a.n1());
|
||||
bool b2 = is_finite(a.n2());
|
||||
CGAL_assertion(b1 == b2);
|
||||
return b1;
|
||||
}
|
||||
private:
|
||||
typedef Algebraic_structure_traits<NT1> AST1;
|
||||
typedef Algebraic_structure_traits<NT2> AST2;
|
||||
typedef Number_type_checker<NT1, NT2, Cmp> Algebraic_structure;
|
||||
public:
|
||||
// CGAL::Algebraic_structure_traits< >::Gcd
|
||||
class Gcd
|
||||
: public Binary_function< Algebraic_structure,
|
||||
Algebraic_structure,
|
||||
Algebraic_structure > {
|
||||
public:
|
||||
Algebraic_structure operator()(
|
||||
const Algebraic_structure& a,
|
||||
const Algebraic_structure& b) const {
|
||||
CGAL_NT_CHECK_DEBUG("AST::Gcd");
|
||||
return Algebraic_structure(
|
||||
typename AST1::Gcd()(a.n1(),b.n1()),
|
||||
typename AST2::Gcd()(a.n2(),b.n2()));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
bool
|
||||
is_valid(const Number_type_checker<NT1, NT2, Cmp> &a)
|
||||
class NTC_AST_base
|
||||
< Number_type_checker< NT1, NT2, Cmp> , Euclidean_ring_tag >
|
||||
:public NTC_AST_base
|
||||
< Number_type_checker< NT1, NT2, Cmp> , Unique_factorization_domain_tag >
|
||||
{
|
||||
bool b1 = is_valid(a.n1());
|
||||
bool b2 = is_valid(a.n2());
|
||||
CGAL_assertion(b1 == b2);
|
||||
// Should we also call a.is_valid() ?
|
||||
return b1;
|
||||
}
|
||||
private:
|
||||
typedef Algebraic_structure_traits<NT1> AST1;
|
||||
typedef Algebraic_structure_traits<NT2> AST2;
|
||||
typedef Number_type_checker<NT1, NT2, Cmp> Algebraic_structure;
|
||||
public:
|
||||
// CGAL::Algebraic_structure_traits< >::Div
|
||||
class Div
|
||||
: public Binary_function< Algebraic_structure,
|
||||
Algebraic_structure,
|
||||
Algebraic_structure > {
|
||||
public:
|
||||
Algebraic_structure operator()(
|
||||
const Algebraic_structure& a,
|
||||
const Algebraic_structure& b) const {
|
||||
CGAL_NT_CHECK_DEBUG("AST::Div");
|
||||
return Algebraic_structure(
|
||||
typename AST1::Div()(a.n1(),b.n1()),
|
||||
typename AST2::Div()(a.n2(),b.n2()));
|
||||
}
|
||||
};
|
||||
// CGAL::Algebraic_structure_traits< >::Mod
|
||||
class Mod
|
||||
: public Binary_function< Algebraic_structure,
|
||||
Algebraic_structure,
|
||||
Algebraic_structure > {
|
||||
public:
|
||||
Algebraic_structure operator()(
|
||||
const Algebraic_structure& a,
|
||||
const Algebraic_structure& b) const {
|
||||
CGAL_NT_CHECK_DEBUG("AST::Mod");
|
||||
return Algebraic_structure(
|
||||
typename AST1::Mod()(a.n1(),b.n1()),
|
||||
typename AST2::Mod()(a.n2(),b.n2()));
|
||||
}
|
||||
};
|
||||
|
||||
// CGAL::Algebraic_structure_traits< >::Div_mod
|
||||
class Div_mod {
|
||||
public:
|
||||
typedef Algebraic_structure first_argument_type;
|
||||
typedef Algebraic_structure second_argument_type;
|
||||
typedef Algebraic_structure& third_argument_type;
|
||||
typedef Algebraic_structure& fourth_argument_type;
|
||||
typedef Arity_tag< 4 > Arity;
|
||||
typedef void result_type;
|
||||
|
||||
void operator()(
|
||||
const Algebraic_structure& a,
|
||||
const Algebraic_structure& b,
|
||||
Algebraic_structure& q,
|
||||
Algebraic_structure& r) const {
|
||||
CGAL_NT_CHECK_DEBUG("AST::Div_mod");
|
||||
NT1 q1,r1;
|
||||
NT2 q2,r2;
|
||||
typename AST1::Div_mod()(a.n1(),b.n1(),q1,r1);
|
||||
typename AST1::Div_mod()(a.n2(),b.n2(),q2,r2);
|
||||
q = Algebraic_structure(q1,q2);
|
||||
r = Algebraic_structure(r1,r2);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
std::pair<double, double>
|
||||
to_interval(const Number_type_checker<NT1, NT2, Cmp> &a)
|
||||
{
|
||||
std::pair<double, double> i1 = to_interval(a.n1());
|
||||
std::pair<double, double> i2 = to_interval(a.n2());
|
||||
// Here we could check that there is a common point.
|
||||
// CGAL_assertion( ??? );
|
||||
|
||||
// We return one of the two.
|
||||
return i1;
|
||||
}
|
||||
class NTC_AST_base
|
||||
< Number_type_checker< NT1, NT2, Cmp> , Field_tag >
|
||||
:public NTC_AST_base
|
||||
< Number_type_checker< NT1, NT2, Cmp> , Integral_domain_tag >
|
||||
{};
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
double
|
||||
to_double(const Number_type_checker<NT1, NT2, Cmp> &a)
|
||||
class NTC_AST_base
|
||||
< Number_type_checker< NT1, NT2, Cmp> , Field_with_sqrt_tag >
|
||||
:public NTC_AST_base
|
||||
< Number_type_checker< NT1, NT2, Cmp> , Field_tag >
|
||||
{
|
||||
double d1 = to_double(a.n1());
|
||||
double d2 = to_double(a.n2());
|
||||
// What can we check ?
|
||||
// We return one of the two.
|
||||
return d1;
|
||||
}
|
||||
private:
|
||||
typedef Algebraic_structure_traits<NT1> AST1;
|
||||
typedef Algebraic_structure_traits<NT2> AST2;
|
||||
typedef Number_type_checker<NT1, NT2, Cmp> Algebraic_structure;
|
||||
|
||||
public:
|
||||
|
||||
// CGAL::Algebraic_structure_traits< >::Sqrt
|
||||
class Sqrt
|
||||
: public Unary_function< Algebraic_structure , Algebraic_structure > {
|
||||
public:
|
||||
Algebraic_structure operator()(const Algebraic_structure& a) const {
|
||||
CGAL_NT_CHECK_DEBUG("AST::Sqrt");
|
||||
return Algebraic_structure(
|
||||
typename AST1::Sqrt()(a.n1()),
|
||||
typename AST2::Sqrt()(a.n2()));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace NTC_INTERN
|
||||
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
class Algebraic_structure_traits <Number_type_checker<NT1, NT2, Cmp> >
|
||||
:public NTC_INTERN::NTC_AST_base
|
||||
< Number_type_checker< NT1, NT2, Cmp> ,
|
||||
typename Algebraic_structure_traits<NT1>::Algebraic_structure_tag >
|
||||
{
|
||||
typedef Algebraic_structure_traits<NT1> AST1;
|
||||
public:
|
||||
typedef Number_type_checker< NT1, NT2, Cmp> Algebraic_structure;
|
||||
typedef typename AST1::Algebraic_structure_tag Algebraic_structure_tag;
|
||||
typedef typename AST1::Is_exact Is_exact;
|
||||
|
||||
};
|
||||
|
||||
|
||||
namespace NTC_INTERN{
|
||||
template < typename Number_type_checker, typename Is_real_embeddable >
|
||||
class NTC_RET_base;
|
||||
|
||||
template < typename NT >
|
||||
class NTC_RET_base<NT,Tag_false>
|
||||
:public Real_embeddable_traits<NT,Tag_false>
|
||||
{};
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
class NTC_RET_base
|
||||
< Number_type_checker<NT1, NT2, Cmp> , Tag_true>
|
||||
:public Real_embeddable_traits_base< Number_type_checker< NT1, NT2, Cmp > >
|
||||
{
|
||||
private:
|
||||
typedef Real_embeddable_traits<NT1> RET1;
|
||||
typedef Real_embeddable_traits<NT2> RET2;
|
||||
typedef Number_type_checker<NT1, NT2, Cmp> Real_embeddable;
|
||||
public:
|
||||
|
||||
// CGAL::Real_embeddable_traits< >::Abs
|
||||
class Abs
|
||||
: public Unary_function< Real_embeddable , Real_embeddable > {
|
||||
public:
|
||||
Real_embeddable operator()(const Real_embeddable& a) const {
|
||||
CGAL_NT_CHECK_DEBUG("RET::Abs");
|
||||
return Real_embeddable(
|
||||
typename RET1::Abs()(a.n1()),
|
||||
typename RET2::Abs()(a.n2()));
|
||||
}
|
||||
};
|
||||
|
||||
// CGAL::Real_embeddable_traits< >::Sign
|
||||
class Sign
|
||||
: public Unary_function< Real_embeddable , ::CGAL::Sign > {
|
||||
public:
|
||||
::CGAL::Sign operator()(const Real_embeddable& a) const {
|
||||
CGAL_NT_CHECK_DEBUG("RET::Sign");
|
||||
::CGAL::Sign r1 = typename RET1::Sign()(a.n1());
|
||||
::CGAL::Sign r2 = typename RET2::Sign()(a.n2());
|
||||
CGAL_assertion( r1 == r2 );
|
||||
return r1;
|
||||
}
|
||||
};
|
||||
|
||||
// CGAL::Real_embeddable_traits< >::Is_finite
|
||||
class Is_finite
|
||||
: public Unary_function< Real_embeddable , bool > {
|
||||
public:
|
||||
bool operator()(const Real_embeddable& a) const {
|
||||
CGAL_NT_CHECK_DEBUG("RET::Is_finite");
|
||||
bool r1 = typename RET1::Is_finite()(a.n1());
|
||||
bool r2 = typename RET2::Is_finite()(a.n2());
|
||||
CGAL_assertion( r1 == r2 );
|
||||
return r1;
|
||||
}
|
||||
};
|
||||
|
||||
// CGAL::Real_embeddable_traits< >::Is_positive
|
||||
class Is_positive
|
||||
: public Unary_function< Real_embeddable , bool > {
|
||||
public:
|
||||
bool operator()(const Real_embeddable& a) const {
|
||||
CGAL_NT_CHECK_DEBUG("RET::Is_positive");
|
||||
bool r1 = typename RET1::Is_positive()(a.n1());
|
||||
bool r2 = typename RET2::Is_positive()(a.n2());
|
||||
CGAL_assertion( r1 == r2 );
|
||||
return r1;
|
||||
}
|
||||
};
|
||||
|
||||
// CGAL::Real_embeddable_traits< >::Is_negative
|
||||
class Is_negative
|
||||
: public Unary_function< Real_embeddable , bool > {
|
||||
public:
|
||||
bool operator()(const Real_embeddable& a) const {
|
||||
CGAL_NT_CHECK_DEBUG("RET::Is_negative");
|
||||
bool r1 = typename RET1::Is_negative()(a.n1());
|
||||
bool r2 = typename RET2::Is_negative()(a.n2());
|
||||
CGAL_assertion( r1 == r2 );
|
||||
return r1;
|
||||
}
|
||||
};
|
||||
|
||||
// CGAL::Real_embeddable_traits< >::Is_zero
|
||||
class Is_zero
|
||||
: public Unary_function< Real_embeddable , bool > {
|
||||
public:
|
||||
bool operator()(const Real_embeddable& a) const {
|
||||
CGAL_NT_CHECK_DEBUG("RET::Is_zero");
|
||||
bool r1 = typename RET1::Is_zero()(a.n1());
|
||||
bool r2 = typename RET2::Is_zero()(a.n2());
|
||||
CGAL_assertion( r1 == r2 );
|
||||
return r1;
|
||||
}
|
||||
};
|
||||
|
||||
// CGAL::Real_embeddable_traits< >::Compare
|
||||
class Compare
|
||||
: public Binary_function< Real_embeddable , Real_embeddable, Comparison_result > {
|
||||
public:
|
||||
Comparison_result operator()(const Real_embeddable& a, const Real_embeddable& b) const {
|
||||
CGAL_NT_CHECK_DEBUG("RET::Compare");
|
||||
Comparison_result r1 = typename RET1::Compare()(a.n1(),b.n1());
|
||||
Comparison_result r2 = typename RET2::Compare()(a.n2(),b.n2());
|
||||
CGAL_assertion( r1 == r2 );
|
||||
return r1;
|
||||
}
|
||||
};
|
||||
|
||||
// CGAL::Real_embeddable_traits< >::To_double
|
||||
class To_double
|
||||
: public Unary_function< Real_embeddable , double > {
|
||||
public:
|
||||
double operator()(const Real_embeddable& a) const {
|
||||
CGAL_NT_CHECK_DEBUG("RET::To_double");
|
||||
double r1 = typename RET1::To_double()(a.n1());
|
||||
double r2 = typename RET2::To_double()(a.n2());
|
||||
CGAL_assertion( r1 == r2 );
|
||||
return r1;
|
||||
}
|
||||
};
|
||||
|
||||
// CGAL::Real_embeddable_traits< >::To_interval
|
||||
class To_interval
|
||||
: public Unary_function< Real_embeddable , std::pair<double, double> > {
|
||||
public:
|
||||
std::pair<double, double> operator()(const Real_embeddable& a) const {
|
||||
CGAL_NT_CHECK_DEBUG("RET::To_interval");
|
||||
std::pair<double, double> r1 = typename RET1::To_interval()(a.n1());
|
||||
std::pair<double, double> r2 = typename RET2::To_interval()(a.n2());
|
||||
CGAL_assertion( r1 == r2 );
|
||||
return r1;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace NTC_INTERN
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
class Real_embeddable_traits
|
||||
< Number_type_checker<NT1, NT2, Cmp> >
|
||||
:public NTC_INTERN::NTC_RET_base< Number_type_checker< NT1, NT2, Cmp > ,
|
||||
typename Real_embeddable_traits<NT1>::Is_real_embeddable >
|
||||
{
|
||||
typedef Real_embeddable_traits<NT1> RET1;
|
||||
public:
|
||||
typedef Number_type_checker< NT1, NT2, Cmp > Real_embeddable;
|
||||
typedef typename RET1::Is_real_embeddable Is_real_embeddable;
|
||||
};
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
struct Coercion_traits< Number_type_checker<NT1,NT2,Cmp>,
|
||||
Number_type_checker<NT1,NT2,Cmp> >{
|
||||
typedef Tag_true Are_explicit_interoperable;
|
||||
typedef Tag_true Are_implicit_interoperable;
|
||||
typedef Number_type_checker<NT1,NT2,Cmp> Coercion_type;
|
||||
struct Cast{
|
||||
typedef Coercion_type result_type;
|
||||
Coercion_type operator()(const Coercion_type& x) const { return x;}
|
||||
};
|
||||
};
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
struct Coercion_traits< Number_type_checker<NT1,NT2,Cmp>, int >{
|
||||
typedef Tag_true Are_explicit_interoperable;
|
||||
typedef Tag_true Are_implicit_interoperable;
|
||||
typedef Number_type_checker<NT1,NT2,Cmp> Coercion_type;
|
||||
struct Cast{
|
||||
typedef Coercion_type result_type;
|
||||
Coercion_type operator()(const Coercion_type& x) const { return x;}
|
||||
Coercion_type operator()(int x) const { return Coercion_type(x);}
|
||||
};
|
||||
};
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
struct Coercion_traits< int , Number_type_checker<NT1,NT2,Cmp> >
|
||||
:public Coercion_traits< Number_type_checker<NT1,NT2,Cmp> , int >{};
|
||||
|
||||
namespace NTC_INTERN {
|
||||
|
||||
|
||||
template < typename NT_checker, typename Tag = Tag_false >
|
||||
struct Coercion_traits_double{
|
||||
typedef Tag_false Are_explicit_interoperable;
|
||||
typedef Tag_false Are_implicit_interoperable;
|
||||
typedef Null_tag Coercion_type;
|
||||
};
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp>
|
||||
struct Coercion_traits_double< Number_type_checker<NT1,NT2,Cmp> ,
|
||||
Tag_true >{
|
||||
typedef Tag_true Are_explicit_interoperable;
|
||||
typedef Tag_true Are_implicit_interoperable;
|
||||
typedef Number_type_checker<NT1,NT2,Cmp> Coercion_type;
|
||||
struct Cast{
|
||||
typedef Coercion_type result_type;
|
||||
Coercion_type operator()(const Coercion_type& x) const { return x;}
|
||||
Coercion_type operator()(const double& x) const {
|
||||
return Coercion_type(x);
|
||||
}
|
||||
};
|
||||
};
|
||||
} // namespace NTC_INTERN
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
struct Coercion_traits< Number_type_checker<NT1,NT2,Cmp>, double >
|
||||
:public NTC_INTERN::Coercion_traits_double< Number_type_checker<NT1,NT2,Cmp>,
|
||||
typename Coercion_traits<NT1,double>::Are_implicit_interoperable >
|
||||
{};
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
struct Coercion_traits< double , Number_type_checker<NT1,NT2,Cmp> >
|
||||
:public Coercion_traits< Number_type_checker<NT1,NT2,Cmp>, double > {};
|
||||
|
||||
|
||||
// What to do with the IO ?
|
||||
|
|
|
|||
|
|
@ -1,65 +0,0 @@
|
|||
// Copyright (c) 2005 Utrecht University (The Netherlands),
|
||||
// ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),
|
||||
// INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
|
||||
// (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),
|
||||
// and Tel-Aviv University (Israel). 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; version 2.1 of the License.
|
||||
// See the file LICENSE.LGPL distributed with CGAL.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Sylvain Pion
|
||||
|
||||
#ifndef CGAL_NUMBER_TYPE_CHECKER_FWD_H
|
||||
#define CGAL_NUMBER_TYPE_CHECKER_FWD_H
|
||||
|
||||
// Forward declarations
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
class Number_type_checker;
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
double
|
||||
to_double(const Number_type_checker<NT1, NT2, Cmp> &);
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
std::pair<double, double>
|
||||
to_interval(const Number_type_checker<NT1, NT2, Cmp> &);
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
Number_type_checker<NT1, NT2, Cmp>
|
||||
sqrt(const Number_type_checker<NT1, NT2, Cmp> &);
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
bool
|
||||
is_finite(const Number_type_checker<NT1, NT2, Cmp> &);
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
bool
|
||||
is_valid(const Number_type_checker<NT1, NT2, Cmp> &);
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
Sign
|
||||
sign(const Number_type_checker<NT1, NT2, Cmp> &);
|
||||
|
||||
template < typename NT1, typename NT2, typename Cmp >
|
||||
Comparison_result
|
||||
compare(const Number_type_checker<NT1, NT2, Cmp> &,
|
||||
const Number_type_checker<NT1, NT2, Cmp> &);
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif // CGAL_NUMBER_TYPE_CHECKER_FWD_H
|
||||
|
|
@ -42,16 +42,12 @@
|
|||
# include <cctype>
|
||||
#endif
|
||||
|
||||
#include <CGAL/Quotient_fwd.h>
|
||||
|
||||
#include <CGAL/Interval_nt.h>
|
||||
#include <CGAL/Kernel/mpl.h>
|
||||
|
||||
#include <boost/operators.hpp>
|
||||
|
||||
#include <CGAL/Root_of_traits.h>
|
||||
#include <CGAL/make_root_of_2.h>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
#define CGAL_int(T) typename First_if_different<int, T>::Type
|
||||
|
|
@ -750,30 +746,6 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
|
||||
template < class NT >
|
||||
inline
|
||||
typename Root_of_traits< NT >::RootOf_2
|
||||
make_root_of_2(const Quotient< NT > &a, const Quotient< NT > &b,
|
||||
const Quotient< NT > &c, bool d)
|
||||
{
|
||||
return CGALi::make_root_of_2_rational< NT, Quotient< NT > >(a,b,c,d);
|
||||
}
|
||||
|
||||
template < class NT >
|
||||
inline
|
||||
typename Root_of_traits< NT >::RootOf_2
|
||||
make_root_of_2(const Quotient< NT > &a, const Quotient< NT > &b, const Quotient< NT > &c)
|
||||
{
|
||||
return typename Root_of_traits< NT >::RootOf_2(a,b,c);
|
||||
}
|
||||
|
||||
// Quotient<NT> should be the same as Root_of_traits<NT>::RootOf_1
|
||||
// i.e the default implementation.
|
||||
template < class NT >
|
||||
struct Root_of_traits< Quotient< NT > >
|
||||
: public Root_of_traits< NT > {};
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif // CGAL_QUOTIENT_H
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
// Copyright (c) 1999-2005 Utrecht University (The Netherlands),
|
||||
// ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),
|
||||
// INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
|
||||
// (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),
|
||||
// and Tel-Aviv University (Israel). 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; version 2.1 of the License.
|
||||
// See the file LICENSE.LGPL distributed with CGAL.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Stefan Schirra, Sylvain Pion
|
||||
|
||||
#ifndef CGAL_QUOTIENT_FWD_H
|
||||
#define CGAL_QUOTIENT_FWD_H
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
template <class NT> class Quotient;
|
||||
template <class RT> struct Root_of_traits;
|
||||
|
||||
|
||||
template < class NT >
|
||||
typename Root_of_traits< NT >::RootOf_2
|
||||
make_root_of_2(const Quotient< NT > &a, const Quotient< NT > &b,
|
||||
const Quotient< NT > &c, bool d);
|
||||
|
||||
template < class NT >
|
||||
typename Root_of_traits< NT >::RootOf_2
|
||||
make_root_of_2(const Quotient< NT > &a, const Quotient< NT > &b,
|
||||
const Quotient< NT > &c);
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif // CGAL_QUOTIENT_FWD_H
|
||||
|
|
@ -17,7 +17,8 @@
|
|||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
template< class Real_embeddable_ >
|
||||
template< class Real_embeddable_ ,
|
||||
typename Is_real_embeddable_ = Tag_false >
|
||||
class Real_embeddable_traits {
|
||||
public:
|
||||
typedef Real_embeddable_ Real_embeddable;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <CGAL/number_type_basic.h>
|
||||
#include <CGAL/Root_of_2_fwd.h>
|
||||
#include <CGAL/Root_of_traits.h>
|
||||
#include <CGAL/NT_converter.h>
|
||||
#include <CGAL/Kernel/mpl.h>
|
||||
|
|
@ -79,6 +78,8 @@ namespace CGAL {
|
|||
// polynomial class which performed this task (and others)...
|
||||
// - overloaded versions of make_root_of_2<>() for Lazy_exact_nt<> and others.
|
||||
|
||||
template <class RT> class Root_of_traits;
|
||||
|
||||
template < typename RT_ >
|
||||
class Root_of_2 {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
// Copyright (c) 2005,2006 INRIA Sophia-Antipolis (France)
|
||||
// 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; version 2.1 of the License.
|
||||
// See the file LICENSE.LGPL distributed with CGAL.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Sylvain Pion, Monique Teillaud, Athanasios Kakargias
|
||||
|
||||
#ifndef CGAL_ROOT_OF_2_FWD_H
|
||||
#define CGAL_ROOT_OF_2_FWD_H
|
||||
|
||||
#include <CGAL/config.h>
|
||||
#include <utility>
|
||||
#include <CGAL/enum.h>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
template < typename T > class Root_of_2;
|
||||
|
||||
template < typename T >
|
||||
Root_of_2<T> inverse(const Root_of_2<T>&);
|
||||
|
||||
template < typename T >
|
||||
Root_of_2<T> make_sqrt(const T&);
|
||||
|
||||
namespace CGALi {
|
||||
template < typename RT,
|
||||
typename Has_sqrt = typename Number_type_traits<RT>::Has_sqrt >
|
||||
struct Make_root_of_2_helper;
|
||||
} // CGALi
|
||||
|
||||
// Template default version generating a Root_of_2<>.
|
||||
template < typename RT >
|
||||
typename CGALi::Make_root_of_2_helper<RT>::result_type
|
||||
make_root_of_2(const RT &a, const RT &b, const RT &c, bool smaller);
|
||||
|
||||
//template < typename RT >
|
||||
//typename CGALi::Make_root_of_2_helper<RT>::result_type
|
||||
//make_root_of_2(const typename Root_of_traits< RT >::RootOf_1 &a,
|
||||
// const typename Root_of_traits< RT >::RootOf_1 &b,
|
||||
// const typename Root_of_traits< RT >::RootOf_1 &c);
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif // CGAL_ROOT_OF_2_FWD_H
|
||||
|
|
@ -22,38 +22,129 @@
|
|||
#define CGAL_ROOT_OF_TRAITS_H
|
||||
|
||||
#include <CGAL/number_type_basic.h>
|
||||
#include <CGAL/Root_of_2_fwd.h>
|
||||
#include <CGAL/Quotient_fwd.h>
|
||||
#include <CGAL/Root_of_2.h>
|
||||
#include <CGAL/Quotient.h>
|
||||
|
||||
namespace CGAL {
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
namespace CGALi {
|
||||
|
||||
template < typename NT, class Algebraic_structure_tag>
|
||||
struct Root_of_traits_helper{
|
||||
typedef Quotient<NT> Root_of_1;
|
||||
typedef Root_of_2<NT> Root_of_2;
|
||||
struct Make_root_of_2{
|
||||
typedef Root_of_2 result_type;
|
||||
NT operator()(const NT& a, const NT& b, const NT& c){
|
||||
return Root_of_2(a,b,c);
|
||||
}
|
||||
Root_of_1 operator()(const Root_of_1& a, const Root_of_1& b, const Root_of_1& c){
|
||||
// dummy, since I'm not sure about the semantic yet.
|
||||
return Root_of_2(a,b,c);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Dispatcher for the case Has_sqrt==Tag_true or not.
|
||||
template < typename RT,
|
||||
typename Has_sqrt = typename Number_type_traits<RT>::Has_sqrt >
|
||||
struct Root_of_traits_helper
|
||||
template < typename FT>
|
||||
struct Root_of_traits_helper < FT, Field_tag >
|
||||
{
|
||||
typedef Quotient< RT > RootOf_1;
|
||||
typedef Root_of_2< RT > RootOf_2;
|
||||
typedef FT Root_of_1;
|
||||
private:
|
||||
typedef Fraction_traits<FT> FrT;
|
||||
typedef typename FrT::Numerator RT;
|
||||
typedef typename FrT::Decompose Decompose;
|
||||
public:
|
||||
typedef Root_of_2< RT > Root_of_2;
|
||||
|
||||
struct Make_root_of_2{
|
||||
typedef FT result_type;
|
||||
Root_of_2 operator()(const FT& a, const FT& b, const FT& c){
|
||||
return Root_of_2(a,b,c);
|
||||
}
|
||||
Root_of_2 operator()(const FT& a, const FT& b, const FT& c, bool smaller){
|
||||
Decompose decompose;
|
||||
RT a_num,b_num,c_num;
|
||||
RT a_den,b_den,c_den; // Denomiantor same as RT
|
||||
|
||||
decompose(a,a_num,a_den);
|
||||
decompose(b,b_num,b_den);
|
||||
decompose(c,c_num,c_den);
|
||||
|
||||
RT a_ = a_num * b_den * c_den;
|
||||
RT b_ = b_num * a_den * c_den;
|
||||
RT c_ = c_num * a_den * b_den;
|
||||
|
||||
return make_root_of_2(a_,b_,c_,smaller);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Specialization for Has_sqrt==Tag_true.
|
||||
template < typename RT >
|
||||
struct Root_of_traits_helper < RT, Tag_true >
|
||||
template < typename NT >
|
||||
struct Root_of_traits_helper < NT, Field_with_sqrt_tag >
|
||||
{
|
||||
typedef RT RootOf_1;
|
||||
typedef RT RootOf_2;
|
||||
typedef NT Root_of_1;
|
||||
typedef NT Root_of_2;
|
||||
|
||||
struct Make_root_of_2{
|
||||
typedef NT result_type;
|
||||
// just a copy, not sure about the semantic of smaller
|
||||
NT operator()(const NT& a, const NT& b, const NT& c, bool smaller){
|
||||
// former make_root_of_2_sqrt()
|
||||
CGAL_assertion( a != 0 );
|
||||
NT discriminant = CGAL_NTS square(b) - a*c*4;
|
||||
CGAL_assertion( discriminant >= 0 );
|
||||
NT d = CGAL_NTS sqrt(discriminant);
|
||||
if ((smaller && a>0) || (!smaller && a<0))
|
||||
d = -d;
|
||||
return (d-b)/(a*2);
|
||||
}
|
||||
// it's so easy
|
||||
NT operator()(const NT& a, const NT& b, const NT& c){
|
||||
return a + b * CGAL_NTS sqrt(c) ;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template < typename NT >
|
||||
struct Root_of_traits_helper < NT, Field_with_root_of_tag >
|
||||
:public Root_of_traits_helper < NT, Field_with_sqrt_tag>{};
|
||||
|
||||
} // namespace CGALi
|
||||
|
||||
|
||||
// Default Traits class for RT types
|
||||
template < typename RT >
|
||||
// Default Traits class for NT types
|
||||
template < typename NT >
|
||||
struct Root_of_traits
|
||||
: public CGALi::Root_of_traits_helper<RT> {};
|
||||
: public CGALi::Root_of_traits_helper<NT,
|
||||
typename Algebraic_structure_traits<NT>::Algebraic_structure_tag> {
|
||||
typedef CGALi::Root_of_traits_helper<NT,
|
||||
typename Algebraic_structure_traits<NT>::Algebraic_structure_tag> Base;
|
||||
typedef typename Base::Root_of_1 RootOf_1;
|
||||
typedef typename Base::Root_of_2 RootOf_2;
|
||||
};
|
||||
|
||||
} // namespace CGAL
|
||||
template < class NT >
|
||||
inline
|
||||
typename Root_of_traits< NT >::Root_of_2
|
||||
make_root_of_2(NT a, const NT &b, const NT &c)
|
||||
{
|
||||
typename Root_of_traits<NT>::Make_root_of_2 make_root_of_2;
|
||||
return make_root_of_2(a,b,c);
|
||||
}
|
||||
|
||||
|
||||
template < class NT >
|
||||
inline
|
||||
typename Root_of_traits< NT >::Root_of_2
|
||||
make_root_of_2(NT a, int b_, const NT &c)
|
||||
{
|
||||
NT b(b_);
|
||||
typename Root_of_traits<NT>::Make_root_of_2 make_root_of_2;
|
||||
return make_root_of_2(a,b,c);
|
||||
}
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif // CGAL_ROOT_OF_TRAITS_H
|
||||
|
|
|
|||
|
|
@ -20,6 +20,19 @@
|
|||
//
|
||||
//
|
||||
// Author(s) : Sylvain Pion
|
||||
|
||||
// This file gathers the necessary adaptors so that the following
|
||||
// C++ number types that come with GMP can be used by CGAL :
|
||||
// - mpz_class (see #include <CGAL/mpz_class.h>)
|
||||
// - mpq_class (see #include <CGAL/mpq_class.h>)
|
||||
|
||||
// - mpf_class support is commented out until to_interval() is implemented.
|
||||
// It is probably not very useful with CGAL anyway.
|
||||
|
||||
// Note that GMP++ use the expression template mechanism, which makes things
|
||||
// a little bit complicated in order to make square(x+y) work for example.
|
||||
// Reading gmpxx.h shows that ::__gmp_expr<T, T> is the mp[zqf]_class proper,
|
||||
// while ::__gmp_expr<T, U> is the others "expressions".
|
||||
|
||||
#ifndef CGAL_GMPXX_H
|
||||
#define CGAL_GMPXX_H
|
||||
|
|
@ -32,96 +45,9 @@
|
|||
#include <CGAL/mpz_class.h>
|
||||
#include <CGAL/mpq_class.h>
|
||||
#include <CGAL/gmpxx_coercion_traits.h>
|
||||
|
||||
//#include <CGAL/Root_of_traits.h>
|
||||
//#include <CGAL/Root_of_2.h>
|
||||
|
||||
#include <CGAL/functional_base.h> // Unary_function, Binary_function
|
||||
|
||||
// This file gathers the necessary adaptors so that the following
|
||||
// C++ number types that come with GMP can be used by CGAL :
|
||||
// - mpz_class
|
||||
// - mpq_class
|
||||
|
||||
// - mpf_class support is commented out until to_interval() is implemented.
|
||||
// It is probably not very useful with CGAL anyway.
|
||||
|
||||
// Note that GMP++ use the expression template mechanism, which makes things
|
||||
// a little bit complicated in order to make square(x+y) work for example.
|
||||
// Reading gmpxx.h shows that ::__gmp_expr<T, T> is the mp[zqf]_class proper,
|
||||
// while ::__gmp_expr<T, U> is the others "expressions".
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
/* FIX ME: THERE IS NO CONSTRUCTOR FT(x,y)
|
||||
AVALIABLE FOR THIS TYPE
|
||||
|
||||
namespace CGALi {
|
||||
|
||||
inline
|
||||
Root_of_2< ::mpz_class >
|
||||
make_root_of_2_gmpxx(const ::mpz_class & a,
|
||||
const ::mpz_class & b,
|
||||
const ::mpz_class & c,
|
||||
bool d)
|
||||
{
|
||||
return Root_of_2< ::mpz_class >(a, b, c, d);
|
||||
}
|
||||
|
||||
inline
|
||||
Root_of_2< ::mpz_class >
|
||||
make_root_of_2_gmpxx(const ::mpq_class & a,
|
||||
const ::mpq_class & b,
|
||||
const ::mpq_class & c,
|
||||
bool d)
|
||||
{
|
||||
typedef Rational_traits< ::mpq_class > Rational;
|
||||
|
||||
Rational r;
|
||||
CGAL_assertion( r.denominator(a) > 0 );
|
||||
CGAL_assertion( r.denominator(b) > 0 );
|
||||
CGAL_assertion( r.denominator(c) > 0 );
|
||||
*/
|
||||
/* const RT lcm = ( r.denominator(a) * r.denominator(b) * r.denominator(c) )/
|
||||
( gcd( r.denominator(a), gcd(r.denominator(b), r.denominator(c)) ) );
|
||||
|
||||
RT a_ = r.numerator(a) * ( lcm / r.denominator(a) );
|
||||
RT b_ = r.numerator(b) * ( lcm / r.denominator(b) );
|
||||
RT c_ = r.numerator(c) * ( lcm / r.denominator(c) );
|
||||
*/
|
||||
/* ::mpz_class a_ = r.numerator(a) * r.denominator(b) * r.denominator(c);
|
||||
::mpz_class b_ = r.numerator(b) * r.denominator(a) * r.denominator(c);
|
||||
::mpz_class c_ = r.numerator(c) * r.denominator(a) * r.denominator(b);
|
||||
|
||||
return Root_of_2< ::mpz_class >(a, b, c, d);
|
||||
}
|
||||
|
||||
} // CGALi
|
||||
|
||||
template < typename T, typename U1, typename U2, typename U3 >
|
||||
inline
|
||||
typename Root_of_traits< ::__gmp_expr<T, T> >::RootOf_2
|
||||
make_root_of_2(const ::__gmp_expr< T, U1> & a,
|
||||
const ::__gmp_expr< T, U2> & b,
|
||||
const ::__gmp_expr< T, U3> & c,
|
||||
bool d)
|
||||
{
|
||||
return CGALi::make_root_of_2_gmpxx(a, b, c, d);
|
||||
}
|
||||
|
||||
template < typename T, typename U >
|
||||
struct Root_of_traits< ::__gmp_expr<T, U> >
|
||||
{
|
||||
typedef ::mpq_class RootOf_1;
|
||||
typedef Root_of_2< ::mpz_class > RootOf_2;
|
||||
};*/
|
||||
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
// XXX : These seem necessary.
|
||||
// I don't know why doing them in namespace CGAL is not enough.
|
||||
// using to_double;
|
||||
// using is_valid;
|
||||
|
||||
#endif // CGAL_GMPXX_H
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
// Copyright (c) 2002,2003,2005 Utrecht University (The Netherlands),
|
||||
// ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),
|
||||
// INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
|
||||
// (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),
|
||||
// and Tel-Aviv University (Israel). 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; version 2.1 of the License.
|
||||
// See the file LICENSE.LGPL distributed with CGAL.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Sylvain Pion
|
||||
|
||||
#ifndef CGAL_GMPXX_FWD_H
|
||||
#define CGAL_GMPXX_FWD_H
|
||||
|
||||
#ifdef CGAL_USE_GMPXX
|
||||
|
||||
#include <gmpxx.h>
|
||||
#include <CGAL/Root_of_2_fwd.h>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
/* FIX gmpxx.h first
|
||||
template < typename T, typename U1, typename U2, typename U3 >
|
||||
typename Root_of_traits< ::__gmp_expr<T, T> >::RootOf_2
|
||||
make_root_of_2(const ::__gmp_expr< T, U1> & a,
|
||||
const ::__gmp_expr< T, U2> & b,
|
||||
const ::__gmp_expr< T, U3> & c,
|
||||
bool d);*/
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif // CGAL_USE_GMPXX
|
||||
|
||||
#endif // CGAL_GMPXX_FWD_H
|
||||
|
|
@ -1,185 +0,0 @@
|
|||
// Copyright (c) 2005,2006 INRIA Sophia-Antipolis (France)
|
||||
// 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; version 2.1 of the License.
|
||||
// See the file LICENSE.LGPL distributed with CGAL.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// $URL$
|
||||
// $Id$
|
||||
//
|
||||
//
|
||||
// Author(s) : Sylvain Pion, Monique Teillaud, Athanasios Kakargias
|
||||
|
||||
#ifndef CGAL_MAKE_ROOT_OF_2_H
|
||||
#define CGAL_MAKE_ROOT_OF_2_H
|
||||
|
||||
#include <iostream>
|
||||
#include <CGAL/number_type_basic.h>
|
||||
#include <CGAL/number_utils.h>
|
||||
#include <CGAL/Root_of_traits.h>
|
||||
#include <CGAL/Root_of_2_fwd.h>
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
namespace CGALi {
|
||||
|
||||
// This version is internal and can be re-used for
|
||||
// number types which also support division and sqrt().
|
||||
template < typename NT >
|
||||
NT
|
||||
make_root_of_2_sqrt(const NT &a, const NT &b, const NT &c, bool smaller)
|
||||
{
|
||||
CGAL_assertion( a != 0 );
|
||||
NT discriminant = CGAL_NTS square(b) - a*c*4;
|
||||
CGAL_assertion( discriminant >= 0 );
|
||||
NT d = CGAL_NTS sqrt(discriminant);
|
||||
if ((smaller && a>0) || (!smaller && a<0))
|
||||
d = -d;
|
||||
return (d-b)/(a*2);
|
||||
}
|
||||
|
||||
// This version is internal and can be re-used for
|
||||
// number types which also support division and sqrt().
|
||||
template < typename NT >
|
||||
NT
|
||||
make_root_of_2_sqrt(const NT &a, const NT &b, const NT &c)
|
||||
{
|
||||
CGAL_assertion( c >= 0 );
|
||||
return a + b * sqrt(c);
|
||||
}
|
||||
|
||||
// This version is internal and can be re-used for
|
||||
// number types which also support division and sqrt().
|
||||
template < typename NT >
|
||||
NT
|
||||
make_root_of_2_sqrt(const NT &a, const int &b, const NT &c)
|
||||
{
|
||||
CGAL_assertion( c >= 0 );
|
||||
return a + (NT(b)) * sqrt(c);
|
||||
}
|
||||
|
||||
// This version is internal and can be re-used for
|
||||
// number types which are rational.
|
||||
template < typename RT, typename FT >
|
||||
Root_of_2< RT >
|
||||
make_root_of_2_rational(const FT &a, const FT &b, const FT &c, bool smaller)
|
||||
{
|
||||
typedef Rational_traits< FT > Rational;
|
||||
|
||||
Rational r;
|
||||
// CGAL_assertion( r.denominator(a) > 0 );
|
||||
// CGAL_assertion( r.denominator(b) > 0 );
|
||||
// CGAL_assertion( r.denominator(c) > 0 );
|
||||
|
||||
/* const RT lcm = ( r.denominator(a) * r.denominator(b) * r.denominator(c) )/
|
||||
( gcd( r.denominator(a), gcd(r.denominator(b), r.denominator(c)) ) );
|
||||
|
||||
RT a_ = r.numerator(a) * ( lcm / r.denominator(a) );
|
||||
RT b_ = r.numerator(b) * ( lcm / r.denominator(b) );
|
||||
RT c_ = r.numerator(c) * ( lcm / r.denominator(c) );
|
||||
*/
|
||||
RT a_ = r.numerator(a) * r.denominator(b) * r.denominator(c);
|
||||
RT b_ = r.numerator(b) * r.denominator(a) * r.denominator(c);
|
||||
RT c_ = r.numerator(c) * r.denominator(a) * r.denominator(b);
|
||||
|
||||
return make_root_of_2(a_,b_,c_,smaller);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// automatic dispatcher between the 2 generic versions (using Root_of_2 or
|
||||
// sqrt()), if sqrt() exists (checking Has_sqrt).
|
||||
template < typename RT,
|
||||
typename Has_sqrt /*= typename Number_type_traits<RT>::Has_sqrt*/ >
|
||||
struct Make_root_of_2_helper
|
||||
{
|
||||
typedef Root_of_2<RT> result_type;
|
||||
|
||||
result_type operator()(const RT& a, const RT& b, const RT& c, bool smaller)
|
||||
const
|
||||
{
|
||||
return Root_of_2<RT>(a, b, c, smaller);
|
||||
}
|
||||
|
||||
result_type operator()(const RT& a, const RT& b, const RT& c)
|
||||
const
|
||||
{
|
||||
return Root_of_2<RT>(a, b, c);
|
||||
}
|
||||
|
||||
result_type operator()(const RT& a, const int &b, const RT& c)
|
||||
const
|
||||
{
|
||||
const RT ba = RT(b);
|
||||
return make_root_of_2(a, ba, c);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Specialization for Has_sqrt == Tag_true
|
||||
template < typename RT >
|
||||
struct Make_root_of_2_helper <RT, Tag_true>
|
||||
{
|
||||
typedef RT result_type;
|
||||
|
||||
result_type operator()(const RT& a, const RT& b, const RT& c, bool smaller)
|
||||
const
|
||||
{
|
||||
return CGALi::make_root_of_2_sqrt(a, b, c, smaller);
|
||||
}
|
||||
|
||||
result_type operator()(const RT& a, const RT& b, const RT& c)
|
||||
const
|
||||
{
|
||||
return CGALi::make_root_of_2_sqrt(a, b, c);
|
||||
}
|
||||
|
||||
result_type operator()(const RT& a, const int &b, const RT& c)
|
||||
const
|
||||
{
|
||||
return CGALi::make_root_of_2_sqrt(a, b, c);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace CGALi
|
||||
|
||||
// Template default version generating a Root_of_2<>.
|
||||
template < typename RT >
|
||||
inline
|
||||
typename CGALi::Make_root_of_2_helper<RT>::result_type
|
||||
make_root_of_2(const RT &a, const RT &b, const RT &c, bool smaller)
|
||||
{
|
||||
CGAL_assertion( a != 0 );
|
||||
return CGALi::Make_root_of_2_helper<RT>()(a, b, c, smaller);
|
||||
}
|
||||
|
||||
// Template default version generating a Root_of_2<>.
|
||||
template < typename RT >
|
||||
inline
|
||||
typename CGALi::Make_root_of_2_helper<RT>::result_type
|
||||
make_root_of_2(const RT &a, const RT &b, const RT &c)
|
||||
{
|
||||
return CGALi::Make_root_of_2_helper<RT>()(a, b, c);
|
||||
}
|
||||
|
||||
// Template default version generating a Root_of_2<>.
|
||||
template < typename RT >
|
||||
inline
|
||||
typename CGALi::Make_root_of_2_helper<RT>::result_type
|
||||
make_root_of_2(const RT &a, const int &b, const RT &c)
|
||||
{
|
||||
return CGALi::Make_root_of_2_helper<RT>()(a, b, c);
|
||||
}
|
||||
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_MAKE_ROOT_OF_2_H
|
||||
|
|
@ -280,75 +280,5 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
/* FIX ME: THERE IS NO CONSTRUCTOR FT(x,y)
|
||||
AVALIABLE FOR THIS TYPE
|
||||
|
||||
namespace CGALi {
|
||||
|
||||
inline
|
||||
Root_of_2< ::mpz_class >
|
||||
make_root_of_2_gmpxx(const ::mpz_class & a,
|
||||
const ::mpz_class & b,
|
||||
const ::mpz_class & c,
|
||||
bool d)
|
||||
{
|
||||
return Root_of_2< ::mpz_class >(a, b, c, d);
|
||||
}
|
||||
|
||||
inline
|
||||
Root_of_2< ::mpz_class >
|
||||
make_root_of_2_gmpxx(const ::mpq_class & a,
|
||||
const ::mpq_class & b,
|
||||
const ::mpq_class & c,
|
||||
bool d)
|
||||
{
|
||||
typedef Rational_traits< ::mpq_class > Rational;
|
||||
|
||||
Rational r;
|
||||
CGAL_assertion( r.denominator(a) > 0 );
|
||||
CGAL_assertion( r.denominator(b) > 0 );
|
||||
CGAL_assertion( r.denominator(c) > 0 );
|
||||
*/
|
||||
/* const RT lcm = ( r.denominator(a) * r.denominator(b) * r.denominator(c) )/
|
||||
( gcd( r.denominator(a), gcd(r.denominator(b), r.denominator(c)) ) );
|
||||
|
||||
RT a_ = r.numerator(a) * ( lcm / r.denominator(a) );
|
||||
RT b_ = r.numerator(b) * ( lcm / r.denominator(b) );
|
||||
RT c_ = r.numerator(c) * ( lcm / r.denominator(c) );
|
||||
*/
|
||||
/* ::mpz_class a_ = r.numerator(a) * r.denominator(b) * r.denominator(c);
|
||||
::mpz_class b_ = r.numerator(b) * r.denominator(a) * r.denominator(c);
|
||||
::mpz_class c_ = r.numerator(c) * r.denominator(a) * r.denominator(b);
|
||||
|
||||
return Root_of_2< ::mpz_class >(a, b, c, d);
|
||||
}
|
||||
|
||||
} // CGALi
|
||||
|
||||
template < typename T, typename U1, typename U2, typename U3 >
|
||||
inline
|
||||
typename Root_of_traits< ::__gmp_expr<T, T> >::RootOf_2
|
||||
make_root_of_2(const ::__gmp_expr< T, U1> & a,
|
||||
const ::__gmp_expr< T, U2> & b,
|
||||
const ::__gmp_expr< T, U3> & c,
|
||||
bool d)
|
||||
{
|
||||
return CGALi::make_root_of_2_gmpxx(a, b, c, d);
|
||||
}
|
||||
|
||||
template < typename T, typename U >
|
||||
struct Root_of_traits< ::__gmp_expr<T, U> >
|
||||
{
|
||||
typedef ::mpq_class RootOf_1;
|
||||
typedef Root_of_2< ::mpz_class > RootOf_2;
|
||||
};*/
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
// XXX : These seem necessary.
|
||||
// I don't know why doing them in namespace CGAL is not enough.
|
||||
// using to_double;
|
||||
// using is_valid;
|
||||
|
||||
|
||||
#endif // CGAL_MPZ_CLASS_H
|
||||
|
|
|
|||
|
|
@ -83,29 +83,6 @@
|
|||
#include <CGAL/long_long.h>
|
||||
#endif
|
||||
|
||||
|
||||
//#include <CGAL/Interval_nt_fwd.h>
|
||||
|
||||
// Including all number type files is necessary for compilers implementing
|
||||
// two-stage name lookup (like g++ >= 3.4).
|
||||
// A nicer solution needs more thought.
|
||||
|
||||
#ifndef CGAL_CFG_NO_TWO_STAGE_NAME_LOOKUP
|
||||
|
||||
#include <CGAL/Lazy_exact_nt_fwd.h>
|
||||
#include <CGAL/Nef_polynomial_fwd.h>
|
||||
#include <CGAL/Number_type_checker_fwd.h>
|
||||
|
||||
#ifdef CGAL_USE_GMPXX
|
||||
# include <CGAL/gmpxx_fwd.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <CGAL/Quotient_fwd.h>
|
||||
#include <CGAL/Root_of_2_fwd.h>
|
||||
|
||||
#include <CGAL/make_root_of_2.h>
|
||||
|
||||
#endif // CGAL_CFG_NO_TWO_STAGE_NAME_LOOKUP
|
||||
#include <CGAL/Root_of_traits.h>
|
||||
|
||||
#endif // CGAL_NUMBER_TYPE_BASIC_H
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@
|
|||
#include <CGAL/Quotient.h>
|
||||
#include <CGAL/MP_Float.h>
|
||||
|
||||
#include <CGAL/Arithmetic_kernel.h>
|
||||
#include <CGAL/_test_algebraic_structure.h>
|
||||
#include <CGAL/_test_real_embeddable.h>
|
||||
|
||||
typedef CGAL::Quotient<CGAL::MP_Float> NT0;
|
||||
|
||||
struct my_cmp
|
||||
|
|
@ -28,5 +32,21 @@ int main()
|
|||
|
||||
CGAL::orientation(p, q, r);
|
||||
|
||||
#ifdef CGAL_HAVE_DEFAULT_ARITHMETIC_KERNEL
|
||||
{ // Integer
|
||||
typedef CGAL::Arithmetic_kernel::Integer Integer;
|
||||
typedef CGAL::Number_type_checker<Integer,Integer> NT;
|
||||
typedef CGAL::Euclidean_ring_tag Tag;
|
||||
typedef CGAL::Tag_true Is_exact;
|
||||
CGAL::test_algebraic_structure<NT,Tag, Is_exact>();
|
||||
}
|
||||
{// Rational
|
||||
typedef CGAL::Arithmetic_kernel::Rational Rational;
|
||||
typedef CGAL::Number_type_checker<Rational,Rational> NT;
|
||||
typedef CGAL::Field_tag Tag;
|
||||
typedef CGAL::Tag_true Is_exact;
|
||||
CGAL::test_algebraic_structure<NT,Tag, Is_exact>();
|
||||
}
|
||||
#endif // CGAL_HAVE_DEFAULT_ARITHMETIC_KERNEL
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@
|
|||
# include <CGAL/long_long.h>
|
||||
#endif
|
||||
|
||||
#include <CGAL/Number_type_checker.h>
|
||||
|
||||
#include <CGAL/_test_utilities.h>
|
||||
|
||||
typedef CGAL::Quotient<CGAL::MP_Float> QMPF;
|
||||
|
|
@ -94,13 +96,15 @@ int main()
|
|||
//TESTIT(CORE::Expr, "CORE::Expr")
|
||||
#endif
|
||||
|
||||
// LEDA based NTs
|
||||
// LEDA based NTs
|
||||
#ifdef CGAL_USE_LEDA
|
||||
TESTIT(leda_integer, "leda_integer")
|
||||
TESTIT(leda_rational, "leda_rational")
|
||||
TESTIT(leda_bigfloat, "leda_bigfloat")
|
||||
TESTIT(leda_real, "leda_real")
|
||||
TESTIT(leda_integer, "leda_integer")
|
||||
TESTIT(leda_rational, "leda_rational")
|
||||
TESTIT(leda_bigfloat, "leda_bigfloat")
|
||||
TESTIT(leda_real, "leda_real")
|
||||
typedef CGAL::Number_type_checker<leda_rational,leda_real> NT_checker;
|
||||
TESTIT(NT_checker, "NT_checker");
|
||||
#endif // CGAL_USE_LEDA
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue