BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Polynomial/Real_embeddable_traits.h
Go to the documentation of this file.
00001 // Copyright (c) 2008 Max-Planck-Institute Saarbruecken (Germany)
00002 //
00003 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public License as
00005 // published by the Free Software Foundation; version 2.1 of the License.
00006 // See the file LICENSE.LGPL distributed with CGAL.
00007 //
00008 // Licensees holding a valid commercial license may use this file in
00009 // accordance with the commercial license agreement provided with the software.
00010 //
00011 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 //
00014 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Polynomial/include/CGAL/Polynomial/Real_embeddable_traits.h $
00015 // $Id: Real_embeddable_traits.h 47254 2008-12-06 21:18:27Z afabri $
00016 //
00017 //
00018 // Author(s)     : Arno Eigenwillig <arno@mpi-inf.mpg.de>
00019 //                 Michael Hemmer <hemmer@informatik.uni-mainz.de> 
00020 //
00021 // ============================================================================
00022 
00023 // TODO: The comments are all original EXACUS comments and aren't adapted. So
00024 //         they may be wrong now.
00025 
00026 
00027 #ifndef CGAL_POLYNOMIAL_REAL_EMBEDDABLE_TRAITS_H
00028 #define CGAL_POLYNOMIAL_REAL_EMBEDDABLE_TRAITS_H
00029 
00030 #include <CGAL/basic.h>
00031 
00032 CGAL_BEGIN_NAMESPACE
00033 
00034 namespace CGALi {
00035 template< class Polynomial , class TAG> class Real_embeddable_traits_poly_base;
00036 
00037 template< class NT , class TAG> class Real_embeddable_traits_poly_base< Polynomial<NT>, TAG > 
00038   : public INTERN_RET::Real_embeddable_traits_base< Polynomial<NT> , CGAL::Tag_false > {};
00039   
00040 // Real embeddable traits
00041 // TODO: Polynomials aren't Real_embeddable! But for debugging and testing
00042 //       reasons, the real embeddable functors are provided.
00043 template< class NT > class Real_embeddable_traits_poly_base< Polynomial<NT>, CGAL::Tag_true > 
00044   : public INTERN_RET::Real_embeddable_traits_base< Polynomial<NT> , CGAL::Tag_false > {
00045 public:
00046   
00047     typedef Tag_false Is_real_embeddable;
00048     
00049     class Abs {
00050     public:
00051         typedef Polynomial<NT> argument_type;
00052         typedef Polynomial<NT> result_type;
00053         Polynomial<NT> operator()( const Polynomial<NT>& x ) const {
00054             return x.abs(); 
00055         }
00056     };
00057 
00058     class Sgn {
00059     public:
00060         typedef Polynomial<NT>              argument_type;
00061         typedef CGAL::Sign        result_type;
00062         CGAL::Sign operator()( const Polynomial<NT>& x ) const {
00063             return x.sign();
00064         }
00065     };
00066     
00067     class Compare {
00068     public:
00069         typedef Polynomial<NT>                    first_argument_type;
00070         typedef Polynomial<NT>                    second_argument_type;
00071         typedef CGAL::Comparison_result result_type;
00072         
00073         CGAL::Comparison_result operator()( 
00074                 const Polynomial<NT>& x, 
00075                 const Polynomial<NT>& y ) const {
00076             return x.compare(y);
00077         }
00078         
00079         CGAL_IMPLICIT_INTEROPERABLE_BINARY_OPERATOR_WITH_RT( Polynomial<NT>,
00080                 CGAL::Comparison_result )
00081     };
00082 
00083     class To_double {
00084     public:
00085         typedef typename Real_embeddable_traits<NT>::To_double NT_to_double;
00086         typedef Polynomial<typename NT_to_double::result_type> result_type;
00087         typedef Polynomial<NT> argument_type;
00088         result_type operator()( const Polynomial<NT>& x ) const {
00089             CGAL_precondition(x.degree() >= 0);
00090             NT_to_double to_double;
00091             return result_type(
00092                     ::boost::make_transform_iterator(x.begin(),to_double),
00093                     ::boost::make_transform_iterator(x.end()  ,to_double));
00094         }
00095     };
00096 
00097     class To_interval {
00098     public:
00099         typedef typename Real_embeddable_traits<NT>::To_interval NT_to_interval;
00100         typedef Polynomial<typename NT_to_interval::result_type> result_type;
00101         typedef Polynomial<NT> argument_type;
00102         result_type operator()( const Polynomial<NT>& x ) const {
00103             CGAL_precondition( x.degree() >= 0 );
00104             NT_to_interval to_interval;  
00105             return result_type(
00106                     ::boost::make_transform_iterator(x.begin(),to_interval),
00107                     ::boost::make_transform_iterator(x.end()  ,to_interval));
00108         }
00109     };
00110 };
00111 } // namespace CGALi
00112 
00113 template <typename NT>
00114 struct Real_embeddable_traits<Polynomial<NT> > 
00115   :public CGALi::Real_embeddable_traits_poly_base<
00116   Polynomial<NT>,
00117   typename Real_embeddable_traits<typename CGALi::Innermost_coefficient_type<NT>::Type>::Is_real_embeddable>
00118 {};
00119 
00120 CGAL_END_NAMESPACE
00121 #endif // CGAL_POLYNOMIAL_REAL_EMBEDDABLE_TRAITS_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines