changed c-style to c++-style comments

This commit is contained in:
Luis Peñaranda 2013-09-19 15:37:59 -03:00
parent f92dc1c904
commit 9f45c20123
4 changed files with 82 additions and 90 deletions

View File

@ -122,7 +122,8 @@ public:
bool is_valid()const; bool is_valid()const;
bool is_finite()const; bool is_finite()const;
/*template<class>*/ double to_double()const; //template<class>
double to_double()const;
std::pair<double,double> to_interval() const; std::pair<double,double> to_interval() const;
Algebraic_1 sqrt()const; Algebraic_1 sqrt()const;
}; // class Algebraic_1 }; // class Algebraic_1

View File

@ -22,16 +22,15 @@
// //
// ============================================================================ // ============================================================================
/*! \file RS/isolator.h /// \file RS/isolator.h
\brief Defines class CGAL::RS_real_root_isolator /// Defines class CGAL::RS_real_root_isolator
///
Isolate real roots of polynomials with Fabrice Roullier's Rs. /// Isolate real roots of polynomials with Fabrice Roullier's Rs.
///
The polynomial has to be a univariate polynomial over any number type /// 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 /// which is contained in the real numbers. The polynomial does not need to
be square-free. /// be square-free.
///
*/
#ifndef CGAL_ALGEBRAIC_KERNEL_D_RS_ISOLATOR_H #ifndef CGAL_ALGEBRAIC_KERNEL_D_RS_ISOLATOR_H
#define CGAL_ALGEBRAIC_KERNEL_D_RS_ISOLATOR_H #define CGAL_ALGEBRAIC_KERNEL_D_RS_ISOLATOR_H
@ -45,11 +44,9 @@ namespace CGAL {
namespace internal { namespace internal {
/*! \brief A model of concept RealRootIsolator. /// A model of concept RealRootIsolator.
///
Polynomial_ must be Polynomial<Gmpz>, and Bound_ must be Gmpfr. /// Polynomial_ must be Polynomial<Gmpz>, and Bound_ must be Gmpfr.
*/
template <class Polynomial_, class Bound_> template <class Polynomial_, class Bound_>
class RS_real_root_isolator { class RS_real_root_isolator {
@ -68,11 +65,9 @@ private:
typedef Gmpfi Interval; typedef Gmpfi Interval;
public: public:
/*! \brief Constructor from univariate square free polynomial. /// Constructor from univariate square free polynomial.
/// The RealRootIsolator provides isolating intervals for the real
The RealRootIsolator provides isolating intervals for the real /// roots of the polynomial
roots of the polynomial
*/
RS_real_root_isolator(const Polynomial& p = Polynomial(Coefficient(0))) : RS_real_root_isolator(const Polynomial& p = Polynomial(Coefficient(0))) :
_m_polynomial(p) _m_polynomial(p)
//, _m_interval_given(false) //, _m_interval_given(false)
@ -84,61 +79,58 @@ public:
public: // functions public: // functions
/*! \brief returns the defining polynomial*/ //! Returns the defining polynomial.
Polynomial polynomial() const { Polynomial polynomial() const {
return _m_polynomial; return _m_polynomial;
} }
//! returns the number of real roots //! Returns the number of real roots.
int number_of_real_roots() const { int number_of_real_roots() const {
return _m_real_roots.size(); return _m_real_roots.size();
} }
/*! \brief returns true if the isolating interval is degenerated to a /// Returns true if the isolating interval is degenerated to a
single point. /// single point.
///
If is_exact_root(i) is true, /// If is_exact_root(i) is true,
then left_bound(int i) equals \f$root_i\f$. \n /// then left_bound(int i) equals \f$root_i\f$. \n
If is_exact_root(i) is true, /// If is_exact_root(i) is true,
then right_bound(int i) equals \f$root_i\f$. \n /// then right_bound(int i) equals \f$root_i\f$. \n
*/
bool is_exact_root(int i) const { bool is_exact_root(int i) const {
return(_m_real_roots[i].inf()==_m_real_roots[i].sup()); return(_m_real_roots[i].inf()==_m_real_roots[i].sup());
} }
public: public:
/*! \brief returns \f${l_i}\f$ the left bound of the isolating interval /// Returns \f${l_i}\f$ the left bound of the isolating interval
for root \f$root_{i}\f$. /// for root \f$root_{i}\f$.
///
In case is_exact_root(i) is true, \f$l_i = root_{i}\f$,\n /// In case is_exact_root(i) is true, \f$l_i = root_{i}\f$,\n
otherwise: \f$l_i < root_{i}\f$. /// 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 > root_{i-1}\f$. \n
If \f$i-1>=0\f$, then \f$l_i >= r_{i-1}\f$, /// If \f$i-1>=0\f$, then \f$l_i >= r_{i-1}\f$,
the right bound of \f$root_{i-1}\f$\n /// the right bound of \f$root_{i-1}\f$\n
///
\pre 0 <= i < number_of_real_roots() /// \pre 0 <= i < number_of_real_roots()
*/
Bound left_bound(int i) const { Bound left_bound(int i) const {
CGAL_assertion(i >= 0); CGAL_assertion(i >= 0);
CGAL_assertion(i < this->number_of_real_roots()); CGAL_assertion(i < this->number_of_real_roots());
return _m_real_roots[i].inf(); return _m_real_roots[i].inf();
} }
/*! \brief returns \f${r_i}\f$ the right bound of the isolating interval /// Returns \f${r_i}\f$ the right bound of the isolating interval
for root \f$root_{i}\f$. /// for root \f$root_{i}\f$.
///
In case is_exact_root(i) is true, \f$r_i = root_{i}\f$,\n /// In case is_exact_root(i) is true, \f$r_i = root_{i}\f$,\n
otherwise: \f$r_i > root_{i}\f$. /// otherwise: \f$r_i > root_{i}\f$.
///
If \f$i+1< n \f$, then \f$r_i < root_{i+1}\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 /// where \f$n\f$ is number of real roots.\n
If \f$i+1< n \f$, then \f$r_i <= l_{i+1}\f$, /// If \f$i+1< n \f$, then \f$r_i <= l_{i+1}\f$,
the left bound of \f$root_{i+1}\f$\n /// the left bound of \f$root_{i+1}\f$\n
///
\pre 0 <= i < number_of_real_roots() /// \pre 0 <= i < number_of_real_roots()
*/
Bound right_bound(int i) const { Bound right_bound(int i) const {
CGAL_assertion(i >= 0); CGAL_assertion(i >= 0);
CGAL_assertion(i < this->number_of_real_roots()); CGAL_assertion(i < this->number_of_real_roots());

View File

@ -251,39 +251,37 @@ struct Ediv_1:
public std::binary_function<RS_polynomial_1,RS_polynomial_1,RS_polynomial_1*>{ public std::binary_function<RS_polynomial_1,RS_polynomial_1,RS_polynomial_1*>{
RS_polynomial_1* RS_polynomial_1*
operator()(const RS_polynomial_1 &f,const RS_polynomial_1 &g){ operator()(const RS_polynomial_1 &f,const RS_polynomial_1 &g){
/* //int degf,degg,i;
int degf,degg,i; //mpz_ptr lcg;
mpz_ptr lcg; //mpz_t r;
mpz_t r; //degf=f.get_degree();
degf=f.get_degree(); //degg=g.get_degree();
degg=g.get_degree(); //RS_polynomial_1 *q=new RS_polynomial_1(degf-degg);
RS_polynomial_1 *q=new RS_polynomial_1(degf-degg); //lcg=g.leading_coefficient();
lcg=g.leading_coefficient(); //if(!degg){
if(!degg){ // for(int i=0;i<=degf;++i)
for(int i=0;i<=degf;++i) // mpz_divexact(q->coef(i),f.coef(i),lcg);
mpz_divexact(q->coef(i),f.coef(i),lcg); // return q;
return q; //}
} //mpz_init(r);
mpz_init(r); //mpz_set(r,f.leading_coefficient());
mpz_set(r,f.leading_coefficient()); //std::cout<<"f="<<f<<std::endl;
std::cout<<"f="<<f<<std::endl; //std::cout<<"g="<<g<<std::endl;
std::cout<<"g="<<g<<std::endl; //for(i=degf-degg;i>0;--i){
for(i=degf-degg;i>0;--i){ // //std::cout<<"\ni="<<i;
//std::cout<<"\ni="<<i; // mpz_divexact(q->coef(i),r/ *f.coef(i+degg)* /,lcg);
mpz_divexact(q->coef(i),r/ *f.coef(i+degg)* /,lcg); // //--------------------------------------------------
//-------------------------------------------------- // // mpz_mul(r,q->coef(i),lcg);
// mpz_mul(r,q->coef(i),lcg); // // mpz_sub(r,f.coef(i+degf-degg-1),r);
// mpz_sub(r,f.coef(i+degf-degg-1),r); // //--------------------------------------------------
//-------------------------------------------------- // mpz_mul(r,q->coef(i),g.coef(degg-1));
mpz_mul(r,q->coef(i),g.coef(degg-1)); // mpz_sub(r,f.coef(i+degf-degg-1),r);
mpz_sub(r,f.coef(i+degf-degg-1),r); // std::cout<<"i="<<i<<", q[i]="<<q->coef(i)<<", r="<<Gmpz(r)<<std::endl;
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_divexact(q->coef(0),r/ *f.coef(degg)* /,lcg); //mpz_clear(r);
mpz_clear(r); ////std::cout<<"\nediv("<<f<<","<<g<<") = "<<(*q)<<std::endl;
//std::cout<<"\nediv("<<f<<","<<g<<") = "<<(*q)<<std::endl; //return q;
return q;
*/
// naive implementation // naive implementation
RS_polynomial_1 *ret=new RS_polynomial_1(Pdivquo_1()(f,g)); RS_polynomial_1 *ret=new RS_polynomial_1(Pdivquo_1()(f,g));
return ret; return ret;

View File

@ -35,7 +35,8 @@ template <class GcdPolicy>
CGAL::Sign sign_1_no_rs(const RS_polynomial_1 &p,const Algebraic_1 &x){ CGAL::Sign sign_1_no_rs(const RS_polynomial_1 &p,const Algebraic_1 &x){
typedef GcdPolicy Gcd; typedef GcdPolicy Gcd;
unsigned bisect_steps=/*4*/1000; //unsigned bisect_steps=4;
unsigned bisect_steps=1000;
rs_sign s; rs_sign s;
CGAL::Sign sleft,sright; CGAL::Sign sleft,sright;
RS_polynomial_1 *gcd,*deriv; RS_polynomial_1 *gcd,*deriv;