mirror of https://github.com/CGAL/cgal
changed c-style to c++-style comments
This commit is contained in:
parent
f92dc1c904
commit
9f45c20123
|
|
@ -122,7 +122,8 @@ public:
|
|||
|
||||
bool is_valid()const;
|
||||
bool is_finite()const;
|
||||
/*template<class>*/ double to_double()const;
|
||||
//template<class>
|
||||
double to_double()const;
|
||||
std::pair<double,double> to_interval() const;
|
||||
Algebraic_1 sqrt()const;
|
||||
}; // class Algebraic_1
|
||||
|
|
|
|||
|
|
@ -22,16 +22,15 @@
|
|||
//
|
||||
// ============================================================================
|
||||
|
||||
/*! \file RS/isolator.h
|
||||
\brief Defines class CGAL::RS_real_root_isolator
|
||||
|
||||
Isolate real roots of polynomials with Fabrice Roullier's Rs.
|
||||
|
||||
The polynomial has to be a univariate polynomial over any number type
|
||||
which is contained in the real numbers. The polynomial does not need to
|
||||
be square-free.
|
||||
|
||||
*/
|
||||
/// \file RS/isolator.h
|
||||
/// Defines class CGAL::RS_real_root_isolator
|
||||
///
|
||||
/// Isolate real roots of polynomials with Fabrice Roullier's Rs.
|
||||
///
|
||||
/// The polynomial has to be a univariate polynomial over any number type
|
||||
/// which is contained in the real numbers. The polynomial does not need to
|
||||
/// be square-free.
|
||||
///
|
||||
|
||||
#ifndef CGAL_ALGEBRAIC_KERNEL_D_RS_ISOLATOR_H
|
||||
#define CGAL_ALGEBRAIC_KERNEL_D_RS_ISOLATOR_H
|
||||
|
|
@ -45,11 +44,9 @@ namespace CGAL {
|
|||
|
||||
namespace internal {
|
||||
|
||||
/*! \brief A model of concept RealRootIsolator.
|
||||
|
||||
Polynomial_ must be Polynomial<Gmpz>, and Bound_ must be Gmpfr.
|
||||
|
||||
*/
|
||||
/// A model of concept RealRootIsolator.
|
||||
///
|
||||
/// Polynomial_ must be Polynomial<Gmpz>, and Bound_ must be Gmpfr.
|
||||
template <class Polynomial_, class Bound_>
|
||||
class RS_real_root_isolator {
|
||||
|
||||
|
|
@ -68,11 +65,9 @@ private:
|
|||
typedef Gmpfi Interval;
|
||||
|
||||
public:
|
||||
/*! \brief Constructor from univariate square free polynomial.
|
||||
|
||||
The RealRootIsolator provides isolating intervals for the real
|
||||
roots of the polynomial
|
||||
*/
|
||||
/// Constructor from univariate square free polynomial.
|
||||
/// The RealRootIsolator provides isolating intervals for the real
|
||||
/// roots of the polynomial
|
||||
RS_real_root_isolator(const Polynomial& p = Polynomial(Coefficient(0))) :
|
||||
_m_polynomial(p)
|
||||
//, _m_interval_given(false)
|
||||
|
|
@ -84,61 +79,58 @@ public:
|
|||
|
||||
public: // functions
|
||||
|
||||
/*! \brief returns the defining polynomial*/
|
||||
//! Returns the defining polynomial.
|
||||
Polynomial polynomial() const {
|
||||
return _m_polynomial;
|
||||
}
|
||||
|
||||
//! returns the number of real roots
|
||||
//! Returns the number of real roots.
|
||||
int number_of_real_roots() const {
|
||||
return _m_real_roots.size();
|
||||
}
|
||||
|
||||
/*! \brief returns true if the isolating interval is degenerated to a
|
||||
single point.
|
||||
|
||||
If is_exact_root(i) is true,
|
||||
then left_bound(int i) equals \f$root_i\f$. \n
|
||||
If is_exact_root(i) is true,
|
||||
then right_bound(int i) equals \f$root_i\f$. \n
|
||||
*/
|
||||
/// Returns true if the isolating interval is degenerated to a
|
||||
/// single point.
|
||||
///
|
||||
/// If is_exact_root(i) is true,
|
||||
/// then left_bound(int i) equals \f$root_i\f$. \n
|
||||
/// If is_exact_root(i) is true,
|
||||
/// then right_bound(int i) equals \f$root_i\f$. \n
|
||||
bool is_exact_root(int i) const {
|
||||
return(_m_real_roots[i].inf()==_m_real_roots[i].sup());
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/*! \brief returns \f${l_i}\f$ the left bound of the isolating interval
|
||||
for root \f$root_{i}\f$.
|
||||
|
||||
In case is_exact_root(i) is true, \f$l_i = root_{i}\f$,\n
|
||||
otherwise: \f$l_i < root_{i}\f$.
|
||||
|
||||
If \f$i-1>=0\f$, then \f$l_i > root_{i-1}\f$. \n
|
||||
If \f$i-1>=0\f$, then \f$l_i >= r_{i-1}\f$,
|
||||
the right bound of \f$root_{i-1}\f$\n
|
||||
|
||||
\pre 0 <= i < number_of_real_roots()
|
||||
*/
|
||||
/// Returns \f${l_i}\f$ the left bound of the isolating interval
|
||||
/// for root \f$root_{i}\f$.
|
||||
///
|
||||
/// In case is_exact_root(i) is true, \f$l_i = root_{i}\f$,\n
|
||||
/// otherwise: \f$l_i < root_{i}\f$.
|
||||
///
|
||||
/// If \f$i-1>=0\f$, then \f$l_i > root_{i-1}\f$. \n
|
||||
/// If \f$i-1>=0\f$, then \f$l_i >= r_{i-1}\f$,
|
||||
/// the right bound of \f$root_{i-1}\f$\n
|
||||
///
|
||||
/// \pre 0 <= i < number_of_real_roots()
|
||||
Bound left_bound(int i) const {
|
||||
CGAL_assertion(i >= 0);
|
||||
CGAL_assertion(i < this->number_of_real_roots());
|
||||
return _m_real_roots[i].inf();
|
||||
}
|
||||
|
||||
/*! \brief returns \f${r_i}\f$ the right bound of the isolating interval
|
||||
for root \f$root_{i}\f$.
|
||||
|
||||
In case is_exact_root(i) is true, \f$r_i = root_{i}\f$,\n
|
||||
otherwise: \f$r_i > root_{i}\f$.
|
||||
|
||||
If \f$i+1< n \f$, then \f$r_i < root_{i+1}\f$,
|
||||
where \f$n\f$ is number of real roots.\n
|
||||
If \f$i+1< n \f$, then \f$r_i <= l_{i+1}\f$,
|
||||
the left bound of \f$root_{i+1}\f$\n
|
||||
|
||||
\pre 0 <= i < number_of_real_roots()
|
||||
*/
|
||||
/// Returns \f${r_i}\f$ the right bound of the isolating interval
|
||||
/// for root \f$root_{i}\f$.
|
||||
///
|
||||
/// In case is_exact_root(i) is true, \f$r_i = root_{i}\f$,\n
|
||||
/// otherwise: \f$r_i > root_{i}\f$.
|
||||
///
|
||||
/// If \f$i+1< n \f$, then \f$r_i < root_{i+1}\f$,
|
||||
/// where \f$n\f$ is number of real roots.\n
|
||||
/// If \f$i+1< n \f$, then \f$r_i <= l_{i+1}\f$,
|
||||
/// the left bound of \f$root_{i+1}\f$\n
|
||||
///
|
||||
/// \pre 0 <= i < number_of_real_roots()
|
||||
Bound right_bound(int i) const {
|
||||
CGAL_assertion(i >= 0);
|
||||
CGAL_assertion(i < this->number_of_real_roots());
|
||||
|
|
|
|||
|
|
@ -251,39 +251,37 @@ struct Ediv_1:
|
|||
public std::binary_function<RS_polynomial_1,RS_polynomial_1,RS_polynomial_1*>{
|
||||
RS_polynomial_1*
|
||||
operator()(const RS_polynomial_1 &f,const RS_polynomial_1 &g){
|
||||
/*
|
||||
int degf,degg,i;
|
||||
mpz_ptr lcg;
|
||||
mpz_t r;
|
||||
degf=f.get_degree();
|
||||
degg=g.get_degree();
|
||||
RS_polynomial_1 *q=new RS_polynomial_1(degf-degg);
|
||||
lcg=g.leading_coefficient();
|
||||
if(!degg){
|
||||
for(int i=0;i<=degf;++i)
|
||||
mpz_divexact(q->coef(i),f.coef(i),lcg);
|
||||
return q;
|
||||
}
|
||||
mpz_init(r);
|
||||
mpz_set(r,f.leading_coefficient());
|
||||
std::cout<<"f="<<f<<std::endl;
|
||||
std::cout<<"g="<<g<<std::endl;
|
||||
for(i=degf-degg;i>0;--i){
|
||||
//std::cout<<"\ni="<<i;
|
||||
mpz_divexact(q->coef(i),r/ *f.coef(i+degg)* /,lcg);
|
||||
//--------------------------------------------------
|
||||
// mpz_mul(r,q->coef(i),lcg);
|
||||
// mpz_sub(r,f.coef(i+degf-degg-1),r);
|
||||
//--------------------------------------------------
|
||||
mpz_mul(r,q->coef(i),g.coef(degg-1));
|
||||
mpz_sub(r,f.coef(i+degf-degg-1),r);
|
||||
std::cout<<"i="<<i<<", q[i]="<<q->coef(i)<<", r="<<Gmpz(r)<<std::endl;
|
||||
}
|
||||
mpz_divexact(q->coef(0),r/ *f.coef(degg)* /,lcg);
|
||||
mpz_clear(r);
|
||||
//std::cout<<"\nediv("<<f<<","<<g<<") = "<<(*q)<<std::endl;
|
||||
return q;
|
||||
*/
|
||||
//int degf,degg,i;
|
||||
//mpz_ptr lcg;
|
||||
//mpz_t r;
|
||||
//degf=f.get_degree();
|
||||
//degg=g.get_degree();
|
||||
//RS_polynomial_1 *q=new RS_polynomial_1(degf-degg);
|
||||
//lcg=g.leading_coefficient();
|
||||
//if(!degg){
|
||||
// for(int i=0;i<=degf;++i)
|
||||
// mpz_divexact(q->coef(i),f.coef(i),lcg);
|
||||
// return q;
|
||||
//}
|
||||
//mpz_init(r);
|
||||
//mpz_set(r,f.leading_coefficient());
|
||||
//std::cout<<"f="<<f<<std::endl;
|
||||
//std::cout<<"g="<<g<<std::endl;
|
||||
//for(i=degf-degg;i>0;--i){
|
||||
// //std::cout<<"\ni="<<i;
|
||||
// mpz_divexact(q->coef(i),r/ *f.coef(i+degg)* /,lcg);
|
||||
// //--------------------------------------------------
|
||||
// // mpz_mul(r,q->coef(i),lcg);
|
||||
// // mpz_sub(r,f.coef(i+degf-degg-1),r);
|
||||
// //--------------------------------------------------
|
||||
// mpz_mul(r,q->coef(i),g.coef(degg-1));
|
||||
// mpz_sub(r,f.coef(i+degf-degg-1),r);
|
||||
// std::cout<<"i="<<i<<", q[i]="<<q->coef(i)<<", r="<<Gmpz(r)<<std::endl;
|
||||
//}
|
||||
//mpz_divexact(q->coef(0),r/ *f.coef(degg)* /,lcg);
|
||||
//mpz_clear(r);
|
||||
////std::cout<<"\nediv("<<f<<","<<g<<") = "<<(*q)<<std::endl;
|
||||
//return q;
|
||||
// naive implementation
|
||||
RS_polynomial_1 *ret=new RS_polynomial_1(Pdivquo_1()(f,g));
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ template <class GcdPolicy>
|
|||
CGAL::Sign sign_1_no_rs(const RS_polynomial_1 &p,const Algebraic_1 &x){
|
||||
typedef GcdPolicy Gcd;
|
||||
|
||||
unsigned bisect_steps=/*4*/1000;
|
||||
//unsigned bisect_steps=4;
|
||||
unsigned bisect_steps=1000;
|
||||
rs_sign s;
|
||||
CGAL::Sign sleft,sright;
|
||||
RS_polynomial_1 *gcd,*deriv;
|
||||
|
|
|
|||
Loading…
Reference in New Issue