mirror of https://github.com/CGAL/cgal
Add assertions in refiners.
The assertions check that the endpoints of the interval to refine have different evaluation signs, or they are the same point and its evaluation is zero.
This commit is contained in:
parent
67556fbef3
commit
5089db3e37
|
|
@ -47,7 +47,7 @@ operator()(const Polynomial_&,Bound_&,Bound_&,int){
|
||||||
|
|
||||||
// This works with any type of polynomial, but only for Gmpfr bounds.
|
// This works with any type of polynomial, but only for Gmpfr bounds.
|
||||||
// TODO: Beyond writing generically, optimize this function. This would
|
// 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<>
|
template<>
|
||||||
void
|
void
|
||||||
Bisection_refiner_1<Polynomial<Gmpz>,Gmpfr>::
|
Bisection_refiner_1<Polynomial<Gmpz>,Gmpfr>::
|
||||||
|
|
@ -58,8 +58,6 @@ operator()(const Polynomial<Gmpz> &pol,Gmpfr &left,Gmpfr &right,int prec){
|
||||||
typedef CGAL::RS_AK1::Signat_1<Polynomial,Gmpfr>
|
typedef CGAL::RS_AK1::Signat_1<Polynomial,Gmpfr>
|
||||||
Signat;
|
Signat;
|
||||||
CGAL_precondition(left<=right);
|
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 ["<<left<<","<<right<<"]"<<std::endl;
|
//std::cout<<"refining ["<<left<<","<<right<<"]"<<std::endl;
|
||||||
|
|
||||||
CGAL_RS_GMPFR_MAKE_UNIQUE(left,temp_left);
|
CGAL_RS_GMPFR_MAKE_UNIQUE(left,temp_left);
|
||||||
|
|
@ -72,6 +70,7 @@ operator()(const Polynomial<Gmpz> &pol,Gmpfr &left,Gmpfr &right,int prec){
|
||||||
mpfr_t center;
|
mpfr_t center;
|
||||||
|
|
||||||
sl=signof(left);
|
sl=signof(left);
|
||||||
|
CGAL_precondition(sl!=signof(right)||(left==right&&sl==ZERO));
|
||||||
if(sl==ZERO)
|
if(sl==ZERO)
|
||||||
return;
|
return;
|
||||||
pl=left.get_precision();
|
pl=left.get_precision();
|
||||||
|
|
@ -120,8 +119,6 @@ operator()(const Polynomial<Gmpq> &pol,Gmpfr &left,Gmpfr &right,int prec){
|
||||||
typedef CGAL::RS_AK1::Signat_1<Polynomial,Gmpfr>
|
typedef CGAL::RS_AK1::Signat_1<Polynomial,Gmpfr>
|
||||||
Signat;
|
Signat;
|
||||||
CGAL_precondition(left<=right);
|
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 ["<<left<<","<<right<<"]"<<std::endl;
|
//std::cout<<"refining ["<<left<<","<<right<<"]"<<std::endl;
|
||||||
|
|
||||||
CGAL_RS_GMPFR_MAKE_UNIQUE(left,temp_left);
|
CGAL_RS_GMPFR_MAKE_UNIQUE(left,temp_left);
|
||||||
|
|
@ -134,6 +131,7 @@ operator()(const Polynomial<Gmpq> &pol,Gmpfr &left,Gmpfr &right,int prec){
|
||||||
mpfr_t center;
|
mpfr_t center;
|
||||||
|
|
||||||
sl=signof(left);
|
sl=signof(left);
|
||||||
|
CGAL_precondition(sl!=signof(right)||(left==right&&sl==ZERO));
|
||||||
if(sl==ZERO)
|
if(sl==ZERO)
|
||||||
return;
|
return;
|
||||||
pl=left.get_precision();
|
pl=left.get_precision();
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,11 @@
|
||||||
#include <rs3_fncts.h>
|
#include <rs3_fncts.h>
|
||||||
#include "Gmpfr_make_unique.h"
|
#include "Gmpfr_make_unique.h"
|
||||||
|
|
||||||
|
// If we want assertions, we need to evaluate.
|
||||||
|
#ifndef CGAL_NO_ASSERTIONS
|
||||||
|
#include "signat_1.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace CGAL{
|
namespace CGAL{
|
||||||
namespace RS3{
|
namespace RS3{
|
||||||
|
|
||||||
|
|
@ -51,8 +56,15 @@ operator()
|
||||||
typedef Polynomial_traits_d<Polynomial> Ptraits;
|
typedef Polynomial_traits_d<Polynomial> Ptraits;
|
||||||
typedef Ptraits::Degree Degree;
|
typedef Ptraits::Degree Degree;
|
||||||
CGAL_precondition(left<=right);
|
CGAL_precondition(left<=right);
|
||||||
// TODO: add precondition to check whether the interval is a point
|
#ifndef CGAL_NO_ASSERTIONS
|
||||||
// or the evaluations on its endpoints have different signs
|
typedef Ptraits::Make_square_free Sfpart;
|
||||||
|
typedef CGAL::RS_AK1::Signat_1<Polynomial,Gmpfr>
|
||||||
|
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 ["<<left<<","<<right<<"]"<<std::endl;
|
//std::cout<<"refining ["<<left<<","<<right<<"]"<<std::endl;
|
||||||
int deg=Degree()(pol);
|
int deg=Degree()(pol);
|
||||||
mpz_t* coefficients=(mpz_t*)malloc((deg+1)*sizeof(mpz_t));
|
mpz_t* coefficients=(mpz_t*)malloc((deg+1)*sizeof(mpz_t));
|
||||||
|
|
@ -98,12 +110,21 @@ operator()
|
||||||
typedef Polynomial_traits_d<ZPolynomial> ZPtraits;
|
typedef Polynomial_traits_d<ZPolynomial> ZPtraits;
|
||||||
typedef ZPtraits::Degree ZDegree;
|
typedef ZPtraits::Degree ZDegree;
|
||||||
CGAL_precondition(left<=right);
|
CGAL_precondition(left<=right);
|
||||||
// TODO: add precondition to check whether the interval is a point
|
#ifndef CGAL_NO_ASSERTIONS
|
||||||
// or the evaluations on its endpoints have different signs
|
typedef ZPtraits::Make_square_free ZSfpart;
|
||||||
|
typedef CGAL::RS_AK1::Signat_1<ZPolynomial,Gmpfr>
|
||||||
|
Signat;
|
||||||
|
#endif
|
||||||
//std::cout<<"refining ["<<left<<","<<right<<"]"<<std::endl;
|
//std::cout<<"refining ["<<left<<","<<right<<"]"<<std::endl;
|
||||||
Polynomial<Gmpz> zpol=CGAL::RS_AK1::Polynomial_converter_1<
|
Polynomial<Gmpz> zpol=CGAL::RS_AK1::Polynomial_converter_1<
|
||||||
CGAL::Polynomial<Gmpq>,
|
CGAL::Polynomial<Gmpq>,
|
||||||
CGAL::Polynomial<Gmpz> >()(qpol);
|
CGAL::Polynomial<Gmpz> >()(qpol);
|
||||||
|
#ifndef CGAL_NO_ASSERTIONS
|
||||||
|
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);
|
int deg=ZDegree()(zpol);
|
||||||
mpz_t* coefficients=(mpz_t*)malloc((deg+1)*sizeof(mpz_t));
|
mpz_t* coefficients=(mpz_t*)malloc((deg+1)*sizeof(mpz_t));
|
||||||
__mpfi_struct interval;
|
__mpfi_struct interval;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,11 @@
|
||||||
#include <rs3_fncts.h>
|
#include <rs3_fncts.h>
|
||||||
#include "Gmpfr_make_unique.h"
|
#include "Gmpfr_make_unique.h"
|
||||||
|
|
||||||
|
// If we want assertions, we need to evaluate.
|
||||||
|
#ifndef CGAL_NO_ASSERTIONS
|
||||||
|
#include "signat_1.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace CGAL{
|
namespace CGAL{
|
||||||
namespace RS3{
|
namespace RS3{
|
||||||
|
|
||||||
|
|
@ -51,8 +56,15 @@ operator()
|
||||||
typedef Polynomial_traits_d<Polynomial> Ptraits;
|
typedef Polynomial_traits_d<Polynomial> Ptraits;
|
||||||
typedef Ptraits::Degree Degree;
|
typedef Ptraits::Degree Degree;
|
||||||
CGAL_precondition(left<=right);
|
CGAL_precondition(left<=right);
|
||||||
// TODO: add precondition to check whether the interval is a point
|
#ifndef CGAL_NO_ASSERTIONS
|
||||||
// or the evaluations on its endpoints have different signs
|
typedef Ptraits::Make_square_free Sfpart;
|
||||||
|
typedef CGAL::RS_AK1::Signat_1<Polynomial,Gmpfr>
|
||||||
|
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 ["<<left<<","<<right<<"]"<<std::endl;
|
//std::cout<<"refining ["<<left<<","<<right<<"]"<<std::endl;
|
||||||
int deg=Degree()(pol);
|
int deg=Degree()(pol);
|
||||||
mpz_t* coefficients=(mpz_t*)malloc((deg+1)*sizeof(mpz_t));
|
mpz_t* coefficients=(mpz_t*)malloc((deg+1)*sizeof(mpz_t));
|
||||||
|
|
@ -104,13 +116,22 @@ operator()
|
||||||
typedef Polynomial_traits_d<ZPolynomial> ZPtraits;
|
typedef Polynomial_traits_d<ZPolynomial> ZPtraits;
|
||||||
typedef ZPtraits::Degree ZDegree;
|
typedef ZPtraits::Degree ZDegree;
|
||||||
CGAL_precondition(left<=right);
|
CGAL_precondition(left<=right);
|
||||||
// TODO: add precondition to check whether the interval is a point
|
#ifndef CGAL_NO_ASSERTIONS
|
||||||
// or the evaluations on its endpoints have different signs
|
typedef ZPtraits::Make_square_free ZSfpart;
|
||||||
|
typedef CGAL::RS_AK1::Signat_1<ZPolynomial,Gmpfr>
|
||||||
|
Signat;
|
||||||
|
#endif
|
||||||
//std::cout<<"refining ["<<left<<","<<right<<"]"<<std::endl;
|
//std::cout<<"refining ["<<left<<","<<right<<"]"<<std::endl;
|
||||||
// Construct a Gmpz polynomial from the original Gmpq polynomial.
|
// Construct a Gmpz polynomial from the original Gmpq polynomial.
|
||||||
Polynomial<Gmpz> zpol=CGAL::RS_AK1::Polynomial_converter_1<
|
Polynomial<Gmpz> zpol=CGAL::RS_AK1::Polynomial_converter_1<
|
||||||
CGAL::Polynomial<Gmpq>,
|
CGAL::Polynomial<Gmpq>,
|
||||||
CGAL::Polynomial<Gmpz> >()(qpol);
|
CGAL::Polynomial<Gmpz> >()(qpol);
|
||||||
|
#ifndef CGAL_NO_ASSERTIONS
|
||||||
|
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);
|
int deg=ZDegree()(zpol);
|
||||||
mpz_t* coefficients=(mpz_t*)malloc((deg+1)*sizeof(mpz_t));
|
mpz_t* coefficients=(mpz_t*)malloc((deg+1)*sizeof(mpz_t));
|
||||||
__mpfi_struct interval;
|
__mpfi_struct interval;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue