renaming:

AlgebraicStructureTraits::Algebraic_structure -> ..::Type
RealEmbeddableTraits::Real_emebddable -> ..::Type
CoercionTraits::Coercion_type -> ..::Type
FractionTraits::Fraction -> ..::Type
This commit is contained in:
Michael Hemmer 2006-11-24 10:47:04 +00:00
parent f1eced21ab
commit f002c6fd13
53 changed files with 1183 additions and 1182 deletions

View File

@ -49,10 +49,10 @@ struct Field_with_root_of_tag : public Field_with_kth_root_tag {};
// The algebraic structure traits template // The algebraic structure traits template
// ========================================================================= // =========================================================================
template< class Algebraic_structure_ > template< class Type_ >
class Algebraic_structure_traits { class Algebraic_structure_traits {
public: public:
typedef Algebraic_structure_ Algebraic_structure; typedef Type_ Type;
typedef Null_tag Algebraic_structure_tag; typedef Null_tag Algebraic_structure_tag;
typedef Null_tag Is_exact; typedef Null_tag Is_exact;
@ -75,24 +75,24 @@ class Algebraic_structure_traits {
// The algebraic structure traits base class // The algebraic structure traits base class
// ========================================================================= // =========================================================================
template< class Algebraic_structure, class Algebra_type > template< class Type, class Algebra_type >
class Algebraic_structure_traits_base; class Algebraic_structure_traits_base;
//! The template specialization that can be used for types that are not any //! The template specialization that can be used for types that are not any
//! of the number type concepts. All functors are set to \c Null_functor //! of the number type concepts. All functors are set to \c Null_functor
//! or suitable defaults. The \c Simplify functor does nothing by default. //! or suitable defaults. The \c Simplify functor does nothing by default.
template< class Algebraic_structure_ > template< class Type_ >
class Algebraic_structure_traits_base< Algebraic_structure_, Null_tag > { class Algebraic_structure_traits_base< Type_, Null_tag > {
public: public:
typedef Algebraic_structure_ Algebraic_structure; typedef Type_ Type;
typedef Null_tag Algebraic_structure_tag; typedef Null_tag Algebraic_structure_tag;
typedef Tag_false Is_exact; typedef Tag_false Is_exact;
// does nothing by default // does nothing by default
class Simplify class Simplify
: public Unary_function< Algebraic_structure&, void > { : public Unary_function< Type&, void > {
public: public:
void operator()( Algebraic_structure& ) const {} void operator()( Type& ) const {}
}; };
typedef Null_functor Unit_part; typedef Null_functor Unit_part;
@ -113,48 +113,48 @@ class Algebraic_structure_traits_base< Algebraic_structure_, Null_tag > {
//! The template specialization that is used if the number type is //! The template specialization that is used if the number type is
//! a model of the \c IntegralDomainWithoutDiv concept. The \c Simplify //! a model of the \c IntegralDomainWithoutDiv concept. The \c Simplify
//! does nothing by default and the \c Unit_part is equal to //! does nothing by default and the \c Unit_part is equal to
//! \c Algebraic_structure(-1) for negative numbers and //! \c Type(-1) for negative numbers and
//! \c Algebraic_structure(1) otherwise //! \c Type(1) otherwise
template< class Algebraic_structure_ > template< class Type_ >
class Algebraic_structure_traits_base< Algebraic_structure_, class Algebraic_structure_traits_base< Type_,
Integral_domain_without_division_tag > Integral_domain_without_division_tag >
: public Algebraic_structure_traits_base< Algebraic_structure_, : public Algebraic_structure_traits_base< Type_,
Null_tag > { Null_tag > {
public: public:
typedef Algebraic_structure_ Algebraic_structure; typedef Type_ Type;
typedef Integral_domain_without_division_tag Algebraic_structure_tag; typedef Integral_domain_without_division_tag Algebraic_structure_tag;
// returns Algebraic_structure(1) by default // returns Type(1) by default
class Unit_part class Unit_part
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return( x < Algebraic_structure(0)) ? return( x < Type(0)) ?
Algebraic_structure(-1) : Algebraic_structure(1); Type(-1) : Type(1);
} }
}; };
class Square class Square
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return x*x; return x*x;
} }
}; };
class Is_zero class Is_zero
: public Unary_function< Algebraic_structure, bool > { : public Unary_function< Type, bool > {
public: public:
bool operator()( const Algebraic_structure& x ) const { bool operator()( const Type& x ) const {
return x == Algebraic_structure(0); return x == Type(0);
} }
}; };
class Is_one class Is_one
: public Unary_function< Algebraic_structure, bool > { : public Unary_function< Type, bool > {
public: public:
bool operator()( const Algebraic_structure& x ) const { bool operator()( const Type& x ) const {
return x == Algebraic_structure(1); return x == Type(1);
} }
}; };
@ -167,13 +167,13 @@ class Algebraic_structure_traits_base< Algebraic_structure_,
//! for the \c IntegralDomainWithoutDiv concept. The additionally required //! for the \c IntegralDomainWithoutDiv concept. The additionally required
//! \c Integral_division functor needs to be implemented in the //! \c Integral_division functor needs to be implemented in the
//! \c Algebraic_structure_traits itself. //! \c Algebraic_structure_traits itself.
template< class Algebraic_structure_ > template< class Type_ >
class Algebraic_structure_traits_base< Algebraic_structure_, class Algebraic_structure_traits_base< Type_,
Integral_domain_tag > Integral_domain_tag >
: public Algebraic_structure_traits_base< Algebraic_structure_, : public Algebraic_structure_traits_base< Type_,
Integral_domain_without_division_tag > { Integral_domain_without_division_tag > {
public: public:
typedef Algebraic_structure_ Algebraic_structure; typedef Type_ Type;
typedef Integral_domain_tag Algebraic_structure_tag; typedef Integral_domain_tag Algebraic_structure_tag;
}; };
@ -184,37 +184,37 @@ class Algebraic_structure_traits_base< Algebraic_structure_,
//! \c Integral_div functor //! \c Integral_div functor
//! and \c Gcd functor need to be implemented in the //! and \c Gcd functor need to be implemented in the
//! \c Algebraic_structure_traits itself. //! \c Algebraic_structure_traits itself.
template< class Algebraic_structure_ > template< class Type_ >
class Algebraic_structure_traits_base< Algebraic_structure_, class Algebraic_structure_traits_base< Type_,
Unique_factorization_domain_tag > Unique_factorization_domain_tag >
: public Algebraic_structure_traits_base< Algebraic_structure_, : public Algebraic_structure_traits_base< Type_,
Integral_domain_tag > { Integral_domain_tag > {
public: public:
typedef Algebraic_structure_ Algebraic_structure; typedef Type_ Type;
typedef Unique_factorization_domain_tag Algebraic_structure_tag; typedef Unique_factorization_domain_tag Algebraic_structure_tag;
}; };
//! The template specialization that is used if the number type is //! The template specialization that is used if the number type is
//! a model of the \c EuclideanRing concept. //! a model of the \c EuclideanRing concept.
template< class Algebraic_structure_ > template< class Type_ >
class Algebraic_structure_traits_base< Algebraic_structure_, class Algebraic_structure_traits_base< Type_,
Euclidean_ring_tag > Euclidean_ring_tag >
: public Algebraic_structure_traits_base< Algebraic_structure_, : public Algebraic_structure_traits_base< Type_,
Unique_factorization_domain_tag > { Unique_factorization_domain_tag > {
public: public:
typedef Algebraic_structure_ Algebraic_structure; typedef Type_ Type;
typedef Euclidean_ring_tag Algebraic_structure_tag; typedef Euclidean_ring_tag Algebraic_structure_tag;
// maps to \c Div by default. // maps to \c Div by default.
class Integral_division class Integral_division
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( Type operator()(
const Algebraic_structure& x, const Type& x,
const Algebraic_structure& y) const { const Type& y) const {
typedef Algebraic_structure_traits<Algebraic_structure> AST; typedef Algebraic_structure_traits<Type> AST;
typedef typename AST::Is_exact Is_exact; typedef typename AST::Is_exact Is_exact;
typename AST::Div actual_div; typename AST::Div actual_div;
@ -224,37 +224,37 @@ class Algebraic_structure_traits_base< Algebraic_structure_,
"Algebraic_structure_traits<...>::Integral_div()(x,y)" ); "Algebraic_structure_traits<...>::Integral_div()(x,y)" );
return actual_div( x, y); return actual_div( x, y);
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Algebraic_structure ) ; CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Type ) ;
}; };
// Algorithm from NiX/euclids_algorithm.h // Algorithm from NiX/euclids_algorithm.h
class Gcd class Gcd
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( Type operator()(
const Algebraic_structure& x, const Type& x,
const Algebraic_structure& y) const { const Type& y) const {
typedef Algebraic_structure_traits<Algebraic_structure> AST; typedef Algebraic_structure_traits<Type> AST;
typename AST::Mod mod; typename AST::Mod mod;
typename AST::Unit_part unit_part; typename AST::Unit_part unit_part;
typename AST::Integral_division integral_div; typename AST::Integral_division integral_div;
// First: the extreme cases and negative sign corrections. // First: the extreme cases and negative sign corrections.
if (x == Algebraic_structure(0)) { if (x == Type(0)) {
if (y == Algebraic_structure(0)) if (y == Type(0))
return Algebraic_structure(0); return Type(0);
return integral_div( y, unit_part(y) ); return integral_div( y, unit_part(y) );
} }
if (y == Algebraic_structure(0)) if (y == Type(0))
return integral_div(x, unit_part(x) ); return integral_div(x, unit_part(x) );
Algebraic_structure u = integral_div( x, unit_part(x) ); Type u = integral_div( x, unit_part(x) );
Algebraic_structure v = integral_div( y, unit_part(y) ); Type v = integral_div( y, unit_part(y) );
// Second: assuming mod is the most expensive op here, // Second: assuming mod is the most expensive op here,
// we don't compute it unnecessarily if u < v // we don't compute it unnecessarily if u < v
if (u < v) { if (u < v) {
v = mod(v,u); v = mod(v,u);
// maintain invariant of v > 0 for the loop below // maintain invariant of v > 0 for the loop below
if ( v == Algebraic_structure(0) ) if ( v == Type(0) )
return u; return u;
} }
// Third: generic case of two positive integer values and u >= v. // Third: generic case of two positive integer values and u >= v.
@ -269,34 +269,34 @@ class Algebraic_structure_traits_base< Algebraic_structure_,
// But we want to save us all the variable assignments and unroll // But we want to save us all the variable assignments and unroll
// the loop. Before that, we transform it into a do {...} while() // the loop. Before that, we transform it into a do {...} while()
// loop to reduce branching statements. // loop to reduce branching statements.
Algebraic_structure w; Type w;
do { do {
w = mod(u,v); w = mod(u,v);
if ( w == Algebraic_structure(0)) if ( w == Type(0))
return v; return v;
u = mod(v,w); u = mod(v,w);
if ( u == Algebraic_structure(0)) if ( u == Type(0))
return w; return w;
v = mod(w,u); v = mod(w,u);
} while (v != Algebraic_structure(0)); } while (v != Type(0));
return u; return u;
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Algebraic_structure ); CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Type );
}; };
// based on \c Div and \c Mod. // based on \c Div and \c Mod.
class Div_mod { class Div_mod {
public: public:
typedef Algebraic_structure first_argument_type; typedef Type first_argument_type;
typedef Algebraic_structure second_argument_type; typedef Type second_argument_type;
typedef Algebraic_structure& third_argument_type; typedef Type& third_argument_type;
typedef Algebraic_structure& fourth_argument_type; typedef Type& fourth_argument_type;
typedef Arity_tag< 4 > Arity; typedef Arity_tag< 4 > Arity;
typedef void result_type; typedef void result_type;
void operator()( const Algebraic_structure& x, void operator()( const Type& x,
const Algebraic_structure& y, const Type& y,
Algebraic_structure& q, Algebraic_structure& r) const { Type& q, Type& r) const {
typedef Algebraic_structure_traits<Algebraic_structure> Traits; typedef Algebraic_structure_traits<Type> Traits;
typename Traits::Div actual_div; typename Traits::Div actual_div;
typename Traits::Mod actual_mod; typename Traits::Mod actual_mod;
q = actual_div( x, y ); q = actual_div( x, y );
@ -308,12 +308,12 @@ class Algebraic_structure_traits_base< Algebraic_structure_,
void operator()( void operator()(
const NT1& x, const NT1& x,
const NT2& y, const NT2& y,
Algebraic_structure& q, Type& q,
Algebraic_structure& r ) const { Type& r ) const {
typedef Coercion_traits< NT1, NT2 > CT; typedef Coercion_traits< NT1, NT2 > CT;
typedef typename CT::Coercion_type Coercion_type; typedef typename CT::Type Type;
BOOST_STATIC_ASSERT(( BOOST_STATIC_ASSERT((
::boost::is_same<Coercion_type , Algebraic_structure >::value)); ::boost::is_same<Type , Type >::value));
typename Coercion_traits< NT1, NT2 >::Cast cast; typename Coercion_traits< NT1, NT2 >::Cast cast;
operator()( cast(x), cast(y), q, r ); operator()( cast(x), cast(y), q, r );
@ -322,38 +322,38 @@ class Algebraic_structure_traits_base< Algebraic_structure_,
// based on \c Div_mod. // based on \c Div_mod.
class Div class Div
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y) const { const Type& y) const {
typename Algebraic_structure_traits<Algebraic_structure> typename Algebraic_structure_traits<Type>
::Div_mod actual_div_mod; ::Div_mod actual_div_mod;
Algebraic_structure q; Type q;
Algebraic_structure r; Type r;
actual_div_mod( x, y, q, r ); actual_div_mod( x, y, q, r );
return q; return q;
}; };
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Algebraic_structure ) CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Type )
}; };
// based on \c Div_mod. // based on \c Div_mod.
class Mod class Mod
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y) const { const Type& y) const {
typename Algebraic_structure_traits<Algebraic_structure> typename Algebraic_structure_traits<Type>
::Div_mod actual_div_mod; ::Div_mod actual_div_mod;
Algebraic_structure q; Type q;
Algebraic_structure r; Type r;
actual_div_mod( x, y, q, r ); actual_div_mod( x, y, q, r );
return r; return r;
}; };
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Algebraic_structure ) CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Type )
}; };
}; };
@ -366,37 +366,37 @@ class Algebraic_structure_traits_base< Algebraic_structure_,
//! See also \link NiX_NT_traits_functors concept NT_traits \endlink . //! See also \link NiX_NT_traits_functors concept NT_traits \endlink .
//! \ingroup NiX_NT_traits_bases //! \ingroup NiX_NT_traits_bases
// //
template< class Algebraic_structure_ > template< class Type_ >
class Algebraic_structure_traits_base< Algebraic_structure_, Field_tag > class Algebraic_structure_traits_base< Type_, Field_tag >
: public Algebraic_structure_traits_base< Algebraic_structure_, : public Algebraic_structure_traits_base< Type_,
Integral_domain_tag > { Integral_domain_tag > {
public: public:
typedef Algebraic_structure_ Algebraic_structure; typedef Type_ Type;
typedef Field_tag Algebraic_structure_tag; typedef Field_tag Algebraic_structure_tag;
// returns the argument \a a by default // returns the argument \a a by default
class Unit_part class Unit_part
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return( x == Algebraic_structure(0)) ? Algebraic_structure(1) : x; return( x == Type(0)) ? Type(1) : x;
} }
}; };
// maps to \c operator/ by default. // maps to \c operator/ by default.
class Integral_division class Integral_division
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y) const { const Type& y) const {
typedef Algebraic_structure_traits<Algebraic_structure> AST; typedef Algebraic_structure_traits<Type> AST;
typedef typename AST::Is_exact Is_exact; typedef typename AST::Is_exact Is_exact;
CGAL_precondition_msg( !Is_exact::value || (x / y) * y == x, CGAL_precondition_msg( !Is_exact::value || (x / y) * y == x,
"'x' must be divisible by 'y' in " "'x' must be divisible by 'y' in "
"Algebraic_structure_traits<...>::Integral_div()(x,y)" ); "Algebraic_structure_traits<...>::Integral_div()(x,y)" );
return x / y; return x / y;
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Algebraic_structure ) CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Type )
}; };
}; };
@ -408,23 +408,23 @@ class Algebraic_structure_traits_base< Algebraic_structure_, Field_tag >
//! implemented in the \c NT_traits itself. //! implemented in the \c NT_traits itself.
//! \ingroup NiX_NT_traits_bases //! \ingroup NiX_NT_traits_bases
// //
template< class Algebraic_structure_ > template< class Type_ >
class Algebraic_structure_traits_base< Algebraic_structure_, class Algebraic_structure_traits_base< Type_,
Field_with_sqrt_tag> Field_with_sqrt_tag>
: public Algebraic_structure_traits_base< Algebraic_structure_, : public Algebraic_structure_traits_base< Type_,
Field_tag> { Field_tag> {
public: public:
typedef Algebraic_structure_ Algebraic_structure; typedef Type_ Type;
typedef Field_with_sqrt_tag Algebraic_structure_tag; typedef Field_with_sqrt_tag Algebraic_structure_tag;
struct Is_square struct Is_square
:public Binary_function<Algebraic_structure,Algebraic_structure&,bool> :public Binary_function<Type,Type&,bool>
{ {
bool operator()(const Algebraic_structure& x) const {return true;} bool operator()(const Type& x) const {return true;}
bool operator()( bool operator()(
const Algebraic_structure& x, const Type& x,
Algebraic_structure & result) const { Type & result) const {
typename Algebraic_structure_traits<Algebraic_structure>::Sqrt sqrt; typename Algebraic_structure_traits<Type>::Sqrt sqrt;
result = sqrt(x); result = sqrt(x);
return true; return true;
} }
@ -438,16 +438,16 @@ class Algebraic_structure_traits_base< Algebraic_structure_,
//! implemented in the \c Algebraic_structure_traits itself. //! implemented in the \c Algebraic_structure_traits itself.
//! \ingroup NiX_NT_traits_bases //! \ingroup NiX_NT_traits_bases
// //
template< class Algebraic_structure_ > template< class Type_ >
class Algebraic_structure_traits_base< Algebraic_structure_, class Algebraic_structure_traits_base< Type_,
Field_with_kth_root_tag> Field_with_kth_root_tag>
: public Algebraic_structure_traits_base< Algebraic_structure_, : public Algebraic_structure_traits_base< Type_,
Field_with_sqrt_tag> { Field_with_sqrt_tag> {
public: public:
typedef Algebraic_structure_ Algebraic_structure; typedef Type_ Type;
typedef Field_with_kth_root_tag Algebraic_structure_tag; typedef Field_with_kth_root_tag Algebraic_structure_tag;
}; };
@ -461,58 +461,58 @@ class Algebraic_structure_traits_base< Algebraic_structure_,
//! implemented in the \c NT_traits itself. //! implemented in the \c NT_traits itself.
//! \ingroup NiX_NT_traits_bases //! \ingroup NiX_NT_traits_bases
// //
template< class Algebraic_structure_ > template< class Type_ >
class Algebraic_structure_traits_base< Algebraic_structure_, class Algebraic_structure_traits_base< Type_,
Field_with_root_of_tag > Field_with_root_of_tag >
: public Algebraic_structure_traits_base< Algebraic_structure_, : public Algebraic_structure_traits_base< Type_,
Field_with_kth_root_tag > { Field_with_kth_root_tag > {
public: public:
typedef Algebraic_structure_ Algebraic_structure; typedef Type_ Type;
typedef Field_with_root_of_tag Algebraic_structure_tag; typedef Field_with_root_of_tag Algebraic_structure_tag;
}; };
// Some common functors to be used by AST specializations // Some common functors to be used by AST specializations
namespace INTERN_AST { namespace INTERN_AST {
template< class Algebraic_structure > template< class Type >
class Div_per_operator class Div_per_operator
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y ) const { const Type& y ) const {
return x / y; return x / y;
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Algebraic_structure ) CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Type )
}; };
template< class Algebraic_structure > template< class Type >
class Mod_per_operator class Mod_per_operator
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y ) const { const Type& y ) const {
return x % y; return x % y;
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Algebraic_structure ) CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Type )
}; };
template< class Algebraic_structure > template< class Type >
class Is_square_per_sqrt class Is_square_per_sqrt
: public Binary_function< Algebraic_structure, Algebraic_structure&, : public Binary_function< Type, Type&,
bool > { bool > {
public: public:
bool operator()( const Algebraic_structure& x, bool operator()( const Type& x,
Algebraic_structure& y ) const { Type& y ) const {
typename Algebraic_structure_traits< Algebraic_structure >::Sqrt typename Algebraic_structure_traits< Type >::Sqrt
actual_sqrt; actual_sqrt;
y = actual_sqrt( x ); y = actual_sqrt( x );
return y * y == x; return y * y == x;
} }
bool operator()( const Algebraic_structure& x) const { bool operator()( const Type& x) const {
Algebraic_structure dummy; Type dummy;
return operator()(x,dummy); return operator()(x,dummy);
} }
}; };

View File

@ -39,7 +39,7 @@
template < class NT1, class NT2 > \ template < class NT1, class NT2 > \
Result_type operator()( const NT1& x, const NT2& y ) const { \ Result_type operator()( const NT1& x, const NT2& y ) const { \
BOOST_STATIC_ASSERT((::boost::is_same< \ BOOST_STATIC_ASSERT((::boost::is_same< \
typename Coercion_traits< NT1, NT2 >::Coercion_type, NT \ typename Coercion_traits< NT1, NT2 >::Type, NT \
>::value)); \ >::value)); \
\ \
typename Coercion_traits< NT1, NT2 >::Cast cast; \ typename Coercion_traits< NT1, NT2 >::Cast cast; \
@ -54,24 +54,24 @@ CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( NT, NT )
struct Coercion_traits< FROM , TO >{ \ struct Coercion_traits< FROM , TO >{ \
typedef Tag_true Are_explicit_interoperable; \ typedef Tag_true Are_explicit_interoperable; \
typedef Tag_true Are_implicit_interoperable; \ typedef Tag_true Are_implicit_interoperable; \
typedef TO Coercion_type; \ typedef TO Type; \
struct Cast{ \ struct Cast{ \
typedef Coercion_type result_type; \ typedef Type result_type; \
Coercion_type operator()(const TO& x) const { return x;} \ Type operator()(const TO& x) const { return x;} \
Coercion_type operator()(const FROM& x) const { \ Type operator()(const FROM& x) const { \
return Coercion_type(x);} \ return Type(x);} \
}; \ }; \
}; \ }; \
template <> \ template <> \
struct Coercion_traits< TO , FROM >{ \ struct Coercion_traits< TO , FROM >{ \
typedef Tag_true Are_explicit_interoperable; \ typedef Tag_true Are_explicit_interoperable; \
typedef Tag_true Are_implicit_interoperable; \ typedef Tag_true Are_implicit_interoperable; \
typedef TO Coercion_type; \ typedef TO Type; \
struct Cast{ \ struct Cast{ \
typedef Coercion_type result_type; \ typedef Type result_type; \
Coercion_type operator()(const TO& x) const { return x;} \ Type operator()(const TO& x) const { return x;} \
Coercion_type operator()(const FROM& x) const { \ Type operator()(const FROM& x) const { \
return Coercion_type(x);} \ return Type(x);} \
}; \ }; \
}; };
@ -80,24 +80,24 @@ CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( NT, NT )
struct Coercion_traits< FROM , TO >{ \ struct Coercion_traits< FROM , TO >{ \
typedef Tag_true Are_explicit_interoperable; \ typedef Tag_true Are_explicit_interoperable; \
typedef Tag_true Are_implicit_interoperable; \ typedef Tag_true Are_implicit_interoperable; \
typedef TO Coercion_type; \ typedef TO Type; \
struct Cast{ \ struct Cast{ \
typedef Coercion_type result_type; \ typedef Type result_type; \
Coercion_type operator()(const TO& x) const { return x;} \ Type operator()(const TO& x) const { return x;} \
Coercion_type operator()(const FROM& x) const { \ Type operator()(const FROM& x) const { \
return Coercion_type(x);} \ return Type(x);} \
}; \ }; \
}; \ }; \
template <TEM> \ template <TEM> \
struct Coercion_traits< TO , FROM >{ \ struct Coercion_traits< TO , FROM >{ \
typedef Tag_true Are_explicit_interoperable; \ typedef Tag_true Are_explicit_interoperable; \
typedef Tag_true Are_implicit_interoperable; \ typedef Tag_true Are_implicit_interoperable; \
typedef TO Coercion_type; \ typedef TO Type; \
struct Cast{ \ struct Cast{ \
typedef Coercion_type result_type; \ typedef Type result_type; \
Coercion_type operator()(const TO& x) const { return x;} \ Type operator()(const TO& x) const { return x;} \
Coercion_type operator()(const FROM& x) const { \ Type operator()(const FROM& x) const { \
return Coercion_type(x);} \ return Type(x);} \
}; \ }; \
}; };
@ -108,10 +108,10 @@ CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( NT, NT )
struct Coercion_traits< A , A >{ \ struct Coercion_traits< A , A >{ \
typedef Tag_true Are_explicit_interoperable; \ typedef Tag_true Are_explicit_interoperable; \
typedef Tag_true Are_implicit_interoperable; \ typedef Tag_true Are_implicit_interoperable; \
typedef A Coercion_type; \ typedef A Type; \
struct Cast{ \ struct Cast{ \
typedef Coercion_type result_type; \ typedef Type result_type; \
Coercion_type operator()(const A& x) const { return x;} \ Type operator()(const A& x) const { return x;} \
}; \ }; \
}; };
@ -120,10 +120,10 @@ CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( NT, NT )
struct Coercion_traits< A , A >{ \ struct Coercion_traits< A , A >{ \
typedef Tag_true Are_explicit_interoperable; \ typedef Tag_true Are_explicit_interoperable; \
typedef Tag_true Are_implicit_interoperable; \ typedef Tag_true Are_implicit_interoperable; \
typedef A Coercion_type; \ typedef A Type; \
struct Cast{ \ struct Cast{ \
typedef Coercion_type result_type; \ typedef Type result_type; \
Coercion_type operator()(const A& x) const {return x;} \ Type operator()(const A& x) const {return x;} \
}; \ }; \
}; };
@ -181,10 +181,10 @@ template <class A>
struct Coercion_traits<A,A>{ struct Coercion_traits<A,A>{
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_false Are_implicit_interoperable; typedef Tag_false Are_implicit_interoperable;
typedef A Coercion_type; typedef A Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
Coercion_type inline operator()(const A& x) const { Type inline operator()(const A& x) const {
return x; return x;
} }
}; };
@ -213,7 +213,7 @@ template <class A, class B>
struct Coercion_traits_for_level<A,B,0> { struct Coercion_traits_for_level<A,B,0> {
typedef Tag_false Are_explicit_interoperable; typedef Tag_false Are_explicit_interoperable;
typedef Tag_false Are_implicit_interoperable; typedef Tag_false Are_implicit_interoperable;
typedef void Coercion_type; typedef void Type;
typedef Null_functor Cast; typedef Null_functor Cast;
}; };

View File

@ -32,7 +32,7 @@ CGAL_BEGIN_NAMESPACE
/*! \ingroup NiX_Fraction_traits_spec /*! \ingroup NiX_Fraction_traits_spec
* \brief Traits class for accessing numerator and denominator.\n * \brief Traits class for accessing numerator and denominator.\n
* It is a model of the concept FractionTraits. * It is a model of the concept TypeTraits.
* *
* This is the default version of NiX::Fraction_traits. * This is the default version of NiX::Fraction_traits.
* It typedefs NiX::Fraction_traits::Is_decomposable * It typedefs NiX::Fraction_traits::Is_decomposable
@ -41,10 +41,10 @@ CGAL_BEGIN_NAMESPACE
* \see module NiX_Fraction_traits * \see module NiX_Fraction_traits
* \see module NiX_Cofraction_traits * \see module NiX_Cofraction_traits
*/ */
template <class Fraction_ > template <class Type_ >
class Fraction_traits { class Fraction_traits {
public: public:
typedef Fraction_ Fraction; typedef Type_ Type;
typedef Tag_false Is_fraction; typedef Tag_false Is_fraction;
typedef Null_tag Numerator; typedef Null_tag Numerator;
typedef Null_tag Denominator; typedef Null_tag Denominator;

View File

@ -17,11 +17,11 @@
CGAL_BEGIN_NAMESPACE CGAL_BEGIN_NAMESPACE
template< class Real_embeddable_ , template< class Type_ ,
typename Is_real_embeddable_ = Tag_false > typename Is_real_embeddable_ = Tag_false >
class Real_embeddable_traits { class Real_embeddable_traits {
public: public:
typedef Real_embeddable_ Real_embeddable; typedef Type_ Type;
typedef Tag_false Is_real_embeddable; typedef Tag_false Is_real_embeddable;
typedef Null_functor Abs; typedef Null_functor Abs;
@ -36,67 +36,67 @@ class Real_embeddable_traits {
}; };
namespace INTERN_RET { namespace INTERN_RET {
template< class Real_embeddable, class AST_is_zero > template< class Type, class AST_is_zero >
class Is_zero_selector class Is_zero_selector
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public: public:
//! the function call. //! the function call.
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
return AST_is_zero()(x); return AST_is_zero()(x);
} }
}; };
template< class Real_embeddable > template< class Type >
class Is_zero_selector< Real_embeddable, Null_functor > class Is_zero_selector< Type, Null_functor >
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public: public:
//! the function call. //! the function call.
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
return x == Real_embeddable(0); return x == Type(0);
} }
}; };
} // INTERN_RET } // INTERN_RET
template< class Real_embeddable_ > template< class Type_ >
class Real_embeddable_traits_base { class Real_embeddable_traits_base {
public: public:
typedef Real_embeddable_ Real_embeddable; typedef Type_ Type;
typedef Tag_true Is_real_embeddable; typedef Tag_true Is_real_embeddable;
//! The generic \c Is_zero functor implementation uses one comparison //! The generic \c Is_zero functor implementation uses one comparison
typedef INTERN_RET::Is_zero_selector< Real_embeddable, typedef INTERN_RET::Is_zero_selector< Type,
typename Algebraic_structure_traits< Real_embeddable >::Is_zero typename Algebraic_structure_traits< Type >::Is_zero
> Is_zero; > Is_zero;
//! The generic \c Is_finite functor returns true //! The generic \c Is_finite functor returns true
class Is_finite class Is_finite
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public: public:
bool operator()( const Real_embeddable& ) const { bool operator()( const Type& ) const {
return true; return true;
} }
}; };
//! The generic \c Abs functor implementation //! The generic \c Abs functor implementation
//! uses one comparisons and the unary minus if necessary. //! uses one comparisons and the unary minus if necessary.
class Abs class Abs
: public Unary_function< Real_embeddable, Real_embeddable > { : public Unary_function< Type, Type > {
public: public:
//! the function call. //! the function call.
Real_embeddable operator()( const Real_embeddable& x ) const { Type operator()( const Type& x ) const {
return( x < Real_embeddable(0) ) ? -x : x; return( x < Type(0) ) ? -x : x;
} }
}; };
//! The generic \c Sign functor implementation uses two comparisons. //! The generic \c Sign functor implementation uses two comparisons.
class Sign class Sign
: public Unary_function< Real_embeddable, ::CGAL::Sign > { : public Unary_function< Type, ::CGAL::Sign > {
public: public:
//! the function call. //! the function call.
::CGAL::Sign operator()( const Real_embeddable& x ) const { ::CGAL::Sign operator()( const Type& x ) const {
if ( x < Real_embeddable(0)) if ( x < Type(0))
return NEGATIVE; return NEGATIVE;
if ( x > Real_embeddable(0)) if ( x > Type(0))
return POSITIVE; return POSITIVE;
return ZERO; return ZERO;
} }
@ -104,32 +104,32 @@ class Real_embeddable_traits_base {
//! The generic \c Is_positive functor implementation uses one comparison. //! The generic \c Is_positive functor implementation uses one comparison.
class Is_positive class Is_positive
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public: public:
//! the function call. //! the function call.
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
return x > Real_embeddable(0); return x > Type(0);
} }
}; };
//! The generic \c Is_negative functor implementation uses one comparison. //! The generic \c Is_negative functor implementation uses one comparison.
class Is_negative class Is_negative
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public: public:
//! the function call. //! the function call.
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
return x < Real_embeddable(0); return x < Type(0);
} }
}; };
//! The generic \c Compare functor implementation uses two comparisons. //! The generic \c Compare functor implementation uses two comparisons.
class Compare class Compare
: public Binary_function< Real_embeddable, Real_embeddable, : public Binary_function< Type, Type,
Comparison_result > { Comparison_result > {
public: public:
//! the function call. //! the function call.
Comparison_result operator()( const Real_embeddable& x, Comparison_result operator()( const Type& x,
const Real_embeddable& y) const { const Type& y) const {
if( x < y ) if( x < y )
return SMALLER; return SMALLER;
if( x > y ) if( x > y )
@ -137,7 +137,7 @@ class Real_embeddable_traits_base {
return EQUAL; return EQUAL;
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( Real_embeddable, CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( Type,
Comparison_result ); Comparison_result );
}; };
@ -147,33 +147,33 @@ class Real_embeddable_traits_base {
// Some common functors to be used by RET specializations // Some common functors to be used by RET specializations
namespace INTERN_RET { namespace INTERN_RET {
template< class Real_embeddable, class Is_real_embeddable > template< class Type, class Is_real_embeddable >
class Real_embeddable_traits_base_selector; class Real_embeddable_traits_base_selector;
template< class Real_embeddable > template< class Type >
class Real_embeddable_traits_base_selector< Real_embeddable, Tag_false > class Real_embeddable_traits_base_selector< Type, Tag_false >
: public Real_embeddable_traits< Null_tag > {}; : public Real_embeddable_traits< Null_tag > {};
template< class Real_embeddable > template< class Type >
class Real_embeddable_traits_base_selector< Real_embeddable, Tag_true > class Real_embeddable_traits_base_selector< Type, Tag_true >
: public Real_embeddable_traits_base< Real_embeddable > {}; : public Real_embeddable_traits_base< Type > {};
template< class Real_embeddable > template< class Type >
class To_double_by_conversion class To_double_by_conversion
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
//! the function call. //! the function call.
double operator()( const Real_embeddable& x ) const { double operator()( const Type& x ) const {
return static_cast<double>(x); return static_cast<double>(x);
} }
}; };
template< class Real_embeddable > template< class Type >
class To_interval_by_conversion class To_interval_by_conversion
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
//! the function call. //! the function call.
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
return std::pair<double,double>( x, x ); return std::pair<double,double>( x, x );
} }

View File

@ -96,57 +96,57 @@ sqrt( const AS& x ) {
template< class A, class B > template< class A, class B >
inline inline
typename Algebraic_structure_traits< typename Coercion_traits<A,B>::Coercion_type> typename Algebraic_structure_traits< typename Coercion_traits<A,B>::Type>
::Integral_division::result_type ::Integral_division::result_type
integral_division( const A& x, const B& y ) { integral_division( const A& x, const B& y ) {
typedef typename Coercion_traits<A,B>::Coercion_type Coercion_type; typedef typename Coercion_traits<A,B>::Type Type;
typename Algebraic_structure_traits< Coercion_type >::Integral_division typename Algebraic_structure_traits< Type >::Integral_division
integral_division; integral_division;
return integral_division( x, y ); return integral_division( x, y );
} }
template< class A, class B > template< class A, class B >
inline inline
typename Algebraic_structure_traits< typename Coercion_traits<A,B>::Coercion_type > typename Algebraic_structure_traits< typename Coercion_traits<A,B>::Type >
::Gcd::result_type ::Gcd::result_type
gcd( const A& x, const B& y ) { gcd( const A& x, const B& y ) {
typedef typename Coercion_traits<A,B>::Coercion_type Coercion_type; typedef typename Coercion_traits<A,B>::Type Type;
typename Algebraic_structure_traits< Coercion_type >::Gcd gcd; typename Algebraic_structure_traits< Type >::Gcd gcd;
return gcd( x, y ); return gcd( x, y );
} }
template< class A, class B > template< class A, class B >
inline inline
typename Algebraic_structure_traits< typename Coercion_traits<A,B>::Coercion_type > typename Algebraic_structure_traits< typename Coercion_traits<A,B>::Type >
::Mod::result_type ::Mod::result_type
mod( const A& x, const B& y ) { mod( const A& x, const B& y ) {
typedef typename Coercion_traits<A,B>::Coercion_type Coercion_type; typedef typename Coercion_traits<A,B>::Type Type;
typename Algebraic_structure_traits<Coercion_type >::Mod mod; typename Algebraic_structure_traits<Type >::Mod mod;
return mod( x, y ); return mod( x, y );
} }
template< class A, class B > template< class A, class B >
inline inline
typename Algebraic_structure_traits< typename Coercion_traits<A,B>::Coercion_type > typename Algebraic_structure_traits< typename Coercion_traits<A,B>::Type >
::Div::result_type ::Div::result_type
div( const A& x, const B& y ) { div( const A& x, const B& y ) {
typedef typename Coercion_traits<A,B>::Coercion_type Coercion_type; typedef typename Coercion_traits<A,B>::Type Type;
typename Algebraic_structure_traits<Coercion_type >::Div div; typename Algebraic_structure_traits<Type >::Div div;
return div( x, y ); return div( x, y );
} }
template< class A, class B > template< class A, class B >
inline inline
typename Algebraic_structure_traits< typename Coercion_traits<A,B>::Coercion_type > typename Algebraic_structure_traits< typename Coercion_traits<A,B>::Type >
::Div_mod::result_type ::Div_mod::result_type
div_mod( div_mod(
const A& x, const A& x,
const B& y, const B& y,
typename Coercion_traits<A,B>::Coercion_type& q, typename Coercion_traits<A,B>::Type& q,
typename Coercion_traits<A,B>::Coercion_type& r ) { typename Coercion_traits<A,B>::Type& r ) {
typedef typename Coercion_traits<A,B>::Coercion_type Coercion_type; typedef typename Coercion_traits<A,B>::Type Type;
typename Algebraic_structure_traits< Coercion_type >::Div_mod div_mod; typename Algebraic_structure_traits< Type >::Div_mod div_mod;
div_mod( x, y, q, r ); div_mod( x, y, q, r );
} }
@ -196,12 +196,12 @@ return is_zero( x );
template <class A, class B> template <class A, class B>
inline inline
typename Real_embeddable_traits< typename Coercion_traits<A,B>::Coercion_type > typename Real_embeddable_traits< typename Coercion_traits<A,B>::Type >
::Compare::result_type ::Compare::result_type
compare(const A& a, const B& b) compare(const A& a, const B& b)
{ {
typedef typename Coercion_traits<A,B>::Coercion_type Coercion_type; typedef typename Coercion_traits<A,B>::Type Type;
typename Real_embeddable_traits<Coercion_type>::Compare compare; typename Real_embeddable_traits<Type>::Compare compare;
return compare (a,b); return compare (a,b);
// return (a < b) ? SMALLER : (b < a) ? LARGER : EQUAL; // return (a < b) ? SMALLER : (b < a) ? LARGER : EQUAL;
} }

View File

@ -13,8 +13,8 @@
int main(){ int main(){
typedef CGAL::Algebraic_structure_traits<void> AST; typedef CGAL::Algebraic_structure_traits<void> AST;
typedef AST::Algebraic_structure Algebraic_structure; typedef AST::Type Type;
BOOST_STATIC_ASSERT((::boost::is_same<void,Algebraic_structure>::value)); BOOST_STATIC_ASSERT((::boost::is_same<void,Type>::value));
typedef AST::Algebraic_structure_tag Algebraic_structure_tag; typedef AST::Algebraic_structure_tag Algebraic_structure_tag;
BOOST_STATIC_ASSERT((::boost::is_same<CGAL::Null_tag,Algebraic_structure_tag>::value)); BOOST_STATIC_ASSERT((::boost::is_same<CGAL::Null_tag,Algebraic_structure_tag>::value));

View File

@ -4,6 +4,7 @@
int main(){ int main(){
{ {
typedef CGAL::Coercion_traits<int,int> CT; typedef CGAL::Coercion_traits<int,int> CT;
BOOST_STATIC_ASSERT(( boost::is_same<CT::Type,int>::value));
BOOST_STATIC_ASSERT( BOOST_STATIC_ASSERT(
( boost::is_same<CT::Are_implicit_interoperable,CGAL::Tag_true>::value)); ( boost::is_same<CT::Are_implicit_interoperable,CGAL::Tag_true>::value));
BOOST_STATIC_ASSERT( BOOST_STATIC_ASSERT(
@ -12,6 +13,7 @@ int main(){
} }
{ {
typedef CGAL::Coercion_traits<CGAL::Tag_true,CGAL::Tag_false> CT; typedef CGAL::Coercion_traits<CGAL::Tag_true,CGAL::Tag_false> CT;
BOOST_STATIC_ASSERT(( boost::is_same<CT::Type,void>::value));
BOOST_STATIC_ASSERT( BOOST_STATIC_ASSERT(
( boost::is_same<CT::Are_implicit_interoperable,CGAL::Tag_false>::value)); ( boost::is_same<CT::Are_implicit_interoperable,CGAL::Tag_false>::value));
BOOST_STATIC_ASSERT( BOOST_STATIC_ASSERT(

View File

@ -13,8 +13,8 @@
int main(){ int main(){
typedef CGAL::Real_embeddable_traits<void> RET; typedef CGAL::Real_embeddable_traits<void> RET;
typedef RET::Real_embeddable Real_embeddable; typedef RET::Type Type;
BOOST_STATIC_ASSERT((::boost::is_same<void,Real_embeddable>::value)); BOOST_STATIC_ASSERT((::boost::is_same<void,Type>::value));
typedef RET::Is_real_embeddable Is_real_embeddable; typedef RET::Is_real_embeddable Is_real_embeddable;
BOOST_STATIC_ASSERT((::boost::is_same<CGAL::Tag_false,Is_real_embeddable>::value)); BOOST_STATIC_ASSERT((::boost::is_same<CGAL::Tag_false,Is_real_embeddable>::value));

View File

@ -32,27 +32,27 @@ template <> class Algebraic_structure_traits< CORE::BigFloat >
typedef Tag_false Is_exact; typedef Tag_false Is_exact;
class Sqrt class Sqrt
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return CORE::sqrt( x ); return CORE::sqrt( x );
} }
}; };
class Kth_root class Kth_root
: public Binary_function<int, Algebraic_structure, Algebraic_structure> { : public Binary_function<int, Type, Type> {
public: public:
Algebraic_structure operator()( int k, Type operator()( int k,
const Algebraic_structure& x) const { const Type& x) const {
CGAL_precondition_msg( k > 0, "'k' must be positive for k-th roots"); CGAL_precondition_msg( k > 0, "'k' must be positive for k-th roots");
// CORE::radical isn't implemented for negative values of x, so we // CORE::radical isn't implemented for negative values of x, so we
// have to handle this case separately // have to handle this case separately
if( x < 0 && k%2 != 0) { if( x < 0 && k%2 != 0) {
return Algebraic_structure(-CORE::radical( -x, k ) ); return Type(-CORE::radical( -x, k ) );
} }
return Algebraic_structure( CORE::radical( x, k ) ); return Type( CORE::radical( x, k ) );
} }
}; };
}; };
@ -65,35 +65,35 @@ template <> class Real_embeddable_traits< CORE::BigFloat >
public: public:
class Abs class Abs
: public Unary_function< Real_embeddable, Real_embeddable > { : public Unary_function< Type, Type > {
public: public:
Real_embeddable operator()( const Real_embeddable& x ) const { Type operator()( const Type& x ) const {
return CORE::abs( x ); return CORE::abs( x );
} }
}; };
class Sign class Sign
: public Unary_function< Real_embeddable, ::CGAL::Sign > { : public Unary_function< Type, ::CGAL::Sign > {
public: public:
::CGAL::Sign operator()( const Real_embeddable& x ) const { ::CGAL::Sign operator()( const Type& x ) const {
return (::CGAL::Sign) CORE::sign( x ); return (::CGAL::Sign) CORE::sign( x );
} }
}; };
class Compare class Compare
: public Binary_function< Real_embeddable, Real_embeddable, : public Binary_function< Type, Type,
Comparison_result > { Comparison_result > {
public: public:
Comparison_result operator()( const Real_embeddable& x, Comparison_result operator()( const Type& x,
const Real_embeddable& y ) const { const Type& y ) const {
return (Comparison_result) CORE::cmp( x, y ); return (Comparison_result) CORE::cmp( x, y );
} }
}; };
class To_double class To_double
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
double operator()( const Real_embeddable& x ) const { double operator()( const Type& x ) const {
// this call is required to get reasonable values for the double // this call is required to get reasonable values for the double
// approximation // approximation
return x.doubleValue(); return x.doubleValue();
@ -101,9 +101,9 @@ template <> class Real_embeddable_traits< CORE::BigFloat >
}; };
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
Real_embeddable_traits<CORE::Expr>::To_interval to_interval; Real_embeddable_traits<CORE::Expr>::To_interval to_interval;
CORE::Expr temp(x); CORE::Expr temp(x);

View File

@ -31,18 +31,18 @@ template <> class Algebraic_structure_traits< CORE::BigInt >
public: public:
typedef Tag_true Is_exact; typedef Tag_true Is_exact;
typedef INTERN_AST::Is_square_per_sqrt< Algebraic_structure > typedef INTERN_AST::Is_square_per_sqrt< Type >
Is_square; Is_square;
typedef INTERN_AST::Div_per_operator< Algebraic_structure > Div; typedef INTERN_AST::Div_per_operator< Type > Div;
typedef INTERN_AST::Mod_per_operator< Algebraic_structure > Mod; typedef INTERN_AST::Mod_per_operator< Type > Mod;
class Sqrt class Sqrt
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
//! computes the largest NT not larger than the square root of \a a. //! computes the largest NT not larger than the square root of \a a.
Algebraic_structure operator()( const Algebraic_structure& x) const { Type operator()( const Type& x) const {
Algebraic_structure result; Type result;
mpz_sqrt(result.get_mp(), x.get_mp()); mpz_sqrt(result.get_mp(), x.get_mp());
return result; return result;
} }
@ -50,14 +50,14 @@ template <> class Algebraic_structure_traits< CORE::BigInt >
class Gcd class Gcd
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y) const { const Type& y) const {
if ( x == Algebraic_structure(0) && y == Algebraic_structure(0) ) if ( x == Type(0) && y == Type(0) )
return Algebraic_structure(0); return Type(0);
Algebraic_structure result; Type result;
mpz_gcd(result.get_mp(), x.get_mp(), y.get_mp()); mpz_gcd(result.get_mp(), x.get_mp(), y.get_mp());
return result; return result;
} }
@ -73,36 +73,36 @@ template <> class Real_embeddable_traits< CORE::BigInt >
public: public:
class Abs class Abs
: public Unary_function< Real_embeddable, Real_embeddable > { : public Unary_function< Type, Type > {
public: public:
Real_embeddable operator()( const Real_embeddable& x ) const { Type operator()( const Type& x ) const {
return CORE::abs( x ); return CORE::abs( x );
} }
}; };
class Sign class Sign
: public Unary_function< Real_embeddable, ::CGAL::Sign > { : public Unary_function< Type, ::CGAL::Sign > {
public: public:
::CGAL::Sign operator()( const Real_embeddable& x ) const { ::CGAL::Sign operator()( const Type& x ) const {
return (::CGAL::Sign) CORE::sign( x ); return (::CGAL::Sign) CORE::sign( x );
} }
}; };
class Compare class Compare
: public Binary_function< Real_embeddable, Real_embeddable, : public Binary_function< Type, Type,
Comparison_result > { Comparison_result > {
public: public:
Comparison_result operator()( const Real_embeddable& x, Comparison_result operator()( const Type& x,
const Real_embeddable& y ) const { const Type& y ) const {
typedef Real_embeddable_traits<int> Int_traits; typedef Real_embeddable_traits<int> Int_traits;
return Int_traits::Sign()( ::CORE::cmp(x,y)); return Int_traits::Sign()( ::CORE::cmp(x,y));
} }
}; };
class To_double class To_double
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
double operator()( const Real_embeddable& x ) const { double operator()( const Type& x ) const {
// this call is required to get reasonable values for the double // this call is required to get reasonable values for the double
// approximation // approximation
return x.doubleValue(); return x.doubleValue();
@ -110,9 +110,9 @@ template <> class Real_embeddable_traits< CORE::BigInt >
}; };
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
Real_embeddable_traits<CORE::Expr>::To_interval to_interval; Real_embeddable_traits<CORE::Expr>::To_interval to_interval;
CORE::Expr temp(x); CORE::Expr temp(x);

View File

@ -59,36 +59,36 @@ template <> class Real_embeddable_traits< CORE::BigRat >
public: public:
class Abs class Abs
: public Unary_function< Real_embeddable, Real_embeddable > { : public Unary_function< Type, Type > {
public: public:
Real_embeddable operator()( const Real_embeddable& x ) const { Type operator()( const Type& x ) const {
return CORE::abs( x ); return CORE::abs( x );
} }
}; };
class Sign class Sign
: public Unary_function< Real_embeddable, ::CGAL::Sign > { : public Unary_function< Type, ::CGAL::Sign > {
public: public:
::CGAL::Sign operator()( const Real_embeddable& x ) const { ::CGAL::Sign operator()( const Type& x ) const {
return (::CGAL::Sign) CORE::sign( x ); return (::CGAL::Sign) CORE::sign( x );
} }
}; };
class Compare class Compare
: public Binary_function< Real_embeddable, Real_embeddable, : public Binary_function< Type, Type,
Comparison_result > { Comparison_result > {
public: public:
Comparison_result operator()( const Real_embeddable& x, Comparison_result operator()( const Type& x,
const Real_embeddable& y ) const { const Type& y ) const {
typedef Real_embeddable_traits<int> Int_traits; typedef Real_embeddable_traits<int> Int_traits;
return Int_traits::Sign()( ::CORE::cmp(x,y)); return Int_traits::Sign()( ::CORE::cmp(x,y));
} }
}; };
class To_double class To_double
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
double operator()( const Real_embeddable& x ) const { double operator()( const Type& x ) const {
// this call is required to get reasonable values for the double // this call is required to get reasonable values for the double
// approximation // approximation
return x.doubleValue(); return x.doubleValue();
@ -96,9 +96,9 @@ template <> class Real_embeddable_traits< CORE::BigRat >
}; };
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
Real_embeddable_traits<CORE::Expr>::To_interval to_interval; Real_embeddable_traits<CORE::Expr>::To_interval to_interval;
CORE::Expr temp(x); CORE::Expr temp(x);
@ -114,7 +114,7 @@ template <> class Real_embeddable_traits< CORE::BigRat >
template <> template <>
class Fraction_traits< CORE::BigRat > { class Fraction_traits< CORE::BigRat > {
public: public:
typedef CORE::BigRat Fraction; typedef CORE::BigRat Type;
typedef ::CGAL::Tag_true Is_fraction; typedef ::CGAL::Tag_true Is_fraction;
typedef CORE::BigInt Numerator; typedef CORE::BigInt Numerator;
typedef Numerator Denominator; typedef Numerator Denominator;
@ -123,11 +123,11 @@ public:
class Decompose { class Decompose {
public: public:
typedef Fraction first_argument_type; typedef Type first_argument_type;
typedef Numerator& second_argument_type; typedef Numerator& second_argument_type;
typedef Numerator& third_argument_type; typedef Numerator& third_argument_type;
void operator () ( void operator () (
const Fraction& rat, const Type& rat,
Numerator& num, Numerator& num,
Numerator& den) { Numerator& den) {
num = CGAL_CORE_NUMERATOR(rat); num = CGAL_CORE_NUMERATOR(rat);
@ -139,11 +139,11 @@ public:
public: public:
typedef Numerator first_argument_type; typedef Numerator first_argument_type;
typedef Numerator second_argument_type; typedef Numerator second_argument_type;
typedef Fraction result_type; typedef Type result_type;
Fraction operator ()( Type operator ()(
const Numerator& num , const Numerator& num ,
const Numerator& den ) { const Numerator& den ) {
return Fraction(num, den); return Type(num, den);
} }
}; };
}; };

View File

@ -41,18 +41,18 @@ template <> class Algebraic_structure_traits< CORE::Expr >
typedef Tag_true Is_exact; typedef Tag_true Is_exact;
class Sqrt class Sqrt
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return CORE::sqrt( x ); return CORE::sqrt( x );
} }
}; };
class Kth_root class Kth_root
: public Binary_function<int, Algebraic_structure, Algebraic_structure> { : public Binary_function<int, Type, Type> {
public: public:
Algebraic_structure operator()( int k, Type operator()( int k,
const Algebraic_structure& x) const { const Type& x) const {
CGAL_precondition_msg( k > 0, "'k' must be positive for k-th roots"); CGAL_precondition_msg( k > 0, "'k' must be positive for k-th roots");
// CORE::radical isn't implemented for negative values of x, so we // CORE::radical isn't implemented for negative values of x, so we
// have to handle this case separately // have to handle this case separately
@ -66,7 +66,7 @@ template <> class Algebraic_structure_traits< CORE::Expr >
class Root_of { class Root_of {
public: public:
// typedef CORE::BigRat Boundary; // typedef CORE::BigRat Boundary;
typedef Algebraic_structure result_type; typedef Type result_type;
typedef Arity_tag< 3 > Arity; typedef Arity_tag< 3 > Arity;
@ -74,30 +74,30 @@ template <> class Algebraic_structure_traits< CORE::Expr >
// constructs the kth roots of the polynomial // constructs the kth roots of the polynomial
// given by the iterator range, starting from 0. // given by the iterator range, starting from 0.
template< class ForwardIterator > template< class ForwardIterator >
Algebraic_structure operator()( int k, Type operator()( int k,
ForwardIterator begin, ForwardIterator begin,
ForwardIterator end) const { ForwardIterator end) const {
std::vector<Algebraic_structure> coeffs; std::vector<Type> coeffs;
for(ForwardIterator it = begin; it != end; it++){ for(ForwardIterator it = begin; it != end; it++){
coeffs.push_back(*it); coeffs.push_back(*it);
} }
CORE::Polynomial<Algebraic_structure> polynomial(coeffs); CORE::Polynomial<Type> polynomial(coeffs);
return Algebraic_structure(polynomial,k); return Type(polynomial,k);
}; };
// TODO: Need to be fixed: polynomial<CORE::Expr>.eval() cannot return // TODO: Need to be fixed: polynomial<CORE::Expr>.eval() cannot return
// CORE::BigFloat, so this does not compile. // CORE::BigFloat, so this does not compile.
/* template <class ForwardIterator> /* template <class ForwardIterator>
Algebraic_structure operator()( CORE::BigRat lower, Type operator()( CORE::BigRat lower,
CORE::BigRat upper, CORE::BigRat upper,
ForwardIterator begin, ForwardIterator begin,
ForwardIterator end) const { ForwardIterator end) const {
std::vector<Algebraic_structure> coeffs; std::vector<Type> coeffs;
for(ForwardIterator it = begin; it != end; it++){ for(ForwardIterator it = begin; it != end; it++){
coeffs.push_back(*it); coeffs.push_back(*it);
} }
CORE::Polynomial<Algebraic_structure> polynomial(coeffs); CORE::Polynomial<Type> polynomial(coeffs);
CORE::BigFloat lower_bf, upper_bf; CORE::BigFloat lower_bf, upper_bf;
CORE::BigFloat eval_at_lower(0), eval_at_upper(0); CORE::BigFloat eval_at_lower(0), eval_at_upper(0);
@ -119,7 +119,7 @@ template <> class Algebraic_structure_traits< CORE::Expr >
} }
CORE::BFInterval interval(lower_bf,upper_bf); CORE::BFInterval interval(lower_bf,upper_bf);
return Algebraic_structure(polynomial,interval); return Type(polynomial,interval);
}; */ }; */
}; };
@ -130,39 +130,39 @@ template <> class Real_embeddable_traits< CORE::Expr >
public: public:
class Abs class Abs
: public Unary_function< Real_embeddable, Real_embeddable > { : public Unary_function< Type, Type > {
public: public:
Real_embeddable operator()( const Real_embeddable& x ) const { Type operator()( const Type& x ) const {
return CORE::abs( x ); return CORE::abs( x );
} }
}; };
class Sign class Sign
: public Unary_function< Real_embeddable, ::CGAL::Sign > { : public Unary_function< Type, ::CGAL::Sign > {
public: public:
::CGAL::Sign operator()( const Real_embeddable& x ) const { ::CGAL::Sign operator()( const Type& x ) const {
return (::CGAL::Sign) CORE::sign( x ); return (::CGAL::Sign) CORE::sign( x );
} }
}; };
class Compare class Compare
: public Binary_function< Real_embeddable, Real_embeddable, : public Binary_function< Type, Type,
Comparison_result > { Comparison_result > {
public: public:
Comparison_result operator()( const Real_embeddable& x, Comparison_result operator()( const Type& x,
const Real_embeddable& y ) const { const Type& y ) const {
return (Comparison_result) CORE::cmp( x, y ); return (Comparison_result) CORE::cmp( x, y );
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( Real_embeddable, CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( Type,
Comparison_result ); Comparison_result );
}; };
class To_double class To_double
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
double operator()( const Real_embeddable& x ) const { double operator()( const Type& x ) const {
// this call is required to get reasonable values for the double // this call is required to get reasonable values for the double
// approximation // approximation
x.approx( 53, 1 ); x.approx( 53, 1 );
@ -171,9 +171,9 @@ template <> class Real_embeddable_traits< CORE::Expr >
}; };
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
std::pair<double,double> result; std::pair<double,double> result;
x.doubleInterval(result.first, result.second); x.doubleInterval(result.first, result.second);

View File

@ -21,8 +21,8 @@
// //
// Author(s) : Sylvain Pion // Author(s) : Sylvain Pion
#ifndef CGAL_EXACT_TYPE_SELECTER_H #ifndef CGAL_EXACT_Type_SELECTER_H
#define CGAL_EXACT_TYPE_SELECTER_H #define CGAL_EXACT_Type_SELECTER_H
// This is an undocumented private helper for Filtered_kernel. // This is an undocumented private helper for Filtered_kernel.
@ -113,4 +113,4 @@ struct Exact_type_selecter<Lazy_exact_nt<ET> >
CGAL_END_NAMESPACE CGAL_END_NAMESPACE
#endif // CGAL_EXACT_TYPE_SELECTER_H #endif // CGAL_EXACT_Type_SELECTER_H

View File

@ -22,8 +22,8 @@
// Author(s) : Andreas Fabri, Sylvain Pion // Author(s) : Andreas Fabri, Sylvain Pion
#ifndef CGAL_GMPQ_TYPE_H #ifndef CGAL_GMPQ_Type_H
#define CGAL_GMPQ_TYPE_H #define CGAL_GMPQ_Type_H
#include <CGAL/basic.h> #include <CGAL/basic.h>
#include <CGAL/GMP/Gmpz_type.h> #include <CGAL/GMP/Gmpz_type.h>
@ -418,4 +418,4 @@ operator>>(std::istream& is, Gmpq &z)
CGAL_END_NAMESPACE CGAL_END_NAMESPACE
#endif // CGAL_GMPQ_TYPE_H #endif // CGAL_GMPQ_Type_H

View File

@ -22,8 +22,8 @@
// Author(s) : Andreas Fabri, Stefan Schirra, Sylvain Pion // Author(s) : Andreas Fabri, Stefan Schirra, Sylvain Pion
#ifndef CGAL_GMPZ_TYPE_H #ifndef CGAL_GMPZ_Type_H
#define CGAL_GMPZ_TYPE_H #define CGAL_GMPZ_Type_H
#include <CGAL/basic.h> #include <CGAL/basic.h>
#include <gmp.h> #include <gmp.h>
@ -477,4 +477,4 @@ operator>>(std::istream& is, Gmpz &z)
CGAL_END_NAMESPACE CGAL_END_NAMESPACE
#endif // CGAL_GMPZ_TYPE_H #endif // CGAL_GMPZ_Type_H

View File

@ -18,8 +18,8 @@
// //
// Author(s) : Bernd Gaertner <gaertner@inf.ethz.ch> // Author(s) : Bernd Gaertner <gaertner@inf.ethz.ch>
#ifndef CGAL_GMPZF_TYPE_H #ifndef CGAL_GMPZF_Type_H
#define CGAL_GMPZF_TYPE_H #define CGAL_GMPZF_Type_H
// includes // includes
#include <CGAL/basic.h> #include <CGAL/basic.h>
@ -531,6 +531,6 @@ bool operator>(const Gmpzf &a, int b)
CGAL_END_NAMESPACE CGAL_END_NAMESPACE
#endif // CGAL_GMPZF_TYPE_H #endif // CGAL_GMPZF_Type_H
// ===== EOF ================================================================== // ===== EOF ==================================================================

View File

@ -39,27 +39,27 @@ template <> class Algebraic_structure_traits< Gmpq >
typedef Tag_true Is_exact; typedef Tag_true Is_exact;
class Is_square class Is_square
: public Binary_function< Algebraic_structure, Algebraic_structure&, : public Binary_function< Type, Type&,
bool > { bool > {
public: public:
bool operator()( const Algebraic_structure& x_, Algebraic_structure& y ) const { bool operator()( const Type& x_, Type& y ) const {
Gmpq x( x_ ); Gmpq x( x_ );
mpq_canonicalize( x.mpq() ); mpq_canonicalize( x.mpq() );
Algebraic_structure_traits< Gmpz >::Sqrt sqrt; Algebraic_structure_traits< Gmpz >::Sqrt sqrt;
y = Gmpq( sqrt( x.numerator() ), sqrt( x.denominator() ) ); y = Gmpq( sqrt( x.numerator() ), sqrt( x.denominator() ) );
return y*y == x; return y*y == x;
} }
bool operator()( const Algebraic_structure& x) const { bool operator()( const Type& x) const {
Algebraic_structure y; Type y;
return operator()(x,y); return operator()(x,y);
} }
}; };
class Simplify class Simplify
: public Unary_function< Algebraic_structure&, void > { : public Unary_function< Type&, void > {
public: public:
void operator()( Algebraic_structure& x) const { void operator()( Type& x) const {
mpq_canonicalize( x.mpq() ); mpq_canonicalize( x.mpq() );
} }
}; };
@ -73,25 +73,25 @@ template <> class Real_embeddable_traits< Gmpq >
public: public:
class Sign class Sign
: public Unary_function< Real_embeddable, ::CGAL::Sign > { : public Unary_function< Type, ::CGAL::Sign > {
public: public:
::CGAL::Sign operator()( const Real_embeddable& x ) const { ::CGAL::Sign operator()( const Type& x ) const {
return x.sign(); return x.sign();
} }
}; };
class To_double class To_double
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
double operator()( const Real_embeddable& x ) const { double operator()( const Type& x ) const {
return x.to_double(); return x.to_double();
} }
}; };
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
mpfr_t y; mpfr_t y;
mpfr_init2 (y, 53); /* Assume IEEE-754 */ mpfr_init2 (y, 53); /* Assume IEEE-754 */
mpfr_set_q (y, x.mpq(), GMP_RNDD); mpfr_set_q (y, x.mpq(), GMP_RNDD);
@ -110,7 +110,7 @@ template <> class Real_embeddable_traits< Gmpq >
template <> template <>
class Fraction_traits< Gmpq > { class Fraction_traits< Gmpq > {
public: public:
typedef Gmpq Fraction; typedef Gmpq Type;
typedef ::CGAL::Tag_true Is_fraction; typedef ::CGAL::Tag_true Is_fraction;
typedef Gmpz Numerator; typedef Gmpz Numerator;
typedef Gmpz Denominator; typedef Gmpz Denominator;

View File

@ -47,14 +47,14 @@ template <> class Algebraic_structure_traits< Gmpz >
public: public:
typedef Tag_true Is_exact; typedef Tag_true Is_exact;
typedef INTERN_AST::Is_square_per_sqrt< Algebraic_structure > typedef INTERN_AST::Is_square_per_sqrt< Type >
Is_square; Is_square;
class Integral_division class Integral_division
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y ) const { const Type& y ) const {
Gmpz result; Gmpz result;
mpz_divexact(result.mpz(), x.mpz(), y.mpz()); mpz_divexact(result.mpz(), x.mpz(), y.mpz());
CGAL_postcondition_msg(result * y == x, "exact_division failed\n"); CGAL_postcondition_msg(result * y == x, "exact_division failed\n");
@ -63,18 +63,18 @@ public:
}; };
class Gcd class Gcd
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y ) const { const Type& y ) const {
Gmpz result; Gmpz result;
mpz_gcd(result.mpz(), x.mpz(), y.mpz()); mpz_gcd(result.mpz(), x.mpz(), y.mpz());
return result; return result;
} }
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const int& y ) const { const int& y ) const {
if (y > 0) if (y > 0)
{ {
@ -85,19 +85,19 @@ public:
return CGAL_NTS gcd(x, Gmpz(y)); return CGAL_NTS gcd(x, Gmpz(y));
} }
Algebraic_structure operator()( const int& x, Type operator()( const int& x,
const Algebraic_structure& y ) const { const Type& y ) const {
return CGAL_NTS gcd(Gmpz(x), y ); return CGAL_NTS gcd(Gmpz(x), y );
} }
}; };
typedef INTERN_AST::Div_per_operator< Algebraic_structure > Div; typedef INTERN_AST::Div_per_operator< Type > Div;
typedef INTERN_AST::Mod_per_operator< Algebraic_structure > Mod; typedef INTERN_AST::Mod_per_operator< Type > Mod;
class Sqrt class Sqrt
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
Gmpz result; Gmpz result;
mpz_sqrt(result.mpz(), x.mpz()); mpz_sqrt(result.mpz(), x.mpz());
return result; return result;
@ -110,25 +110,25 @@ template <> class Real_embeddable_traits< Gmpz >
public: public:
class Sign class Sign
: public Unary_function< Real_embeddable, ::CGAL::Sign > { : public Unary_function< Type, ::CGAL::Sign > {
public: public:
::CGAL::Sign operator()( const Real_embeddable& x ) const { ::CGAL::Sign operator()( const Type& x ) const {
return x.sign(); return x.sign();
} }
}; };
class To_double class To_double
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
double operator()( const Real_embeddable& x ) const { double operator()( const Type& x ) const {
return x.to_double(); return x.to_double();
} }
}; };
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
mpfr_t y; mpfr_t y;
mpfr_init2 (y, 53); /* Assume IEEE-754 */ mpfr_init2 (y, 53); /* Assume IEEE-754 */
@ -145,7 +145,7 @@ public:
template<> class Algebraic_structure_traits< Quotient<Gmpz> > template<> class Algebraic_structure_traits< Quotient<Gmpz> >
: public INTERN_QUOTIENT::Algebraic_structure_traits_quotient_base<Quotient<Gmpz> >{ : public INTERN_QUOTIENT::Algebraic_structure_traits_quotient_base<Quotient<Gmpz> >{
// specialization of to double functor // specialization of to double functor
typedef Quotient<Gmpz> Algebraic_structure; typedef Quotient<Gmpz> Type;
struct To_double: public Unary_function<Quotient<Gmpz>, double>{ struct To_double: public Unary_function<Quotient<Gmpz>, double>{
double operator()(const Quotient<Gmpz>& quot){ double operator()(const Quotient<Gmpz>& quot){

View File

@ -36,48 +36,48 @@ public:
typedef Tag_true Is_exact; typedef Tag_true Is_exact;
struct Is_zero struct Is_zero
: public Unary_function< Algebraic_structure, bool > { : public Unary_function< Type, bool > {
public: public:
bool operator()( const Algebraic_structure& x ) const { bool operator()( const Type& x ) const {
return x.is_zero(); return x.is_zero();
} }
}; };
struct Integral_division struct Integral_division
: public Binary_function< Algebraic_structure, : public Binary_function< Type,
Algebraic_structure, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( Type operator()(
const Algebraic_structure& x, const Type& x,
const Algebraic_structure& y ) const { const Type& y ) const {
return x.integral_division(y); return x.integral_division(y);
} }
}; };
struct Gcd struct Gcd
: public Binary_function< Algebraic_structure, : public Binary_function< Type,
Algebraic_structure, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( Type operator()(
const Algebraic_structure& x, const Type& x,
const Algebraic_structure& y ) const { const Type& y ) const {
return x.gcd(y); return x.gcd(y);
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR(int); CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR(int);
}; };
typedef INTERN_AST::Div_per_operator< Algebraic_structure > Div; typedef INTERN_AST::Div_per_operator< Type > Div;
typedef INTERN_AST::Mod_per_operator< Algebraic_structure > Mod; typedef INTERN_AST::Mod_per_operator< Type > Mod;
struct Sqrt struct Sqrt
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return x.sqrt(); return x.sqrt();
} }
}; };
typedef INTERN_AST::Is_square_per_sqrt<Algebraic_structure> Is_square; typedef INTERN_AST::Is_square_per_sqrt<Type> Is_square;
}; };
@ -92,37 +92,37 @@ public:
typedef AST::Is_zero Is_zero; typedef AST::Is_zero Is_zero;
struct Sign struct Sign
: public Unary_function< Real_embeddable, ::CGAL::Sign > { : public Unary_function< Type, ::CGAL::Sign > {
public: public:
::CGAL::Sign operator()( const Real_embeddable& x ) const { ::CGAL::Sign operator()( const Type& x ) const {
return x.sign(); return x.sign();
} }
}; };
struct Compare struct Compare
: public Binary_function< Real_embeddable, : public Binary_function< Type,
Real_embeddable, Type,
Comparison_result > { Comparison_result > {
public: public:
Comparison_result operator()( Comparison_result operator()(
const Real_embeddable& x, const Type& x,
const Real_embeddable& y ) const { const Type& y ) const {
return x.compare(y); return x.compare(y);
} }
}; };
struct To_double struct To_double
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
double operator()( const Real_embeddable& x ) const { double operator()( const Type& x ) const {
return x.to_double(); return x.to_double();
} }
}; };
struct To_interval struct To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
// dummy // dummy
return std::pair<double,double>(0.0,0.0); return std::pair<double,double>(0.0,0.0);
} }

View File

@ -907,73 +907,73 @@ namespace INTERN_INTERVAL_NT {
template< bool B > class Real_embeddable_traits< Interval_nt<B> > template< bool B > class Real_embeddable_traits< Interval_nt<B> >
: public Real_embeddable_traits_base< Interval_nt<B> > { : public Real_embeddable_traits_base< Interval_nt<B> > {
public: public:
typedef Interval_nt<B> Real_embeddable; typedef Interval_nt<B> Type;
class Abs class Abs
: public Unary_function< Real_embeddable, Real_embeddable > { : public Unary_function< Type, Type > {
public: public:
Real_embeddable operator()( const Real_embeddable& x ) const { Type operator()( const Type& x ) const {
return INTERN_INTERVAL_NT::abs( x ); return INTERN_INTERVAL_NT::abs( x );
} }
}; };
class Sign class Sign
: public Unary_function< Real_embeddable, Uncertain< ::CGAL::Sign > > { : public Unary_function< Type, Uncertain< ::CGAL::Sign > > {
public: public:
Uncertain< ::CGAL::Sign > operator()( const Real_embeddable& x ) const { Uncertain< ::CGAL::Sign > operator()( const Type& x ) const {
return INTERN_INTERVAL_NT::sign( x ); return INTERN_INTERVAL_NT::sign( x );
} }
}; };
class Is_positive class Is_positive
: public Unary_function< Real_embeddable, Uncertain<bool> > { : public Unary_function< Type, Uncertain<bool> > {
public: public:
Uncertain<bool> operator()( const Real_embeddable& x ) const { Uncertain<bool> operator()( const Type& x ) const {
return INTERN_INTERVAL_NT::is_positive( x ); return INTERN_INTERVAL_NT::is_positive( x );
} }
}; };
class Is_negative class Is_negative
: public Unary_function< Real_embeddable, Uncertain<bool> > { : public Unary_function< Type, Uncertain<bool> > {
public: public:
Uncertain<bool> operator()( const Real_embeddable& x ) const { Uncertain<bool> operator()( const Type& x ) const {
return INTERN_INTERVAL_NT::is_negative( x ); return INTERN_INTERVAL_NT::is_negative( x );
} }
}; };
class Compare class Compare
: public Binary_function< Real_embeddable, Real_embeddable, : public Binary_function< Type, Type,
Uncertain<Comparison_result> > { Uncertain<Comparison_result> > {
public: public:
Uncertain<Comparison_result> operator()( Uncertain<Comparison_result> operator()(
const Real_embeddable& x, const Type& x,
const Real_embeddable& y ) const { const Type& y ) const {
return INTERN_INTERVAL_NT::compare( x, y ); return INTERN_INTERVAL_NT::compare( x, y );
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( Real_embeddable, CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( Type,
Comparison_result ); Comparison_result );
}; };
class To_double class To_double
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
double operator()( const Real_embeddable& x ) const { double operator()( const Type& x ) const {
return INTERN_INTERVAL_NT::to_double( x ); return INTERN_INTERVAL_NT::to_double( x );
} }
}; };
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
return INTERN_INTERVAL_NT::to_interval( x ); return INTERN_INTERVAL_NT::to_interval( x );
} }
}; };
class Is_finite class Is_finite
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public : public :
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
return CGAL_NTS is_finite( x.inf() ) && CGAL_NTS is_finite( x.sup() ); return CGAL_NTS is_finite( x.inf() ) && CGAL_NTS is_finite( x.sup() );
} }
}; };
@ -986,37 +986,37 @@ class Algebraic_structure_traits< Interval_nt<B> >
: public Algebraic_structure_traits_base< Interval_nt<B>, : public Algebraic_structure_traits_base< Interval_nt<B>,
Field_with_sqrt_tag > { Field_with_sqrt_tag > {
public: public:
typedef Interval_nt<B> Algebraic_structure; typedef Interval_nt<B> Type;
typedef Tag_false Is_exact; typedef Tag_false Is_exact;
class Is_zero class Is_zero
: public Unary_function< Algebraic_structure, Uncertain<bool> > { : public Unary_function< Type, Uncertain<bool> > {
public: public:
Uncertain<bool> operator()( const Algebraic_structure& x ) const { Uncertain<bool> operator()( const Type& x ) const {
return INTERN_INTERVAL_NT::is_zero( x ); return INTERN_INTERVAL_NT::is_zero( x );
} }
}; };
class Is_one class Is_one
: public Unary_function< Algebraic_structure, Uncertain<bool> > { : public Unary_function< Type, Uncertain<bool> > {
public: public:
Uncertain<bool> operator()( const Algebraic_structure& x ) const { Uncertain<bool> operator()( const Type& x ) const {
return INTERN_INTERVAL_NT::is_one( x ); return INTERN_INTERVAL_NT::is_one( x );
} }
}; };
class Square class Square
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return INTERN_INTERVAL_NT::square( x ); return INTERN_INTERVAL_NT::square( x );
} }
}; };
class Sqrt class Sqrt
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return INTERN_INTERVAL_NT::sqrt( x ); return INTERN_INTERVAL_NT::sqrt( x );
} }
}; };
@ -1067,7 +1067,7 @@ template<class A , bool P>
struct Coercion_traits_interval_nt<A, Interval_nt<P>, Tag_true>{ struct Coercion_traits_interval_nt<A, Interval_nt<P>, Tag_true>{
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_false Are_implicit_interoperable; typedef Tag_false Are_implicit_interoperable;
typedef Interval_nt<P> Coercion_type; typedef Interval_nt<P> Type;
struct Cast { struct Cast {
typedef Interval_nt<P> result_type; typedef Interval_nt<P> result_type;
Interval_nt<P> inline operator()(const Interval_nt<P>& x ) const { Interval_nt<P> inline operator()(const Interval_nt<P>& x ) const {

View File

@ -791,39 +791,39 @@ operator==(const Lazy_exact_nt<ET>& a, int b)
template <typename ET1, typename ET2> template <typename ET1, typename ET2>
Lazy_exact_nt< typename Coercion_traits<ET1, ET2>::Coercion_type > Lazy_exact_nt< typename Coercion_traits<ET1, ET2>::Type >
operator+(const Lazy_exact_nt<ET1>& a, const Lazy_exact_nt<ET2>& b) operator+(const Lazy_exact_nt<ET1>& a, const Lazy_exact_nt<ET2>& b)
{ {
CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION)); CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION));
return new Lazy_exact_Add<typename Coercion_traits<ET1, ET2>::Coercion_type, return new Lazy_exact_Add<typename Coercion_traits<ET1, ET2>::Type,
ET1, ET2>(a, b); ET1, ET2>(a, b);
} }
template <typename ET1, typename ET2> template <typename ET1, typename ET2>
Lazy_exact_nt< typename Coercion_traits<ET1, ET2>::Coercion_type > Lazy_exact_nt< typename Coercion_traits<ET1, ET2>::Type >
operator-(const Lazy_exact_nt<ET1>& a, const Lazy_exact_nt<ET2>& b) operator-(const Lazy_exact_nt<ET1>& a, const Lazy_exact_nt<ET2>& b)
{ {
CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION)); CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION));
return new Lazy_exact_Sub<typename Coercion_traits<ET1, ET2>::Coercion_type, return new Lazy_exact_Sub<typename Coercion_traits<ET1, ET2>::Type,
ET1, ET2>(a, b); ET1, ET2>(a, b);
} }
template <typename ET1, typename ET2> template <typename ET1, typename ET2>
Lazy_exact_nt< typename Coercion_traits<ET1, ET2>::Coercion_type > Lazy_exact_nt< typename Coercion_traits<ET1, ET2>::Type >
operator*(const Lazy_exact_nt<ET1>& a, const Lazy_exact_nt<ET2>& b) operator*(const Lazy_exact_nt<ET1>& a, const Lazy_exact_nt<ET2>& b)
{ {
CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION)); CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION));
return new Lazy_exact_Mul<typename Coercion_traits<ET1, ET2>::Coercion_type, return new Lazy_exact_Mul<typename Coercion_traits<ET1, ET2>::Type,
ET1, ET2>(a, b); ET1, ET2>(a, b);
} }
template <typename ET1, typename ET2> template <typename ET1, typename ET2>
Lazy_exact_nt< typename Coercion_traits<ET1, ET2>::Coercion_type > Lazy_exact_nt< typename Coercion_traits<ET1, ET2>::Type >
operator/(const Lazy_exact_nt<ET1>& a, const Lazy_exact_nt<ET2>& b) operator/(const Lazy_exact_nt<ET1>& a, const Lazy_exact_nt<ET2>& b)
{ {
CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION)); CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION));
CGAL_precondition(b != 0); CGAL_precondition(b != 0);
return new Lazy_exact_Div<typename Coercion_traits<ET1, ET2>::Coercion_type, return new Lazy_exact_Div<typename Coercion_traits<ET1, ET2>::Type,
ET1, ET2>(a, b); ET1, ET2>(a, b);
} }
@ -1078,7 +1078,7 @@ struct Div_mod_selector {
NT& q, NT& q,
NT& r ) const { NT& r ) const {
BOOST_STATIC_ASSERT((::boost::is_same< BOOST_STATIC_ASSERT((::boost::is_same<
typename Coercion_traits< NT1, NT2 >::Coercion_type, NT typename Coercion_traits< NT1, NT2 >::Type, NT
>::value)); >::value));
typename Coercion_traits< NT1, NT2 >::Cast cast; typename Coercion_traits< NT1, NT2 >::Cast cast;
@ -1162,21 +1162,21 @@ template < typename ET > class Real_embeddable_traits< Lazy_exact_nt<ET> >
::Is_real_embeddable, Tag_true >::value)); ::Is_real_embeddable, Tag_true >::value));
public: public:
typedef Lazy_exact_nt<ET> Real_embeddable; typedef Lazy_exact_nt<ET> Type;
class Abs class Abs
: public Unary_function< Real_embeddable, Real_embeddable > { : public Unary_function< Type, Type > {
public: public:
Real_embeddable operator()( const Real_embeddable& a ) const { Type operator()( const Type& a ) const {
CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION)); CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION));
return new Lazy_exact_Abs<ET>(a); return new Lazy_exact_Abs<ET>(a);
} }
}; };
class Sign class Sign
: public Unary_function< Real_embeddable, ::CGAL::Sign > { : public Unary_function< Type, ::CGAL::Sign > {
public: public:
::CGAL::Sign operator()( const Real_embeddable& a ) const { ::CGAL::Sign operator()( const Type& a ) const {
CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION)); CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION));
Uncertain< ::CGAL::Sign> res = CGAL_NTS sign(a.approx()); Uncertain< ::CGAL::Sign> res = CGAL_NTS sign(a.approx());
if (is_singleton(res)) if (is_singleton(res))
@ -1187,11 +1187,11 @@ template < typename ET > class Real_embeddable_traits< Lazy_exact_nt<ET> >
}; };
class Compare class Compare
: public Binary_function< Real_embeddable, Real_embeddable, : public Binary_function< Type, Type,
Comparison_result > { Comparison_result > {
public: public:
Comparison_result operator()( const Real_embeddable& a, Comparison_result operator()( const Type& a,
const Real_embeddable& b ) const { const Type& b ) const {
CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION)); CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION));
if (a.identical(b)) if (a.identical(b))
return EQUAL; return EQUAL;
@ -1202,15 +1202,15 @@ template < typename ET > class Real_embeddable_traits< Lazy_exact_nt<ET> >
return CGAL_NTS compare(a.exact(), b.exact()); return CGAL_NTS compare(a.exact(), b.exact());
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( Real_embeddable, CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( Type,
Comparison_result ); Comparison_result );
}; };
class To_double class To_double
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
double operator()( const Real_embeddable& a ) const { double operator()( const Type& a ) const {
CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION)); CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION));
const Interval_nt<false>& app = a.approx(); const Interval_nt<false>& app = a.approx();
@ -1233,18 +1233,18 @@ template < typename ET > class Real_embeddable_traits< Lazy_exact_nt<ET> >
}; };
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& a ) const { std::pair<double, double> operator()( const Type& a ) const {
CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION)); CGAL_PROFILER(std::string("calls to : ") + std::string(CGAL_PRETTY_FUNCTION));
return a.approx().pair(); return a.approx().pair();
} }
}; };
class Is_finite class Is_finite
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public: public:
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
return CGAL_NTS is_finite(x.approx()) || CGAL_NTS is_finite(x.exact()); return CGAL_NTS is_finite(x.approx()) || CGAL_NTS is_finite(x.exact());
} }
}; };
@ -1255,7 +1255,7 @@ template <class ET1, class ET2, class F>
class Lazy_exact_nt_coercion_traits_base{ class Lazy_exact_nt_coercion_traits_base{
typedef Tag_false Are_explicit_interoperable; typedef Tag_false Are_explicit_interoperable;
typedef Tag_false Are_implicit_interoperable; typedef Tag_false Are_implicit_interoperable;
//typedef Null_type Coercion_type //typedef Null_type Type
typedef Null_functor Cast; typedef Null_functor Cast;
}; };
@ -1266,19 +1266,19 @@ class Lazy_exact_nt_coercion_traits_base
typedef Lazy_exact_nt<ET1> A; typedef Lazy_exact_nt<ET1> A;
typedef Lazy_exact_nt<ET2> B; typedef Lazy_exact_nt<ET2> B;
public: public:
typedef Lazy_exact_nt<typename CT::Coercion_type> Coercion_type; typedef Lazy_exact_nt<typename CT::Type> Type;
typedef typename CT::Are_implicit_interoperable Are_explicit_interoperable; typedef typename CT::Are_implicit_interoperable Are_explicit_interoperable;
typedef typename CT::Are_implicit_interoperable Are_implicit_interoperable; typedef typename CT::Are_implicit_interoperable Are_implicit_interoperable;
class Cast{ class Cast{
private: private:
template <class T> template <class T>
inline Coercion_type cast(const T& x) const{ return Coercion_type(x); } inline Type cast(const T& x) const{ return Type(x); }
inline Coercion_type cast(const Coercion_type& x) const{ return x; } inline Type cast(const Type& x) const{ return x; }
public: public:
typedef Coercion_type result_type; typedef Type result_type;
Coercion_type operator()(const A& x) const { return cast(x);} Type operator()(const A& x) const { return cast(x);}
Coercion_type operator()(const B& x) const { return cast(x);} Type operator()(const B& x) const { return cast(x);}
}; };
}; };
@ -1308,7 +1308,7 @@ struct Coercion_traits< Lazy_exact_nt<ET1>, Lazy_exact_nt<ET2> >
=boost::is_same< Are_implicit_interoperable, Tag_false>::value; \ =boost::is_same< Are_implicit_interoperable, Tag_false>::value; \
public: \ public: \
typedef typename boost::mpl::if_c <interoperable,Null_tag,NT> \ typedef typename boost::mpl::if_c <interoperable,Null_tag,NT> \
::type Coercion_type; \ ::type Type; \
typedef typename boost::mpl::if_c <interoperable, Null_functor, \ typedef typename boost::mpl::if_c <interoperable, Null_functor, \
INTERN_CT::Cast_from_to<NTX,NT> >::type Cast; \ INTERN_CT::Cast_from_to<NTX,NT> >::type Cast; \
}; \ }; \
@ -1332,7 +1332,7 @@ template < class ET >
class Fraction_traits_base <Lazy_exact_nt<ET> , CGAL::Tag_false> class Fraction_traits_base <Lazy_exact_nt<ET> , CGAL::Tag_false>
: public Fraction_traits<ET> { : public Fraction_traits<ET> {
public: public:
typedef Lazy_exact_nt<ET> Fraction; typedef Lazy_exact_nt<ET> Type;
}; };
template < class ET > template < class ET >
@ -1341,7 +1341,7 @@ class Fraction_traits_base <Lazy_exact_nt<ET> , CGAL::Tag_true>{
typedef typename ETT::Numerator ET_numerator; typedef typename ETT::Numerator ET_numerator;
typedef typename ETT::Denominator ET_denominator; typedef typename ETT::Denominator ET_denominator;
public: public:
typedef Lazy_exact_nt<ET> Fraction; typedef Lazy_exact_nt<ET> Type;
typedef Tag_true Is_fraction; typedef Tag_true Is_fraction;
typedef Lazy_exact_nt<ET_numerator> Numerator; typedef Lazy_exact_nt<ET_numerator> Numerator;
typedef Lazy_exact_nt<ET_denominator> Denominator; typedef Lazy_exact_nt<ET_denominator> Denominator;
@ -1352,18 +1352,18 @@ public:
return Denominator(common_factor(a.exact(),b.exact())); return Denominator(common_factor(a.exact(),b.exact()));
} }
}; };
struct Compose : Binary_function<Fraction,Numerator,Denominator>{ struct Compose : Binary_function<Type,Numerator,Denominator>{
Fraction operator()(const Numerator& n, const Denominator& d) const { Type operator()(const Numerator& n, const Denominator& d) const {
typename ETT::Compose compose; typename ETT::Compose compose;
return Fraction(compose(n.exact(),d.exact())); return Type(compose(n.exact(),d.exact()));
} }
}; };
struct Decompose { struct Decompose {
typedef void result_type; typedef void result_type;
typedef Fraction first_argument_type; typedef Type first_argument_type;
typedef Numerator second_argument_type; typedef Numerator second_argument_type;
typedef Denominator third_argument_type; typedef Denominator third_argument_type;
void operator()(const Fraction& f, Numerator& n, Denominator& d) const { void operator()(const Type& f, Numerator& n, Denominator& d) const {
typename ETT::Decompose decompose; typename ETT::Decompose decompose;
ET_numerator nn; ET_numerator nn;
ET_denominator dd; ET_denominator dd;

View File

@ -376,13 +376,13 @@ template <> class Algebraic_structure_traits< MP_Float >
#endif #endif
struct Integral_division struct Integral_division
: public Binary_function< Algebraic_structure, : public Binary_function< Type,
Algebraic_structure, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( Type operator()(
const Algebraic_structure& x, const Type& x,
const Algebraic_structure& y ) const { const Type& y ) const {
#ifdef CGAL_MP_FLOAT_ALLOW_INEXACT // inexact #ifdef CGAL_MP_FLOAT_ALLOW_INEXACT // inexact
return x/y; return x/y;
#else // exact #else // exact
@ -396,44 +396,44 @@ template <> class Algebraic_structure_traits< MP_Float >
class Square class Square
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return INTERN_MP_FLOAT::square(x); return INTERN_MP_FLOAT::square(x);
} }
}; };
#ifdef CGAL_MP_FLOAT_ALLOW_INEXACT #ifdef CGAL_MP_FLOAT_ALLOW_INEXACT
class Sqrt class Sqrt
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return approximate_sqrt( x ); return approximate_sqrt( x );
} }
}; };
#endif #endif
class Gcd class Gcd
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y ) const { const Type& y ) const {
return INTERN_MP_FLOAT::gcd( x, y ); return INTERN_MP_FLOAT::gcd( x, y );
} }
}; };
class Div class Div
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y ) const { const Type& y ) const {
return INTERN_MP_FLOAT::div( x, y ); return INTERN_MP_FLOAT::div( x, y );
} }
}; };
typedef INTERN_AST::Mod_per_operator< Algebraic_structure > Mod; typedef INTERN_AST::Mod_per_operator< Type > Mod;
}; };
@ -444,35 +444,35 @@ template <> class Real_embeddable_traits< MP_Float >
public: public:
class Sign class Sign
: public Unary_function< Real_embeddable, ::CGAL::Sign > { : public Unary_function< Type, ::CGAL::Sign > {
public: public:
::CGAL::Sign operator()( const Real_embeddable& x ) const { ::CGAL::Sign operator()( const Type& x ) const {
return x.sign(); return x.sign();
} }
}; };
class Compare class Compare
: public Binary_function< Real_embeddable, Real_embeddable, : public Binary_function< Type, Type,
Comparison_result > { Comparison_result > {
public: public:
Comparison_result operator()( const Real_embeddable& x, Comparison_result operator()( const Type& x,
const Real_embeddable& y ) const { const Type& y ) const {
return INTERN_MP_FLOAT::compare( x, y ); return INTERN_MP_FLOAT::compare( x, y );
} }
}; };
class To_double class To_double
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
double operator()( const Real_embeddable& x ) const { double operator()( const Type& x ) const {
return INTERN_MP_FLOAT::to_double( x ); return INTERN_MP_FLOAT::to_double( x );
} }
}; };
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
return INTERN_MP_FLOAT::to_interval( x ); return INTERN_MP_FLOAT::to_interval( x );
} }
}; };

View File

@ -21,8 +21,8 @@
// //
// Author(s) : Sylvain Pion, Michael Hemmer // Author(s) : Sylvain Pion, Michael Hemmer
#ifndef CGAL_NUMBER_TYPE_CHECKER_H #ifndef CGAL_NUMBER_Type_CHECKER_H
#define CGAL_NUMBER_TYPE_CHECKER_H #define CGAL_NUMBER_Type_CHECKER_H
#include <CGAL/number_type_basic.h> #include <CGAL/number_type_basic.h>
@ -445,14 +445,14 @@ class NTC_AST_base
private: private:
typedef Algebraic_structure_traits<NT1> AST1; typedef Algebraic_structure_traits<NT1> AST1;
typedef Algebraic_structure_traits<NT2> AST2; typedef Algebraic_structure_traits<NT2> AST2;
typedef Number_type_checker<NT1, NT2, Cmp> Algebraic_structure; typedef Number_type_checker<NT1, NT2, Cmp> Type;
public: public:
//CGAL::Algebraic_structure_traits<>::Simplify //CGAL::Algebraic_structure_traits<>::Simplify
class Simplify class Simplify
: public Unary_function< Algebraic_structure& , void > { : public Unary_function< Type& , void > {
public: public:
void operator()( Algebraic_structure& a) const { void operator()( Type& a) const {
typename AST1::Simplify()(a.n1()); typename AST1::Simplify()(a.n1());
typename AST2::Simplify()(a.n2()); typename AST2::Simplify()(a.n2());
CGAL_assertion(a.is_valid()); CGAL_assertion(a.is_valid());
@ -461,9 +461,9 @@ public:
//CGAL::Algebraic_structure_traits< >::Is_zero //CGAL::Algebraic_structure_traits< >::Is_zero
class Is_zero class Is_zero
: public Unary_function< Algebraic_structure, bool > { : public Unary_function< Type, bool > {
public: public:
bool operator()(const Algebraic_structure& a ) const { bool operator()(const Type& a ) const {
bool b1 = typename AST1::Is_zero()(a.n1()); bool b1 = typename AST1::Is_zero()(a.n1());
bool b2 = typename AST2::Is_zero()(a.n2()); bool b2 = typename AST2::Is_zero()(a.n2());
CGAL_assertion(b1 == b2 ); CGAL_assertion(b1 == b2 );
@ -474,9 +474,9 @@ public:
// CGAL::Algebraic_structure_traits< >::Is_one // CGAL::Algebraic_structure_traits< >::Is_one
class Is_one class Is_one
: public Unary_function< Algebraic_structure, bool > { : public Unary_function< Type, bool > {
public: public:
bool operator()(const Algebraic_structure& a) const { bool operator()(const Type& a) const {
bool b1 = typename AST1::Is_one()(a.n1()); bool b1 = typename AST1::Is_one()(a.n1());
bool b2 = typename AST2::Is_one()(a.n2()); bool b2 = typename AST2::Is_one()(a.n2());
CGAL_assertion(b1 == b2 ); CGAL_assertion(b1 == b2 );
@ -486,10 +486,10 @@ public:
}; };
// CGAL::Algebraic_structure_traits< >::Square // CGAL::Algebraic_structure_traits< >::Square
class Square class Square
: public Unary_function< Algebraic_structure , Algebraic_structure > { : public Unary_function< Type , Type > {
public: public:
Algebraic_structure operator()(const Algebraic_structure& a) const { Type operator()(const Type& a) const {
return Algebraic_structure( return Type(
typename AST1::Square()(a.n1()), typename AST1::Square()(a.n1()),
typename AST2::Square()(a.n2())); typename AST2::Square()(a.n2()));
} }
@ -498,11 +498,11 @@ public:
// CGAL::Algebraic_structure_traits< >::Unit_part // CGAL::Algebraic_structure_traits< >::Unit_part
class Unit_part class Unit_part
: public Unary_function< Algebraic_structure , Algebraic_structure > { : public Unary_function< Type , Type > {
public: public:
Algebraic_structure operator()(const Algebraic_structure& a) const { Type operator()(const Type& a) const {
CGAL_NT_CHECK_DEBUG("AST::Unit_part"); CGAL_NT_CHECK_DEBUG("AST::Unit_part");
return Algebraic_structure( return Type(
typename AST1::Unit_part()(a.n1()), typename AST1::Unit_part()(a.n1()),
typename AST2::Unit_part()(a.n2())); typename AST2::Unit_part()(a.n2()));
} }
@ -518,21 +518,21 @@ class NTC_AST_base
private: private:
typedef Algebraic_structure_traits<NT1> AST1; typedef Algebraic_structure_traits<NT1> AST1;
typedef Algebraic_structure_traits<NT2> AST2; typedef Algebraic_structure_traits<NT2> AST2;
typedef Number_type_checker<NT1, NT2, Cmp> Algebraic_structure; typedef Number_type_checker<NT1, NT2, Cmp> Type;
public: public:
// CGAL::Algebraic_structure_traits< >::Integral_division // CGAL::Algebraic_structure_traits< >::Integral_division
class Integral_division class Integral_division
: public Binary_function< Algebraic_structure, : public Binary_function< Type,
Algebraic_structure, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( Type operator()(
const Algebraic_structure& a, const Type& a,
const Algebraic_structure& b) const { const Type& b) const {
CGAL_NT_CHECK_DEBUG("AST::Integral_division"); CGAL_NT_CHECK_DEBUG("AST::Integral_division");
return Algebraic_structure( return Type(
typename AST1::Integral_division()(a.n1(),b.n1()), typename AST1::Integral_division()(a.n1(),b.n1()),
typename AST2::Integral_division()(a.n2(),b.n2())); typename AST2::Integral_division()(a.n2(),b.n2()));
} }
@ -549,19 +549,19 @@ class NTC_AST_base
private: private:
typedef Algebraic_structure_traits<NT1> AST1; typedef Algebraic_structure_traits<NT1> AST1;
typedef Algebraic_structure_traits<NT2> AST2; typedef Algebraic_structure_traits<NT2> AST2;
typedef Number_type_checker<NT1, NT2, Cmp> Algebraic_structure; typedef Number_type_checker<NT1, NT2, Cmp> Type;
public: public:
// CGAL::Algebraic_structure_traits< >::Gcd // CGAL::Algebraic_structure_traits< >::Gcd
class Gcd class Gcd
: public Binary_function< Algebraic_structure, : public Binary_function< Type,
Algebraic_structure, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( Type operator()(
const Algebraic_structure& a, const Type& a,
const Algebraic_structure& b) const { const Type& b) const {
CGAL_NT_CHECK_DEBUG("AST::Gcd"); CGAL_NT_CHECK_DEBUG("AST::Gcd");
return Algebraic_structure( return Type(
typename AST1::Gcd()(a.n1(),b.n1()), typename AST1::Gcd()(a.n1(),b.n1()),
typename AST2::Gcd()(a.n2(),b.n2())); typename AST2::Gcd()(a.n2(),b.n2()));
} }
@ -577,34 +577,34 @@ class NTC_AST_base
private: private:
typedef Algebraic_structure_traits<NT1> AST1; typedef Algebraic_structure_traits<NT1> AST1;
typedef Algebraic_structure_traits<NT2> AST2; typedef Algebraic_structure_traits<NT2> AST2;
typedef Number_type_checker<NT1, NT2, Cmp> Algebraic_structure; typedef Number_type_checker<NT1, NT2, Cmp> Type;
public: public:
// CGAL::Algebraic_structure_traits< >::Div // CGAL::Algebraic_structure_traits< >::Div
class Div class Div
: public Binary_function< Algebraic_structure, : public Binary_function< Type,
Algebraic_structure, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( Type operator()(
const Algebraic_structure& a, const Type& a,
const Algebraic_structure& b) const { const Type& b) const {
CGAL_NT_CHECK_DEBUG("AST::Div"); CGAL_NT_CHECK_DEBUG("AST::Div");
return Algebraic_structure( return Type(
typename AST1::Div()(a.n1(),b.n1()), typename AST1::Div()(a.n1(),b.n1()),
typename AST2::Div()(a.n2(),b.n2())); typename AST2::Div()(a.n2(),b.n2()));
} }
}; };
// CGAL::Algebraic_structure_traits< >::Mod // CGAL::Algebraic_structure_traits< >::Mod
class Mod class Mod
: public Binary_function< Algebraic_structure, : public Binary_function< Type,
Algebraic_structure, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( Type operator()(
const Algebraic_structure& a, const Type& a,
const Algebraic_structure& b) const { const Type& b) const {
CGAL_NT_CHECK_DEBUG("AST::Mod"); CGAL_NT_CHECK_DEBUG("AST::Mod");
return Algebraic_structure( return Type(
typename AST1::Mod()(a.n1(),b.n1()), typename AST1::Mod()(a.n1(),b.n1()),
typename AST2::Mod()(a.n2(),b.n2())); typename AST2::Mod()(a.n2(),b.n2()));
} }
@ -613,25 +613,25 @@ public:
// CGAL::Algebraic_structure_traits< >::Div_mod // CGAL::Algebraic_structure_traits< >::Div_mod
class Div_mod { class Div_mod {
public: public:
typedef Algebraic_structure first_argument_type; typedef Type first_argument_type;
typedef Algebraic_structure second_argument_type; typedef Type second_argument_type;
typedef Algebraic_structure& third_argument_type; typedef Type& third_argument_type;
typedef Algebraic_structure& fourth_argument_type; typedef Type& fourth_argument_type;
typedef Arity_tag< 4 > Arity; typedef Arity_tag< 4 > Arity;
typedef void result_type; typedef void result_type;
void operator()( void operator()(
const Algebraic_structure& a, const Type& a,
const Algebraic_structure& b, const Type& b,
Algebraic_structure& q, Type& q,
Algebraic_structure& r) const { Type& r) const {
CGAL_NT_CHECK_DEBUG("AST::Div_mod"); CGAL_NT_CHECK_DEBUG("AST::Div_mod");
NT1 q1,r1; NT1 q1,r1;
NT2 q2,r2; NT2 q2,r2;
typename AST1::Div_mod()(a.n1(),b.n1(),q1,r1); typename AST1::Div_mod()(a.n1(),b.n1(),q1,r1);
typename AST1::Div_mod()(a.n2(),b.n2(),q2,r2); typename AST1::Div_mod()(a.n2(),b.n2(),q2,r2);
q = Algebraic_structure(q1,q2); q = Type(q1,q2);
r = Algebraic_structure(r1,r2); r = Type(r1,r2);
} }
}; };
}; };
@ -653,17 +653,17 @@ class NTC_AST_base
private: private:
typedef Algebraic_structure_traits<NT1> AST1; typedef Algebraic_structure_traits<NT1> AST1;
typedef Algebraic_structure_traits<NT2> AST2; typedef Algebraic_structure_traits<NT2> AST2;
typedef Number_type_checker<NT1, NT2, Cmp> Algebraic_structure; typedef Number_type_checker<NT1, NT2, Cmp> Type;
public: public:
// CGAL::Algebraic_structure_traits< >::Sqrt // CGAL::Algebraic_structure_traits< >::Sqrt
class Sqrt class Sqrt
: public Unary_function< Algebraic_structure , Algebraic_structure > { : public Unary_function< Type , Type > {
public: public:
Algebraic_structure operator()(const Algebraic_structure& a) const { Type operator()(const Type& a) const {
CGAL_NT_CHECK_DEBUG("AST::Sqrt"); CGAL_NT_CHECK_DEBUG("AST::Sqrt");
return Algebraic_structure( return Type(
typename AST1::Sqrt()(a.n1()), typename AST1::Sqrt()(a.n1()),
typename AST2::Sqrt()(a.n2())); typename AST2::Sqrt()(a.n2()));
} }
@ -681,7 +681,7 @@ class Algebraic_structure_traits <Number_type_checker<NT1, NT2, Cmp> >
{ {
typedef Algebraic_structure_traits<NT1> AST1; typedef Algebraic_structure_traits<NT1> AST1;
public: public:
typedef Number_type_checker< NT1, NT2, Cmp> Algebraic_structure; typedef Number_type_checker< NT1, NT2, Cmp> Type;
typedef typename AST1::Algebraic_structure_tag Algebraic_structure_tag; typedef typename AST1::Algebraic_structure_tag Algebraic_structure_tag;
typedef typename AST1::Is_exact Is_exact; typedef typename AST1::Is_exact Is_exact;
@ -705,16 +705,16 @@ class NTC_RET_base
private: private:
typedef Real_embeddable_traits<NT1> RET1; typedef Real_embeddable_traits<NT1> RET1;
typedef Real_embeddable_traits<NT2> RET2; typedef Real_embeddable_traits<NT2> RET2;
typedef Number_type_checker<NT1, NT2, Cmp> Real_embeddable; typedef Number_type_checker<NT1, NT2, Cmp> Type;
public: public:
// CGAL::Real_embeddable_traits< >::Abs // CGAL::Real_embeddable_traits< >::Abs
class Abs class Abs
: public Unary_function< Real_embeddable , Real_embeddable > { : public Unary_function< Type , Type > {
public: public:
Real_embeddable operator()(const Real_embeddable& a) const { Type operator()(const Type& a) const {
CGAL_NT_CHECK_DEBUG("RET::Abs"); CGAL_NT_CHECK_DEBUG("RET::Abs");
return Real_embeddable( return Type(
typename RET1::Abs()(a.n1()), typename RET1::Abs()(a.n1()),
typename RET2::Abs()(a.n2())); typename RET2::Abs()(a.n2()));
} }
@ -722,9 +722,9 @@ public:
// CGAL::Real_embeddable_traits< >::Sign // CGAL::Real_embeddable_traits< >::Sign
class Sign class Sign
: public Unary_function< Real_embeddable , ::CGAL::Sign > { : public Unary_function< Type , ::CGAL::Sign > {
public: public:
::CGAL::Sign operator()(const Real_embeddable& a) const { ::CGAL::Sign operator()(const Type& a) const {
CGAL_NT_CHECK_DEBUG("RET::Sign"); CGAL_NT_CHECK_DEBUG("RET::Sign");
::CGAL::Sign r1 = typename RET1::Sign()(a.n1()); ::CGAL::Sign r1 = typename RET1::Sign()(a.n1());
::CGAL::Sign r2 = typename RET2::Sign()(a.n2()); ::CGAL::Sign r2 = typename RET2::Sign()(a.n2());
@ -735,9 +735,9 @@ public:
// CGAL::Real_embeddable_traits< >::Is_finite // CGAL::Real_embeddable_traits< >::Is_finite
class Is_finite class Is_finite
: public Unary_function< Real_embeddable , bool > { : public Unary_function< Type , bool > {
public: public:
bool operator()(const Real_embeddable& a) const { bool operator()(const Type& a) const {
CGAL_NT_CHECK_DEBUG("RET::Is_finite"); CGAL_NT_CHECK_DEBUG("RET::Is_finite");
bool r1 = typename RET1::Is_finite()(a.n1()); bool r1 = typename RET1::Is_finite()(a.n1());
bool r2 = typename RET2::Is_finite()(a.n2()); bool r2 = typename RET2::Is_finite()(a.n2());
@ -748,9 +748,9 @@ public:
// CGAL::Real_embeddable_traits< >::Is_positive // CGAL::Real_embeddable_traits< >::Is_positive
class Is_positive class Is_positive
: public Unary_function< Real_embeddable , bool > { : public Unary_function< Type , bool > {
public: public:
bool operator()(const Real_embeddable& a) const { bool operator()(const Type& a) const {
CGAL_NT_CHECK_DEBUG("RET::Is_positive"); CGAL_NT_CHECK_DEBUG("RET::Is_positive");
bool r1 = typename RET1::Is_positive()(a.n1()); bool r1 = typename RET1::Is_positive()(a.n1());
bool r2 = typename RET2::Is_positive()(a.n2()); bool r2 = typename RET2::Is_positive()(a.n2());
@ -761,9 +761,9 @@ public:
// CGAL::Real_embeddable_traits< >::Is_negative // CGAL::Real_embeddable_traits< >::Is_negative
class Is_negative class Is_negative
: public Unary_function< Real_embeddable , bool > { : public Unary_function< Type , bool > {
public: public:
bool operator()(const Real_embeddable& a) const { bool operator()(const Type& a) const {
CGAL_NT_CHECK_DEBUG("RET::Is_negative"); CGAL_NT_CHECK_DEBUG("RET::Is_negative");
bool r1 = typename RET1::Is_negative()(a.n1()); bool r1 = typename RET1::Is_negative()(a.n1());
bool r2 = typename RET2::Is_negative()(a.n2()); bool r2 = typename RET2::Is_negative()(a.n2());
@ -774,9 +774,9 @@ public:
// CGAL::Real_embeddable_traits< >::Is_zero // CGAL::Real_embeddable_traits< >::Is_zero
class Is_zero class Is_zero
: public Unary_function< Real_embeddable , bool > { : public Unary_function< Type , bool > {
public: public:
bool operator()(const Real_embeddable& a) const { bool operator()(const Type& a) const {
CGAL_NT_CHECK_DEBUG("RET::Is_zero"); CGAL_NT_CHECK_DEBUG("RET::Is_zero");
bool r1 = typename RET1::Is_zero()(a.n1()); bool r1 = typename RET1::Is_zero()(a.n1());
bool r2 = typename RET2::Is_zero()(a.n2()); bool r2 = typename RET2::Is_zero()(a.n2());
@ -787,9 +787,9 @@ public:
// CGAL::Real_embeddable_traits< >::Compare // CGAL::Real_embeddable_traits< >::Compare
class Compare class Compare
: public Binary_function< Real_embeddable , Real_embeddable, Comparison_result > { : public Binary_function< Type , Type, Comparison_result > {
public: public:
Comparison_result operator()(const Real_embeddable& a, const Real_embeddable& b) const { Comparison_result operator()(const Type& a, const Type& b) const {
CGAL_NT_CHECK_DEBUG("RET::Compare"); CGAL_NT_CHECK_DEBUG("RET::Compare");
Comparison_result r1 = typename RET1::Compare()(a.n1(),b.n1()); Comparison_result r1 = typename RET1::Compare()(a.n1(),b.n1());
Comparison_result r2 = typename RET2::Compare()(a.n2(),b.n2()); Comparison_result r2 = typename RET2::Compare()(a.n2(),b.n2());
@ -800,9 +800,9 @@ public:
// CGAL::Real_embeddable_traits< >::To_double // CGAL::Real_embeddable_traits< >::To_double
class To_double class To_double
: public Unary_function< Real_embeddable , double > { : public Unary_function< Type , double > {
public: public:
double operator()(const Real_embeddable& a) const { double operator()(const Type& a) const {
CGAL_NT_CHECK_DEBUG("RET::To_double"); CGAL_NT_CHECK_DEBUG("RET::To_double");
double r1 = typename RET1::To_double()(a.n1()); double r1 = typename RET1::To_double()(a.n1());
double r2 = typename RET2::To_double()(a.n2()); double r2 = typename RET2::To_double()(a.n2());
@ -813,9 +813,9 @@ public:
// CGAL::Real_embeddable_traits< >::To_interval // CGAL::Real_embeddable_traits< >::To_interval
class To_interval class To_interval
: public Unary_function< Real_embeddable , std::pair<double, double> > { : public Unary_function< Type , std::pair<double, double> > {
public: public:
std::pair<double, double> operator()(const Real_embeddable& a) const { std::pair<double, double> operator()(const Type& a) const {
CGAL_NT_CHECK_DEBUG("RET::To_interval"); CGAL_NT_CHECK_DEBUG("RET::To_interval");
std::pair<double, double> r1 = typename RET1::To_interval()(a.n1()); std::pair<double, double> r1 = typename RET1::To_interval()(a.n1());
std::pair<double, double> r2 = typename RET2::To_interval()(a.n2()); std::pair<double, double> r2 = typename RET2::To_interval()(a.n2());
@ -835,7 +835,7 @@ class Real_embeddable_traits
{ {
typedef Real_embeddable_traits<NT1> RET1; typedef Real_embeddable_traits<NT1> RET1;
public: public:
typedef Number_type_checker< NT1, NT2, Cmp > Real_embeddable; typedef Number_type_checker< NT1, NT2, Cmp > Type;
typedef typename RET1::Is_real_embeddable Is_real_embeddable; typedef typename RET1::Is_real_embeddable Is_real_embeddable;
}; };
@ -844,10 +844,10 @@ struct Coercion_traits< Number_type_checker<NT1,NT2,Cmp>,
Number_type_checker<NT1,NT2,Cmp> >{ Number_type_checker<NT1,NT2,Cmp> >{
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_true Are_implicit_interoperable; typedef Tag_true Are_implicit_interoperable;
typedef Number_type_checker<NT1,NT2,Cmp> Coercion_type; typedef Number_type_checker<NT1,NT2,Cmp> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
Coercion_type operator()(const Coercion_type& x) const { return x;} Type operator()(const Type& x) const { return x;}
}; };
}; };
@ -855,11 +855,11 @@ template < typename NT1, typename NT2, typename Cmp >
struct Coercion_traits< Number_type_checker<NT1,NT2,Cmp>, int >{ struct Coercion_traits< Number_type_checker<NT1,NT2,Cmp>, int >{
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_true Are_implicit_interoperable; typedef Tag_true Are_implicit_interoperable;
typedef Number_type_checker<NT1,NT2,Cmp> Coercion_type; typedef Number_type_checker<NT1,NT2,Cmp> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
Coercion_type operator()(const Coercion_type& x) const { return x;} Type operator()(const Type& x) const { return x;}
Coercion_type operator()(int x) const { return Coercion_type(x);} Type operator()(int x) const { return Type(x);}
}; };
}; };
@ -874,7 +874,7 @@ template < typename NT_checker, typename Tag = Tag_false >
struct Coercion_traits_double{ struct Coercion_traits_double{
typedef Tag_false Are_explicit_interoperable; typedef Tag_false Are_explicit_interoperable;
typedef Tag_false Are_implicit_interoperable; typedef Tag_false Are_implicit_interoperable;
typedef Null_tag Coercion_type; typedef Null_tag Type;
}; };
template < typename NT1, typename NT2, typename Cmp> template < typename NT1, typename NT2, typename Cmp>
@ -882,12 +882,12 @@ struct Coercion_traits_double< Number_type_checker<NT1,NT2,Cmp> ,
Tag_true >{ Tag_true >{
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_true Are_implicit_interoperable; typedef Tag_true Are_implicit_interoperable;
typedef Number_type_checker<NT1,NT2,Cmp> Coercion_type; typedef Number_type_checker<NT1,NT2,Cmp> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
Coercion_type operator()(const Coercion_type& x) const { return x;} Type operator()(const Type& x) const { return x;}
Coercion_type operator()(const double& x) const { Type operator()(const double& x) const {
return Coercion_type(x); return Type(x);
} }
}; };
}; };
@ -926,4 +926,4 @@ operator>> (std::istream & is, Number_type_checker<NT1, NT2, Cmp> &b)
CGAL_END_NAMESPACE CGAL_END_NAMESPACE
#endif // CGAL_NUMBER_TYPE_CHECKER_H #endif // CGAL_NUMBER_Type_CHECKER_H

View File

@ -19,8 +19,8 @@
// Author(s) : Sylvain Pion, Monique Teillaud, Athanasios Kakargias // Author(s) : Sylvain Pion, Monique Teillaud, Athanasios Kakargias
// Olivier Devillers // Olivier Devillers
#ifndef CGAL_NUMBER_TYPES_ROOT_OF_COMPARISON_FUNCTIONS_22_H #ifndef CGAL_NUMBER_TypeS_ROOT_OF_COMPARISON_FUNCTIONS_22_H
#define CGAL_NUMBER_TYPES_ROOT_OF_COMPARISON_FUNCTIONS_22_H #define CGAL_NUMBER_TypeS_ROOT_OF_COMPARISON_FUNCTIONS_22_H
#include <CGAL/enum.h> #include <CGAL/enum.h>
#include <CGAL/kernel_assertions.h> #include <CGAL/kernel_assertions.h>
@ -221,4 +221,4 @@ inline FT calcD(const FT& A1, const FT& I1, const FT& A2, const FT& I2)
} // namespace CGALi } // namespace CGALi
} // namespace CGAL } // namespace CGAL
#endif // CGAL_NUMBER_TYPES_ROOT_OF_COMPARISON_FUNCTIONS_22_H #endif // CGAL_NUMBER_TypeS_ROOT_OF_COMPARISON_FUNCTIONS_22_H

View File

@ -523,7 +523,7 @@ template<class NT> class Algebraic_structure_traits_quotient_base;
template< class NT > class Algebraic_structure_traits_quotient_base< Quotient<NT> > template< class NT > class Algebraic_structure_traits_quotient_base< Quotient<NT> >
: public Algebraic_structure_traits_base< Quotient<NT>, Field_tag > { : public Algebraic_structure_traits_base< Quotient<NT>, Field_tag > {
public: public:
typedef Quotient<NT> Algebraic_structure; typedef Quotient<NT> Type;
typedef typename Algebraic_structure_traits<NT>::Is_exact Is_exact; typedef typename Algebraic_structure_traits<NT>::Is_exact Is_exact;
@ -555,15 +555,15 @@ public:
typedef typename boost::mpl::if_c< typedef typename boost::mpl::if_c<
!boost::is_same< typename Algebraic_structure_traits<NT>::Sqrt, !boost::is_same< typename Algebraic_structure_traits<NT>::Sqrt,
Null_functor >::value, Null_functor >::value,
typename INTERN_QUOTIENT::Sqrt_selector< Algebraic_structure, typename INTERN_QUOTIENT::Sqrt_selector< Type,
Is_exact >::Sqrt, Is_exact >::Sqrt,
Null_functor Null_functor
>::type Sqrt; >::type Sqrt;
class Simplify class Simplify
: public Unary_function< Algebraic_structure&, void > { : public Unary_function< Type&, void > {
public: public:
void operator()( Algebraic_structure& x) const { void operator()( Type& x) const {
x.normalize(); x.normalize();
} }
}; };
@ -576,22 +576,22 @@ template < class NT > class Real_embeddable_traits_quotient_base< Quotient<NT> >
: public INTERN_RET::Real_embeddable_traits_base_selector< Quotient<NT>, : public INTERN_RET::Real_embeddable_traits_base_selector< Quotient<NT>,
typename Real_embeddable_traits< NT >::Is_real_embeddable > { typename Real_embeddable_traits< NT >::Is_real_embeddable > {
public: public:
typedef Quotient<NT> Real_embeddable; typedef Quotient<NT> Type;
class Compare class Compare
: public Binary_function< Real_embeddable, Real_embeddable, : public Binary_function< Type, Type,
Comparison_result > { Comparison_result > {
public: public:
Comparison_result operator()( const Real_embeddable& x, Comparison_result operator()( const Type& x,
const Real_embeddable& y ) const { const Type& y ) const {
return quotient_cmp(x, y); return quotient_cmp(x, y);
} }
}; };
class To_double class To_double
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
double operator()( const Real_embeddable& x ) const { double operator()( const Type& x ) const {
// Original global function was marked with an TODO!! // Original global function was marked with an TODO!!
if (x.num == 0 ) if (x.num == 0 )
return 0; return 0;
@ -621,9 +621,9 @@ template < class NT > class Real_embeddable_traits_quotient_base< Quotient<NT> >
}; };
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
Interval_nt<> quot = Interval_nt<> quot =
Interval_nt<>(CGAL_NTS to_interval(x.numerator())) / Interval_nt<>(CGAL_NTS to_interval(x.numerator())) /
Interval_nt<>(CGAL_NTS to_interval(x.denominator())); Interval_nt<>(CGAL_NTS to_interval(x.denominator()));
@ -632,9 +632,9 @@ template < class NT > class Real_embeddable_traits_quotient_base< Quotient<NT> >
}; };
class Is_finite class Is_finite
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public: public:
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
return CGAL_NTS is_finite(x.num) && CGAL_NTS is_finite(x.den); return CGAL_NTS is_finite(x.num) && CGAL_NTS is_finite(x.den);
} }
}; };
@ -659,13 +659,13 @@ struct Coercion_traits<typename First_if_different<int, NT>::Type,Quotient<NT> >
{ {
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_true Are_implicit_interoperable; typedef Tag_true Are_implicit_interoperable;
typedef Quotient<NT> Coercion_type; typedef Quotient<NT> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
Coercion_type operator()(const Quotient<NT>& x) const { return x;} Type operator()(const Quotient<NT>& x) const { return x;}
Coercion_type operator()( Type operator()(
const typename First_if_different<int, NT>::Type& x) const { const typename First_if_different<int, NT>::Type& x) const {
return Coercion_type(x);} return Type(x);}
}; };
}; };
template <class NT> template <class NT>
@ -679,13 +679,13 @@ struct Coercion_traits<typename First_if_different<double, NT>::Type,
Quotient<NT> >{ Quotient<NT> >{
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_true Are_implicit_interoperable; typedef Tag_true Are_implicit_interoperable;
typedef Quotient<NT> Coercion_type; typedef Quotient<NT> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
Coercion_type operator()(const Quotient<NT>& x) const { return x;} Type operator()(const Quotient<NT>& x) const { return x;}
Coercion_type operator()( Type operator()(
const typename First_if_different<double, NT>::Type& x) const { const typename First_if_different<double, NT>::Type& x) const {
return Coercion_type(x);} return Type(x);}
}; };
}; };
template <class NT> template <class NT>
@ -704,7 +704,7 @@ CGAL_DEFINE_COERCION_TRAITS_FROM_TO_TEM ( NT, Quotient<NT>, class NT);
template <class NT> template <class NT>
class Fraction_traits< Quotient<NT> > { class Fraction_traits< Quotient<NT> > {
public: public:
typedef Quotient<NT> Fraction; typedef Quotient<NT> Type;
typedef ::CGAL::Tag_true Is_fraction; typedef ::CGAL::Tag_true Is_fraction;
typedef NT Numerator; typedef NT Numerator;
typedef Numerator Denominator; typedef Numerator Denominator;
@ -716,11 +716,11 @@ public:
class Decompose { class Decompose {
public: public:
typedef Fraction first_argument_type; typedef Type first_argument_type;
typedef Numerator& second_argument_type; typedef Numerator& second_argument_type;
typedef Numerator& third_argument_type; typedef Numerator& third_argument_type;
void operator () ( void operator () (
const Fraction& rat, const Type& rat,
Numerator& num, Numerator& num,
Numerator& den) { Numerator& den) {
num = rat.numerator(); num = rat.numerator();
@ -732,11 +732,11 @@ public:
public: public:
typedef Numerator first_argument_type; typedef Numerator first_argument_type;
typedef Numerator second_argument_type; typedef Numerator second_argument_type;
typedef Fraction result_type; typedef Type result_type;
Fraction operator ()( Type operator ()(
const Numerator& num , const Numerator& num ,
const Numerator& den ) { const Numerator& den ) {
Fraction result(num, den); Type result(num, den);
return result; return result;
} }
}; };

View File

@ -305,12 +305,12 @@ template <class RT>
struct Coercion_traits< RT , Root_of_2<RT> >{ struct Coercion_traits< RT , Root_of_2<RT> >{
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_true Are_implicit_interoperable; typedef Tag_true Are_implicit_interoperable;
typedef Root_of_2<RT> Coercion_type; typedef Root_of_2<RT> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
Coercion_type operator()(const Root_of_2<RT>& x) const { return x;} Type operator()(const Root_of_2<RT>& x) const { return x;}
Coercion_type operator()(const RT& x) const { Type operator()(const RT& x) const {
return Coercion_type(x);} return Type(x);}
}; };
}; };
@ -318,12 +318,12 @@ template <class RT>
struct Coercion_traits< CGAL_int(RT) , Root_of_2<RT> >{ struct Coercion_traits< CGAL_int(RT) , Root_of_2<RT> >{
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_true Are_implicit_interoperable; typedef Tag_true Are_implicit_interoperable;
typedef Root_of_2<RT> Coercion_type; typedef Root_of_2<RT> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
Coercion_type operator()(const Root_of_2<RT>& x) const { return x;} Type operator()(const Root_of_2<RT>& x) const { return x;}
Coercion_type operator()(CGAL_int(RT) x) const { Type operator()(CGAL_int(RT) x) const {
return Coercion_type(x);} return Type(x);}
}; };
}; };
@ -331,12 +331,12 @@ template <class RT>
struct Coercion_traits< typename Root_of_traits<RT>::RootOf_1 , Root_of_2<RT> >{ struct Coercion_traits< typename Root_of_traits<RT>::RootOf_1 , Root_of_2<RT> >{
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_true Are_implicit_interoperable; typedef Tag_true Are_implicit_interoperable;
typedef Root_of_2<RT> Coercion_type; typedef Root_of_2<RT> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
Coercion_type operator()(const Root_of_2<RT>& x) const { return x;} Type operator()(const Root_of_2<RT>& x) const { return x;}
Coercion_type operator()(const RT& x) const { Type operator()(const RT& x) const {
return Coercion_type(x);} return Type(x);}
}; };
}; };
@ -402,7 +402,7 @@ class Algebraic_structure_traits<Root_of_2<RT> >
:public Algebraic_structure_traits_base<Root_of_2<RT> , Null_tag >{ :public Algebraic_structure_traits_base<Root_of_2<RT> , Null_tag >{
public: public:
typedef Root_of_2<RT> Algebraic_structure; typedef Root_of_2<RT> Type;
typedef typename Algebraic_structure_traits<RT>::Is_exact Is_exact; typedef typename Algebraic_structure_traits<RT>::Is_exact Is_exact;
struct Square struct Square
: public Unary_function< Root_of_2<RT> , Root_of_2<RT> >{ : public Unary_function< Root_of_2<RT> , Root_of_2<RT> >{
@ -433,21 +433,21 @@ class Real_embeddable_traits<Root_of_2<RT> >
typedef typename Root_of_traits<RT>::RootOf_1 Root_of_1; typedef typename Root_of_traits<RT>::RootOf_1 Root_of_1;
public: public:
typedef Root_of_2<RT> Real_embeddable; typedef Root_of_2<RT> Type;
typedef Tag_true Is_real_embeddable; typedef Tag_true Is_real_embeddable;
class Abs class Abs
: public Unary_function< Real_embeddable, Real_embeddable >{ : public Unary_function< Type, Type >{
public: public:
Real_embeddable operator()(const Real_embeddable& x) const { Type operator()(const Type& x) const {
return (x>=0)?x:-x; return (x>=0)?x:-x;
} }
}; };
class Sign class Sign
: public Unary_function< Real_embeddable, ::CGAL::Sign >{ : public Unary_function< Type, ::CGAL::Sign >{
public: public:
::CGAL::Sign operator()(const Real_embeddable& a) const { ::CGAL::Sign operator()(const Type& a) const {
const ::CGAL::Sign sign_alpha = CGAL_NTS sign(a.alpha()); const ::CGAL::Sign sign_alpha = CGAL_NTS sign(a.alpha());
if (a.is_rational()) return (sign_alpha); if (a.is_rational()) return (sign_alpha);
// If alpha and beta have the same sign, return this sign. // If alpha and beta have the same sign, return this sign.
@ -465,13 +465,13 @@ public:
}; };
class Compare class Compare
: public Binary_function< Real_embeddable, : public Binary_function< Type,
Real_embeddable, Type,
Comparison_result >{ Comparison_result >{
public: public:
Comparison_result operator()( Comparison_result operator()(
const Real_embeddable& a, const Type& a,
const Real_embeddable& b) const{ const Type& b) const{
typedef typename Root_of_traits< RT >::RootOf_1 FT; typedef typename Root_of_traits< RT >::RootOf_1 FT;
typedef typename First_if_different<FT, RT>::Type WhatType; typedef typename First_if_different<FT, RT>::Type WhatType;
typedef typename boost::is_same< WhatType, RT > do_not_filter; typedef typename boost::is_same< WhatType, RT > do_not_filter;
@ -585,7 +585,7 @@ public:
Comparison_result Comparison_result
inline inline
operator()( operator()(
const Real_embeddable& a, const Type& a,
const Root_of_1& b const Root_of_1& b
) const{ ) const{
typedef typename Root_of_traits< RT >::RootOf_1 FT; typedef typename Root_of_traits< RT >::RootOf_1 FT;
@ -614,13 +614,13 @@ public:
inline inline
operator()( operator()(
const Root_of_1& a, const Root_of_1& a,
const Real_embeddable& b const Type& b
) const{ return opposite(this->operator()(b,a) ); } ) const{ return opposite(this->operator()(b,a) ); }
Comparison_result Comparison_result
inline inline
operator()( operator()(
const Real_embeddable& a, const Type& a,
const RT& b const RT& b
) const{ ) const{
typedef typename Root_of_traits< RT >::RootOf_1 FT; typedef typename Root_of_traits< RT >::RootOf_1 FT;
@ -668,9 +668,9 @@ public:
}; };
class To_double class To_double
: public Unary_function< Real_embeddable, double >{ : public Unary_function< Type, double >{
public: public:
double operator()(const Real_embeddable& x) const { double operator()(const Type& x) const {
typedef typename Root_of_traits<RT>::RootOf_1 FT; typedef typename Root_of_traits<RT>::RootOf_1 FT;
typedef Rational_traits< FT > Rational; typedef Rational_traits< FT > Rational;
Rational r; Rational r;
@ -692,9 +692,9 @@ public:
}; };
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > >{ : public Unary_function< Type, std::pair< double, double > >{
public: public:
std::pair<double,double> operator()(const Real_embeddable& x) const { std::pair<double,double> operator()(const Type& x) const {
if(x.is_rational()) return CGAL_NTS to_interval(x.alpha()); if(x.is_rational()) return CGAL_NTS to_interval(x.alpha());

View File

@ -52,7 +52,7 @@ struct Root_of_traits_helper < FT, Field_tag >
typedef FT Root_of_1; typedef FT Root_of_1;
private: private:
typedef Fraction_traits<FT> FrT; typedef Fraction_traits<FT> FrT;
// Field must be a Fraction (Decomposable) // Field must be a Type (Decomposable)
BOOST_STATIC_ASSERT((FrT::Is_fraction::value)); BOOST_STATIC_ASSERT((FrT::Is_fraction::value));
typedef typename FrT::Numerator RT; typedef typename FrT::Numerator RT;

View File

@ -52,7 +52,7 @@
template \< class ArithmeticTraitsSqrtExtension \> template \< class ArithmeticTraitsSqrtExtension \>
class my_class { class my_class {
public: public:
NiX_SNAP_ARITHMETIC_TRAITS_SQRT_EXTENSION_TYPEDEFS(ArithmeticTraitsSqrtExtension); NiX_SNAP_ARITHMETIC_TRAITS_SQRT_EXTENSION_TypeDEFS(ArithmeticTraitsSqrtExtension);
// ... // ...
}; };
</PRE> </PRE>
@ -62,8 +62,8 @@
of your class and saves typing the lengthy ArithmeticTraits:: of your class and saves typing the lengthy ArithmeticTraits::
prefix. prefix.
*/ */
#define CGAL_SNAP_ARITHMETIC_TRAITS_SQRT_EXTENSION_TYPEDEFS(AT) \ #define CGAL_SNAP_ARITHMETIC_TRAITS_SQRT_EXTENSION_TypeDEFS(AT) \
CGAL_SNAP_ARITHMETIC_TRAITS_TYPEDEFS(AT) \ CGAL_SNAP_ARITHMETIC_TRAITS_TypeDEFS(AT) \
typedef typename AT::Extn Extn; \ typedef typename AT::Extn Extn; \
typedef typename AT::Nested_extn Nested_extn; \ typedef typename AT::Nested_extn Nested_extn; \
typedef typename AT::Poly_extn1 Poly_extn1; \ typedef typename AT::Poly_extn1 Poly_extn1; \
@ -558,104 +558,104 @@ template <class NT,class ROOT> bool operator >=
{ return ( (p-Sqrt_extension<NT,ROOT>(num)).sign() >= 0 );} { return ( (p-Sqrt_extension<NT,ROOT>(num)).sign() >= 0 );}
// Algebraic structure traits // Algebraic structure traits
template< class Algebraic_structure, class Algebraic_type > template< class Type, class Algebraic_type >
class Sqrt_extension_algebraic_structure_traits_base; class Sqrt_extension_algebraic_structure_traits_base;
template< class Algebraic_structure > template< class Type >
class Sqrt_extension_algebraic_structure_traits_base< Algebraic_structure, class Sqrt_extension_algebraic_structure_traits_base< Type,
CGAL::Integral_domain_without_division_tag > CGAL::Integral_domain_without_division_tag >
: public Algebraic_structure_traits_base< Algebraic_structure, : public Algebraic_structure_traits_base< Type,
CGAL::Integral_domain_without_division_tag > { CGAL::Integral_domain_without_division_tag > {
public: public:
typedef CGAL::Integral_domain_without_division_tag Algebraic_structure_tag; typedef CGAL::Integral_domain_without_division_tag Algebraic_structure_tag;
class Simplify class Simplify
: public Unary_function< Algebraic_structure&, void > { : public Unary_function< Type&, void > {
public: public:
typedef void result_type; typedef void result_type;
typedef Algebraic_structure& argument_type; typedef Type& argument_type;
void operator()( Algebraic_structure& x ) const { void operator()( Type& x ) const {
x.simplify(); x.simplify();
} }
}; };
}; };
template< class Algebraic_structure > template< class Type >
class Sqrt_extension_algebraic_structure_traits_base< Algebraic_structure, class Sqrt_extension_algebraic_structure_traits_base< Type,
CGAL::Integral_domain_tag > CGAL::Integral_domain_tag >
: public Sqrt_extension_algebraic_structure_traits_base< Algebraic_structure, : public Sqrt_extension_algebraic_structure_traits_base< Type,
CGAL::Integral_domain_without_division_tag > { CGAL::Integral_domain_without_division_tag > {
public: public:
typedef CGAL::Integral_domain_tag Algebraic_structure_tag; typedef CGAL::Integral_domain_tag Algebraic_structure_tag;
class Integral_division class Integral_division
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y ) const { const Type& y ) const {
return x/y; return x/y;
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Algebraic_structure ) CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Type )
}; };
}; };
template< class Algebraic_structure > template< class Type >
class Sqrt_extension_algebraic_structure_traits_base< Algebraic_structure, class Sqrt_extension_algebraic_structure_traits_base< Type,
CGAL::Unique_factorization_domain_tag > CGAL::Unique_factorization_domain_tag >
: public Sqrt_extension_algebraic_structure_traits_base< Algebraic_structure, : public Sqrt_extension_algebraic_structure_traits_base< Type,
CGAL::Integral_domain_tag > { CGAL::Integral_domain_tag > {
// Nothing new // Nothing new
}; };
template< class Algebraic_structure > template< class Type >
class Sqrt_extension_algebraic_structure_traits_base< Algebraic_structure, class Sqrt_extension_algebraic_structure_traits_base< Type,
CGAL::Euclidean_ring_tag > CGAL::Euclidean_ring_tag >
: public Sqrt_extension_algebraic_structure_traits_base< Algebraic_structure, : public Sqrt_extension_algebraic_structure_traits_base< Type,
CGAL::Integral_domain_tag > { CGAL::Integral_domain_tag > {
// Nothing new // Nothing new
}; };
template< class Algebraic_structure > template< class Type >
class Sqrt_extension_algebraic_structure_traits_base< Algebraic_structure, class Sqrt_extension_algebraic_structure_traits_base< Type,
CGAL::Field_tag > CGAL::Field_tag >
: public Sqrt_extension_algebraic_structure_traits_base< Algebraic_structure, : public Sqrt_extension_algebraic_structure_traits_base< Type,
CGAL::Integral_domain_tag > { CGAL::Integral_domain_tag > {
public: public:
typedef Field_tag Algebraic_structure_tag; typedef Field_tag Algebraic_structure_tag;
class Unit_part class Unit_part
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return( x == Algebraic_structure(0) ? Algebraic_structure(1) : x ); return( x == Type(0) ? Type(1) : x );
} }
}; };
}; };
template< class Algebraic_structure > template< class Type >
class Sqrt_extension_algebraic_structure_traits_base< Algebraic_structure, class Sqrt_extension_algebraic_structure_traits_base< Type,
CGAL::Field_with_sqrt_tag > CGAL::Field_with_sqrt_tag >
: public Sqrt_extension_algebraic_structure_traits_base< Algebraic_structure, : public Sqrt_extension_algebraic_structure_traits_base< Type,
CGAL::Field_tag > { CGAL::Field_tag > {
// Nothing new // Nothing new
}; };
template< class Algebraic_structure > template< class Type >
class Sqrt_extension_algebraic_structure_traits_base< Algebraic_structure, class Sqrt_extension_algebraic_structure_traits_base< Type,
CGAL::Field_with_kth_root_tag > CGAL::Field_with_kth_root_tag >
: public Sqrt_extension_algebraic_structure_traits_base< Algebraic_structure, : public Sqrt_extension_algebraic_structure_traits_base< Type,
// TODO: Why not Fiel_tag? // TODO: Why not Fiel_tag?
CGAL::Field_with_sqrt_tag > { CGAL::Field_with_sqrt_tag > {
// Nothing new // Nothing new
}; };
template< class Algebraic_structure > template< class Type >
class Sqrt_extension_algebraic_structure_traits_base< Algebraic_structure, class Sqrt_extension_algebraic_structure_traits_base< Type,
CGAL::Field_with_root_of_tag > CGAL::Field_with_root_of_tag >
: public Sqrt_extension_algebraic_structure_traits_base< Algebraic_structure, : public Sqrt_extension_algebraic_structure_traits_base< Type,
// TODO: Why not Fiel_tag? // TODO: Why not Fiel_tag?
CGAL::Field_with_sqrt_tag > { CGAL::Field_with_sqrt_tag > {
// Nothing new // Nothing new
@ -667,7 +667,7 @@ class Algebraic_structure_traits< Sqrt_extension< COEFF, ROOT > >
Sqrt_extension< COEFF, ROOT >, Sqrt_extension< COEFF, ROOT >,
typename Algebraic_structure_traits< COEFF >::Algebraic_structure_tag > { typename Algebraic_structure_traits< COEFF >::Algebraic_structure_tag > {
public: public:
typedef Sqrt_extension< COEFF, ROOT > Algebraic_structure; typedef Sqrt_extension< COEFF, ROOT > Type;
// Tag_true if COEFF and ROOT are exact // Tag_true if COEFF and ROOT are exact
typedef typename ::boost::mpl::if_c< typedef typename ::boost::mpl::if_c<
@ -687,14 +687,14 @@ class Real_embeddable_traits< Sqrt_extension<COEFF, ROOT> >
Sqrt_extension<COEFF, ROOT>, Sqrt_extension<COEFF, ROOT>,
typename Real_embeddable_traits<COEFF>::Is_real_embeddable > { typename Real_embeddable_traits<COEFF>::Is_real_embeddable > {
public: public:
typedef Sqrt_extension<COEFF, ROOT> Real_embeddable; typedef Sqrt_extension<COEFF, ROOT> Type;
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
private: private:
typedef boost::numeric::interval<double> Double_interval; typedef boost::numeric::interval<double> Double_interval;
public: public:
std::pair<double,double> operator()(const Real_embeddable& x) const { std::pair<double,double> operator()(const Type& x) const {
if(x.is_extended()){ if(x.is_extended()){
std::pair<double, double> pair_a0 = CGAL_NTS to_interval( x.a0() ); std::pair<double, double> pair_a0 = CGAL_NTS to_interval( x.a0() );
std::pair<double, double> pair_a1_root = CGAL_NTS to_interval( std::pair<double, double> pair_a1_root = CGAL_NTS to_interval(
@ -713,17 +713,17 @@ class Real_embeddable_traits< Sqrt_extension<COEFF, ROOT> >
}; };
class To_double class To_double
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
// The main problem here is, that even tough the total // The main problem here is, that even tough the total
// expression fits into double, one of the coefficients // expression fits into double, one of the coefficients
// or the root may not. ?? ! // or the root may not. ?? !
double operator()(const Real_embeddable& x) const { double operator()(const Type& x) const {
if(x.is_extended()){ if(x.is_extended()){
return CGAL_NTS to_double(x.a0()) return CGAL_NTS to_double(x.a0())
+ int(CGAL_NTS sign(x.a1())) + int(CGAL_NTS sign(x.a1()))
* CGAL_NTS sqrt(CGAL_NTS to_double(x.a1()*x.a1() * * CGAL_NTS sqrt(CGAL_NTS to_double(x.a1()*x.a1() *
Real_embeddable(x.root()))); Type(x.root())));
}else{ }else{
return CGAL_NTS to_double(x.a0()); return CGAL_NTS to_double(x.a0());
} }
@ -737,7 +737,7 @@ class Real_embeddable_traits< Sqrt_extension<COEFF, ROOT> >
// ############## initializing for NT_traits_comparable_base // ############## initializing for NT_traits_comparable_base
/*template <class EXT, class TYPETAG> /*template <class EXT, class TypeTAG>
class Sqrt_ext_NTtr_comp_base; class Sqrt_ext_NTtr_comp_base;
template <class NT, class ROOT > template <class NT, class ROOT >
@ -1036,13 +1036,13 @@ Extension to_Sqrt_extension(AlgebraicReal x, bool simplify_radicant = false) {
switch (p.degree()) { switch (p.degree()) {
case 2: { case 2: {
typedef NiX::Coercion_traits< NT, Coefficient > CT; typedef NiX::Coercion_traits< NT, Coefficient > CT;
typedef typename CT::Coercion_type Coercion_type; typedef typename CT::Type Type;
typename CGAL::Algebraic_structure_traits<Coercion_type>::Integral_div idiv; typename CGAL::Algebraic_structure_traits<Type>::Integral_div idiv;
typename CT::Cast cast; typename CT::Cast cast;
Coercion_type den(Coercion_type(2) * cast(p[2])); Type den(Type(2) * cast(p[2]));
NiX_assert(NiX::sign(den) == CGAL::POSITIVE); NiX_assert(NiX::sign(den) == CGAL::POSITIVE);
Coercion_type mid = idiv(cast(-p[1]), den); Type mid = idiv(cast(-p[1]), den);
NiX::simplify(mid); NiX::simplify(mid);
ROOT rad = p[1]*p[1] - ROOT(4)*p[0]*p[2]; ROOT rad = p[1]*p[1] - ROOT(4)*p[0]*p[2];
NiX_assert(rad != ROOT(0)); // double root of algebraic real polynomial NiX_assert(rad != ROOT(0)); // double root of algebraic real polynomial
@ -1052,7 +1052,7 @@ Extension to_Sqrt_extension(AlgebraicReal x, bool simplify_radicant = false) {
typename CGAL::Algebraic_structure_traits< ROOT >::Sqrt isqrt; typename CGAL::Algebraic_structure_traits< ROOT >::Sqrt isqrt;
ROOT root = isqrt(rad); ROOT root = isqrt(rad);
if (root * root == rad) { if (root * root == rad) {
Coercion_type c = idiv(f, den); Type c = idiv(f, den);
switch (x.compare(mid)) { switch (x.compare(mid)) {
case CGAL::LARGER: break; case CGAL::LARGER: break;
case CGAL::SMALLER: c = -c; break; case CGAL::SMALLER: c = -c; break;
@ -1075,7 +1075,7 @@ Extension to_Sqrt_extension(AlgebraicReal x, bool simplify_radicant = false) {
i += 1; i += 1;
} }
} }
Coercion_type c = idiv(f, den); Type c = idiv(f, den);
switch (x.compare(mid)) { switch (x.compare(mid)) {
case CGAL::LARGER: break; case CGAL::LARGER: break;
case CGAL::SMALLER: c = -c; break; case CGAL::SMALLER: c = -c; break;
@ -1163,7 +1163,7 @@ public:
//################################# NiX::Fraction_traits ################## //################################# NiX::Fraction_traits ##################
// Select the right alternative as Fraction_traits // Select the right alternative as Fraction_traits
// The actual Fraction traits is Inter::Sqrt_ext_Ftr_base_2 // The actual Type traits is Inter::Sqrt_ext_Ftr_base_2
// The selction is done in two steps: // The selction is done in two steps:
// 1. Inter::Sqrt_ext_Ftr_base_1 selects by the BOOL_TAG whether the COEFF type // 1. Inter::Sqrt_ext_Ftr_base_1 selects by the BOOL_TAG whether the COEFF type
// Is_decomposable // Is_decomposable
@ -1284,7 +1284,7 @@ template <class COEFF, class ROOT_NT>
class Sqrt_ext_Ftr_base_1< Sqrt_extension<COEFF,ROOT_NT >, CGAL::Tag_true > class Sqrt_ext_Ftr_base_1< Sqrt_extension<COEFF,ROOT_NT >, CGAL::Tag_true >
: public Sqrt_ext_Ftr_base_2< : public Sqrt_ext_Ftr_base_2<
Sqrt_extension<COEFF,ROOT_NT >, Sqrt_extension<COEFF,ROOT_NT >,
::boost::is_same< typename NiX::Coercion_traits<ROOT_NT,typename NiX::Fraction_traits<COEFF>::Numerator>::Coercion_type, ::boost::is_same< typename NiX::Coercion_traits<ROOT_NT,typename NiX::Fraction_traits<COEFF>::Numerator>::Type,
typename NiX::Fraction_traits<COEFF>::Numerator>::value > typename NiX::Fraction_traits<COEFF>::Numerator>::value >
{ {
//nothing new //nothing new
@ -1307,7 +1307,7 @@ namespace Intern{
typedef SqrtExt Numerator; typedef SqrtExt Numerator;
typedef ::CGAL::Tag_false Is_composable; typedef ::CGAL::Tag_false Is_composable;
typedef ::LiS::Null_tag Denominator; typedef ::LiS::Null_tag Denominator;
typedef ::LiS::Null_tag Fraction; typedef ::LiS::Null_tag Type;
typedef ::LiS::Null_tag Compose; typedef ::LiS::Null_tag Compose;
}; };
template <class SqrtExt> template <class SqrtExt>
@ -1315,13 +1315,13 @@ namespace Intern{
typedef typename SqrtExt::NT Coeff; typedef typename SqrtExt::NT Coeff;
typedef typename SqrtExt::ROOT Root; typedef typename SqrtExt::ROOT Root;
typedef typename NiX::Cofraction_traits<Coeff> CFT; typedef typename NiX::Cofraction_traits<Coeff> CFT;
typedef typename CFT::Fraction Fraction_coeff; typedef typename CFT::Type Type_coeff;
public: public:
typedef SqrtExt Numerator; typedef SqrtExt Numerator;
typedef ::CGAL::Tag_true Is_composable; typedef ::CGAL::Tag_true Is_composable;
typedef typename CFT::Denominator Denominator; typedef typename CFT::Denominator Denominator;
typedef NiX::Sqrt_extension<Fraction_coeff,Root> Fraction; typedef NiX::Sqrt_extension<Type_coeff,Root> Type;
class Compose { class Compose {
public: public:
@ -1330,14 +1330,14 @@ namespace Intern{
//! second argument type //! second argument type
typedef Denominator second_argument_type; typedef Denominator second_argument_type;
//! result type //! result type
typedef Fraction result_type; typedef Type result_type;
//! Compose fraction //! Compose fraction
Fraction operator() (Numerator num, Type operator() (Numerator num,
Denominator den){ Denominator den){
if(num.is_extended()){ if(num.is_extended()){
typename CFT::Compose compose_coeff; typename CFT::Compose compose_coeff;
Fraction_coeff a0_new(compose_coeff(num.a0(),den)); Type_coeff a0_new(compose_coeff(num.a0(),den));
Fraction_coeff a1_new(compose_coeff(num.a1(),den)); Type_coeff a1_new(compose_coeff(num.a1(),den));
return result_type(a0_new, a1_new, num.root()); return result_type(a0_new, a1_new, num.root());
}else{ }else{
typename CFT::Compose compose_coeff; typename CFT::Compose compose_coeff;
@ -1386,7 +1386,7 @@ public:
typedef Arithmetic_traits Base; typedef Arithmetic_traits Base;
// load the typedefs from the base class // load the typedefs from the base class
NiX_SNAP_ARITHMETIC_TRAITS_TYPEDEFS(Arithmetic_traits); NiX_SNAP_ARITHMETIC_TRAITS_TypeDEFS(Arithmetic_traits);
//! a number with one root //! a number with one root
typedef NiX::Sqrt_extension< Extn_NT, Extn_root_NT > Extn; typedef NiX::Sqrt_extension< Extn_NT, Extn_root_NT > Extn;
@ -1448,14 +1448,14 @@ private:
public: public:
typedef CGAL::Tag_true Are_explicit_interoperable; typedef CGAL::Tag_true Are_explicit_interoperable;
typedef CGAL::Tag_false Are_implicit_interoperable; typedef CGAL::Tag_false Are_implicit_interoperable;
typedef Sqrt_extension<typename CT::Coercion_type, Root> Coercion_type; typedef Sqrt_extension<typename CT::Type, Root> Type;
struct Cast{ struct Cast{
private: private:
inline Coercion_type cast(const Coercion_type& x) const{ return x; } inline Type cast(const Type& x) const{ return x; }
template <class T> template <class T>
inline Coercion_type cast(const T& x) const{ inline Type cast(const T& x) const{
typename CT::Cast cast; typename CT::Cast cast;
if (x.is_extended()) { if (x.is_extended()) {
return result_type(cast(x.a0()),cast(x.a1()),x.root()); return result_type(cast(x.a0()),cast(x.a1()),x.root());
@ -1464,10 +1464,10 @@ public:
} }
} }
public: public:
typedef Coercion_type result_type; typedef Type result_type;
// this is in order to allow A and B only // this is in order to allow A and B only
Coercion_type operator()(const A& x) const { return cast(x);} Type operator()(const A& x) const { return cast(x);}
Coercion_type operator()(const B& x) const { return cast(x);} Type operator()(const B& x) const { return cast(x);}
}; };
}; };
@ -1483,12 +1483,12 @@ public:
typedef CGAL::Tag_true Are_explicit_interoperable; typedef CGAL::Tag_true Are_explicit_interoperable;
typedef CGAL::Tag_false Are_implicit_interoperable; typedef CGAL::Tag_false Are_implicit_interoperable;
// Coercion_type = A // Type = A
typedef Sqrt_extension<Sqrt_extension<Coeff,Root_1>, Root_2> Coercion_type; typedef Sqrt_extension<Sqrt_extension<Coeff,Root_1>, Root_2> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
Coercion_type operator()(const A& x) const { return x;} Type operator()(const A& x) const { return x;}
Coercion_type operator()(const B& x) const { return Coercion_type(x);} Type operator()(const B& x) const { return Type(x);}
}; };
}; };
@ -1518,11 +1518,11 @@ public:
typedef CGAL::Tag_true Are_explicit_interoperable; typedef CGAL::Tag_true Are_explicit_interoperable;
typedef CGAL::Tag_false Are_implicit_interoperable; typedef CGAL::Tag_false Are_implicit_interoperable;
typedef Sqrt_extension<Sqrt_extension<Coeff,Root_1>, Root_1> Coercion_type; typedef Sqrt_extension<Sqrt_extension<Coeff,Root_1>, Root_1> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
Coercion_type operator()(const A& x) const { return x;} Type operator()(const A& x) const { return x;}
Coercion_type operator()(const B& x) const { return Coercion_type(x);} Type operator()(const B& x) const { return Type(x);}
}; };
}; };
@ -1587,17 +1587,17 @@ public:
typedef CGAL::Tag_true Are_explicit_interoperable; typedef CGAL::Tag_true Are_explicit_interoperable;
typedef CGAL::Tag_false Are_implicit_interoperable; typedef CGAL::Tag_false Are_implicit_interoperable;
typedef FieldWithSqrt Coercion_type; typedef FieldWithSqrt Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
Coercion_type operator()(const A& x) const { Type operator()(const A& x) const {
typedef Coercion_traits<Coeff,FieldWithSqrt> CT_coeff; typedef Coercion_traits<Coeff,FieldWithSqrt> CT_coeff;
typedef Coercion_traits<Root ,FieldWithSqrt> CT_root; typedef Coercion_traits<Root ,FieldWithSqrt> CT_root;
typename CT_coeff::Cast coeff_cast; typename CT_coeff::Cast coeff_cast;
typename CT_root::Cast root_cast; typename CT_root::Cast root_cast;
if (x.is_extended()) { if (x.is_extended()) {
typename CGAL::Algebraic_structure_traits< typename CGAL::Algebraic_structure_traits<
typename CT_root::Coercion_type>::Sqrt sqrt; typename CT_root::Type>::Sqrt sqrt;
return // a0+a1*sqrt(root) return // a0+a1*sqrt(root)
coeff_cast(x.a0())+ coeff_cast(x.a0())+
coeff_cast(x.a1())* coeff_cast(x.a1())*
@ -1606,7 +1606,7 @@ public:
return coeff_cast(x.a0()); return coeff_cast(x.a0());
} }
} }
Coercion_type operator()(const B& x) const { return x;} Type operator()(const B& x) const { return x;}
}; };
}; };
@ -1620,20 +1620,20 @@ private:
public: public:
typedef CGAL::Tag_true Are_explicit_interoperable; typedef CGAL::Tag_true Are_explicit_interoperable;
typedef CGAL::Tag_false Are_implicit_interoperable; typedef CGAL::Tag_false Are_implicit_interoperable;
typedef Sqrt_extension<typename CT::Coercion_type,Root> Coercion_type; typedef Sqrt_extension<typename CT::Type,Root> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
Coercion_type operator()(const A& x) const { Type operator()(const A& x) const {
typename CT::Cast cast; typename CT::Cast cast;
if (x.is_extended()) { if (x.is_extended()) {
return Coercion_type(cast(x.a0()),cast(x.a1()),x.root()); return Type(cast(x.a0()),cast(x.a1()),x.root());
} else { } else {
return Coercion_type(cast(x.a0())); return Type(cast(x.a0()));
} }
} }
Coercion_type operator()(const B& x) const { Type operator()(const B& x) const {
typename CT::Cast cast; typename CT::Cast cast;
return Coercion_type(cast(x)); return Type(cast(x));
} }
}; };
}; };

View File

@ -140,18 +140,18 @@ template <> class Algebraic_structure_traits< double >
typedef Tag_false Is_exact; typedef Tag_false Is_exact;
class Sqrt class Sqrt
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return CGAL_CLIB_STD::sqrt( x ); return CGAL_CLIB_STD::sqrt( x );
} }
}; };
class Kth_root class Kth_root
: public Binary_function<int, Algebraic_structure, Algebraic_structure> { : public Binary_function<int, Type, Type> {
public: public:
Algebraic_structure operator()( int k, Type operator()( int k,
const Algebraic_structure& x) const { const Type& x) const {
CGAL_precondition_msg( k > 0, "'k' must be positive for k-th roots"); CGAL_precondition_msg( k > 0, "'k' must be positive for k-th roots");
return CGAL_CLIB_STD::pow(x, 1.0 / double(k)); return CGAL_CLIB_STD::pow(x, 1.0 / double(k));
} }
@ -166,25 +166,25 @@ template <> class Real_embeddable_traits< double >
// GCC is faster with std::fabs(). // GCC is faster with std::fabs().
#ifdef __GNUG__ #ifdef __GNUG__
class Abs class Abs
: public Unary_function< Real_embeddable, Real_embeddable > { : public Unary_function< Type, Type > {
public: public:
Real_embeddable operator()( const Real_embeddable& x ) const { Type operator()( const Type& x ) const {
return CGAL_CLIB_STD::fabs( x ); return CGAL_CLIB_STD::fabs( x );
} }
}; };
#endif #endif
typedef INTERN_RET::To_double_by_conversion< Real_embeddable > typedef INTERN_RET::To_double_by_conversion< Type >
To_double; To_double;
typedef INTERN_RET::To_interval_by_conversion< Real_embeddable > typedef INTERN_RET::To_interval_by_conversion< Type >
To_interval; To_interval;
// Is_finite depends on platform // Is_finite depends on platform
#ifdef __sgi #ifdef __sgi
class Is_finite class Is_finite
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public : public :
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
switch (fp_class_d(x)) { switch (fp_class_d(x)) {
case FP_POS_NORM: case FP_POS_NORM:
case FP_NEG_NORM: case FP_NEG_NORM:
@ -205,29 +205,29 @@ template <> class Real_embeddable_traits< double >
#elif defined CGAL_CFG_IEEE_754_BUG #elif defined CGAL_CFG_IEEE_754_BUG
class Is_finite class Is_finite
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public : public :
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
Real_embeddable d = x; Type d = x;
IEEE_754_double* p = reinterpret_cast<IEEE_754_double*>(&d); IEEE_754_double* p = reinterpret_cast<IEEE_754_double*>(&d);
return is_finite_by_mask_double( p->c.H ); return is_finite_by_mask_double( p->c.H );
} }
}; };
#elif defined CGAL_CFG_NUMERIC_LIMITS_BUG #elif defined CGAL_CFG_NUMERIC_LIMITS_BUG
class Is_finite class Is_finite
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public : public :
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
return (x == x) && (is_valid(x-x)); return (x == x) && (is_valid(x-x));
} }
}; };
#else #else
class Is_finite class Is_finite
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public : public :
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
return (x != std::numeric_limits<Real_embeddable>::infinity()) return (x != std::numeric_limits<Type>::infinity())
&& (-x != std::numeric_limits<Real_embeddable>::infinity()) && (-x != std::numeric_limits<Type>::infinity())
&& is_valid(x); && is_valid(x);
} }
}; };

View File

@ -116,18 +116,18 @@ template <> class Algebraic_structure_traits< float >
typedef Tag_false Is_exact; typedef Tag_false Is_exact;
class Sqrt class Sqrt
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return CGAL_CLIB_STD::sqrt( x ); return CGAL_CLIB_STD::sqrt( x );
} }
}; };
class Kth_root class Kth_root
: public Binary_function<int, Algebraic_structure, Algebraic_structure> { : public Binary_function<int, Type, Type> {
public: public:
Algebraic_structure operator()( int k, Type operator()( int k,
const Algebraic_structure& x) const { const Type& x) const {
CGAL_precondition_msg( k > 0, "'k' must be positive for k-th roots"); CGAL_precondition_msg( k > 0, "'k' must be positive for k-th roots");
return CGAL_CLIB_STD::pow(double(x), 1.0 / double(k)); return CGAL_CLIB_STD::pow(double(x), 1.0 / double(k));
}; };
@ -139,17 +139,17 @@ template <> class Real_embeddable_traits< float >
: public Real_embeddable_traits_base< float > { : public Real_embeddable_traits_base< float > {
public: public:
typedef INTERN_RET::To_double_by_conversion< Real_embeddable > typedef INTERN_RET::To_double_by_conversion< Type >
To_double; To_double;
typedef INTERN_RET::To_interval_by_conversion< Real_embeddable > typedef INTERN_RET::To_interval_by_conversion< Type >
To_interval; To_interval;
// Is_finite depends on platform // Is_finite depends on platform
#ifdef __sgi #ifdef __sgi
class Is_finite class Is_finite
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public: public:
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
switch (fp_class_f(x)) { switch (fp_class_f(x)) {
case FP_POS_NORM: case FP_POS_NORM:
case FP_NEG_NORM: case FP_NEG_NORM:
@ -171,19 +171,19 @@ template <> class Real_embeddable_traits< float >
#elif defined CGAL_CFG_IEEE_754_BUG #elif defined CGAL_CFG_IEEE_754_BUG
class Is_finite class Is_finite
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public: public:
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
Real_embeddable f = x; Type f = x;
IEEE_754_float* p = reinterpret_cast<IEEE_754_float*>(&f); IEEE_754_float* p = reinterpret_cast<IEEE_754_float*>(&f);
return is_finite_by_mask_float( p->c ); return is_finite_by_mask_float( p->c );
} }
}; };
#else #else
class Is_finite class Is_finite
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public: public:
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
return (x == x) && (is_valid(x-x)); return (x == x) && (is_valid(x-x));
} }
}; };

View File

@ -34,11 +34,11 @@ struct Coercion_traits<
::__gmp_expr< ::__gmpz_value , U>,::__gmp_expr< ::__gmpz_value , U> >{ ::__gmp_expr< ::__gmpz_value , U>,::__gmp_expr< ::__gmpz_value , U> >{
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_true Are_implicit_interoperable; typedef Tag_true Are_implicit_interoperable;
typedef ::__gmp_expr< ::__gmpz_value , ::__gmpz_value> Coercion_type; typedef ::__gmp_expr< ::__gmpz_value , ::__gmpz_value> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
template <class U3> template <class U3>
Coercion_type operator()(const ::__gmp_expr< ::__gmpz_value , U3>& x) const { Type operator()(const ::__gmp_expr< ::__gmpz_value , U3>& x) const {
return x; return x;
} }
}; };
@ -49,11 +49,11 @@ struct Coercion_traits<
::__gmp_expr< ::__gmpz_value , U1>,::__gmp_expr< ::__gmpz_value , U2> >{ ::__gmp_expr< ::__gmpz_value , U1>,::__gmp_expr< ::__gmpz_value , U2> >{
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_true Are_implicit_interoperable; typedef Tag_true Are_implicit_interoperable;
typedef ::__gmp_expr< ::__gmpz_value , ::__gmpz_value> Coercion_type; typedef ::__gmp_expr< ::__gmpz_value , ::__gmpz_value> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
template <class U3> template <class U3>
Coercion_type operator()(const ::__gmp_expr< ::__gmpz_value , U3>& x) const { Type operator()(const ::__gmp_expr< ::__gmpz_value , U3>& x) const {
return x; return x;
} }
}; };
@ -67,11 +67,11 @@ struct Coercion_traits<
::__gmp_expr< ::__gmpq_value , U>,::__gmp_expr< ::__gmpq_value , U> >{ ::__gmp_expr< ::__gmpq_value , U>,::__gmp_expr< ::__gmpq_value , U> >{
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_true Are_implicit_interoperable; typedef Tag_true Are_implicit_interoperable;
typedef ::__gmp_expr< ::__gmpq_value , ::__gmpq_value> Coercion_type; typedef ::__gmp_expr< ::__gmpq_value , ::__gmpq_value> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
template <class U3> template <class U3>
Coercion_type operator()(const ::__gmp_expr< ::__gmpq_value , U3>& x) const { Type operator()(const ::__gmp_expr< ::__gmpq_value , U3>& x) const {
return x; return x;
} }
}; };
@ -82,11 +82,11 @@ struct Coercion_traits<
::__gmp_expr< ::__gmpq_value , U1>,::__gmp_expr< ::__gmpq_value , U2> >{ ::__gmp_expr< ::__gmpq_value , U1>,::__gmp_expr< ::__gmpq_value , U2> >{
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_true Are_implicit_interoperable; typedef Tag_true Are_implicit_interoperable;
typedef ::__gmp_expr< ::__gmpq_value , ::__gmpq_value> Coercion_type; typedef ::__gmp_expr< ::__gmpq_value , ::__gmpq_value> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
template <class U3> template <class U3>
Coercion_type operator()(const ::__gmp_expr< ::__gmpq_value , U3>& x) const { Type operator()(const ::__gmp_expr< ::__gmpq_value , U3>& x) const {
return x; return x;
} }
}; };
@ -100,16 +100,16 @@ struct Coercion_traits<
::__gmp_expr< ::__gmpz_value , U1>,::__gmp_expr< ::__gmpq_value , U2> >{ ::__gmp_expr< ::__gmpz_value , U1>,::__gmp_expr< ::__gmpq_value , U2> >{
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_true Are_implicit_interoperable; typedef Tag_true Are_implicit_interoperable;
typedef ::__gmp_expr< ::__gmpq_value , ::__gmpq_value> Coercion_type; typedef ::__gmp_expr< ::__gmpq_value , ::__gmpq_value> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
template <class U3> template <class U3>
Coercion_type operator()(const ::__gmp_expr< ::__gmpq_value , U3>& x) const { Type operator()(const ::__gmp_expr< ::__gmpq_value , U3>& x) const {
return x; return x;
} }
template <class U3> template <class U3>
Coercion_type operator()(const ::__gmp_expr< ::__gmpz_value , U3>& x) const { Type operator()(const ::__gmp_expr< ::__gmpz_value , U3>& x) const {
return Coercion_type(x); return Type(x);
} }
}; };
}; };
@ -124,14 +124,14 @@ struct Coercion_traits<
::__gmp_expr< GMPX_VALUE , U1>, int >{ ::__gmp_expr< GMPX_VALUE , U1>, int >{
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_true Are_implicit_interoperable; typedef Tag_true Are_implicit_interoperable;
typedef ::__gmp_expr< GMPX_VALUE , GMPX_VALUE> Coercion_type; typedef ::__gmp_expr< GMPX_VALUE , GMPX_VALUE> Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
template <class U3> template <class U3>
Coercion_type operator()(const ::__gmp_expr< GMPX_VALUE , U3>& x) const { Type operator()(const ::__gmp_expr< GMPX_VALUE , U3>& x) const {
return x; return x;
} }
Coercion_type operator()(int x) const { return Coercion_type(x); } Type operator()(int x) const { return Type(x); }
}; };
}; };
// gmpz_class implicit interoperable with int // gmpz_class implicit interoperable with int

View File

@ -30,19 +30,19 @@
CGAL_BEGIN_NAMESPACE CGAL_BEGIN_NAMESPACE
namespace INTERN_INT { namespace INTERN_INT {
template< class Algebraic_structure > template< class Type >
class Is_square_per_double_conversion class Is_square_per_double_conversion
: public Binary_function< Algebraic_structure, Algebraic_structure&, : public Binary_function< Type, Type&,
bool > { bool > {
public: public:
bool operator()( const Algebraic_structure& x, bool operator()( const Type& x,
Algebraic_structure& y ) const { Type& y ) const {
y = (Algebraic_structure) CGAL_CLIB_STD::sqrt( (double)x ); y = (Type) CGAL_CLIB_STD::sqrt( (double)x );
return x == y * y; return x == y * y;
} }
bool operator()( const Algebraic_structure& x ) const { bool operator()( const Type& x ) const {
Algebraic_structure y = Type y =
(Algebraic_structure) CGAL_CLIB_STD::sqrt( (double)x ); (Type) CGAL_CLIB_STD::sqrt( (double)x );
return x == y * y; return x == y * y;
} }
@ -56,20 +56,20 @@ template<> class Algebraic_structure_traits< int >
public: public:
typedef Tag_true Is_exact; typedef Tag_true Is_exact;
typedef INTERN_AST::Div_per_operator< Algebraic_structure > Div; typedef INTERN_AST::Div_per_operator< Type > Div;
typedef INTERN_AST::Mod_per_operator< Algebraic_structure > Mod; typedef INTERN_AST::Mod_per_operator< Type > Mod;
typedef INTERN_INT:: typedef INTERN_INT::
Is_square_per_double_conversion< Algebraic_structure > Is_square; Is_square_per_double_conversion< Type > Is_square;
}; };
template <> class Real_embeddable_traits< int > template <> class Real_embeddable_traits< int >
: public Real_embeddable_traits_base< int > { : public Real_embeddable_traits_base< int > {
public: public:
typedef INTERN_RET::To_double_by_conversion< Real_embeddable > typedef INTERN_RET::To_double_by_conversion< Type >
To_double; To_double;
typedef INTERN_RET::To_interval_by_conversion< Real_embeddable > typedef INTERN_RET::To_interval_by_conversion< Type >
To_interval; To_interval;
}; };
@ -82,20 +82,20 @@ template<> class Algebraic_structure_traits< long int >
public: public:
typedef Tag_true Is_exact; typedef Tag_true Is_exact;
typedef INTERN_AST::Div_per_operator< Algebraic_structure > Div; typedef INTERN_AST::Div_per_operator< Type > Div;
typedef INTERN_AST::Mod_per_operator< Algebraic_structure > Mod; typedef INTERN_AST::Mod_per_operator< Type > Mod;
typedef INTERN_INT:: typedef INTERN_INT::
Is_square_per_double_conversion< Algebraic_structure > Is_square; Is_square_per_double_conversion< Type > Is_square;
}; };
template <> class Real_embeddable_traits< long int > template <> class Real_embeddable_traits< long int >
: public Real_embeddable_traits_base< long int > { : public Real_embeddable_traits_base< long int > {
public: public:
typedef INTERN_RET::To_double_by_conversion< Real_embeddable > typedef INTERN_RET::To_double_by_conversion< Type >
To_double; To_double;
typedef INTERN_RET::To_interval_by_conversion< Real_embeddable > typedef INTERN_RET::To_interval_by_conversion< Type >
To_interval; To_interval;
}; };
@ -112,12 +112,12 @@ template<> class Algebraic_structure_traits< short int >
// interoperability. This is nescessary because of the implicit conversion // interoperability. This is nescessary because of the implicit conversion
// to int for binary operations between short ints. // to int for binary operations between short ints.
class Integral_division class Integral_division
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y) const { const Type& y) const {
Algebraic_structure_traits<Algebraic_structure>::Div actual_div; Algebraic_structure_traits<Type>::Div actual_div;
CGAL_precondition_msg( actual_div( x, y) * y == x, CGAL_precondition_msg( actual_div( x, y) * y == x,
"'x' must be divisible by 'y' in " "'x' must be divisible by 'y' in "
"Algebraic_structure_traits<...>::Integral_div()(x,y)" ); "Algebraic_structure_traits<...>::Integral_div()(x,y)" );
@ -126,58 +126,58 @@ template<> class Algebraic_structure_traits< short int >
}; };
class Gcd class Gcd
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y) const { const Type& y) const {
Algebraic_structure_traits<Algebraic_structure>::Mod mod; Algebraic_structure_traits<Type>::Mod mod;
Algebraic_structure_traits<Algebraic_structure>::Unit_part unit_part; Algebraic_structure_traits<Type>::Unit_part unit_part;
Algebraic_structure_traits<Algebraic_structure>::Integral_division integral_div; Algebraic_structure_traits<Type>::Integral_division integral_div;
// First: the extreme cases and negative sign corrections. // First: the extreme cases and negative sign corrections.
if (x == Algebraic_structure(0)) { if (x == Type(0)) {
if (y == Algebraic_structure(0)) if (y == Type(0))
return Algebraic_structure(0); return Type(0);
return integral_div( y, unit_part(y) ); return integral_div( y, unit_part(y) );
} }
if (y == Algebraic_structure(0)) if (y == Type(0))
return integral_div(x, unit_part(x) ); return integral_div(x, unit_part(x) );
Algebraic_structure u = integral_div( x, unit_part(x) ); Type u = integral_div( x, unit_part(x) );
Algebraic_structure v = integral_div( y, unit_part(y) ); Type v = integral_div( y, unit_part(y) );
// Second: assuming mod is the most expensive op here, we don't compute it // Second: assuming mod is the most expensive op here, we don't compute it
// unnecessarily if u < v // unnecessarily if u < v
if (u < v) { if (u < v) {
v = mod(v,u); v = mod(v,u);
// maintain invariant of v > 0 for the loop below // maintain invariant of v > 0 for the loop below
if ( v == Algebraic_structure(0) ) if ( v == Type(0) )
return u; return u;
} }
Algebraic_structure w; Type w;
do { do {
w = mod(u,v); w = mod(u,v);
if ( w == Algebraic_structure(0)) if ( w == Type(0))
return v; return v;
u = mod(v,w); u = mod(v,w);
if ( u == Algebraic_structure(0)) if ( u == Type(0))
return w; return w;
v = mod(w,u); v = mod(w,u);
} while (v != Algebraic_structure(0)); } while (v != Type(0));
return u; return u;
} }
}; };
class Div_mod { class Div_mod {
public: public:
typedef Algebraic_structure first_argument_type; typedef Type first_argument_type;
typedef Algebraic_structure second_argument_type; typedef Type second_argument_type;
typedef Algebraic_structure& third_argument_type; typedef Type& third_argument_type;
typedef Algebraic_structure& fourth_argument_type; typedef Type& fourth_argument_type;
typedef Arity_tag< 4 > Arity; typedef Arity_tag< 4 > Arity;
typedef void result_type; typedef void result_type;
void operator()( const Algebraic_structure& x, void operator()( const Type& x,
const Algebraic_structure& y, const Type& y,
Algebraic_structure& q, Algebraic_structure& r) const { Type& q, Type& r) const {
q = x / y; q = x / y;
r = x % y; r = x % y;
return; return;
@ -186,37 +186,37 @@ template<> class Algebraic_structure_traits< short int >
// based on \c Div_mod. // based on \c Div_mod.
class Div class Div
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y) const { const Type& y) const {
return x / y; return x / y;
}; };
}; };
// based on \c Div_mod. // based on \c Div_mod.
class Mod class Mod
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y) const { const Type& y) const {
return x % y; return x % y;
}; };
}; };
typedef INTERN_INT:: typedef INTERN_INT::
Is_square_per_double_conversion< Algebraic_structure > Is_square; Is_square_per_double_conversion< Type > Is_square;
}; };
template <> class Real_embeddable_traits< short int > template <> class Real_embeddable_traits< short int >
: public Real_embeddable_traits_base< short int > { : public Real_embeddable_traits_base< short int > {
public: public:
typedef INTERN_RET::To_double_by_conversion< Real_embeddable > typedef INTERN_RET::To_double_by_conversion< Type >
To_double; To_double;
typedef INTERN_RET::To_interval_by_conversion< Real_embeddable > typedef INTERN_RET::To_interval_by_conversion< Type >
To_interval; To_interval;
}; };

View File

@ -51,18 +51,18 @@ template <> class Algebraic_structure_traits< leda_bigfloat >
typedef Tag_false Is_exact; typedef Tag_false Is_exact;
class Sqrt class Sqrt
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return CGAL_LEDA_SCOPE::sqrt( x ); return CGAL_LEDA_SCOPE::sqrt( x );
} }
}; };
class Kth_root class Kth_root
: public Binary_function<int, Algebraic_structure, Algebraic_structure> { : public Binary_function<int, Type, Type> {
public: public:
Algebraic_structure operator()( int k, Type operator()( int k,
const Algebraic_structure& x) const { const Type& x) const {
CGAL_precondition_msg(k > 0, "'k' must be positive for k-th roots"); CGAL_precondition_msg(k > 0, "'k' must be positive for k-th roots");
// heuristic: we ask for as many precision as the argument has // heuristic: we ask for as many precision as the argument has
long d = x.get_significant_length(); long d = x.get_significant_length();
@ -79,43 +79,43 @@ template <> class Real_embeddable_traits< leda_bigfloat >
public: public:
class Abs class Abs
: public Unary_function< Real_embeddable, Real_embeddable > { : public Unary_function< Type, Type > {
public: public:
Real_embeddable operator()( const Real_embeddable& x ) const { Type operator()( const Type& x ) const {
return CGAL_LEDA_SCOPE::abs( x ); return CGAL_LEDA_SCOPE::abs( x );
} }
}; };
class Sign class Sign
: public Unary_function< Real_embeddable, ::CGAL::Sign > { : public Unary_function< Type, ::CGAL::Sign > {
public: public:
::CGAL::Sign operator()( const Real_embeddable& x ) const { ::CGAL::Sign operator()( const Type& x ) const {
return (::CGAL::Sign) CGAL_LEDA_SCOPE::sign( x ); return (::CGAL::Sign) CGAL_LEDA_SCOPE::sign( x );
} }
}; };
class Compare class Compare
: public Binary_function< Real_embeddable, Real_embeddable, : public Binary_function< Type, Type,
Comparison_result > { Comparison_result > {
public: public:
Comparison_result operator()( const Real_embeddable& x, Comparison_result operator()( const Type& x,
const Real_embeddable& y ) const { const Type& y ) const {
return (Comparison_result) CGAL_LEDA_SCOPE::compare( x, y ); return (Comparison_result) CGAL_LEDA_SCOPE::compare( x, y );
} }
}; };
class To_double class To_double
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
double operator()( const Real_embeddable& x ) const { double operator()( const Type& x ) const {
return x.to_double(); return x.to_double();
} }
}; };
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
// assuming leda_bigfloat guarantee 1 bit error max // assuming leda_bigfloat guarantee 1 bit error max
Protect_FPU_rounding<true> P (CGAL_FE_TONEAREST); Protect_FPU_rounding<true> P (CGAL_FE_TONEAREST);
@ -127,9 +127,9 @@ template <> class Real_embeddable_traits< leda_bigfloat >
}; };
class Is_finite class Is_finite
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public: public:
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
return !( CGAL_LEDA_SCOPE::isInf(x) || CGAL_LEDA_SCOPE::isNaN(x) ); return !( CGAL_LEDA_SCOPE::isInf(x) || CGAL_LEDA_SCOPE::isNaN(x) );
} }
}; };

View File

@ -93,11 +93,11 @@ template <>
struct Coercion_traits< ::leda::bigfloat ,::leda::rational >{ struct Coercion_traits< ::leda::bigfloat ,::leda::rational >{
typedef Tag_true Are_explicit_interoperable; typedef Tag_true Are_explicit_interoperable;
typedef Tag_false Are_implicit_interoperable; typedef Tag_false Are_implicit_interoperable;
typedef ::leda::rational Coercion_type; typedef ::leda::rational Type;
struct Cast{ struct Cast{
typedef Coercion_type result_type; typedef Type result_type;
Coercion_type operator()(const ::leda::rational& x) const { return x;} Type operator()(const ::leda::rational& x) const { return x;}
Coercion_type operator()(const ::leda::bigfloat& x) const { Type operator()(const ::leda::bigfloat& x) const {
#if CGAL_LEDA_VERSION < 500 #if CGAL_LEDA_VERSION < 500
::leda::integer e = x.get_exponent(); ::leda::integer e = x.get_exponent();
::leda::integer s = x.get_significant(); ::leda::integer s = x.get_significant();

View File

@ -48,34 +48,34 @@ template <> class Algebraic_structure_traits< leda_integer >
public: public:
typedef Tag_true Is_exact; typedef Tag_true Is_exact;
typedef INTERN_AST::Is_square_per_sqrt< Algebraic_structure > typedef INTERN_AST::Is_square_per_sqrt< Type >
Is_square; Is_square;
class Gcd class Gcd
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y ) const { const Type& y ) const {
// By definition gcd(0,0) == 0 // By definition gcd(0,0) == 0
if( x == Algebraic_structure(0) && y == Algebraic_structure(0) ) if( x == Type(0) && y == Type(0) )
return Algebraic_structure(0); return Type(0);
return CGAL_LEDA_SCOPE::gcd( x, y ); return CGAL_LEDA_SCOPE::gcd( x, y );
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Algebraic_structure ) CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Type )
}; };
typedef INTERN_AST::Div_per_operator< Algebraic_structure > Div; typedef INTERN_AST::Div_per_operator< Type > Div;
class Mod class Mod
: public Binary_function< Algebraic_structure, Algebraic_structure, : public Binary_function< Type, Type,
Algebraic_structure > { Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x, Type operator()( const Type& x,
const Algebraic_structure& y ) const { const Type& y ) const {
Algebraic_structure m = x % y; Type m = x % y;
// Fix wrong lede result if first operand is negative // Fix wrong lede result if first operand is negative
if( x < 0 && m != 0 ) if( x < 0 && m != 0 )
@ -84,13 +84,13 @@ template <> class Algebraic_structure_traits< leda_integer >
return m; return m;
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Algebraic_structure ) CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Type )
}; };
class Sqrt class Sqrt
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return CGAL_LEDA_SCOPE::sqrt( x ); return CGAL_LEDA_SCOPE::sqrt( x );
} }
}; };
@ -101,44 +101,44 @@ template <> class Real_embeddable_traits< leda_integer >
public: public:
class Abs class Abs
: public Unary_function< Real_embeddable, Real_embeddable > { : public Unary_function< Type, Type > {
public: public:
Real_embeddable operator()( const Real_embeddable& x ) const { Type operator()( const Type& x ) const {
return CGAL_LEDA_SCOPE::abs( x ); return CGAL_LEDA_SCOPE::abs( x );
} }
}; };
class Sign class Sign
: public Unary_function< Real_embeddable, ::CGAL::Sign > { : public Unary_function< Type, ::CGAL::Sign > {
public: public:
::CGAL::Sign operator()( const Real_embeddable& x ) const { ::CGAL::Sign operator()( const Type& x ) const {
return (::CGAL::Sign) CGAL_LEDA_SCOPE::sign( x ); return (::CGAL::Sign) CGAL_LEDA_SCOPE::sign( x );
} }
}; };
class Compare class Compare
: public Binary_function< Real_embeddable, Real_embeddable, : public Binary_function< Type, Type,
Comparison_result > { Comparison_result > {
public: public:
Comparison_result operator()( const Real_embeddable& x, Comparison_result operator()( const Type& x,
const Real_embeddable& y ) const { const Type& y ) const {
return (Comparison_result) CGAL_LEDA_SCOPE::compare( x, y ); return (Comparison_result) CGAL_LEDA_SCOPE::compare( x, y );
} }
}; };
class To_double class To_double
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
double operator()( const Real_embeddable& x ) const { double operator()( const Type& x ) const {
return x.to_double(); return x.to_double();
} }
}; };
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
Protect_FPU_rounding<true> P (CGAL_FE_TONEAREST); Protect_FPU_rounding<true> P (CGAL_FE_TONEAREST);
double cn = CGAL_NTS to_double(x); double cn = CGAL_NTS to_double(x);

View File

@ -53,13 +53,13 @@ template <> class Algebraic_structure_traits< leda_rational >
typedef Tag_true Is_exact; typedef Tag_true Is_exact;
// TODO: How to implement this without having sqrt? // TODO: How to implement this without having sqrt?
// typedef INTERN_AST::Is_square_per_sqrt< Algebraic_structure > // typedef INTERN_AST::Is_square_per_sqrt< Type >
// Is_square; // Is_square;
class Simplify class Simplify
: public Unary_function< Algebraic_structure&, void > { : public Unary_function< Type&, void > {
public: public:
void operator()( Algebraic_structure& x) const { void operator()( Type& x) const {
x.normalize(); x.normalize();
} }
}; };
@ -71,50 +71,50 @@ template <> class Real_embeddable_traits< leda_rational >
public: public:
class Abs class Abs
: public Unary_function< Real_embeddable, Real_embeddable > { : public Unary_function< Type, Type > {
public: public:
Real_embeddable operator()( const Real_embeddable& x ) const { Type operator()( const Type& x ) const {
return CGAL_LEDA_SCOPE::abs( x ); return CGAL_LEDA_SCOPE::abs( x );
} }
}; };
class Sign class Sign
: public Unary_function< Real_embeddable, ::CGAL::Sign > { : public Unary_function< Type, ::CGAL::Sign > {
public: public:
::CGAL::Sign operator()( const Real_embeddable& x ) const { ::CGAL::Sign operator()( const Type& x ) const {
return (::CGAL::Sign) CGAL_LEDA_SCOPE::sign( x ); return (::CGAL::Sign) CGAL_LEDA_SCOPE::sign( x );
} }
}; };
class Compare class Compare
: public Binary_function< Real_embeddable, Real_embeddable, : public Binary_function< Type, Type,
Comparison_result > { Comparison_result > {
public: public:
Comparison_result operator()( const Real_embeddable& x, Comparison_result operator()( const Type& x,
const Real_embeddable& y ) const { const Type& y ) const {
return (Comparison_result) CGAL_LEDA_SCOPE::compare( x, y ); return (Comparison_result) CGAL_LEDA_SCOPE::compare( x, y );
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT(Real_embeddable,Comparison_result); CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT(Type,Comparison_result);
}; };
class To_double class To_double
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
double operator()( const Real_embeddable& x ) const { double operator()( const Type& x ) const {
return x.to_double(); return x.to_double();
} }
}; };
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
#if CGAL_LEDA_VERSION >= 501 #if CGAL_LEDA_VERSION >= 501
CGAL_LEDA_SCOPE::interval temp(x); CGAL_LEDA_SCOPE::interval temp(x);
std::pair<double, double> result(temp.lower_bound(),temp.upper_bound()); std::pair<double, double> result(temp.lower_bound(),temp.upper_bound());
CGAL_postcondition(Real_embeddable(result.first)<=x); CGAL_postcondition(Type(result.first)<=x);
CGAL_postcondition(Real_embeddable(result.second)>=x); CGAL_postcondition(Type(result.second)>=x);
return result; return result;
#else #else
CGAL_LEDA_SCOPE::bigfloat xnum = x.numerator(); CGAL_LEDA_SCOPE::bigfloat xnum = x.numerator();
@ -128,14 +128,14 @@ template <> class Real_embeddable_traits< leda_rational >
double MinDbl = CGAL_LEDA_SCOPE::fp::compose_parts(0,0,0,1); double MinDbl = CGAL_LEDA_SCOPE::fp::compose_parts(0,0,0,1);
double low = xlow.to_double(); double low = xlow.to_double();
while(Real_embeddable(low) > x) low = low - MinDbl; while(Type(low) > x) low = low - MinDbl;
double upp = xupp.to_double(); double upp = xupp.to_double();
while(Real_embeddable(upp) < x) upp = upp + MinDbl; while(Type(upp) < x) upp = upp + MinDbl;
std::pair<double, double> result(low,upp); std::pair<double, double> result(low,upp);
CGAL_postcondition(Real_embeddable(result.first)<=x); CGAL_postcondition(Type(result.first)<=x);
CGAL_postcondition(Real_embeddable(result.second)>=x); CGAL_postcondition(Type(result.second)>=x);
return result; return result;
#endif #endif
// Original CGAL to_interval (seemed to be inferior) // Original CGAL to_interval (seemed to be inferior)
@ -160,7 +160,7 @@ template <> class Real_embeddable_traits< leda_rational >
template <> template <>
class Fraction_traits< leda_rational > { class Fraction_traits< leda_rational > {
public: public:
typedef leda_rational Fraction; typedef leda_rational Type;
typedef ::CGAL::Tag_true Is_fraction; typedef ::CGAL::Tag_true Is_fraction;
typedef leda_integer Numerator; typedef leda_integer Numerator;
typedef Numerator Denominator; typedef Numerator Denominator;
@ -169,11 +169,11 @@ public:
class Decompose { class Decompose {
public: public:
typedef Fraction first_argument_type; typedef Type first_argument_type;
typedef Numerator& second_argument_type; typedef Numerator& second_argument_type;
typedef Numerator& third_argument_type; typedef Numerator& third_argument_type;
void operator () ( void operator () (
const Fraction& rat, const Type& rat,
Numerator& num, Numerator& num,
Numerator& den) { Numerator& den) {
num = rat.numerator(); num = rat.numerator();
@ -185,11 +185,11 @@ public:
public: public:
typedef Numerator first_argument_type; typedef Numerator first_argument_type;
typedef Numerator second_argument_type; typedef Numerator second_argument_type;
typedef Fraction result_type; typedef Type result_type;
Fraction operator ()( Type operator ()(
const Numerator& num , const Numerator& num ,
const Numerator& den ) { const Numerator& den ) {
Fraction result(num, den); Type result(num, den);
result.normalize(); result.normalize();
return result; return result;
} }

View File

@ -56,18 +56,18 @@ template <> class Algebraic_structure_traits< leda_real >
typedef Tag_true Is_exact; typedef Tag_true Is_exact;
class Sqrt class Sqrt
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return CGAL_LEDA_SCOPE::sqrt( x ); return CGAL_LEDA_SCOPE::sqrt( x );
} }
}; };
class Kth_root class Kth_root
: public Binary_function<int, Algebraic_structure, Algebraic_structure> { : public Binary_function<int, Type, Type> {
public: public:
Algebraic_structure operator()( int k, Type operator()( int k,
const Algebraic_structure& x) const { const Type& x) const {
CGAL_precondition_msg(k > 0, "'k' must be positive for k-th roots"); CGAL_precondition_msg(k > 0, "'k' must be positive for k-th roots");
return CGAL_LEDA_SCOPE::root( x, k); return CGAL_LEDA_SCOPE::root( x, k);
} }
@ -77,30 +77,30 @@ template <> class Algebraic_structure_traits< leda_real >
#if CGAL_LEDA_VERSION >= 500 #if CGAL_LEDA_VERSION >= 500
class Root_of { class Root_of {
public: public:
typedef Algebraic_structure result_type; typedef Type result_type;
typedef Arity_tag< 3 > Arity; typedef Arity_tag< 3 > Arity;
// typedef leda_rational Boundary; // typedef leda_rational Boundary;
private: private:
template< class ForwardIterator > template< class ForwardIterator >
inline inline
CGAL_LEDA_SCOPE::polynomial<Algebraic_structure> CGAL_LEDA_SCOPE::polynomial<Type>
make_polynomial(ForwardIterator begin, make_polynomial(ForwardIterator begin,
ForwardIterator end) const { ForwardIterator end) const {
CGAL_LEDA_SCOPE::growing_array<Algebraic_structure> coeffs; CGAL_LEDA_SCOPE::growing_array<Type> coeffs;
for(ForwardIterator it = begin; it < end; it++) for(ForwardIterator it = begin; it < end; it++)
coeffs.push_back(*it); coeffs.push_back(*it);
return CGAL_LEDA_SCOPE::polynomial<Algebraic_structure>(coeffs); return CGAL_LEDA_SCOPE::polynomial<Type>(coeffs);
} }
public: public:
template <class ForwardIterator> template <class ForwardIterator>
Algebraic_structure operator()( int k, Type operator()( int k,
ForwardIterator begin, ForwardIterator begin,
ForwardIterator end) const { ForwardIterator end) const {
return CGAL_LEDA_SCOPE::diamond(k,make_polynomial(begin,end)); return CGAL_LEDA_SCOPE::diamond(k,make_polynomial(begin,end));
}; };
/* template <class ForwardIterator> /* template <class ForwardIterator>
Algebraic_structure operator()( leda_rational lower, Type operator()( leda_rational lower,
leda_rational upper, leda_rational upper,
ForwardIterator begin, ForwardIterator begin,
ForwardIterator end) const { ForwardIterator end) const {
@ -119,39 +119,39 @@ template <> class Real_embeddable_traits< leda_real >
public: public:
class Abs class Abs
: public Unary_function< Real_embeddable, Real_embeddable > { : public Unary_function< Type, Type > {
public: public:
Real_embeddable operator()( const Real_embeddable& x ) const { Type operator()( const Type& x ) const {
return CGAL_LEDA_SCOPE::abs( x ); return CGAL_LEDA_SCOPE::abs( x );
} }
}; };
class Sign class Sign
: public Unary_function< Real_embeddable, ::CGAL::Sign > { : public Unary_function< Type, ::CGAL::Sign > {
public: public:
::CGAL::Sign operator()( const Real_embeddable& x ) const { ::CGAL::Sign operator()( const Type& x ) const {
return (::CGAL::Sign) CGAL_LEDA_SCOPE::sign( x ); return (::CGAL::Sign) CGAL_LEDA_SCOPE::sign( x );
} }
}; };
class Compare class Compare
: public Binary_function< Real_embeddable, Real_embeddable, : public Binary_function< Type, Type,
Comparison_result > { Comparison_result > {
public: public:
Comparison_result operator()( const Real_embeddable& x, Comparison_result operator()( const Type& x,
const Real_embeddable& y ) const { const Type& y ) const {
return (Comparison_result) CGAL_LEDA_SCOPE::compare( x, y ); return (Comparison_result) CGAL_LEDA_SCOPE::compare( x, y );
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( Real_embeddable, CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( Type,
Comparison_result ); Comparison_result );
}; };
class To_double class To_double
: public Unary_function< Real_embeddable, double > { : public Unary_function< Type, double > {
public: public:
double operator()( const Real_embeddable& x ) const { double operator()( const Type& x ) const {
// this call is required to get reasonable values for the double // this call is required to get reasonable values for the double
// approximation (as of LEDA-4.3.1) // approximation (as of LEDA-4.3.1)
x.improve_approximation_to(53); x.improve_approximation_to(53);
@ -160,9 +160,9 @@ template <> class Real_embeddable_traits< leda_real >
}; };
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
#if CGAL_LEDA_VERSION >= 501 #if CGAL_LEDA_VERSION >= 501
leda_bigfloat bnum = x.to_bigfloat(); leda_bigfloat bnum = x.to_bigfloat();
@ -175,15 +175,15 @@ template <> class Real_embeddable_traits< leda_real >
CGAL_LEDA_SCOPE::TO_P_INF); CGAL_LEDA_SCOPE::TO_P_INF);
std::pair<double, double> result(low, upp); std::pair<double, double> result(low, upp);
CGAL_postcondition(Real_embeddable(result.first)<=x); CGAL_postcondition(Type(result.first)<=x);
CGAL_postcondition(Real_embeddable(result.second)>=x); CGAL_postcondition(Type(result.second)>=x);
return result; return result;
#else #else
CGAL_LEDA_SCOPE::interval temp(x); //bug in leda CGAL_LEDA_SCOPE::interval temp(x); //bug in leda
std::pair<double, double> result(temp.lower_bound(),temp.upper_bound()); std::pair<double, double> result(temp.lower_bound(),temp.upper_bound());
CGAL_postcondition_msg(Real_embeddable(result.first)<=x, CGAL_postcondition_msg(Type(result.first)<=x,
"Known bug in LEDA <=5.0"); "Known bug in LEDA <=5.0");
CGAL_postcondition_msg(Real_embeddable(result.first)>=x, CGAL_postcondition_msg(Type(result.first)>=x,
"Known bug in LEDA <=5.0"); "Known bug in LEDA <=5.0");
return result; return result;
// If x is very small and we look closer at x // If x is very small and we look closer at x

View File

@ -121,18 +121,18 @@ template <> class Algebraic_structure_traits< long double >
typedef Tag_false Is_exact; typedef Tag_false Is_exact;
class Sqrt class Sqrt
: public Unary_function< Algebraic_structure, Algebraic_structure > { : public Unary_function< Type, Type > {
public: public:
Algebraic_structure operator()( const Algebraic_structure& x ) const { Type operator()( const Type& x ) const {
return CGAL_CLIB_STD::sqrt( x ); return CGAL_CLIB_STD::sqrt( x );
} }
}; };
class Kth_root class Kth_root
:public Binary_function<int, Algebraic_structure, Algebraic_structure > { :public Binary_function<int, Type, Type > {
public: public:
Algebraic_structure operator()( int k, Type operator()( int k,
const Algebraic_structure& x) const { const Type& x) const {
CGAL_precondition_msg( k > 0, CGAL_precondition_msg( k > 0,
"'k' must be positive for k-th roots"); "'k' must be positive for k-th roots");
return CGAL_CLIB_STD::pow(x, (long double)1.0 / (long double)(k)); return CGAL_CLIB_STD::pow(x, (long double)1.0 / (long double)(k));
@ -145,12 +145,12 @@ template <> class Real_embeddable_traits< long double >
: public Real_embeddable_traits_base< long double > { : public Real_embeddable_traits_base< long double > {
public: public:
typedef INTERN_RET::To_double_by_conversion< Real_embeddable > typedef INTERN_RET::To_double_by_conversion< Type >
To_double; To_double;
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
// We hope that the long double -> double conversion // We hope that the long double -> double conversion
// follows the current rounding mode. // follows the current rounding mode.
@ -166,9 +166,9 @@ template <> class Real_embeddable_traits< long double >
// Is_finite depends on platform // Is_finite depends on platform
#ifdef __sgi #ifdef __sgi
class Is_finite class Is_finite
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public: public:
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
switch (fp_class_d(x)) { switch (fp_class_d(x)) {
case FP_POS_NORM: case FP_POS_NORM:
case FP_NEG_NORM: case FP_NEG_NORM:
@ -188,19 +188,19 @@ template <> class Real_embeddable_traits< long double >
}; };
#elif defined CGAL_CFG_IEEE_754_BUG #elif defined CGAL_CFG_IEEE_754_BUG
class Is_finite class Is_finite
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public: public:
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
Real_embeddable d = x; Type d = x;
IEEE_754_double* p = reinterpret_cast<IEEE_754_double*>(&d); IEEE_754_double* p = reinterpret_cast<IEEE_754_double*>(&d);
return is_finite_by_mask_long_double( p->c.H ); return is_finite_by_mask_long_double( p->c.H );
} }
}; };
#else #else
class Is_finite class Is_finite
: public Unary_function< Real_embeddable, bool > { : public Unary_function< Type, bool > {
public: public:
bool operator()( const Real_embeddable& x ) const { bool operator()( const Type& x ) const {
return (x == x) && (is_valid(x-x)); return (x == x) && (is_valid(x-x));
} }
}; };

View File

@ -39,21 +39,21 @@ template<> class Algebraic_structure_traits< long long int >
public: public:
typedef Tag_true Is_exact; typedef Tag_true Is_exact;
typedef INTERN_AST::Div_per_operator< Algebraic_structure > Div; typedef INTERN_AST::Div_per_operator< Type > Div;
typedef INTERN_AST::Mod_per_operator< Algebraic_structure > Mod; typedef INTERN_AST::Mod_per_operator< Type > Mod;
class Is_square class Is_square
: public Binary_function< Algebraic_structure, Algebraic_structure&, : public Binary_function< Type, Type&,
bool > { bool > {
public: public:
bool operator()( const Algebraic_structure& x, bool operator()( const Type& x,
Algebraic_structure& y ) const { Type& y ) const {
y = (Algebraic_structure) CGAL_CLIB_STD::sqrt( (double)x ); y = (Type) CGAL_CLIB_STD::sqrt( (double)x );
return x == y * y; return x == y * y;
} }
bool operator()( const Algebraic_structure& x) const { bool operator()( const Type& x) const {
Algebraic_structure y Type y
= (Algebraic_structure) CGAL_CLIB_STD::sqrt( (double)x ); = (Type) CGAL_CLIB_STD::sqrt( (double)x );
return x == y * y; return x == y * y;
} }
}; };
@ -63,13 +63,13 @@ template <> class Real_embeddable_traits< long long int >
: public Real_embeddable_traits_base< long long int > { : public Real_embeddable_traits_base< long long int > {
public: public:
typedef INTERN_RET::To_double_by_conversion< Real_embeddable > typedef INTERN_RET::To_double_by_conversion< Type >
To_double; To_double;
class To_interval class To_interval
: public Unary_function< Real_embeddable, std::pair< double, double > > { : public Unary_function< Type, std::pair< double, double > > {
public: public:
std::pair<double, double> operator()( const Real_embeddable& x ) const { std::pair<double, double> operator()( const Type& x ) const {
Protect_FPU_rounding<true> P(CGAL_FE_TONEAREST); Protect_FPU_rounding<true> P(CGAL_FE_TONEAREST);
Interval_nt<false> approx ((double) x); Interval_nt<false> approx ((double) x);
FPU_set_cw(CGAL_FE_UPWARD); FPU_set_cw(CGAL_FE_UPWARD);

View File

@ -27,7 +27,7 @@
#include <CGAL/number_type_basic.h> #include <CGAL/number_type_basic.h>
//#include <gmpxx.h> //#include <gmpxx.h>
#include <CGAL/gmpxx_coercion_traits.h> #include <CGAL/gmpxx_coercion_traits.h>
#include <CGAL/mpz_class.h> // for GCD in Fraction traits #include <CGAL/mpz_class.h> // for GCD in Type traits
// This file gathers the necessary adaptors so that the following // This file gathers the necessary adaptors so that the following
@ -51,7 +51,7 @@ class Algebraic_structure_traits< ::__gmp_expr< ::__gmpq_value,U> >
public: public:
typedef Field_tag Algebraic_structure_tag; typedef Field_tag Algebraic_structure_tag;
typedef Tag_true Is_exact; typedef Tag_true Is_exact;
typedef mpq_class Algebraic_structure; typedef mpq_class Type;
struct Is_zero: public Unary_function< mpq_class , bool > { struct Is_zero: public Unary_function< mpq_class , bool > {
template <class U2> template <class U2>
@ -101,7 +101,7 @@ class Algebraic_structure_traits< ::__gmp_expr< ::__gmpq_value,U> >
"Algebraic_structure_traits<mpq_class>::Integral_div()(x,y)" ); "Algebraic_structure_traits<mpq_class>::Integral_div()(x,y)" );
return result; return result;
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Algebraic_structure ) CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Type )
}; };
class Is_square class Is_square
@ -131,7 +131,7 @@ template < class U >
class Real_embeddable_traits< ::__gmp_expr< ::__gmpq_value,U> > class Real_embeddable_traits< ::__gmp_expr< ::__gmpq_value,U> >
: public Real_embeddable_traits_base< ::__gmp_expr< ::__gmpq_value,U> > { : public Real_embeddable_traits_base< ::__gmp_expr< ::__gmpq_value,U> > {
public: public:
typedef mpq_class Real_embeddable; typedef mpq_class Type;
struct Is_zero: public Unary_function< mpq_class , bool > { struct Is_zero: public Unary_function< mpq_class , bool > {
template <class U2> template <class U2>
@ -188,7 +188,7 @@ class Real_embeddable_traits< ::__gmp_expr< ::__gmpq_value,U> >
return (Comparison_result) CGAL_NTS sign( ::cmp(x, y) ); return (Comparison_result) CGAL_NTS sign( ::cmp(x, y) );
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT
( Real_embeddable, Comparison_result); ( Type, Comparison_result);
}; };
struct To_double struct To_double
@ -224,7 +224,7 @@ class Real_embeddable_traits< ::__gmp_expr< ::__gmpq_value,U> >
template <> template <>
class Fraction_traits< mpq_class > { class Fraction_traits< mpq_class > {
public: public:
typedef mpq_class Fraction; typedef mpq_class Type;
typedef ::CGAL::Tag_true Is_fraction; typedef ::CGAL::Tag_true Is_fraction;
typedef mpz_class Numerator; typedef mpz_class Numerator;

View File

@ -47,7 +47,7 @@ class Algebraic_structure_traits< ::__gmp_expr< ::__gmpz_value,U> >
public: public:
typedef Euclidean_ring_tag Algebraic_structure_tag; typedef Euclidean_ring_tag Algebraic_structure_tag;
typedef Tag_true Is_exact; typedef Tag_true Is_exact;
typedef mpz_class Algebraic_structure; typedef mpz_class Type;
struct Is_zero: public Unary_function< mpz_class , bool > { struct Is_zero: public Unary_function< mpz_class , bool > {
template <class U2> template <class U2>
@ -95,7 +95,7 @@ public:
"Algebraic_structure_traits<mpz_class>::Integral_div()(x,y)" ); "Algebraic_structure_traits<mpz_class>::Integral_div()(x,y)" );
return result; return result;
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Algebraic_structure ) CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Type )
}; };
struct Gcd : public Binary_function< mpz_class, mpz_class, mpz_class > { struct Gcd : public Binary_function< mpz_class, mpz_class, mpz_class > {
@ -107,7 +107,7 @@ public:
mpz_gcd( c.get_mpz_t(), mpz_class(x).get_mpz_t(), mpz_class(y).get_mpz_t() ); mpz_gcd( c.get_mpz_t(), mpz_class(x).get_mpz_t(), mpz_class(y).get_mpz_t() );
return c; return c;
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Algebraic_structure ) CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Type )
}; };
struct Div : public Binary_function< mpz_class, mpz_class, mpz_class > { struct Div : public Binary_function< mpz_class, mpz_class, mpz_class > {
@ -117,7 +117,7 @@ public:
const ::__gmp_expr< ::__gmpz_value,U3>& y) const { const ::__gmp_expr< ::__gmpz_value,U3>& y) const {
return x / y; return x / y;
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Algebraic_structure ) CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Type )
}; };
struct Mod : public Binary_function< mpz_class, mpz_class, mpz_class > { struct Mod : public Binary_function< mpz_class, mpz_class, mpz_class > {
@ -127,7 +127,7 @@ public:
const ::__gmp_expr< ::__gmpz_value,U3>& y) const { const ::__gmp_expr< ::__gmpz_value,U3>& y) const {
return x % y; return x % y;
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Algebraic_structure ) CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Type )
}; };
struct Div_mod { struct Div_mod {
typedef mpz_class first_argument_type; typedef mpz_class first_argument_type;
@ -184,7 +184,7 @@ class Real_embeddable_traits< ::__gmp_expr< ::__gmpz_value,U> >
: public Real_embeddable_traits_base< ::__gmp_expr< ::__gmpz_value,U> > { : public Real_embeddable_traits_base< ::__gmp_expr< ::__gmpz_value,U> > {
public: public:
typedef ::__gmp_expr< ::__gmpz_value, ::__gmpz_value> mpz_class; typedef ::__gmp_expr< ::__gmpz_value, ::__gmpz_value> mpz_class;
typedef mpz_class Real_embeddable; typedef mpz_class Type;
struct Is_zero: public Unary_function< mpz_class , bool > { struct Is_zero: public Unary_function< mpz_class , bool > {
template <class U2> template <class U2>
@ -238,7 +238,7 @@ public:
return (Comparison_result) CGAL_NTS sign( ::cmp(x, y) ); return (Comparison_result) CGAL_NTS sign( ::cmp(x, y) );
} }
CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT
( Real_embeddable, Comparison_result); ( Type, Comparison_result);
}; };
struct To_double struct To_double

View File

@ -22,8 +22,8 @@
// Author(s) : Stefan Schirra // Author(s) : Stefan Schirra
#ifndef CGAL_NUMBER_TYPE_BASIC_H #ifndef CGAL_NUMBER_Type_BASIC_H
#define CGAL_NUMBER_TYPE_BASIC_H #define CGAL_NUMBER_Type_BASIC_H
#define CGAL_PI 3.14159265358979323846 #define CGAL_PI 3.14159265358979323846
@ -91,4 +91,4 @@
#endif // CGAL_USE_GMPXX #endif // CGAL_USE_GMPXX
#endif // CGAL_USE_GMP #endif // CGAL_USE_GMP
#endif // CGAL_NUMBER_TYPE_BASIC_H #endif // CGAL_NUMBER_Type_BASIC_H

View File

@ -56,7 +56,7 @@ void algebraic_real_test()
typedef REAL real_NT; typedef REAL real_NT;
typedef RATIONAL rat_NT; typedef RATIONAL rat_NT;
typedef Z Integer; typedef Z Integer;
typedef typename CGAL::Coercion_traits< Coeff_NT, rat_NT>::Coercion_type Coercion_type; typedef typename CGAL::Coercion_traits< Coeff_NT, rat_NT>::Type Type;
typedef NiX::Algebraic_real<Coeff_NT,real_NT,rat_NT> ALGNUM; typedef NiX::Algebraic_real<Coeff_NT,real_NT,rat_NT> ALGNUM;
typedef NiX::Polynomial<Coeff_NT> Poly; typedef NiX::Polynomial<Coeff_NT> Poly;
@ -123,7 +123,7 @@ void algebraic_real_test()
// general constructor // general constructor
// tmp = 1 // tmp = 1
tmp = ALGNUM(P_1,-2,+2); tmp = ALGNUM(P_1,-2,+2);
if ((LiS::Compare_types< rat_NT, Coercion_type >::same_type)) { if ((LiS::Compare_types< rat_NT, Type >::same_type)) {
NiX_test(tmp.is_rational()); NiX_test(tmp.is_rational());
NiX_test(tmp.type()==NiX::IS_RATIONAL); NiX_test(tmp.type()==NiX::IS_RATIONAL);
NiX_test(tmp==rat_NT(1)); NiX_test(tmp==rat_NT(1));
@ -138,7 +138,7 @@ void algebraic_real_test()
NiX_test(tmp.rational()==1); NiX_test(tmp.rational()==1);
} }
tmp = ALGNUM(P_1,1,1); tmp = ALGNUM(P_1,1,1);
if ((LiS::Compare_types< rat_NT, Coercion_type >::same_type)) { if ((LiS::Compare_types< rat_NT, Type >::same_type)) {
NiX_test(tmp.is_rational()); NiX_test(tmp.is_rational());
NiX_test(tmp.type()==NiX::IS_RATIONAL); NiX_test(tmp.type()==NiX::IS_RATIONAL);
NiX_test(tmp==rat_NT(1)); NiX_test(tmp==rat_NT(1));
@ -458,7 +458,7 @@ void algebraic_real_test_for_set_rational(bool set_rational)
typedef REAL real_NT; typedef REAL real_NT;
typedef RATIONAL rat_NT; typedef RATIONAL rat_NT;
typedef Z Integer; typedef Z Integer;
typedef typename NiX::Coercion_traits< Coeff_NT, rat_NT>::Coercion_type Coercion_type; typedef typename NiX::Coercion_traits< Coeff_NT, rat_NT>::Type Type;
typedef NiX::Algebraic_real<Coeff_NT,real_NT,rat_NT> ALGNUM; typedef NiX::Algebraic_real<Coeff_NT,real_NT,rat_NT> ALGNUM;
typedef NiX::Polynomial<Coeff_NT> Poly; typedef NiX::Polynomial<Coeff_NT> Poly;

View File

@ -54,7 +54,7 @@ void algebraic_real_test()
typedef REAL real_NT; typedef REAL real_NT;
typedef RATIONAL rat_NT; typedef RATIONAL rat_NT;
typedef Z Integer; typedef Z Integer;
typedef typename CGAL::Coercion_traits< Coeff_NT, rat_NT>::Coercion_type Coercion_type; typedef typename CGAL::Coercion_traits< Coeff_NT, rat_NT>::Type Type;
typedef NiX::Algebraic_real<Coeff_NT,real_NT,rat_NT> ALGNUM; typedef NiX::Algebraic_real<Coeff_NT,real_NT,rat_NT> ALGNUM;
typedef NiX::Polynomial<Coeff_NT> Poly; typedef NiX::Polynomial<Coeff_NT> Poly;
@ -121,7 +121,7 @@ void algebraic_real_test()
// general constructor // general constructor
// tmp = 1 // tmp = 1
tmp = ALGNUM(P_1,-2,+2); tmp = ALGNUM(P_1,-2,+2);
if ((LiS::Compare_types< rat_NT, Coercion_type >::same_type)) { if ((LiS::Compare_types< rat_NT, Type >::same_type)) {
NiX_test(tmp.is_rational()); NiX_test(tmp.is_rational());
NiX_test(tmp.type()==NiX::IS_RATIONAL); NiX_test(tmp.type()==NiX::IS_RATIONAL);
NiX_test(tmp==rat_NT(1)); NiX_test(tmp==rat_NT(1));
@ -136,7 +136,7 @@ void algebraic_real_test()
NiX_test(tmp.rational()==1); NiX_test(tmp.rational()==1);
} }
tmp = ALGNUM(P_1,1,1); tmp = ALGNUM(P_1,1,1);
if ((LiS::Compare_types< rat_NT, Coercion_type >::same_type)) { if ((LiS::Compare_types< rat_NT, Type >::same_type)) {
NiX_test(tmp.is_rational()); NiX_test(tmp.is_rational());
NiX_test(tmp.type()==NiX::IS_RATIONAL); NiX_test(tmp.type()==NiX::IS_RATIONAL);
NiX_test(tmp==rat_NT(1)); NiX_test(tmp==rat_NT(1));
@ -456,7 +456,7 @@ void algebraic_real_test_for_set_rational(bool set_rational)
typedef REAL real_NT; typedef REAL real_NT;
typedef RATIONAL rat_NT; typedef RATIONAL rat_NT;
typedef Z Integer; typedef Z Integer;
typedef typename NiX::Coercion_traits< Coeff_NT, rat_NT>::Coercion_type Coercion_type; typedef typename NiX::Coercion_traits< Coeff_NT, rat_NT>::Type Type;
typedef NiX::Algebraic_real<Coeff_NT,real_NT,rat_NT> ALGNUM; typedef NiX::Algebraic_real<Coeff_NT,real_NT,rat_NT> ALGNUM;
typedef NiX::Polynomial<Coeff_NT> Poly; typedef NiX::Polynomial<Coeff_NT> Poly;

View File

@ -79,7 +79,7 @@ void test_lazy_exact_nt() {
typedef CGAL::Coercion_traits<LI,LR> CT; typedef CGAL::Coercion_traits<LI,LR> CT;
BOOST_STATIC_ASSERT((boost::is_same< typename CT::Are_implicit_interoperable,CGAL::Tag_true>::value)); BOOST_STATIC_ASSERT((boost::is_same< typename CT::Are_implicit_interoperable,CGAL::Tag_true>::value));
BOOST_STATIC_ASSERT((boost::is_same< typename CT::Are_explicit_interoperable,CGAL::Tag_true>::value)); BOOST_STATIC_ASSERT((boost::is_same< typename CT::Are_explicit_interoperable,CGAL::Tag_true>::value));
BOOST_STATIC_ASSERT((boost::is_same< typename CT::Coercion_type,LR>::value)); BOOST_STATIC_ASSERT((boost::is_same< typename CT::Type,LR>::value));
LI i(4); LI i(4);
LR r(4); LR r(4);

View File

@ -62,7 +62,7 @@ void test_quotient() {
typedef CGAL::Coercion_traits<I,QI> CT; typedef CGAL::Coercion_traits<I,QI> CT;
BOOST_STATIC_ASSERT((boost::is_same< typename CT::Are_explicit_interoperable,CGAL::Tag_true>::value)); BOOST_STATIC_ASSERT((boost::is_same< typename CT::Are_explicit_interoperable,CGAL::Tag_true>::value));
BOOST_STATIC_ASSERT((boost::is_same< typename CT::Are_implicit_interoperable,CGAL::Tag_true>::value)); BOOST_STATIC_ASSERT((boost::is_same< typename CT::Are_implicit_interoperable,CGAL::Tag_true>::value));
BOOST_STATIC_ASSERT((boost::is_same< typename CT::Coercion_type,QI>::value)); BOOST_STATIC_ASSERT((boost::is_same< typename CT::Type,QI>::value));
} }
} }

View File

@ -15,8 +15,8 @@ template <class NT , class RT>
inline inline
void convert_to(const NT& x, RT& r){ void convert_to(const NT& x, RT& r){
typedef CGAL::Coercion_traits<NT,RT> CT; typedef CGAL::Coercion_traits<NT,RT> CT;
typedef typename CT::Coercion_type Coercion_type; typedef typename CT::Type Type;
BOOST_STATIC_ASSERT((::boost::is_same<Coercion_type,RT>::value)); BOOST_STATIC_ASSERT((::boost::is_same<Type,RT>::value));
r = typename CT::Cast()(x); r = typename CT::Cast()(x);
} }
CGAL_END_NAMESPACE CGAL_END_NAMESPACE
@ -446,7 +446,7 @@ void scalar_factor_traits_test(){
// TODO: No to_Sqrt_extension available in CGAL. // TODO: No to_Sqrt_extension available in CGAL.
/*template <class AT> /*template <class AT>
void to_Sqrt_extension_test() { void to_Sqrt_extension_test() {
// CGAL_SNAP_ARITHMETIC_KERNEL_TYPEDEFS(AT); // CGAL_SNAP_ARITHMETIC_KERNEL_TypeDEFS(AT);
typedef leda_integer Integer; typedef leda_integer Integer;
typedef leda_rational Rational; typedef leda_rational Rational;
typedef CGAL::Sqrt_extension<Rational,Integer> EXT; typedef CGAL::Sqrt_extension<Rational,Integer> EXT;
@ -480,7 +480,7 @@ void to_Sqrt_extension_test() {
// TODO: Adapt when fraction_traits are available // TODO: Adapt when fraction_traits are available
/*template <class AT> /*template <class AT>
void fraction_traits_test(){ void fraction_traits_test(){
//TEST Fraction traits ROOT of type INT //TEST Type traits ROOT of type INT
typedef typename AT::Integer INT; typedef typename AT::Integer INT;
typedef typename AT::Rational RAT; typedef typename AT::Rational RAT;
@ -742,7 +742,7 @@ void polynom_test(){
}*/ }*/
template <class AT> template <class AT>
void sqrt_extension_test(){ void sqrt_extension_test(){
CGAL_SNAP_ARITHMETIC_KERNEL_TYPEDEFS(AT); CGAL_SNAP_ARITHMETIC_KERNEL_TypeDEFS(AT);
general_test<Integer,Integer,CGAL::Integral_domain_tag>(); general_test<Integer,Integer,CGAL::Integral_domain_tag>();
general_test<Rational,Integer,CGAL::Field_tag>(); general_test<Rational,Integer,CGAL::Field_tag>();

View File

@ -139,7 +139,7 @@ typedef LEDA_arithmetic_kernel Arithmetic_kernel;
#endif // defined(CGAL_USE_LEDA) || defined(CGAL_USE_CORE) #endif // defined(CGAL_USE_LEDA) || defined(CGAL_USE_CORE)
// Macro to snap typedefs in Arithmetic_kernel // Macro to snap typedefs in Arithmetic_kernel
#define CGAL_SNAP_ARITHMETIC_KERNEL_TYPEDEFS(AT) \ #define CGAL_SNAP_ARITHMETIC_KERNEL_TypeDEFS(AT) \
typedef typename AT::Integer Integer; \ typedef typename AT::Integer Integer; \
typedef typename AT::Rational Rational; \ typedef typename AT::Rational Rational; \
typedef typename AT::Field_with_sqrt Field_with_sqrt; typedef typename AT::Field_with_sqrt Field_with_sqrt;

View File

@ -16,7 +16,7 @@
* types. * types.
*/ */
// within this file AS ^= Algebraic_structure // within this file AS ^= Type
#include <CGAL/basic.h> #include <CGAL/basic.h>
#include <CGAL/_test_basic.h> #include <CGAL/_test_basic.h>
@ -580,9 +580,9 @@ public:
} }
}; };
// Algebraic_structure_functions ----------------------------------------------- // Type_functions -----------------------------------------------
template <class AS > template <class AS >
void test_Algebraic_structure_functions( void test_Type_functions(
const CGAL::Integral_domain_without_division_tag&) { const CGAL::Integral_domain_without_division_tag&) {
AS x(-15); AS x(-15);
CGAL_NTS simplify(x); CGAL_NTS simplify(x);
@ -594,24 +594,24 @@ void test_Algebraic_structure_functions(
}; };
template <class AS > template <class AS >
void test_Algebraic_structure_functions( const CGAL::Integral_domain_tag&) { void test_Type_functions( const CGAL::Integral_domain_tag&) {
test_Algebraic_structure_functions< AS > test_Type_functions< AS >
(CGAL::Integral_domain_without_division_tag()); (CGAL::Integral_domain_without_division_tag());
CGAL_test_assert(CGAL_NTS integral_division( AS (10), AS (2))== AS (5)); CGAL_test_assert(CGAL_NTS integral_division( AS (10), AS (2))== AS (5));
}; };
template <class AS > template <class AS >
void test_Algebraic_structure_functions( void test_Type_functions(
const CGAL::Unique_factorization_domain_tag&) { const CGAL::Unique_factorization_domain_tag&) {
test_Algebraic_structure_functions< AS >(CGAL::Integral_domain_tag()); test_Type_functions< AS >(CGAL::Integral_domain_tag());
CGAL_test_assert(CGAL_NTS gcd( AS (21), AS (15)) == unit_normal(AS (3))); CGAL_test_assert(CGAL_NTS gcd( AS (21), AS (15)) == unit_normal(AS (3)));
}; };
template <class AS > template <class AS >
void test_Algebraic_structure_functions( const CGAL::Euclidean_ring_tag&) { void test_Type_functions( const CGAL::Euclidean_ring_tag&) {
test_Algebraic_structure_functions< AS >( test_Type_functions< AS >(
CGAL::Unique_factorization_domain_tag()); CGAL::Unique_factorization_domain_tag());
//std::cerr << CGAL_NTS mod( AS(14), AS(5) ) << std::endl; //std::cerr << CGAL_NTS mod( AS(14), AS(5) ) << std::endl;
CGAL_test_assert(CGAL_NTS mod( AS (14), AS (5))== unit_normal( AS (4) )); CGAL_test_assert(CGAL_NTS mod( AS (14), AS (5))== unit_normal( AS (4) ));
@ -623,23 +623,23 @@ void test_Algebraic_structure_functions( const CGAL::Euclidean_ring_tag&) {
}; };
template <class AS > template <class AS >
void test_Algebraic_structure_functions( const CGAL::Field_tag&) { void test_Type_functions( const CGAL::Field_tag&) {
test_Algebraic_structure_functions< AS >(CGAL::Integral_domain_tag()); test_Type_functions< AS >(CGAL::Integral_domain_tag());
CGAL_test_assert(CGAL_NTS unit_part( AS (-15))== AS (-15)); CGAL_test_assert(CGAL_NTS unit_part( AS (-15))== AS (-15));
CGAL_test_assert(CGAL_NTS unit_part( AS (0 ))== AS ( 1)); CGAL_test_assert(CGAL_NTS unit_part( AS (0 ))== AS ( 1));
}; };
template <class AS > template <class AS >
void test_Algebraic_structure_functions( const CGAL::Field_with_sqrt_tag&) { void test_Type_functions( const CGAL::Field_with_sqrt_tag&) {
test_Algebraic_structure_functions< AS >(CGAL::Field_tag()); test_Type_functions< AS >(CGAL::Field_tag());
typedef Algebraic_structure_traits<AS> AST; typedef Algebraic_structure_traits<AS> AST;
typedef typename AST::Is_exact Is_exact; typedef typename AST::Is_exact Is_exact;
AS c = CGAL_NTS sqrt( AS (4)); AS c = CGAL_NTS sqrt( AS (4));
CGAL_test_assert( !Is_exact::value || c == AS (2) ); CGAL_test_assert( !Is_exact::value || c == AS (2) );
} }
template <class AS > template <class AS >
void test_Algebraic_structure_functions( const CGAL::Field_with_root_of_tag&) { void test_Type_functions( const CGAL::Field_with_root_of_tag&) {
test_Algebraic_structure_functions< AS >(CGAL::Field_with_sqrt_tag()); test_Type_functions< AS >(CGAL::Field_with_sqrt_tag());
std::vector< AS > coeffs(4); std::vector< AS > coeffs(4);
coeffs[0]= AS (-27); coeffs[0]= AS (-27);
coeffs[1]= AS (0); coeffs[1]= AS (0);
@ -701,7 +701,7 @@ template <class AS , class Algebra_type, class Is_exact>
void test_algebraic_structure(){ void test_algebraic_structure(){
test_ast_functor_arity<AS>(); test_ast_functor_arity<AS>();
test_Algebraic_structure_functions< AS >(Algebra_type()); test_Type_functions< AS >(Algebra_type());
typedef CGAL::Algebraic_structure_traits< AS > AST; typedef CGAL::Algebraic_structure_traits< AS > AST;
CGAL_SNAP_AST_FUNCTORS(AST); CGAL_SNAP_AST_FUNCTORS(AST);
typedef typename AST::Algebraic_structure_tag Algebra; typedef typename AST::Algebraic_structure_tag Algebra;
@ -850,4 +850,4 @@ void test_algebraic_structure_without_exactness_check(
CGAL_END_NAMESPACE CGAL_END_NAMESPACE
#endif // CGAL_TEST_NUMBER_TYPE_H #endif // CGAL_TEST_NUMBER_Type_H

View File

@ -22,7 +22,7 @@ CGAL_BEGIN_NAMESPACE
namespace INTERN_COERCION_TRAITS { namespace INTERN_COERCION_TRAITS {
template< class A, class B, class Coercion_type, class Compare > template< class A, class B, class Type, class Compare >
class Test_compare { class Test_compare {
public: public:
void operator()() { void operator()() {
@ -30,13 +30,13 @@ class Test_compare {
A a(4); A a(4);
B b(2); B b(2);
typename CGAL::Coercion_traits< A, B >::Cast cast; typename CGAL::Coercion_traits< A, B >::Cast cast;
Coercion_type a_ret = cast(a); Type a_ret = cast(a);
Coercion_type b_ret = cast(b); Type b_ret = cast(b);
CGAL_test_assert( compare( a, b ) == CGAL_NTS compare( a_ret, b_ret ) ); CGAL_test_assert( compare( a, b ) == CGAL_NTS compare( a_ret, b_ret ) );
} }
}; };
template< class A, class B, class Coercion_type, class Integral_division > template< class A, class B, class Type, class Integral_division >
class Test_integral_division { class Test_integral_division {
public: public:
void operator()() { void operator()() {
@ -44,21 +44,21 @@ class Test_integral_division {
A a(4); A a(4);
B b(2); B b(2);
typename CGAL::Coercion_traits< A, B >::Cast cast; typename CGAL::Coercion_traits< A, B >::Cast cast;
Coercion_type a_ret = cast(a); Type a_ret = cast(a);
Coercion_type b_ret = cast(b); Type b_ret = cast(b);
CGAL_test_assert( integral_division( a, b ) == CGAL_test_assert( integral_division( a, b ) ==
CGAL_NTS integral_division( a_ret, b_ret ) ); CGAL_NTS integral_division( a_ret, b_ret ) );
} }
}; };
template< class A, class B, class Coercion_type > template< class A, class B, class Type >
class Test_integral_division< A, B, Coercion_type, CGAL::Null_functor > { class Test_integral_division< A, B, Type, CGAL::Null_functor > {
public: public:
// Nothing to test // Nothing to test
void operator()(){} void operator()(){}
}; };
template< class A, class B, class Coercion_type, class Gcd > template< class A, class B, class Type, class Gcd >
class Test_gcd { class Test_gcd {
public: public:
void operator()() { void operator()() {
@ -66,21 +66,21 @@ class Test_gcd {
A a(4); A a(4);
B b(2); B b(2);
typename CGAL::Coercion_traits< A, B >::Cast cast; typename CGAL::Coercion_traits< A, B >::Cast cast;
Coercion_type a_ret = cast(a); Type a_ret = cast(a);
Coercion_type b_ret = cast(b); Type b_ret = cast(b);
CGAL_test_assert( gcd( a, b ) == CGAL_test_assert( gcd( a, b ) ==
CGAL_NTS gcd( a_ret, b_ret ) ); CGAL_NTS gcd( a_ret, b_ret ) );
} }
}; };
template< class A, class B, class Coercion_type > template< class A, class B, class Type >
class Test_gcd< A, B, Coercion_type, CGAL::Null_functor > { class Test_gcd< A, B, Type, CGAL::Null_functor > {
public: public:
// Nothing to test // Nothing to test
void operator()(){} void operator()(){}
}; };
template< class A, class B, class Coercion_type, class Div_mod > template< class A, class B, class Type, class Div_mod >
class Test_div_mod { class Test_div_mod {
public: public:
void operator()() { void operator()() {
@ -88,12 +88,12 @@ class Test_div_mod {
A a(4); A a(4);
B b(2); B b(2);
typename CGAL::Coercion_traits< A, B >::Cast cast; typename CGAL::Coercion_traits< A, B >::Cast cast;
Coercion_type a_ret = cast(a); Type a_ret = cast(a);
Coercion_type b_ret = cast(b); Type b_ret = cast(b);
Coercion_type q; Type q;
Coercion_type r; Type r;
Coercion_type q_to_compare; Type q_to_compare;
Coercion_type r_to_compare; Type r_to_compare;
div_mod( a, b, q, r ); div_mod( a, b, q, r );
CGAL_NTS div_mod( a_ret, b_ret, q_to_compare, r_to_compare ); CGAL_NTS div_mod( a_ret, b_ret, q_to_compare, r_to_compare );
CGAL_test_assert( q == q_to_compare ); CGAL_test_assert( q == q_to_compare );
@ -101,14 +101,14 @@ class Test_div_mod {
} }
}; };
template< class A, class B, class Coercion_type > template< class A, class B, class Type >
class Test_div_mod< A, B, Coercion_type, CGAL::Null_functor > { class Test_div_mod< A, B, Type, CGAL::Null_functor > {
public: public:
// Nothing to test // Nothing to test
void operator()(){} void operator()(){}
}; };
template< class A, class B, class Coercion_type, class Div > template< class A, class B, class Type, class Div >
class Test_div { class Test_div {
public: public:
void operator()() { void operator()() {
@ -116,21 +116,21 @@ class Test_div {
A a(4); A a(4);
B b(2); B b(2);
typename CGAL::Coercion_traits< A, B >::Cast cast; typename CGAL::Coercion_traits< A, B >::Cast cast;
Coercion_type a_ret = cast(a); Type a_ret = cast(a);
Coercion_type b_ret = cast(b); Type b_ret = cast(b);
CGAL_test_assert( div( a, b ) == CGAL_test_assert( div( a, b ) ==
CGAL_NTS div( a_ret, b_ret ) ); CGAL_NTS div( a_ret, b_ret ) );
} }
}; };
template< class A, class B, class Coercion_type > template< class A, class B, class Type >
class Test_div< A, B, Coercion_type, CGAL::Null_functor > { class Test_div< A, B, Type, CGAL::Null_functor > {
public: public:
// Nothing to test // Nothing to test
void operator()(){} void operator()(){}
}; };
template< class A, class B, class Coercion_type, class Mod > template< class A, class B, class Type, class Mod >
class Test_mod { class Test_mod {
public: public:
void operator()() { void operator()() {
@ -138,83 +138,82 @@ class Test_mod {
A a(4); A a(4);
B b(2); B b(2);
typename CGAL::Coercion_traits< A, B >::Cast cast; typename CGAL::Coercion_traits< A, B >::Cast cast;
Coercion_type a_ret = cast(a); Type a_ret = cast(a);
Coercion_type b_ret = cast(b); Type b_ret = cast(b);
CGAL_test_assert( mod( a, b ) == CGAL_test_assert( mod( a, b ) ==
CGAL_NTS mod( a_ret, b_ret ) ); CGAL_NTS mod( a_ret, b_ret ) );
} }
}; };
template< class A, class B, class Coercion_type > template< class A, class B, class Type >
class Test_mod< A, B, Coercion_type, CGAL::Null_functor > { class Test_mod< A, B, Type, CGAL::Null_functor > {
public: public:
// Nothing to test // Nothing to test
void operator()(){} void operator()(){}
}; };
template< class Coercion_type > template< class Type >
void test_implicit_construction( Coercion_type a ) { void test_implicit_construction( Type a ) {
(void)a; (void)a;
} }
template< class A, class B, class Coercion_type, class Are_implicit_interoperable > template< class A, class B, class Type, class Are_implicit_interoperable >
class Implicit_interoperability_test { class Implicit_interoperability_test {
public: public:
void operator()() { void operator()() {
// test implicit construction // test implicit construction
typedef Coercion_type Coercion_type_type; // Results in 'no matching function for call to...' compile error, if type Type
// Results in 'no matching function for call to...' compile error, if type Coercion_type
// is not implicit constructable from A and B (which is part of the concept) // is not implicit constructable from A and B (which is part of the concept)
test_implicit_construction<Coercion_type>(A(1)); test_implicit_construction<Type>(A(1));
test_implicit_construction<Coercion_type>(B(2)); test_implicit_construction<Type>(B(2));
// test explicit construction // test explicit construction
Coercion_type_type test_var = Coercion_type(A(1)); Type test_var = Type(A(1));
test_var = Coercion_type(B(2)); test_var = Type(B(2));
} }
}; };
template< class A, class B, class Coercion_type > template< class A, class B, class Type >
class Implicit_interoperability_test<A,B,Coercion_type, CGAL::Tag_false > { class Implicit_interoperability_test<A,B,Type, CGAL::Tag_false > {
public: public:
void operator()() {} void operator()() {}
}; };
template< class A, class B, class Coercion_type > template< class A, class B, class Type >
void interoperability_test_one_way() { void interoperability_test_one_way() {
typedef CGAL::Coercion_traits< A, B > CT; typedef CGAL::Coercion_traits< A, B > CT;
CGAL_test_assert((::boost::is_same< typename CT::Are_implicit_interoperable, CGAL_test_assert((::boost::is_same< typename CT::Are_implicit_interoperable,
CGAL::Tag_true CGAL::Tag_true
>::value)); >::value));
CGAL_test_assert((::boost::is_same< typename CT::Coercion_type, Coercion_type >::value)); CGAL_test_assert((::boost::is_same< typename CT::Type, Type >::value));
// Implicit_interoperability_test // Implicit_interoperability_test
Implicit_interoperability_test< A, B, Coercion_type, Implicit_interoperability_test< A, B, Type,
typename CT::Are_implicit_interoperable >()(); typename CT::Are_implicit_interoperable >()();
Test_integral_division< A, B, Coercion_type, Test_integral_division< A, B, Type,
typename CGAL::Algebraic_structure_traits<Coercion_type>::Integral_division >()(); typename CGAL::Algebraic_structure_traits<Type>::Integral_division >()();
Test_gcd< A, B, Coercion_type, Test_gcd< A, B, Type,
typename CGAL::Algebraic_structure_traits<Coercion_type>::Gcd >()(); typename CGAL::Algebraic_structure_traits<Type>::Gcd >()();
Test_div_mod< A, B, Coercion_type, Test_div_mod< A, B, Type,
typename CGAL::Algebraic_structure_traits<Coercion_type>::Div_mod >()(); typename CGAL::Algebraic_structure_traits<Type>::Div_mod >()();
Test_div< A, B, Coercion_type, Test_div< A, B, Type,
typename CGAL::Algebraic_structure_traits<Coercion_type>::Div >()(); typename CGAL::Algebraic_structure_traits<Type>::Div >()();
Test_mod< A, B, Coercion_type, Test_mod< A, B, Type,
typename CGAL::Algebraic_structure_traits<Coercion_type>::Mod >()(); typename CGAL::Algebraic_structure_traits<Type>::Mod >()();
Test_compare< A, B, Coercion_type, Test_compare< A, B, Type,
typename CGAL::Real_embeddable_traits<Coercion_type>::Compare >()(); typename CGAL::Real_embeddable_traits<Type>::Compare >()();
} }
template< class A, class B, class Coercion_type > template< class A, class B, class Type >
void interoperability_test() { void interoperability_test() {
interoperability_test_one_way< A, B, Coercion_type >(); interoperability_test_one_way< A, B, Type >();
interoperability_test_one_way< B, A, Coercion_type >(); interoperability_test_one_way< B, A, Type >();
} }
template< class FROM, class TO > template< class FROM, class TO >
@ -226,13 +225,13 @@ template <class A, class B, class RT>
void coercion_traits_test_one_way(){ void coercion_traits_test_one_way(){
typedef CGAL::Coercion_traits<A,B> CT; typedef CGAL::Coercion_traits<A,B> CT;
{ {
typedef typename CT::Coercion_type Coercion_type; typedef typename CT::Type Type;
typename CT::Cast cast; typename CT::Cast cast;
CGAL_test_assert((::boost::is_same< CGAL_test_assert((::boost::is_same<
typename CT::Are_explicit_interoperable, typename CT::Are_explicit_interoperable,
CGAL::Tag_true CGAL::Tag_true
>::value)); >::value));
CGAL_test_assert((::boost::is_same<Coercion_type,RT>::value)); CGAL_test_assert((::boost::is_same<Type,RT>::value));
A a(3); A a(3);
B b(3); B b(3);
RT rt(3); RT rt(3);
@ -241,16 +240,16 @@ void coercion_traits_test_one_way(){
} }
} }
template <class A, class B, class Coercion_type> template <class A, class B, class Type>
void coercion_traits_test(){ void coercion_traits_test(){
coercion_traits_test_one_way<A,B,Coercion_type>(); coercion_traits_test_one_way<A,B,Type>();
coercion_traits_test_one_way<B,A,Coercion_type>(); coercion_traits_test_one_way<B,A,Type>();
// TODO: Is this here OK? // TODO: Is this here OK?
if((::boost::is_same< typename CGAL::Coercion_traits< A, B >::Are_implicit_interoperable, if((::boost::is_same< typename CGAL::Coercion_traits< A, B >::Are_implicit_interoperable,
CGAL::Tag_true CGAL::Tag_true
>::value)) { >::value)) {
interoperability_test< A, B, Coercion_type >(); interoperability_test< A, B, Type >();
} }
} }

View File

@ -24,7 +24,7 @@ template <class T>
void test_fraction_traits(){ void test_fraction_traits(){
typedef CGAL::Fraction_traits<T> FT; typedef CGAL::Fraction_traits<T> FT;
typedef typename FT::Fraction Fraction; typedef typename FT::Type Type;
typedef typename FT::Is_fraction Is_fraction; typedef typename FT::Is_fraction Is_fraction;
typedef typename FT::Numerator Num; typedef typename FT::Numerator Num;
typedef typename FT::Denominator Den; typedef typename FT::Denominator Den;
@ -32,7 +32,7 @@ void test_fraction_traits(){
typedef typename FT::Decompose Decompose; typedef typename FT::Decompose Decompose;
typedef typename FT::Compose Compose; typedef typename FT::Compose Compose;
BOOST_STATIC_ASSERT( (::boost::is_same<Fraction,T>::value)); BOOST_STATIC_ASSERT( (::boost::is_same<Type,T>::value));
BOOST_STATIC_ASSERT( (::boost::is_same<Is_fraction,Tag_true>::value)); BOOST_STATIC_ASSERT( (::boost::is_same<Is_fraction,Tag_true>::value));
BOOST_STATIC_ASSERT(!(::boost::is_same<Common_factor,Null_functor>::value)); BOOST_STATIC_ASSERT(!(::boost::is_same<Common_factor,Null_functor>::value));
BOOST_STATIC_ASSERT(!(::boost::is_same<Decompose,Null_functor>::value)); BOOST_STATIC_ASSERT(!(::boost::is_same<Decompose,Null_functor>::value));
@ -40,7 +40,7 @@ void test_fraction_traits(){
// Decompose // Decompose
Fraction frac = Fraction(7) / Fraction (5); Type frac = Type(7) / Type (5);
Num num; Num num;
Den den; Den den;
Decompose()(frac,num,den); Decompose()(frac,num,den);

View File

@ -44,48 +44,48 @@
CGAL_BEGIN_NAMESPACE CGAL_BEGIN_NAMESPACE
template<class Real_embeddable, class ToDouble> template<class Type, class ToDouble>
class Test_to_double { class Test_to_double {
public: public:
void operator() (const ToDouble& to_double) { void operator() (const ToDouble& to_double) {
typedef typename ToDouble::argument_type Argument_type; typedef typename ToDouble::argument_type Argument_type;
typedef typename ToDouble::result_type Result_type; typedef typename ToDouble::result_type Result_type;
BOOST_STATIC_ASSERT(( ::boost::is_same<Real_embeddable, Argument_type>::value)); BOOST_STATIC_ASSERT(( ::boost::is_same<Type, Argument_type>::value));
BOOST_STATIC_ASSERT(( ::boost::is_same<double, Result_type>::value)); BOOST_STATIC_ASSERT(( ::boost::is_same<double, Result_type>::value));
CGAL_test_assert(42.0 == to_double(Real_embeddable(42))); CGAL_test_assert(42.0 == to_double(Type(42)));
} }
}; };
template<class Real_embeddable> template<class Type>
class Test_to_double<Real_embeddable, CGAL::Null_tag> { class Test_to_double<Type, CGAL::Null_tag> {
public: public:
void operator() (CGAL::Null_functor) { void operator() (CGAL::Null_functor) {
CGAL_error("To_double functor not implemented"); CGAL_error("To_double functor not implemented");
} }
}; };
template<class Real_embeddable, class To_interval> template<class Type, class To_interval>
class Test_to_interval { class Test_to_interval {
public: public:
void operator() (const To_interval& to_interval) { void operator() (const To_interval& to_interval) {
typedef typename To_interval::argument_type Argument_type; typedef typename To_interval::argument_type Argument_type;
typedef typename To_interval::result_type Result_type; typedef typename To_interval::result_type Result_type;
typedef std::pair<double,double> Interval_type; typedef std::pair<double,double> Interval_type;
BOOST_STATIC_ASSERT(( ::boost::is_same<Real_embeddable, Argument_type>::value)); BOOST_STATIC_ASSERT(( ::boost::is_same<Type, Argument_type>::value));
BOOST_STATIC_ASSERT(( ::boost::is_same<Interval_type, Result_type>::value)); BOOST_STATIC_ASSERT(( ::boost::is_same<Interval_type, Result_type>::value));
// CGAL_test_assert(NiX::in(42.0,to_Interval(Real_embeddable(42)))); // CGAL_test_assert(NiX::in(42.0,to_Interval(Type(42))));
// Instead of 'NiX::in': // Instead of 'NiX::in':
CGAL_test_assert( 42.0 >= to_interval( Real_embeddable(42) ).first ); CGAL_test_assert( 42.0 >= to_interval( Type(42) ).first );
CGAL_test_assert( 42.0 <= to_interval( Real_embeddable(42) ).second ); CGAL_test_assert( 42.0 <= to_interval( Type(42) ).second );
CGAL_test_assert(to_interval(Real_embeddable(42)).first > 41.99); CGAL_test_assert(to_interval(Type(42)).first > 41.99);
CGAL_test_assert(to_interval(Real_embeddable(42)).second < 42.01); CGAL_test_assert(to_interval(Type(42)).second < 42.01);
/* /*
Real_embeddable notdouble = ipower(2,60); Type notdouble = ipower(2,60);
notdouble = notdouble + Real_embeddable(1); notdouble = notdouble + Type(1);
Interval test = to_Interval(notdouble); Interval test = to_Interval(notdouble);
double lower = ipower(2.0,60); double lower = ipower(2.0,60);
double upper = ipower(2.0,53); double upper = ipower(2.0,53);
@ -98,8 +98,8 @@ CGAL_BEGIN_NAMESPACE
} }
}; };
template< class Real_embeddable > template< class Type >
class Test_to_interval< Real_embeddable, CGAL::Null_tag> { class Test_to_interval< Type, CGAL::Null_tag> {
public: public:
void operator() (CGAL::Null_functor) { void operator() (CGAL::Null_functor) {
CGAL_assertion_msg(false, "To_Interval not implemented"); CGAL_assertion_msg(false, "To_Interval not implemented");
@ -123,17 +123,17 @@ void test_ret_functor_arity() {
} }
//! tests if \c Real_embeddable is a model for the \c RealComparable concept //! tests if \c Type is a model for the \c RealComparable concept
//! and terminates the program with an error message if not. //! and terminates the program with an error message if not.
template <class Real_embeddable> template <class Type>
void test_real_embeddable() { void test_real_embeddable() {
typedef CGAL::Real_embeddable_traits<Real_embeddable> RET; typedef CGAL::Real_embeddable_traits<Type> RET;
CGAL_SNAP_RET_FUNCTORS(RET); CGAL_SNAP_RET_FUNCTORS(RET);
typedef typename RET::Is_real_embeddable Is_real_embeddable; typedef typename RET::Is_real_embeddable Is_real_embeddable;
using CGAL::Tag_true; using CGAL::Tag_true;
BOOST_STATIC_ASSERT(( ::boost::is_same< Is_real_embeddable, Tag_true>::value)); BOOST_STATIC_ASSERT(( ::boost::is_same< Is_real_embeddable, Tag_true>::value));
test_ret_functor_arity< Real_embeddable >(); test_ret_functor_arity< Type >();
typename RET::Compare compare; typename RET::Compare compare;
const Sign sign = Sign(); const Sign sign = Sign();
const Abs abs=Abs(); const Abs abs=Abs();
@ -142,9 +142,9 @@ void test_real_embeddable() {
const Is_negative is_negative=Is_negative(); const Is_negative is_negative=Is_negative();
const Is_zero is_zero=Is_zero(); const Is_zero is_zero=Is_zero();
Real_embeddable a(-2); Type a(-2);
Real_embeddable b(1); Type b(1);
Real_embeddable c(0); Type c(0);
CGAL_test_assert( is_finite(a) ); CGAL_test_assert( is_finite(a) );
CGAL_test_assert( is_finite(b) ); CGAL_test_assert( is_finite(b) );
CGAL_test_assert( is_finite(c) ); CGAL_test_assert( is_finite(c) );
@ -185,81 +185,81 @@ void test_real_embeddable() {
CGAL_test_assert( sign(c) > sign(a)); CGAL_test_assert( sign(c) > sign(a));
CGAL_test_assert( sign(a) <= sign(c)); CGAL_test_assert( sign(a) <= sign(c));
CGAL_test_assert( sign(c) >= sign(a)); CGAL_test_assert( sign(c) >= sign(a));
CGAL_test_assert( abs(a) == Real_embeddable(2)); CGAL_test_assert( abs(a) == Type(2));
CGAL_test_assert( abs(b) == Real_embeddable(1)); CGAL_test_assert( abs(b) == Type(1));
CGAL_test_assert( abs(c) == Real_embeddable(0)); CGAL_test_assert( abs(c) == Type(0));
// To_double -------------------------------------------------------------- // To_double --------------------------------------------------------------
const To_double to_double = To_double(); const To_double to_double = To_double();
(void)to_double; (void)to_double;
Test_to_double<Real_embeddable, To_double> ttd; Test_to_double<Type, To_double> ttd;
ttd(to_double); ttd(to_double);
// To_Interval ------------------------------------------------------------ // To_Interval ------------------------------------------------------------
const To_interval to_interval = To_interval(); const To_interval to_interval = To_interval();
(void)to_interval; (void)to_interval;
Test_to_interval<Real_embeddable, To_interval> tti; Test_to_interval<Type, To_interval> tti;
tti(to_interval); tti(to_interval);
// additional functions // additional functions
CGAL_test_assert( CGAL_NTS is_finite( Real_embeddable(1) ) ); CGAL_test_assert( CGAL_NTS is_finite( Type(1) ) );
CGAL_test_assert( CGAL_NTS sign(Real_embeddable(-5))==CGAL::NEGATIVE); CGAL_test_assert( CGAL_NTS sign(Type(-5))==CGAL::NEGATIVE);
CGAL_test_assert( CGAL_NTS abs(Real_embeddable(-5))==Real_embeddable(5)); CGAL_test_assert( CGAL_NTS abs(Type(-5))==Type(5));
// CGAL_test_assert(NiX::in(5.0,NiX::to_interval(Real_embeddable(5)))); // CGAL_test_assert(NiX::in(5.0,NiX::to_interval(Type(5))));
CGAL_test_assert( CGAL_NTS compare(Real_embeddable(-5),Real_embeddable(6))==CGAL::SMALLER); CGAL_test_assert( CGAL_NTS compare(Type(-5),Type(6))==CGAL::SMALLER);
CGAL_test_assert( CGAL_NTS is_positive(Real_embeddable(23)) ); CGAL_test_assert( CGAL_NTS is_positive(Type(23)) );
CGAL_test_assert( CGAL_NTS is_negative(Real_embeddable(-23)) ); CGAL_test_assert( CGAL_NTS is_negative(Type(-23)) );
CGAL_test_assert( CGAL_NTS is_zero( Real_embeddable(0) ) ); CGAL_test_assert( CGAL_NTS is_zero( Type(0) ) );
CGAL_test_assert( !CGAL_NTS is_zero( Real_embeddable(23) ) ); CGAL_test_assert( !CGAL_NTS is_zero( Type(23) ) );
} }
//! tests if \c Real_embeddable says it is not a model for the \c RealComparable //! tests if \c Type says it is not a model for the \c RealComparable
//! concept and terminates the program with an error message if it //! concept and terminates the program with an error message if it
//! actually is. //! actually is.
template <class Real_embeddable> template <class Type>
void test_not_real_embeddable() { void test_not_real_embeddable() {
typedef CGAL::Real_embeddable_traits<Real_embeddable> RET; typedef CGAL::Real_embeddable_traits<Type> RET;
typedef typename RET::Is_real_embeddable Is_real_embeddable; typedef typename RET::Is_real_embeddable Is_real_embeddable;
using CGAL::Tag_false; using CGAL::Tag_false;
BOOST_STATIC_ASSERT(( ::boost::is_same< Is_real_embeddable, Tag_false>::value)); BOOST_STATIC_ASSERT(( ::boost::is_same< Is_real_embeddable, Tag_false>::value));
} }
//template <class Real_embeddable, class CeilLog2Abs> //template <class Type, class CeilLog2Abs>
//void test_rounded_log2_abs(Real_embeddable zero, CGAL::Null_functor, CeilLog2Abs) { //void test_rounded_log2_abs(Type zero, CGAL::Null_functor, CeilLog2Abs) {
// typedef CGAL::Null_functor Null_functor; // typedef CGAL::Null_functor Null_functor;
// BOOST_STATIC_ASSERT(( ::boost::is_same< CeilLog2Abs, Null_functor>::value)); // BOOST_STATIC_ASSERT(( ::boost::is_same< CeilLog2Abs, Null_functor>::value));
//} //}
// //
//template <class Real_embeddable, class FloorLog2Abs, class CeilLog2Abs> //template <class Type, class FloorLog2Abs, class CeilLog2Abs>
//void test_rounded_log2_abs(Real_embeddable zero, FloorLog2Abs fl_log, CeilLog2Abs cl_log) { //void test_rounded_log2_abs(Type zero, FloorLog2Abs fl_log, CeilLog2Abs cl_log) {
// typedef CGAL::Null_functor Null_functor; // typedef CGAL::Null_functor Null_functor;
// BOOST_STATIC_ASSERT((!::boost::is_same< CeilLog2Abs, Null_functor>::value)); // BOOST_STATIC_ASSERT((!::boost::is_same< CeilLog2Abs, Null_functor>::value));
// //
// CGAL_test_assert( fl_log(Real_embeddable( 7)) == 2 ); // CGAL_test_assert( fl_log(Type( 7)) == 2 );
// CGAL_test_assert( cl_log(Real_embeddable( 7)) == 3 ); // CGAL_test_assert( cl_log(Type( 7)) == 3 );
// CGAL_test_assert( fl_log(Real_embeddable( 8)) == 3 ); // CGAL_test_assert( fl_log(Type( 8)) == 3 );
// CGAL_test_assert( cl_log(Real_embeddable( 8)) == 3 ); // CGAL_test_assert( cl_log(Type( 8)) == 3 );
// CGAL_test_assert( fl_log(Real_embeddable(-9)) == 3 ); // CGAL_test_assert( fl_log(Type(-9)) == 3 );
// CGAL_test_assert( cl_log(Real_embeddable(-9)) == 4 ); // CGAL_test_assert( cl_log(Type(-9)) == 4 );
// //
// CGAL_test_assert( NiX::floor_log2_abs(Real_embeddable( 64)) == 6 ); // CGAL_test_assert( NiX::floor_log2_abs(Type( 64)) == 6 );
// CGAL_test_assert( NiX::ceil_log2_abs( Real_embeddable( 64)) == 6 ); // CGAL_test_assert( NiX::ceil_log2_abs( Type( 64)) == 6 );
// CGAL_test_assert( NiX::floor_log2_abs(Real_embeddable(-126)) == 6 ); // CGAL_test_assert( NiX::floor_log2_abs(Type(-126)) == 6 );
// CGAL_test_assert( NiX::ceil_log2_abs( Real_embeddable(-126)) == 7 ); // CGAL_test_assert( NiX::ceil_log2_abs( Type(-126)) == 7 );
//} //}
// //
// //
////! tests that \c Floor_log2_abs and \c Ceil_log2_abs are ////! tests that \c Floor_log2_abs and \c Ceil_log2_abs are
////! \c both CGAL::Null_functor or both working properly ////! \c both CGAL::Null_functor or both working properly
////! (This is independent of the \c RealComparable concept) ////! (This is independent of the \c RealComparable concept)
//template <class Real_embeddable> //template <class Type>
//void test_rounded_log2_abs() { //void test_rounded_log2_abs() {
// //
// typedef typename NiX::Real_embeddable_traits<Real_embeddable>::Floor_log2_abs F; // typedef typename NiX::Real_embeddable_traits<Type>::Floor_log2_abs F;
// typedef typename NiX::Real_embeddable_traits<Real_embeddable>::Ceil_log2_abs C; // typedef typename NiX::Real_embeddable_traits<Type>::Ceil_log2_abs C;
// test_rounded_log2_abs(Real_embeddable(0), F(), C()); // test_rounded_log2_abs(Type(0), F(), C());
//} //}
CGAL_END_NAMESPACE CGAL_END_NAMESPACE

View File

@ -11,13 +11,13 @@
template <class A, class B> template <class A, class B>
inline inline
typename CGAL::Algebraic_structure_traits< typename CGAL::Algebraic_structure_traits<
typename CGAL::Coercion_traits<A,B>::Coercion_type typename CGAL::Coercion_traits<A,B>::Type
>::Integral_division::result_type >::Integral_division::result_type
integral_division(const A& a, const B& b){ integral_division(const A& a, const B& b){
typedef CGAL::Coercion_traits<A,B> CT; typedef CGAL::Coercion_traits<A,B> CT;
typedef typename CT::Coercion_type Coercion_type; typedef typename CT::Type Type;
typename CGAL::Algebraic_structure_traits< typename CGAL::Algebraic_structure_traits<
typename CGAL::Coercion_traits<A,B>::Coercion_type typename CGAL::Coercion_traits<A,B>::Type
>::Integral_division integral_division; >::Integral_division integral_division;
return integral_division(a,b); return integral_division(a,b);
} }
@ -28,12 +28,12 @@ int
test_coercion(const A& a, const B& b){ test_coercion(const A& a, const B& b){
std::cout << "START TEST" << std::endl; std::cout << "START TEST" << std::endl;
typedef CGAL::Coercion_traits<A,B> CT; typedef CGAL::Coercion_traits<A,B> CT;
typedef typename CT::Coercion_type Coercion_type; typedef typename CT::Type Type;
typename CT::Cast cast; typename CT::Cast cast;
Coercion_type x = cast(a); Type x = cast(a);
typename CGAL::Algebraic_structure_traits< typename CGAL::Algebraic_structure_traits<
typename CGAL::Coercion_traits<A,B>::Coercion_type typename CGAL::Coercion_traits<A,B>::Type
>::Integral_division integral_division; >::Integral_division integral_division;
return 1; return 1;