BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Polynomial/Scalar_factor_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/Scalar_factor_traits.h $
00015 // $Id: Scalar_factor_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_SCALAR_FACTOR_TRAITS_H
00028 #define CGAL_POLYNOMIAL_SCALAR_FACTOR_TRAITS_H
00029 
00030 #include <CGAL/basic.h>
00031 
00032 CGAL_BEGIN_NAMESPACE
00033 
00034 // see <CGAL/Scalar_factor_traits.h>
00048 template <class Coeff>
00049 class Scalar_factor_traits< Polynomial<Coeff> > {
00050 public:
00051     typedef Polynomial<Coeff> NT;
00052     typedef typename Scalar_factor_traits<Coeff>::Scalar Scalar;
00053     class Scalar_factor {
00054     public:
00056         typedef NT argument_type;
00058         typedef NT first_argument_type;
00060         typedef Scalar second_argument_type;
00062         typedef Scalar result_type;
00064         Scalar operator()(const NT& p, const Scalar& d_=Scalar(0)) const {
00065             
00066             typename Scalar_factor_traits<Coeff>::Scalar_factor sfac;
00067             const Scalar unity(1);
00068             
00069             Scalar d(d_);
00070             if (p.is_zero()) return d;
00071             
00072             int i = p.degree();
00073             while((d != unity) && (i >= 0)) {
00074                 d = sfac(p[i--],d);
00075             }
00076             return d;
00077         }
00078     };
00079     class Scalar_div {
00080     public:
00082         typedef NT first_argument_type;
00084         typedef Scalar second_argument_type;
00086         void operator () (NT& p, const Scalar& b) const { 
00087             CGAL_precondition(b != Scalar(0));
00088             p.scalar_div(b); 
00089         }
00090     };
00091 };
00092 
00093 CGAL_END_NAMESPACE
00094 #endif // CGAL_POLYNOMIAL_SCALAR_FACTOR_TRAITS_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines