// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). 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. // See the file LICENSE.LGPL distributed with CGAL. // // 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$ // SPDX-License-Identifier: LGPL-3.0+ // // Author: Luis PeƱaranda // This file contains the simplest refiner, that bisects the interval a given // number of times. #ifndef CGAL_RS_BISECTION_REFINER_1_H #define CGAL_RS_BISECTION_REFINER_1_H #include #include "signat_1.h" #include "Gmpfr_make_unique.h" namespace CGAL{ template struct Bisection_refiner_1{ typedef CGAL::RS_AK1::Signat_1 Signat; void operator()(const Polynomial_&,Bound_&,Bound_&,int); }; // class Bisection_refiner_1 // TODO: Write in a generic way, if possible (see next function). template void Bisection_refiner_1:: operator()(const Polynomial_&,Bound_&,Bound_&,int){ CGAL_error_msg("bisection refiner not implemented for these types"); return; } // This works with any type of polynomial, but only for Gmpfr bounds. // TODO: Beyond writing generically, optimize this function. This would // remove the need for the next function, which is essentially the same. template<> void Bisection_refiner_1,Gmpfr>:: operator()(const Polynomial &pol,Gmpfr &left,Gmpfr &right,int prec){ typedef Polynomial Polynomial; typedef Polynomial_traits_d Ptraits; typedef Ptraits::Make_square_free Sfpart; typedef CGAL::RS_AK1::Signat_1 Signat; CGAL_precondition(left<=right); //std::cout<<"refining ["<pc?pl:pc)+(mp_prec_t)prec; mpfr_init2(center,pc); CGAL_assertion_code(int round=) mpfr_prec_round(left.fr(),pc,GMP_RNDN); CGAL_assertion(!round); CGAL_assertion_code(round=) mpfr_prec_round(right.fr(),pc,GMP_RNDN); CGAL_assertion(!round); for(int i=0;i void Bisection_refiner_1,Gmpfr>:: operator()(const Polynomial &pol,Gmpfr &left,Gmpfr &right,int prec){ typedef Polynomial Polynomial; typedef Polynomial_traits_d Ptraits; typedef Ptraits::Make_square_free Sfpart; typedef CGAL::RS_AK1::Signat_1 Signat; CGAL_precondition(left<=right); //std::cout<<"refining ["<pc?pl:pc)+(mp_prec_t)prec; mpfr_init2(center,pc); CGAL_assertion_code(int round=) mpfr_prec_round(left.fr(),pc,GMP_RNDN); CGAL_assertion(!round); CGAL_assertion_code(round=) mpfr_prec_round(right.fr(),pc,GMP_RNDN); CGAL_assertion(!round); for(int i=0;i