// Copyright (c) 2006-2008 Max-Planck-Institute Saarbruecken (Germany). // All rights reserved. // // This file is part of CGAL (www.cgal.org); you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public License as // published by the Free Software Foundation; either version 3 of the License, // or (at your option) any later version. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // // $URL$ // $Id$ // // // Author(s) : Michael Hemmer #ifndef CGAL_SQRT_EXTENSION_ALGEBRAIC_STRUCTURE_TRAITS_H #define CGAL_SQRT_EXTENSION_ALGEBRAIC_STRUCTURE_TRAITS_H #include namespace CGAL { namespace internal { // Algebraic structure traits template< class Type, class Algebraic_type > class Sqrt_extension_algebraic_structure_traits_base; template< class Type > class Sqrt_extension_algebraic_structure_traits_base< Type, CGAL::Integral_domain_without_division_tag > : public Algebraic_structure_traits_base< Type, CGAL::Integral_domain_without_division_tag > { public: typedef CGAL::Integral_domain_without_division_tag Algebraic_category; class Simplify : public std::unary_function< Type&, void > { public: typedef void result_type; typedef Type& argument_type; void operator()( Type& x ) const { x.simplify(); } }; }; template< class Type > class Sqrt_extension_algebraic_structure_traits_base< Type, CGAL::Integral_domain_tag > : public Sqrt_extension_algebraic_structure_traits_base< Type, CGAL::Integral_domain_without_division_tag > { public: typedef CGAL::Integral_domain_tag Algebraic_category; class Integral_division : public std::binary_function< Type, Type, Type > { public: Type operator()( const Type& x,const Type& y ) const { return x/y; } CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR( Type ) }; private: typedef typename Type::NT COEFF; typedef typename Type::ROOT ROOT; typedef typename CGAL::Coercion_traits< ROOT, COEFF >::Cast Root_nt_cast; typedef CGAL::Algebraic_structure_traits AST_COEFF; typedef typename AST_COEFF::Divides Divides_coeff; public: class Divides : public std::binary_function{ typedef typename Divides_coeff::result_type BOOL; public: BOOL operator()( const Type& x, const Type& y) const { Type q; return (*this)(x,y,q); } BOOL operator()( const Type& x, const Type& y, Type& q) const { Divides_coeff divides; // std::cout<<"integral domain for sqrt"< class Sqrt_extension_algebraic_structure_traits_base< Type, CGAL::Unique_factorization_domain_tag > : public Sqrt_extension_algebraic_structure_traits_base< Type, CGAL::Integral_domain_tag > { // Nothing new }; template< class Type > class Sqrt_extension_algebraic_structure_traits_base< Type, CGAL::Euclidean_ring_tag > : public Sqrt_extension_algebraic_structure_traits_base< Type, CGAL::Integral_domain_tag > { // Nothing new }; template< class Type > class Sqrt_extension_algebraic_structure_traits_base< Type, CGAL::Field_tag > : public Sqrt_extension_algebraic_structure_traits_base< Type, CGAL::Integral_domain_tag > { public: typedef Field_tag Algebraic_category; class Unit_part : public std::unary_function< Type, Type > { public: Type operator()( const Type& x ) const { return( x == Type(0) ? Type(1) : x ); } }; class Inverse : public std::unary_function< Type, Type > { public: Type operator()( const Type& x ) const { return Type(1)/x ; } }; }; template< class Type > class Sqrt_extension_algebraic_structure_traits_base< Type, CGAL::Field_with_sqrt_tag > : public Sqrt_extension_algebraic_structure_traits_base< Type, CGAL::Field_tag > { // Nothing new }; template< class Type > class Sqrt_extension_algebraic_structure_traits_base< Type, CGAL::Field_with_kth_root_tag > : public Sqrt_extension_algebraic_structure_traits_base< Type, // TODO: Why not Fiel_tag? CGAL::Field_with_sqrt_tag > { // Nothing new }; template< class Type > class Sqrt_extension_algebraic_structure_traits_base< Type, CGAL::Field_with_root_of_tag > : public Sqrt_extension_algebraic_structure_traits_base< Type, // TODO: Why not Fiel_tag? CGAL::Field_with_sqrt_tag > { // Nothing new }; } // namespace internal template< class COEFF_, class ROOT_, class ACDE_TAG,class FP_TAG> class Algebraic_structure_traits< Sqrt_extension< COEFF_, ROOT_, ACDE_TAG,FP_TAG > > : public internal::Sqrt_extension_algebraic_structure_traits_base< Sqrt_extension< COEFF_, ROOT_, ACDE_TAG,FP_TAG >, typename Algebraic_structure_traits< COEFF_ >::Algebraic_category > { public: typedef Sqrt_extension< COEFF_, ROOT_, ACDE_TAG,FP_TAG > Type; // Tag_true if COEFF and ROOT are exact typedef typename ::boost::mpl::if_c< bool( ::boost::is_same::Is_exact,::CGAL::Tag_true>::value )&& bool( ::boost::is_same::Is_exact,::CGAL::Tag_true>::value ) ,::CGAL::Tag_true,::CGAL::Tag_false>::type Is_exact; typedef typename Algebraic_structure_traits::Is_numerical_sensitive Is_numerical_sensitive; }; } //namespace CGAL #endif