diff --git a/Algebraic_kernel_d/include/CGAL/RS/algebraic_1.h b/Algebraic_kernel_d/include/CGAL/RS/algebraic_1.h index fa8a1e81c07..94219ca1d02 100644 --- a/Algebraic_kernel_d/include/CGAL/RS/algebraic_1.h +++ b/Algebraic_kernel_d/include/CGAL/RS/algebraic_1.h @@ -192,12 +192,13 @@ boost::totally_ordered RT; typedef typename RT::To_double TD; - Refiner()(get_pol(),get_left(),get_right(),CGAL_RS_DBL_PREC); - CGAL_assertion(TD()(get_left())==TD()(get_right())); - return TD()(get_left()); + Refiner()(pol,left,right,CGAL_RS_DBL_PREC); + CGAL_assertion(TD()(left)==TD()(right)); + return TD()(left); } std::pair to_interval()const{ typedef Real_embeddable_traits RT; @@ -266,7 +267,7 @@ public INTERN_RET::Real_embeddable_traits_base< class To_double:public std::unary_function{ public: - double operator()(Type a)const{return a.to_double();} + double operator()(const Type &a)const{return a.to_double();} }; class To_interval: diff --git a/Algebraic_kernel_d/include/CGAL/RS/algebraic_z_1.h b/Algebraic_kernel_d/include/CGAL/RS/algebraic_z_1.h index 3cea711c24c..9e105a2c146 100644 --- a/Algebraic_kernel_d/include/CGAL/RS/algebraic_z_1.h +++ b/Algebraic_kernel_d/include/CGAL/RS/algebraic_z_1.h @@ -184,7 +184,7 @@ boost::totally_ordered RT; typedef typename RT::To_double TD; ZRefiner()(get_zpol(), @@ -258,7 +258,7 @@ public INTERN_RET::Real_embeddable_traits_base< class To_double:public std::unary_function{ public: - double operator()(Type a)const{return a.to_double();} + double operator()(const Type &a)const{return a.to_double();} }; class To_interval: diff --git a/Algebraic_kernel_d/include/CGAL/RS/bisection_refiner_1.h b/Algebraic_kernel_d/include/CGAL/RS/bisection_refiner_1.h index cfb5554f3db..bf41418b323 100644 --- a/Algebraic_kernel_d/include/CGAL/RS/bisection_refiner_1.h +++ b/Algebraic_kernel_d/include/CGAL/RS/bisection_refiner_1.h @@ -47,7 +47,7 @@ operator()(const Polynomial_&,Bound_&,Bound_&,int){ // 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 essentially the same. +// remove the need for the next function, which is essentially the same. template<> void Bisection_refiner_1,Gmpfr>:: @@ -58,8 +58,6 @@ operator()(const Polynomial &pol,Gmpfr &left,Gmpfr &right,int prec){ typedef CGAL::RS_AK1::Signat_1 Signat; CGAL_precondition(left<=right); - // TODO: add precondition to check whether the interval is a point - // or the evaluations on its endpoints have different signs //std::cout<<"refining ["< &pol,Gmpfr &left,Gmpfr &right,int prec){ mpfr_t center; sl=signof(left); + CGAL_precondition(sl!=signof(right)||(left==right&&sl==ZERO)); if(sl==ZERO) return; pl=left.get_precision(); @@ -120,8 +119,6 @@ operator()(const Polynomial &pol,Gmpfr &left,Gmpfr &right,int prec){ typedef CGAL::RS_AK1::Signat_1 Signat; CGAL_precondition(left<=right); - // TODO: add precondition to check whether the interval is a point - // or the evaluations on its endpoints have different signs //std::cout<<"refining ["< &pol,Gmpfr &left,Gmpfr &right,int prec){ mpfr_t center; sl=signof(left); + CGAL_precondition(sl!=signof(right)||(left==right&&sl==ZERO)); if(sl==ZERO) return; pl=left.get_precision(); diff --git a/Algebraic_kernel_d/include/CGAL/RS/rs23_k_isolator_1.h b/Algebraic_kernel_d/include/CGAL/RS/rs23_k_isolator_1.h index ac98576e287..ffb89c7ad4c 100644 --- a/Algebraic_kernel_d/include/CGAL/RS/rs23_k_isolator_1.h +++ b/Algebraic_kernel_d/include/CGAL/RS/rs23_k_isolator_1.h @@ -80,6 +80,7 @@ RS23_k_isolator_1(const CGAL::Polynomial &p):_polynomial(p){ for(int j=0;j +BOOST_STATIC_ASSERT_MSG( + MPFR_VERSION_MAJOR!=3 || + MPFR_VERSION_MINOR!=1 || + MPFR_VERSION_PATCHLEVEL<3 || MPFR_VERSION_PATCHLEVEL>5, + "RS3 does not work with MPFR versions 3.1.3 to 3.1.5. "# + "Please update MPFR or disable RS3."); +#endif // CGAL_USE_RS3 + namespace CGAL{ namespace RS2{ @@ -120,6 +133,7 @@ struct RS2_calls{ // Construct Gmpfr's with pointers to endpoints. Gmpfr left(&(root_pointer->left),root_prec); Gmpfr right(&(root_pointer->right),root_prec); + CGAL_assertion(left<=right); // Copy them, to have the data out of RS memory. *x++=Gmpfi(left,right,root_prec+1); ident_node=rs_export_list_vect_ibfr_nextnode diff --git a/Algebraic_kernel_d/include/CGAL/RS/rs3_k_refiner_1.h b/Algebraic_kernel_d/include/CGAL/RS/rs3_k_refiner_1.h index e00d4eccb4e..e9d6457ca30 100644 --- a/Algebraic_kernel_d/include/CGAL/RS/rs3_k_refiner_1.h +++ b/Algebraic_kernel_d/include/CGAL/RS/rs3_k_refiner_1.h @@ -22,10 +22,16 @@ #define CGAL_RS_RS3_K_REFINER_1_H #include +#include "polynomial_converter_1.h" #include "rs2_calls.h" #include #include "Gmpfr_make_unique.h" +// If we want assertions, we need to evaluate. +#ifndef CGAL_NO_PRECONDITIONS +#include "signat_1.h" +#endif + namespace CGAL{ namespace RS3{ @@ -51,8 +57,15 @@ operator() typedef Polynomial_traits_d Ptraits; typedef Ptraits::Degree Degree; CGAL_precondition(left<=right); - // TODO: add precondition to check whether the interval is a point - // or the evaluations on its endpoints have different signs +#ifndef CGAL_NO_PRECONDITIONS + typedef Ptraits::Make_square_free Sfpart; + typedef CGAL::RS_AK1::Signat_1 + Signat; + Polynomial sfpp=Sfpart()(pol); + Signat signof(sfpp); + CGAL::Sign sl=signof(left); + CGAL_precondition(sl!=signof(right)||(left==right&&sl==ZERO)); +#endif //std::cout<<"refining ["< ZPtraits; typedef ZPtraits::Degree ZDegree; CGAL_precondition(left<=right); - // TODO: add precondition to check whether the interval is a point - // or the evaluations on its endpoints have different signs +#ifndef CGAL_NO_PRECONDITIONS + typedef ZPtraits::Make_square_free ZSfpart; + typedef CGAL::RS_AK1::Signat_1 + Signat; +#endif //std::cout<<"refining ["< zpol=CGAL::RS_AK1::Polynomial_converter_1< CGAL::Polynomial, CGAL::Polynomial >()(qpol); +#ifndef CGAL_NO_PRECONDITIONS + ZPolynomial zsfpp=ZSfpart()(zpol); + Signat signof(zsfpp); + CGAL::Sign sl=signof(left); + CGAL_precondition(sl!=signof(right)||(left==right&&sl==ZERO)); +#endif int deg=ZDegree()(zpol); mpz_t* coefficients=(mpz_t*)malloc((deg+1)*sizeof(mpz_t)); __mpfi_struct interval; diff --git a/Algebraic_kernel_d/include/CGAL/RS/rs3_refiner_1.h b/Algebraic_kernel_d/include/CGAL/RS/rs3_refiner_1.h index 9755484b080..29d3756543d 100644 --- a/Algebraic_kernel_d/include/CGAL/RS/rs3_refiner_1.h +++ b/Algebraic_kernel_d/include/CGAL/RS/rs3_refiner_1.h @@ -26,6 +26,11 @@ #include #include "Gmpfr_make_unique.h" +// If we want assertions, we need to evaluate. +#ifndef CGAL_NO_PRECONDITIONS +#include "signat_1.h" +#endif + namespace CGAL{ namespace RS3{ @@ -51,8 +56,15 @@ operator() typedef Polynomial_traits_d Ptraits; typedef Ptraits::Degree Degree; CGAL_precondition(left<=right); - // TODO: add precondition to check whether the interval is a point - // or the evaluations on its endpoints have different signs +#ifndef CGAL_NO_PRECONDITIONS + typedef Ptraits::Make_square_free Sfpart; + typedef CGAL::RS_AK1::Signat_1 + Signat; + Polynomial sfpp=Sfpart()(pol); + Signat signof(sfpp); + CGAL::Sign sl=signof(left); + CGAL_precondition(sl!=signof(right)||(left==right&&sl==ZERO)); +#endif //std::cout<<"refining ["< ZPtraits; typedef ZPtraits::Degree ZDegree; CGAL_precondition(left<=right); - // TODO: add precondition to check whether the interval is a point - // or the evaluations on its endpoints have different signs +#ifndef CGAL_NO_PRECONDITIONS + typedef ZPtraits::Make_square_free ZSfpart; + typedef CGAL::RS_AK1::Signat_1 + Signat; +#endif //std::cout<<"refining ["< zpol=CGAL::RS_AK1::Polynomial_converter_1< CGAL::Polynomial, CGAL::Polynomial >()(qpol); +#ifndef CGAL_NO_PRECONDITIONS + ZPolynomial zsfpp=ZSfpart()(zpol); + Signat signof(zsfpp); + CGAL::Sign sl=signof(left); + CGAL_precondition(sl!=signof(right)||(left==right&&sl==ZERO)); +#endif int deg=ZDegree()(zpol); mpz_t* coefficients=(mpz_t*)malloc((deg+1)*sizeof(mpz_t)); __mpfi_struct interval;