BWAPI
SPAR/AIModule/BWTA/vendors/CGAL/CGAL/Polynomial/internal/Rational/Descartes_root_counter.h
Go to the documentation of this file.
00001 // Copyright (c) 2005  Stanford University (USA).
00002 // All rights reserved.
00003 //
00004 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public License as
00006 // published by the Free Software Foundation; version 2.1 of the License.
00007 // See the file LICENSE.LGPL distributed with CGAL.
00008 //
00009 // Licensees holding a valid commercial license may use this file in
00010 // accordance with the commercial license agreement provided with the software.
00011 //
00012 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00013 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00014 //
00015 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Kinetic_data_structures/include/CGAL/Polynomial/internal/Rational/Descartes_root_counter.h $
00016 // $Id: Descartes_root_counter.h 35766 2007-01-20 21:39:01Z drussel $
00017 // 
00018 //
00019 // Author(s)     : Daniel Russel <drussel@alumni.princeton.edu>
00020 
00021 #ifndef CGAL_POLYNOMIAL_DESCARTES_ROOT_COUNTER_H
00022 #define CGAL_POLYNOMIAL_DESCARTES_ROOT_COUNTER_H
00023 
00024 #include <CGAL/Polynomial/basic.h>
00025 #include <CGAL/Polynomial/internal/Alternation_counter.h>
00026 
00027 CGAL_POLYNOMIAL_BEGIN_INTERNAL_NAMESPACE;
00028 
00029 template <class Kernel>
00030 class Descartes_root_counter
00031 {
00032     public:
00033         Descartes_root_counter(){}
00034         Descartes_root_counter(const typename Kernel::Function &f,
00035             const Kernel &k): map_(k.map_rational_interval_to_positive_object(f)),
00036         kernel_(k) {
00037 
00038         }
00039 
00040         typedef unsigned int result_type;
00041         typedef typename Kernel::NT first_argument_type;
00042         typedef typename Kernel::NT second_argument_type;
00043 
00045         template <class NTT>
00046             result_type operator()(const NTT &lb, const NTT &ub,
00047                                    CGAL::Sign=CGAL::ZERO,
00048                                    CGAL::Sign=CGAL::ZERO) const
00049         {
00050             typename Kernel::Function mf= map_(lb, ub);
00051 
00052             typename CGAL_POLYNOMIAL_NS::Alternation_counter<first_argument_type> ac;
00053             for (int i=0; i<= mf.degree(); ++i) {
00054                 ac.push_back(mf[i]);
00055             }
00056 //std::cout << "Num alternations is " << ac.number_of_alternations() << std::endl;
00057             return ac.number_of_alternations();
00058         }
00059     protected:
00060         typename Kernel::Map_rational_interval_to_positive map_;
00062         Kernel kernel_;
00063 };
00064 
00065 CGAL_POLYNOMIAL_END_INTERNAL_NAMESPACE;
00066 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines