// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved. // // This file is part of CGAL (www.cgal.org) // // $URL: https://github.com/CGAL/cgal/blob/v5.1/Algebraic_kernel_d/include/CGAL/RS/bisection_refiner_1.h $ // $Id: bisection_refiner_1.h 52164b1 2019-10-19T15:34:59+02:00 Sébastien Loriot // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial // // 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