mirror of https://github.com/CGAL/cgal
parent
1a4079f2f8
commit
1570772295
|
|
@ -113,7 +113,6 @@ public:
|
|||
return content;
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
template< class Coefficient_ >
|
||||
|
|
@ -160,7 +159,8 @@ public:
|
|||
}
|
||||
|
||||
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,
|
||||
Polynomial_d u1, Polynomial_d u2,
|
||||
Polynomial_d& u) const {
|
||||
|
|
@ -181,11 +181,13 @@ public:
|
|||
CGAL_precondition(u1.degree() < m1.degree() || u1.is_zero());
|
||||
CGAL_precondition(u2.degree() < m2.degree() || u2.is_zero());
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -271,13 +273,13 @@ public:
|
|||
a = Innermost_coefficient(0);
|
||||
return 0;
|
||||
}
|
||||
a = CGAL::unit_part( typename Polynomial_traits_d< Polynomial_d >::Innermost_leading_coefficient()( p ) ) *
|
||||
typename Polynomial_traits_d< Polynomial_d >::Multivariate_content()( p );
|
||||
typedef Polynomial_traits_d< Polynomial_d > PT;
|
||||
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 );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
template< class Coefficient_ >
|
||||
|
|
@ -354,10 +356,13 @@ public:
|
|||
return ICoeff(1);
|
||||
}
|
||||
};
|
||||
|
||||
typedef Null_functor Integral_division_up_to_constant_factor;
|
||||
|
||||
struct Univariate_content_up_to_constant_factor
|
||||
: public Unary_function< ICoeff, ICoeff >{
|
||||
ICoeff operator()(const ICoeff& ) const {
|
||||
// TODO: Why not return 0 if argument is 0 ?
|
||||
return ICoeff(1);
|
||||
}
|
||||
};
|
||||
|
|
@ -375,7 +380,6 @@ public:
|
|||
struct Degree_vector{
|
||||
typedef Exponent_vector result_type;
|
||||
typedef Coefficient argument_type;
|
||||
|
||||
// returns the exponent vector of inner_most_lcoeff.
|
||||
result_type operator()(const Coefficient&){
|
||||
return Exponent_vector();
|
||||
|
|
@ -389,7 +393,6 @@ public:
|
|||
CGAL_precondition( ev.empty() );
|
||||
return p;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct Evaluate {
|
||||
|
|
@ -439,6 +442,7 @@ struct Evaluate_homogeneous_func< Polynomial, 1 > {
|
|||
Input_iterator end,
|
||||
int total_degree,
|
||||
const ICoeff& v ) const {
|
||||
// TODO: remove --end in case of Input_iterator
|
||||
--end;
|
||||
CGAL_precondition( begin == end );
|
||||
return p.evaluate_homogeneous( (*end), v, total_degree );
|
||||
|
|
@ -463,10 +467,10 @@ struct Evaluate_homogeneous_func {
|
|||
//typename PT::Evaluate evaluate;
|
||||
typename PT::Degree degree;
|
||||
Evaluate_homogeneous_func< Coefficient > eval_hom;
|
||||
// TODO: remove --end in case of Input_iterator
|
||||
--end;
|
||||
|
||||
std::vector< ICoeff > cv;
|
||||
|
||||
for( int i = 0; i <= degree(p); ++i ) {
|
||||
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_,
|
||||
class ICoeffAlgebraicCategory, class PolynomialAlgebraicCategory >
|
||||
class Polynomial_traits_d_base< Polynomial< Coefficient_ >,
|
||||
|
|
@ -493,12 +498,16 @@ class Polynomial_traits_d_base< Polynomial< Coefficient_ >,
|
|||
// coeff type has no comparison operators available.
|
||||
private:
|
||||
struct Compare_exponents_coeff_pair
|
||||
: public Binary_function< std::pair< Exponent_vector, Innermost_coefficient >,
|
||||
: public Binary_function<
|
||||
std::pair< Exponent_vector, Innermost_coefficient >,
|
||||
bool > {
|
||||
bool operator()( const std::pair< Exponent_vector, Innermost_coefficient >& p1,
|
||||
std::pair< Exponent_vector, Innermost_coefficient >,
|
||||
bool >
|
||||
{
|
||||
bool operator()(
|
||||
const std::pair< Exponent_vector, Innermost_coefficient >& p1,
|
||||
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
|
||||
// Polynomial_traits_d test
|
||||
// CGAL_precondition( p1.first != p2.first );
|
||||
return p1.first < p2.first;
|
||||
}
|
||||
|
|
@ -507,9 +516,8 @@ private:
|
|||
public:
|
||||
|
||||
//
|
||||
// Functors as defined in the reference manual (with sometimes slightly
|
||||
// extended functionality)
|
||||
//
|
||||
// Functors as defined in the reference manual
|
||||
// (with sometimes slightly extended functionality)
|
||||
|
||||
|
||||
// Construct_polynomial;
|
||||
|
|
@ -602,8 +610,7 @@ public:
|
|||
Input_iterator end ,
|
||||
Tag_false) const {
|
||||
std::sort(begin,end,Compare_exponents_coeff_pair());
|
||||
return Create_polynomial_from_monom_rep< Coefficient >()
|
||||
( begin, end );
|
||||
return Create_polynomial_from_monom_rep< Coefficient >()( begin, end );
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -617,7 +624,6 @@ public:
|
|||
return construct(begin,end,Is_coeff());
|
||||
}
|
||||
|
||||
private:
|
||||
public:
|
||||
|
||||
template< class T >
|
||||
|
|
@ -695,9 +701,12 @@ public:
|
|||
|
||||
// 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() );
|
||||
typename PTC::Get_innermost_coefficient gic;
|
||||
typename PT::Get_coefficient gc;
|
||||
|
|
@ -705,10 +714,8 @@ public:
|
|||
ev.pop_back();
|
||||
return gic( gc( p, exponent ), ev );
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// Swap;
|
||||
// Swap variable x_i with x_j
|
||||
struct Swap {
|
||||
typedef Polynomial_d result_type;
|
||||
|
|
@ -720,14 +727,14 @@ public:
|
|||
public:
|
||||
|
||||
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 <= j && j < d);
|
||||
typedef std::pair< Exponent_vector, Innermost_coefficient >
|
||||
Exponents_coeff_pair;
|
||||
typedef std::vector< Exponents_coeff_pair > Monom_rep;
|
||||
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;
|
||||
gmr( p, std::back_inserter( mon_rep ) );
|
||||
for( typename Monom_rep::iterator it = mon_rep.begin();
|
||||
|
|
@ -736,7 +743,8 @@ public:
|
|||
std::swap(it->first[i],it->first[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() );
|
||||
}
|
||||
};
|
||||
|
|
@ -752,8 +760,8 @@ public:
|
|||
typedef int third_argument_type;
|
||||
typedef Arity_tag< 3 > Arity;
|
||||
|
||||
Polynomial_d operator()(const Polynomial_d& p, int i, int j = (d-1) ) const {
|
||||
//std::cout << x <<" " << y << " : " ;
|
||||
Polynomial_d
|
||||
operator()(const Polynomial_d& p, int i, int j = (d-1) ) const {
|
||||
CGAL_precondition(0 <= i && i < d);
|
||||
CGAL_precondition(0 <= j && j < d);
|
||||
typedef std::pair< Exponent_vector, Innermost_coefficient >
|
||||
|
|
@ -775,7 +783,8 @@ public:
|
|||
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() );
|
||||
}
|
||||
};
|
||||
|
|
@ -867,11 +876,17 @@ public:
|
|||
}
|
||||
|
||||
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 );
|
||||
|
||||
typename PT::Evaluate evaluatePoly;
|
||||
typename PTC::Evaluate evaluateCoeff;
|
||||
// TODO: remove --end in case of Input_iterator
|
||||
--end;
|
||||
return evaluateCoeff( evaluatePoly( p, (*end) ), begin, end );
|
||||
}
|
||||
|
|
@ -920,10 +935,17 @@ public:
|
|||
|
||||
// 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 >
|
||||
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;
|
||||
return( CGAL::is_zero( evaluate( p, begin, end ) ) );
|
||||
}
|
||||
|
|
@ -931,10 +953,18 @@ public:
|
|||
|
||||
// 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 >
|
||||
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;
|
||||
return( CGAL::is_zero( evaluate_homogeneous( p, begin, end ) ) );
|
||||
}
|
||||
|
|
@ -942,21 +972,36 @@ public:
|
|||
|
||||
// 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 >
|
||||
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;
|
||||
return CGAL::sign( evaluate( p, begin, end ) );
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Fix error in evaluate homogenous
|
||||
// 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 >
|
||||
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;
|
||||
return CGAL::sign( evaluate_homogeneous( p, begin, end ) );
|
||||
}
|
||||
|
|
@ -965,15 +1010,13 @@ public:
|
|||
// Compare;
|
||||
struct Compare
|
||||
: public Binary_function< Comparison_result, Polynomial_d, Polynomial_d > {
|
||||
|
||||
Comparison_result operator()( const Polynomial_d& p1, const Polynomial_d& p2 ) const {
|
||||
Comparison_result operator()
|
||||
( const Polynomial_d& p1, const Polynomial_d& p2 ) const {
|
||||
return p1.compare( p2 );
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// This is going to be in PolynomialToolBox
|
||||
//
|
||||
struct Coefficient_begin
|
||||
: public Unary_function< Polynomial_d, Coefficient_iterator > {
|
||||
Coefficient_iterator
|
||||
|
|
@ -1296,7 +1339,8 @@ public:
|
|||
|
||||
// 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,
|
||||
int i = (PT::d-1) ) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue