added several TODOs
This commit is contained in:
Michael Hemmer 2008-07-16 14:07:28 +00:00
parent 1a4079f2f8
commit 1570772295
1 changed files with 1312 additions and 1268 deletions

View File

@ -113,7 +113,6 @@ public:
return content; return content;
} }
}; };
}; };
template< class Coefficient_ > template< class Coefficient_ >
@ -160,7 +159,8 @@ public:
} }
void operator() ( void operator() (
const Polynomial_1& m1, const Polynomial_1& m2, const Polynomial_1& m, const Polynomial_1& m1, const Polynomial_1& m2,
const Polynomial_1& m,
const Polynomial_1& s, const Polynomial_1& t, const Polynomial_1& s, const Polynomial_1& t,
Polynomial_d u1, Polynomial_d u2, Polynomial_d u1, Polynomial_d u2,
Polynomial_d& u) const { Polynomial_d& u) const {
@ -181,11 +181,13 @@ public:
CGAL_precondition(u1.degree() < m1.degree() || u1.is_zero()); CGAL_precondition(u1.degree() < m1.degree() || u1.is_zero());
CGAL_precondition(u2.degree() < m2.degree() || u2.is_zero()); CGAL_precondition(u2.degree() < m2.degree() || u2.is_zero());
if(m1.degree() < m2.degree()){ if(m1.degree() < m2.degree()){
Polynomial_d v = pseudo_remainder(cast(s)*(u2-u1),cast(canonicalize(m2))); Polynomial_d v =
pseudo_remainder(cast(s)*(u2-u1),cast(canonicalize(m2)));
u = cast(m1)*v + u1; u = cast(m1)*v + u1;
} }
else{ else{
Polynomial_d v = pseudo_remainder(cast(t)*(u1-u2),cast(canonicalize(m1))); Polynomial_d v
= pseudo_remainder(cast(t)*(u1-u2),cast(canonicalize(m1)));
u = cast(m2)*v + u2; u = cast(m2)*v + u2;
} }
} }
@ -271,13 +273,13 @@ public:
a = Innermost_coefficient(0); a = Innermost_coefficient(0);
return 0; return 0;
} }
a = CGAL::unit_part( typename Polynomial_traits_d< Polynomial_d >::Innermost_leading_coefficient()( p ) ) * typedef Polynomial_traits_d< Polynomial_d > PT;
typename Polynomial_traits_d< Polynomial_d >::Multivariate_content()( p ); typename PT::Innermost_leading_coefficient ilcoeff;
typename PT::Multivariate_content mcontent;
a = CGAL::unit_part( ilcoeff( p ) ) * mcontent( p );
return square_free_factorization( p/Polynomial_d(a), fit, mit ); return square_free_factorization( p/Polynomial_d(a), fit, mit );
} }
}; };
}; };
template< class Coefficient_ > template< class Coefficient_ >
@ -354,10 +356,13 @@ public:
return ICoeff(1); return ICoeff(1);
} }
}; };
typedef Null_functor Integral_division_up_to_constant_factor; typedef Null_functor Integral_division_up_to_constant_factor;
struct Univariate_content_up_to_constant_factor struct Univariate_content_up_to_constant_factor
: public Unary_function< ICoeff, ICoeff >{ : public Unary_function< ICoeff, ICoeff >{
ICoeff operator()(const ICoeff& ) const { ICoeff operator()(const ICoeff& ) const {
// TODO: Why not return 0 if argument is 0 ?
return ICoeff(1); return ICoeff(1);
} }
}; };
@ -375,7 +380,6 @@ public:
struct Degree_vector{ struct Degree_vector{
typedef Exponent_vector result_type; typedef Exponent_vector result_type;
typedef Coefficient argument_type; typedef Coefficient argument_type;
// returns the exponent vector of inner_most_lcoeff. // returns the exponent vector of inner_most_lcoeff.
result_type operator()(const Coefficient&){ result_type operator()(const Coefficient&){
return Exponent_vector(); return Exponent_vector();
@ -389,7 +393,6 @@ public:
CGAL_precondition( ev.empty() ); CGAL_precondition( ev.empty() );
return p; return p;
} }
}; };
struct Evaluate { struct Evaluate {
@ -439,6 +442,7 @@ struct Evaluate_homogeneous_func< Polynomial, 1 > {
Input_iterator end, Input_iterator end,
int total_degree, int total_degree,
const ICoeff& v ) const { const ICoeff& v ) const {
// TODO: remove --end in case of Input_iterator
--end; --end;
CGAL_precondition( begin == end ); CGAL_precondition( begin == end );
return p.evaluate_homogeneous( (*end), v, total_degree ); return p.evaluate_homogeneous( (*end), v, total_degree );
@ -463,10 +467,10 @@ struct Evaluate_homogeneous_func {
//typename PT::Evaluate evaluate; //typename PT::Evaluate evaluate;
typename PT::Degree degree; typename PT::Degree degree;
Evaluate_homogeneous_func< Coefficient > eval_hom; Evaluate_homogeneous_func< Coefficient > eval_hom;
// TODO: remove --end in case of Input_iterator
--end; --end;
std::vector< ICoeff > cv; std::vector< ICoeff > cv;
for( int i = 0; i <= degree(p); ++i ) { for( int i = 0; i <= degree(p); ++i ) {
cv.push_back( eval_hom( p[i], begin, end, total_degree - i, v ) ); cv.push_back( eval_hom( p[i], begin, end, total_degree - i, v ) );
} }
@ -475,7 +479,8 @@ struct Evaluate_homogeneous_func {
} }
}; };
// Now the version for the polynomials with all functors provided by all polynomials // Now the version for the polynomials with all functors provided by all
// polynomials
template< class Coefficient_, template< class Coefficient_,
class ICoeffAlgebraicCategory, class PolynomialAlgebraicCategory > class ICoeffAlgebraicCategory, class PolynomialAlgebraicCategory >
class Polynomial_traits_d_base< Polynomial< Coefficient_ >, class Polynomial_traits_d_base< Polynomial< Coefficient_ >,
@ -493,13 +498,17 @@ class Polynomial_traits_d_base< Polynomial< Coefficient_ >,
// coeff type has no comparison operators available. // coeff type has no comparison operators available.
private: private:
struct Compare_exponents_coeff_pair struct Compare_exponents_coeff_pair
: public Binary_function< std::pair< Exponent_vector, Innermost_coefficient >, : public Binary_function<
std::pair< Exponent_vector, Innermost_coefficient >, std::pair< Exponent_vector, Innermost_coefficient >,
bool > { std::pair< Exponent_vector, Innermost_coefficient >,
bool operator()( const std::pair< Exponent_vector, Innermost_coefficient >& p1, bool >
{
bool operator()(
const std::pair< Exponent_vector, Innermost_coefficient >& p1,
const std::pair< Exponent_vector, Innermost_coefficient >& p2 ) const { const std::pair< Exponent_vector, Innermost_coefficient >& p2 ) const {
// TODO: Precondition leads to an error within test_translate in Polynomial_traits_d test // TODO: Precondition leads to an error within test_translate in
//CGAL_precondition( p1.first != p2.first ); // Polynomial_traits_d test
// CGAL_precondition( p1.first != p2.first );
return p1.first < p2.first; return p1.first < p2.first;
} }
}; };
@ -507,9 +516,8 @@ private:
public: public:
// //
// Functors as defined in the reference manual (with sometimes slightly // Functors as defined in the reference manual
// extended functionality) // (with sometimes slightly extended functionality)
//
// Construct_polynomial; // Construct_polynomial;
@ -602,8 +610,7 @@ public:
Input_iterator end , Input_iterator end ,
Tag_false) const { Tag_false) const {
std::sort(begin,end,Compare_exponents_coeff_pair()); std::sort(begin,end,Compare_exponents_coeff_pair());
return Create_polynomial_from_monom_rep< Coefficient >() return Create_polynomial_from_monom_rep< Coefficient >()( begin, end );
( begin, end );
} }
@ -617,7 +624,6 @@ public:
return construct(begin,end,Is_coeff()); return construct(begin,end,Is_coeff());
} }
private:
public: public:
template< class T > template< class T >
@ -695,9 +701,12 @@ public:
// Get_innermost_coefficient; // Get_innermost_coefficient;
struct Get_innermost_coefficient struct Get_innermost_coefficient
: public Binary_function< Polynomial_d, Exponent_vector, Innermost_coefficient > { : public
Binary_function< Polynomial_d, Exponent_vector, Innermost_coefficient >
{
Innermost_coefficient operator()( const Polynomial_d& p, Exponent_vector ev ) const { Innermost_coefficient
operator()( const Polynomial_d& p, Exponent_vector ev ) const {
CGAL_precondition( !ev.empty() ); CGAL_precondition( !ev.empty() );
typename PTC::Get_innermost_coefficient gic; typename PTC::Get_innermost_coefficient gic;
typename PT::Get_coefficient gc; typename PT::Get_coefficient gc;
@ -705,10 +714,8 @@ public:
ev.pop_back(); ev.pop_back();
return gic( gc( p, exponent ), ev ); return gic( gc( p, exponent ), ev );
}; };
}; };
// Swap;
// Swap variable x_i with x_j // Swap variable x_i with x_j
struct Swap { struct Swap {
typedef Polynomial_d result_type; typedef Polynomial_d result_type;
@ -720,14 +727,14 @@ public:
public: public:
Polynomial_d operator()(const Polynomial_d& p, int i, int j ) const { Polynomial_d operator()(const Polynomial_d& p, int i, int j ) const {
//std::cout << i <<" " << j << " : " ;
CGAL_precondition(0 <= i && i < d); CGAL_precondition(0 <= i && i < d);
CGAL_precondition(0 <= j && j < d); CGAL_precondition(0 <= j && j < d);
typedef std::pair< Exponent_vector, Innermost_coefficient > typedef std::pair< Exponent_vector, Innermost_coefficient >
Exponents_coeff_pair; Exponents_coeff_pair;
typedef std::vector< Exponents_coeff_pair > Monom_rep; typedef std::vector< Exponents_coeff_pair > Monom_rep;
Get_monom_representation gmr; Get_monom_representation gmr;
typename Construct_polynomial::template Create_polynomial_from_monom_rep< Coefficient > construct; typename Construct_polynomial
::template Create_polynomial_from_monom_rep< Coefficient > construct;
Monom_rep mon_rep; Monom_rep mon_rep;
gmr( p, std::back_inserter( mon_rep ) ); gmr( p, std::back_inserter( mon_rep ) );
for( typename Monom_rep::iterator it = mon_rep.begin(); for( typename Monom_rep::iterator it = mon_rep.begin();
@ -736,7 +743,8 @@ public:
std::swap(it->first[i],it->first[j]); std::swap(it->first[i],it->first[j]);
// it->first.swap( i, j ); // it->first.swap( i, j );
} }
std::sort( mon_rep.begin(), mon_rep.end(), Compare_exponents_coeff_pair() ); std::sort
( mon_rep.begin(), mon_rep.end(), Compare_exponents_coeff_pair() );
return construct( mon_rep.begin(), mon_rep.end() ); return construct( mon_rep.begin(), mon_rep.end() );
} }
}; };
@ -752,8 +760,8 @@ public:
typedef int third_argument_type; typedef int third_argument_type;
typedef Arity_tag< 3 > Arity; typedef Arity_tag< 3 > Arity;
Polynomial_d operator()(const Polynomial_d& p, int i, int j = (d-1) ) const { Polynomial_d
//std::cout << x <<" " << y << " : " ; operator()(const Polynomial_d& p, int i, int j = (d-1) ) const {
CGAL_precondition(0 <= i && i < d); CGAL_precondition(0 <= i && i < d);
CGAL_precondition(0 <= j && j < d); CGAL_precondition(0 <= j && j < d);
typedef std::pair< Exponent_vector, Innermost_coefficient > typedef std::pair< Exponent_vector, Innermost_coefficient >
@ -775,7 +783,8 @@ public:
std::swap(it->first[k],it->first[k-1]); std::swap(it->first[k],it->first[k-1]);
} }
std::sort( mon_rep.begin(), mon_rep.end(),Compare_exponents_coeff_pair()); std::sort
( mon_rep.begin(), mon_rep.end(),Compare_exponents_coeff_pair());
return construct( mon_rep.begin(), mon_rep.end() ); return construct( mon_rep.begin(), mon_rep.end() );
} }
}; };
@ -867,11 +876,17 @@ public:
} }
template< class Input_iterator > template< class Input_iterator >
Innermost_coefficient operator()( const Polynomial_d& p, Input_iterator begin, Input_iterator end ) const { Innermost_coefficient
operator()(
const Polynomial_d& p,
Input_iterator begin,
Input_iterator end ) const
{
CGAL_precondition( begin != end ); CGAL_precondition( begin != end );
typename PT::Evaluate evaluatePoly; typename PT::Evaluate evaluatePoly;
typename PTC::Evaluate evaluateCoeff; typename PTC::Evaluate evaluateCoeff;
// TODO: remove --end in case of Input_iterator
--end; --end;
return evaluateCoeff( evaluatePoly( p, (*end) ), begin, end ); return evaluateCoeff( evaluatePoly( p, (*end) ), begin, end );
} }
@ -920,10 +935,17 @@ public:
// Is_zero_at; // Is_zero_at;
struct Is_zero_at { struct Is_zero_at {
typedef bool result_type; private:
typedef Algebraic_structure_traits<Innermost_coefficient> AST;
typedef typename AST::Is_zero::result_type BOOL;
public:
typedef BOOL result_type;
template< class Input_iterator > template< class Input_iterator >
bool operator()( const Polynomial_d& p, Input_iterator begin, Input_iterator end ) const { BOOL operator()(
const Polynomial_d& p,
Input_iterator begin,
Input_iterator end ) const {
typename PT::Evaluate evaluate; typename PT::Evaluate evaluate;
return( CGAL::is_zero( evaluate( p, begin, end ) ) ); return( CGAL::is_zero( evaluate( p, begin, end ) ) );
} }
@ -931,10 +953,18 @@ public:
// Is_zero_at_homogeneous; // Is_zero_at_homogeneous;
struct Is_zero_at_homogeneous { struct Is_zero_at_homogeneous {
typedef bool result_type; private:
typedef Algebraic_structure_traits<Innermost_coefficient> AST;
typedef typename AST::Is_zero::result_type BOOL;
public:
typedef BOOL result_type;
template< class Input_iterator > template< class Input_iterator >
bool operator()( const Polynomial_d& p, Input_iterator begin, Input_iterator end ) const { BOOL operator()(
const Polynomial_d& p,
Input_iterator begin,
Input_iterator end ) const
{
typename PT::Evaluate_homogeneous evaluate_homogeneous; typename PT::Evaluate_homogeneous evaluate_homogeneous;
return( CGAL::is_zero( evaluate_homogeneous( p, begin, end ) ) ); return( CGAL::is_zero( evaluate_homogeneous( p, begin, end ) ) );
} }
@ -942,21 +972,36 @@ public:
// Sign_at; // Sign_at;
struct Sign_at { struct Sign_at {
typedef Sign result_type; private:
typedef Real_embeddable_traits<Innermost_coefficient> RT;
typedef typename RT::Sign::result_type SIGN;
public:
typedef SIGN result_type;
template< class Input_iterator > template< class Input_iterator >
Sign operator()( const Polynomial_d& p, Input_iterator begin, Input_iterator end ) const {
SIGN operator()(
const Polynomial_d& p,
Input_iterator begin,
Input_iterator end ) const
{
typename PT::Evaluate evaluate; typename PT::Evaluate evaluate;
return CGAL::sign( evaluate( p, begin, end ) ); return CGAL::sign( evaluate( p, begin, end ) );
} }
}; };
// TODO: Fix error in evaluate homogenous
// Sign_at_homogeneous; // Sign_at_homogeneous;
struct Sign_at_homogeneous { struct Sign_at_homogeneous {
typedef Sign result_type; typedef Real_embeddable_traits<Innermost_coefficient> RT;
typedef typename RT::Sign::result_type SIGN;
public:
typedef SIGN result_type;
template< class Input_iterator > template< class Input_iterator >
Sign operator()( const Polynomial_d& p, Input_iterator begin, Input_iterator end ) const { SIGN operator()(
const Polynomial_d& p,
Input_iterator begin,
Input_iterator end) const {
typename PT::Evaluate_homogeneous evaluate_homogeneous; typename PT::Evaluate_homogeneous evaluate_homogeneous;
return CGAL::sign( evaluate_homogeneous( p, begin, end ) ); return CGAL::sign( evaluate_homogeneous( p, begin, end ) );
} }
@ -965,15 +1010,13 @@ public:
// Compare; // Compare;
struct Compare struct Compare
: public Binary_function< Comparison_result, Polynomial_d, Polynomial_d > { : public Binary_function< Comparison_result, Polynomial_d, Polynomial_d > {
Comparison_result operator()
Comparison_result operator()( const Polynomial_d& p1, const Polynomial_d& p2 ) const { ( const Polynomial_d& p1, const Polynomial_d& p2 ) const {
return p1.compare( p2 ); return p1.compare( p2 );
} }
}; };
//
// This is going to be in PolynomialToolBox // This is going to be in PolynomialToolBox
//
struct Coefficient_begin struct Coefficient_begin
: public Unary_function< Polynomial_d, Coefficient_iterator > { : public Unary_function< Polynomial_d, Coefficient_iterator > {
Coefficient_iterator Coefficient_iterator
@ -1296,7 +1339,8 @@ public:
// Scale; // Scale;
struct Scale struct Scale
: public Binary_function< Polynomial_d, Innermost_coefficient, Polynomial_d > { : public
Binary_function< Polynomial_d, Innermost_coefficient, Polynomial_d > {
Polynomial_d operator()( Polynomial_d p, const Innermost_coefficient& c, Polynomial_d operator()( Polynomial_d p, const Innermost_coefficient& c,
int i = (PT::d-1) ) { int i = (PT::d-1) ) {
@ -1586,7 +1630,7 @@ template< class Polynomial >
class Polynomial_traits_d class Polynomial_traits_d
: public CGALi::Polynomial_traits_d_base< Polynomial, : public CGALi::Polynomial_traits_d_base< Polynomial,
typename Algebraic_structure_traits< typename Algebraic_structure_traits<
typename CGALi::Innermost_coefficient<Polynomial>::Type >::Algebraic_category, typename CGALi::Innermost_coefficient<Polynomial>::Type >::Algebraic_category,
typename Algebraic_structure_traits< Polynomial >::Algebraic_category > { typename Algebraic_structure_traits< Polynomial >::Algebraic_category > {
//------------ Rebind ----------- //------------ Rebind -----------