mirror of https://github.com/CGAL/cgal
square_free_factorization -> square_free_factorize
---------- added Joachim von zur Gathen and J\"urgen Gerhard, Modern Computer Algebra, Cambridge University Press, 1999
This commit is contained in:
parent
9fcd58c0db
commit
1360cb9e0e
|
|
@ -2918,7 +2918,6 @@ Polynomial/include/CGAL/Polynomial/hgdelta_update.h -text
|
||||||
Polynomial/include/CGAL/Polynomial/may_have_common_factor.h -text
|
Polynomial/include/CGAL/Polynomial/may_have_common_factor.h -text
|
||||||
Polynomial/include/CGAL/Polynomial/modular_filter.h -text
|
Polynomial/include/CGAL/Polynomial/modular_filter.h -text
|
||||||
Polynomial/include/CGAL/Polynomial/resultant.h -text
|
Polynomial/include/CGAL/Polynomial/resultant.h -text
|
||||||
Polynomial/include/CGAL/Polynomial/square_free_factorization.h -text
|
|
||||||
Polynomial/include/CGAL/Polynomial/square_free_factorize.h -text
|
Polynomial/include/CGAL/Polynomial/square_free_factorize.h -text
|
||||||
Polynomial/include/CGAL/Polynomial/sturm_habicht_sequence.h -text
|
Polynomial/include/CGAL/Polynomial/sturm_habicht_sequence.h -text
|
||||||
Polynomial/include/CGAL/Polynomial/subresultants.h -text
|
Polynomial/include/CGAL/Polynomial/subresultants.h -text
|
||||||
|
|
|
||||||
|
|
@ -726,7 +726,7 @@ public:
|
||||||
OutputIterator1 fit, OutputIterator2 mit ) const {
|
OutputIterator1 fit, OutputIterator2 mit ) const {
|
||||||
|
|
||||||
typename Polynomial_traits_2::
|
typename Polynomial_traits_2::
|
||||||
Square_free_factorization_up_to_constant_factor factorize;
|
Square_free_factorize_up_to_constant_factor factorize;
|
||||||
std::vector<Polynomial_2> factors;
|
std::vector<Polynomial_2> factors;
|
||||||
|
|
||||||
int n_factors = factorize(ca.polynomial_2(),
|
int n_factors = factorize(ca.polynomial_2(),
|
||||||
|
|
@ -863,7 +863,7 @@ public:
|
||||||
typedef Decompose_2 Make_square_free_2;
|
typedef Decompose_2 Make_square_free_2;
|
||||||
|
|
||||||
//! Algebraic name
|
//! Algebraic name
|
||||||
typedef Decompose_2 Square_free_factorization;
|
typedef Decompose_2 Square_free_factorize;
|
||||||
|
|
||||||
//! Algebraic name
|
//! Algebraic name
|
||||||
typedef Decompose_2 Make_coprime_2;
|
typedef Decompose_2 Make_coprime_2;
|
||||||
|
|
|
||||||
|
|
@ -207,10 +207,10 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Square_free_factorization_1 {
|
struct Square_free_factorize_1 {
|
||||||
template< class OutputIterator>
|
template< class OutputIterator>
|
||||||
OutputIterator operator()( const Polynomial_1& p, OutputIterator it) const {
|
OutputIterator operator()( const Polynomial_1& p, OutputIterator it) const {
|
||||||
typename PT_1::Square_free_factorization_up_to_constant_factor sqff;
|
typename PT_1::Square_free_factorize_up_to_constant_factor sqff;
|
||||||
return sqff(p,it);
|
return sqff(p,it);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -227,8 +227,8 @@ public:
|
||||||
construct_is_square_free_1_object);
|
construct_is_square_free_1_object);
|
||||||
CGAL_ALGEBRAIC_KERNEL_1_PRED(Make_square_free_1,
|
CGAL_ALGEBRAIC_KERNEL_1_PRED(Make_square_free_1,
|
||||||
construct_make_square_free_1_object);
|
construct_make_square_free_1_object);
|
||||||
CGAL_ALGEBRAIC_KERNEL_1_PRED(Square_free_factorization_1,
|
CGAL_ALGEBRAIC_KERNEL_1_PRED(Square_free_factorize_1,
|
||||||
construct_square_free_factorization_1_object);
|
construct_square_free_factorize_1_object);
|
||||||
CGAL_ALGEBRAIC_KERNEL_1_PRED(Is_coprime_1,
|
CGAL_ALGEBRAIC_KERNEL_1_PRED(Is_coprime_1,
|
||||||
construct_is_coprime_1_object);
|
construct_is_coprime_1_object);
|
||||||
CGAL_ALGEBRAIC_KERNEL_1_PRED(Make_coprime_1,
|
CGAL_ALGEBRAIC_KERNEL_1_PRED(Make_coprime_1,
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ int operator()(const Polynomial& poly,
|
||||||
std::list<Polynomial> sqffac;
|
std::list<Polynomial> sqffac;
|
||||||
std::list<int> facmul;
|
std::list<int> facmul;
|
||||||
|
|
||||||
filtered_square_free_factorization_utcf(poly,
|
filtered_square_free_factorize_utcf(poly,
|
||||||
std::back_inserter(sqffac),
|
std::back_inserter(sqffac),
|
||||||
std::back_inserter(facmul));
|
std::back_inserter(facmul));
|
||||||
|
|
||||||
|
|
@ -266,7 +266,7 @@ int operator()( const Polynomial& poly,
|
||||||
std::list<Polynomial> sqffac;
|
std::list<Polynomial> sqffac;
|
||||||
std::list<int> facmul;
|
std::list<int> facmul;
|
||||||
|
|
||||||
filtered_square_free_factorization_utcf(poly,
|
filtered_square_free_factorize_utcf(poly,
|
||||||
std::back_inserter(sqffac),
|
std::back_inserter(sqffac),
|
||||||
std::back_inserter(facmul));
|
std::back_inserter(facmul));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,12 +133,12 @@ void test_algebraic_kernel_1() {
|
||||||
Polynomial_1 g, q1, q2;
|
Polynomial_1 g, q1, q2;
|
||||||
make_coprime_1( poly1, poly2, g, q1, q2 );
|
make_coprime_1( poly1, poly2, g, q1, q2 );
|
||||||
|
|
||||||
// Test AK::Square_free_factorization_1...
|
// Test AK::Square_free_factorize_1...
|
||||||
typename AK::Square_free_factorization_1 square_free_factorization_1
|
typename AK::Square_free_factorize_1 square_free_factorize_1
|
||||||
= AK().construct_square_free_factorization_1_object();
|
= AK().construct_square_free_factorize_1_object();
|
||||||
|
|
||||||
std::vector<std::pair<Polynomial_1,int> > fac_mult_pairs;
|
std::vector<std::pair<Polynomial_1,int> > fac_mult_pairs;
|
||||||
square_free_factorization_1( poly1, std::back_inserter(fac_mult_pairs) );
|
square_free_factorize_1( poly1, std::back_inserter(fac_mult_pairs) );
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1302,7 +1302,7 @@ public:
|
||||||
typedef Has_finite_number_of_intersections_2 Is_coprime_2;
|
typedef Has_finite_number_of_intersections_2 Is_coprime_2;
|
||||||
|
|
||||||
typedef Decompose_2 Make_square_free_2;
|
typedef Decompose_2 Make_square_free_2;
|
||||||
typedef Decompose_2 Square_free_factorization;
|
typedef Decompose_2 Square_free_factorize;
|
||||||
typedef Decompose_2 Make_coprime_2;
|
typedef Decompose_2 Make_coprime_2;
|
||||||
|
|
||||||
//! \brief computes the derivative w.r.t. the first (innermost) variable
|
//! \brief computes the derivative w.r.t. the first (innermost) variable
|
||||||
|
|
|
||||||
|
|
@ -151737,4 +151737,10 @@ amplification and suppression of local contrast. Contains C code."
|
||||||
, update = "98.03 bibrelex"
|
, update = "98.03 bibrelex"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@book{gg-mca-99
|
||||||
|
, key = Gathen
|
||||||
|
, author = {Joachim von zur Gathen and J{\"u}rgen Gerhard}
|
||||||
|
, title = "Modern Computer Algebra"
|
||||||
|
, publisher = "Cambridge University Press"
|
||||||
|
, year = 1999
|
||||||
|
}
|
||||||
|
|
@ -52,7 +52,7 @@ In case a functor is not provided it is set to \ccc{CGAL::Null_functor}.
|
||||||
%unary operations
|
%unary operations
|
||||||
\ccNestedType{Make_square_free}
|
\ccNestedType{Make_square_free}
|
||||||
{ A model of \ccc{PolynomialTraits_d::MakeSquareFree}.}\ccGlue
|
{ A model of \ccc{PolynomialTraits_d::MakeSquareFree}.}\ccGlue
|
||||||
\ccNestedType{Square_free_factorization}
|
\ccNestedType{Square_free_factorize}
|
||||||
{ In case \ccc{PolynomialTraits::Polynomial_d}
|
{ In case \ccc{PolynomialTraits::Polynomial_d}
|
||||||
is not a model of \ccc{UniqueFactorizationDomain}, this is of type \ccc{CGAL::Null_type},
|
is not a model of \ccc{UniqueFactorizationDomain}, this is of type \ccc{CGAL::Null_type},
|
||||||
otherwise this is a model of \ccc{PolynomialTraits_d::SquareFreeFactorize}.}
|
otherwise this is a model of \ccc{PolynomialTraits_d::SquareFreeFactorize}.}
|
||||||
|
|
@ -77,7 +77,7 @@ is not a model of \ccc{UniqueFactorizationDomain}, this is of type \ccc{CGAL::Nu
|
||||||
\ccNestedType{Content_up_to_constant_factor}
|
\ccNestedType{Content_up_to_constant_factor}
|
||||||
{ A model of \ccc{PolynomialTraits_d::ContentUpToConstantFactor}.}
|
{ A model of \ccc{PolynomialTraits_d::ContentUpToConstantFactor}.}
|
||||||
\ccGlue
|
\ccGlue
|
||||||
\ccNestedType{Square_free_factorization_up_to_constant_factor}
|
\ccNestedType{Square_free_factorize_up_to_constant_factor}
|
||||||
{ A model of \ccc{PolynomialTraits_d::SquareFreeFactorizeUpToConstantFactor}.}
|
{ A model of \ccc{PolynomialTraits_d::SquareFreeFactorizeUpToConstantFactor}.}
|
||||||
|
|
||||||
%resultant
|
%resultant
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ In case a functor is not provided it is set to \ccc{CGAL::Null_functor}.
|
||||||
%unary operations
|
%unary operations
|
||||||
\ccNestedType{Make_square_free}
|
\ccNestedType{Make_square_free}
|
||||||
{ A model of \ccc{PolynomialTraits_d::MakeSquareFree}.}\ccGlue
|
{ A model of \ccc{PolynomialTraits_d::MakeSquareFree}.}\ccGlue
|
||||||
\ccNestedType{Square_free_factorization}
|
\ccNestedType{Square_free_factorize}
|
||||||
{ In case \ccc{PolynomialTraits::Polynomial_d}
|
{ In case \ccc{PolynomialTraits::Polynomial_d}
|
||||||
is not a model of \ccc{UniqueFactorizationDomain}, this is of type \ccc{CGAL::Null_type},
|
is not a model of \ccc{UniqueFactorizationDomain}, this is of type \ccc{CGAL::Null_type},
|
||||||
otherwise this is a model of \ccc{PolynomialTraits_d::SquareFreeFactorize}.}
|
otherwise this is a model of \ccc{PolynomialTraits_d::SquareFreeFactorize}.}
|
||||||
|
|
@ -169,7 +169,7 @@ is not a model of \ccc{UniqueFactorizationDomain}, this is of type \ccc{CGAL::Nu
|
||||||
\ccNestedType{Content_up_to_constant_factor}
|
\ccNestedType{Content_up_to_constant_factor}
|
||||||
{ A model of \ccc{PolynomialTraits_d::ContentUpToConstantFactor}.}
|
{ A model of \ccc{PolynomialTraits_d::ContentUpToConstantFactor}.}
|
||||||
\ccGlue
|
\ccGlue
|
||||||
\ccNestedType{Square_free_factorization_up_to_constant_factor}
|
\ccNestedType{Square_free_factorize_up_to_constant_factor}
|
||||||
{ A model of \ccc{PolynomialTraits_d::SquareFreeFactorizeUpToConstantFactor}.}
|
{ A model of \ccc{PolynomialTraits_d::SquareFreeFactorizeUpToConstantFactor}.}
|
||||||
|
|
||||||
%resultant
|
%resultant
|
||||||
|
|
|
||||||
|
|
@ -56,19 +56,19 @@ template <class NT> inline Polynomial<NT> gcd_utcf_modularizable_algebra_( const
|
||||||
template <class NT> inline NT content_utcf_(const Polynomial<NT>&);
|
template <class NT> inline NT content_utcf_(const Polynomial<NT>&);
|
||||||
|
|
||||||
template <class NT, class OutputIterator1, class OutputIterator2>
|
template <class NT, class OutputIterator1, class OutputIterator2>
|
||||||
inline int filtered_square_free_factorization( Polynomial<NT>, OutputIterator1, OutputIterator2);
|
inline int filtered_square_free_factorize( Polynomial<NT>, OutputIterator1, OutputIterator2);
|
||||||
template <class NT, class OutputIterator1, class OutputIterator2>
|
template <class NT, class OutputIterator1, class OutputIterator2>
|
||||||
inline int filtered_square_free_factorization_utcf( const Polynomial<NT>&, OutputIterator1, OutputIterator2);
|
inline int filtered_square_free_factorize_utcf( const Polynomial<NT>&, OutputIterator1, OutputIterator2);
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization_utcf(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2);
|
inline int square_free_factorize_utcf(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2);
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization_utcf_for_regular_polynomial(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2);
|
inline int square_free_factorize_utcf_for_regular_polynomial(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2);
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2);
|
inline int square_free_factorize(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2);
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization_for_regular_polynomial(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2);
|
inline int square_free_factorize_for_regular_polynomial(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2);
|
||||||
|
|
||||||
template <class NT> inline bool may_have_multiple_factor( const Polynomial<NT>&);
|
template <class NT> inline bool may_have_multiple_factor( const Polynomial<NT>&);
|
||||||
template <class NT> inline bool may_have_common_factor(const Polynomial<NT>&,const Polynomial<NT>&);
|
template <class NT> inline bool may_have_common_factor(const Polynomial<NT>&,const Polynomial<NT>&);
|
||||||
|
|
|
||||||
|
|
@ -1,350 +0,0 @@
|
||||||
// TODO: Add licence
|
|
||||||
//
|
|
||||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
||||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
//
|
|
||||||
// $URL:$
|
|
||||||
// $Id: $
|
|
||||||
//
|
|
||||||
// Author(s) :
|
|
||||||
//
|
|
||||||
// ============================================================================
|
|
||||||
#ifndef CGAL_POLYNOMIAL_SQUARE_FREE_FACTORIZATION_H
|
|
||||||
#define CGAL_POLYNOMIAL_SQUARE_FREE_FACTORIZATION_H
|
|
||||||
|
|
||||||
#include <CGAL/basic.h>
|
|
||||||
#include <CGAL/Polynomial/fwd.h>
|
|
||||||
#include <CGAL/Polynomial/misc.h>
|
|
||||||
#include <CGAL/Polynomial/Polynomial.h>
|
|
||||||
|
|
||||||
CGAL_BEGIN_NAMESPACE
|
|
||||||
namespace CGALi {
|
|
||||||
|
|
||||||
// square-free factorization
|
|
||||||
//
|
|
||||||
// the implementation uses two dispatches:
|
|
||||||
// a) first look at the coefficient's algebra type
|
|
||||||
// b) if the algebra type is of the concept field, try to decompose
|
|
||||||
// the same holds for square-free factorization up to constant factors (utcf)
|
|
||||||
//
|
|
||||||
// sqff -------> algebra type ? ----field-----> decomposable ?
|
|
||||||
// | A | |
|
|
||||||
// UFD | no yes
|
|
||||||
// | | | |
|
|
||||||
// V | |
|
|
||||||
// Yun's algo <---------------------- |
|
|
||||||
// A |
|
|
||||||
// | | |
|
|
||||||
// UFD | V
|
|
||||||
// | | decompose and use
|
|
||||||
// sqff_utcf --> algebra_type ? ----field-- sqff_utcf with numerator
|
|
||||||
// |
|
|
||||||
// integral domain
|
|
||||||
// |
|
|
||||||
// V
|
|
||||||
// Yun's algo (utcf)
|
|
||||||
|
|
||||||
template <class IC, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline int square_free_factorization(const IC&, OutputIterator1, OutputIterator2){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
template <class IC, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline int square_free_factorization_for_regular_polynomial(const IC&, OutputIterator1, OutputIterator2){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline int square_free_factorization(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2);
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline int square_free_factorization_for_regular_polynomial(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2);
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline int square_free_factorization_for_regular_polynomial_(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2, CGAL::Tag_true);
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline int square_free_factorization_for_regular_polynomial_(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2, CGAL::Tag_false);
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline int square_free_factorization_for_regular_polynomial_(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2, Integral_domain_tag);
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline int square_free_factorization_for_regular_polynomial_(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2, Unique_factorization_domain_tag);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline int square_free_factorization
|
|
||||||
(const Polynomial<Coeff>& poly, OutputIterator1 factors, OutputIterator2 multiplicities)
|
|
||||||
{
|
|
||||||
typedef Polynomial<Coeff> POLY;
|
|
||||||
typedef Polynomial_traits_d< POLY > PT;
|
|
||||||
typedef typename PT::Univariate_content_up_to_constant_factor Ucont_utcf;
|
|
||||||
typedef typename PT::Integral_division_up_to_constant_factor Idiv_utcf;
|
|
||||||
|
|
||||||
if (typename PT::Total_degree()(poly) == 0){return 0;}
|
|
||||||
|
|
||||||
Coeff ucont_utcf = Ucont_utcf()(poly);
|
|
||||||
POLY regular_poly = Idiv_utcf()(poly,ucont_utcf);
|
|
||||||
|
|
||||||
int result = square_free_factorization_for_regular_polynomial(
|
|
||||||
regular_poly, factors, multiplicities);
|
|
||||||
|
|
||||||
if (typename PT::Total_degree()(ucont_utcf) > 0){
|
|
||||||
typedef std::vector< Coeff > Factors_uc;
|
|
||||||
typedef std::vector< int > Multiplicities_uc;
|
|
||||||
Factors_uc factors_uc;
|
|
||||||
Multiplicities_uc multiplicities_uc;
|
|
||||||
result += square_free_factorization( ucont_utcf,
|
|
||||||
std::back_inserter(factors_uc),
|
|
||||||
std::back_inserter(multiplicities_uc) );
|
|
||||||
|
|
||||||
for( typename Factors_uc::iterator it = factors_uc.begin();
|
|
||||||
it != factors_uc.end(); ++it ){
|
|
||||||
*factors++ = POLY(*it);
|
|
||||||
}
|
|
||||||
for( Multiplicities_uc::iterator it = multiplicities_uc.begin();
|
|
||||||
it != multiplicities_uc.end(); ++it ){
|
|
||||||
*multiplicities++ = (*it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline int square_free_factorization_for_regular_polynomial
|
|
||||||
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities){
|
|
||||||
typedef Polynomial<Coeff> POLY;
|
|
||||||
typedef typename CGAL::Fraction_traits<POLY>::Is_fraction Is_fraction;
|
|
||||||
return square_free_factorization_for_regular_polynomial_(p,factors,multiplicities,Is_fraction());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline int square_free_factorization_for_regular_polynomial_
|
|
||||||
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities, CGAL::Tag_true){
|
|
||||||
|
|
||||||
typedef Polynomial<Coeff> POLY;
|
|
||||||
typedef Polynomial_traits_d< POLY > PT;
|
|
||||||
typedef Fraction_traits<POLY> FT;
|
|
||||||
|
|
||||||
typename FT::Numerator_type num;
|
|
||||||
typename FT::Denominator_type denom;
|
|
||||||
typename FT::Decompose()(p,num,denom);
|
|
||||||
|
|
||||||
std::vector<typename FT::Numerator_type> ifacs;
|
|
||||||
int result = square_free_factorization_for_regular_polynomial(num,std::back_inserter(ifacs),multiplicities);
|
|
||||||
|
|
||||||
typedef typename std::vector<typename FT::Numerator_type>::iterator Iterator;
|
|
||||||
denom = typename FT::Denominator_type(1);
|
|
||||||
for ( Iterator it = ifacs.begin(); it != ifacs.end(); ++it) {
|
|
||||||
POLY q = typename FT::Compose()(*it, denom);
|
|
||||||
*factors++ = typename PT::Canonicalize()(q);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline int square_free_factorization_for_regular_polynomial_
|
|
||||||
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities, CGAL::Tag_false){
|
|
||||||
typedef Polynomial<Coeff> POLY;
|
|
||||||
typedef typename Algebraic_structure_traits<POLY>::Algebraic_category Algebraic_category;
|
|
||||||
return square_free_factorization_for_regular_polynomial_(p,factors,multiplicities,Algebraic_category());
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline int square_free_factorization_for_regular_polynomial_
|
|
||||||
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities, Integral_domain_tag){
|
|
||||||
// Yun's Square-Free Factorization
|
|
||||||
// see [Geddes et al, 1992], Algorithm 8.2
|
|
||||||
|
|
||||||
typedef Polynomial<Coeff> POLY;
|
|
||||||
typedef Polynomial_traits_d<POLY> PT;
|
|
||||||
typedef typename Polynomial_traits_d<POLY>::Innermost_coefficient_type IC;
|
|
||||||
typename Polynomial_traits_d<POLY>::Innermost_leading_coefficient ilcoeff;
|
|
||||||
//typename Polynomial_traits_d<POLY>::Innermost_coefficient_to_polynomial ictp;
|
|
||||||
typename Polynomial_traits_d<POLY>::Innermost_coefficient_begin begin;
|
|
||||||
typename Polynomial_traits_d<POLY>::Innermost_coefficient_end end;
|
|
||||||
typename Algebraic_extension_traits<IC>::Denominator_for_algebraic_integers dfai;
|
|
||||||
typename Algebraic_extension_traits<IC>::Normalization_factor nfac;
|
|
||||||
typename Scalar_factor_traits<POLY>::Scalar_factor sfac;
|
|
||||||
typename Scalar_factor_traits<POLY>::Scalar_div sdiv;
|
|
||||||
typedef typename Scalar_factor_traits<POLY>::Scalar Scalar;
|
|
||||||
|
|
||||||
|
|
||||||
if (typename PT::Total_degree()(p) == 0) return 0;
|
|
||||||
|
|
||||||
POLY a = canonicalize_polynomial(p);
|
|
||||||
POLY b = diff(a);
|
|
||||||
POLY c = CGAL::CGALi::gcd_utcf(a, b);
|
|
||||||
|
|
||||||
if (c == Coeff(1)) {
|
|
||||||
*factors = a;
|
|
||||||
*multiplicities = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int i = 1, n = 0;
|
|
||||||
|
|
||||||
// extending both polynomials a and b by the denominator for algebraic
|
|
||||||
// integers, which comes out from c=gcd(a,b), such that a and b are
|
|
||||||
// divisible by c
|
|
||||||
IC lcoeff = ilcoeff(c);
|
|
||||||
IC denom = dfai(begin(c), end(c));
|
|
||||||
lcoeff *= denom * nfac(denom);
|
|
||||||
POLY w = (a * POLY(lcoeff)) / c;
|
|
||||||
POLY y = (b * POLY(lcoeff)) / c;
|
|
||||||
|
|
||||||
// extracting a common scalar factor out of w=a/c and y=b/c simultaneously,
|
|
||||||
// such that the parts in z=y-w' are canceled out as they should
|
|
||||||
Scalar sfactor = sfac(y,sfac(w));
|
|
||||||
sdiv(w, sfactor);
|
|
||||||
sdiv(y, sfactor);
|
|
||||||
|
|
||||||
POLY z = y - diff(w);
|
|
||||||
POLY g;
|
|
||||||
|
|
||||||
while (!z.is_zero()) {
|
|
||||||
g = CGAL::CGALi::gcd_utcf(w, z);
|
|
||||||
if (g.degree() > 0) {
|
|
||||||
*factors++ = g;
|
|
||||||
*multiplicities++ = i;
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
lcoeff = ilcoeff(g); // same as above
|
|
||||||
denom =dfai(begin(c), end(c));
|
|
||||||
lcoeff *= denom * nfac(denom);
|
|
||||||
w = (w * POLY(lcoeff)) / g;
|
|
||||||
y = (z * POLY(lcoeff)) / g;
|
|
||||||
Scalar sfactor = sfac(y,sfac(w));
|
|
||||||
sdiv(w, sfactor);
|
|
||||||
sdiv(y, sfactor);
|
|
||||||
|
|
||||||
z = y - diff(w);
|
|
||||||
}
|
|
||||||
|
|
||||||
*factors = w;
|
|
||||||
*multiplicities++ = i;
|
|
||||||
n++;
|
|
||||||
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline int square_free_factorization_for_regular_polynomial_
|
|
||||||
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities, Unique_factorization_domain_tag){
|
|
||||||
// Yun's Square-Free Factorization
|
|
||||||
// see [Geddes et al, 1992], Algorithm 8.2
|
|
||||||
/*
|
|
||||||
@inproceedings{y-osfda-76,
|
|
||||||
author = {David Y.Y. Yun},
|
|
||||||
title = {On square-free decomposition algorithms},
|
|
||||||
booktitle = {SYMSAC '76: Proceedings of the third ACM symposium on Symbolic
|
|
||||||
and algebraic computation},
|
|
||||||
year = {1976},
|
|
||||||
pages = {26--35},
|
|
||||||
location = {Yorktown Heights, New York, United States},
|
|
||||||
doi = {http://doi.acm.org/10.1145/800205.806320},
|
|
||||||
publisher = {ACM Press},
|
|
||||||
address = {New York, NY, USA},
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef Polynomial<Coeff> POLY;
|
|
||||||
typedef Polynomial_traits_d<POLY> PT;
|
|
||||||
|
|
||||||
if (typename PT::Total_degree()(p) == 0) return 0;
|
|
||||||
POLY a = canonicalize_polynomial(p);
|
|
||||||
|
|
||||||
POLY b = diff(a);
|
|
||||||
POLY c = CGAL::gcd(a, b);
|
|
||||||
|
|
||||||
if (c == Coeff(1)) {
|
|
||||||
*factors = a;
|
|
||||||
*multiplicities = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int i = 1, n = 0;
|
|
||||||
POLY w = a/c, y = b/c, z = y - diff(w), g;
|
|
||||||
while (!z.is_zero()) {
|
|
||||||
g = CGAL::gcd(w, z);
|
|
||||||
if (g.degree() > 0) {
|
|
||||||
*factors++ = g;
|
|
||||||
*multiplicities++ = i;
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
w /= g;
|
|
||||||
y = z/g;
|
|
||||||
z = y - diff(w);
|
|
||||||
}
|
|
||||||
*factors = w;
|
|
||||||
*multiplicities++ = i;
|
|
||||||
n++;
|
|
||||||
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// square-free factorization utcf
|
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline int square_free_factorization_utcf
|
|
||||||
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities)
|
|
||||||
{
|
|
||||||
return square_free_factorization(p,factors,multiplicities);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline int square_free_factorization_utcf_for_regular_polynomial
|
|
||||||
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities)
|
|
||||||
{
|
|
||||||
return square_free_factorization_for_regular_polynomial(p,factors,multiplicities);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// filtered square-free factorization
|
|
||||||
|
|
||||||
// ### filtered versions ####
|
|
||||||
|
|
||||||
/*! \brief As NiX::square_free_factorization, but filtered by
|
|
||||||
* NiX::may_have_multiple_root
|
|
||||||
*
|
|
||||||
* Use this function if the polynomial might be square free.
|
|
||||||
*/
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline
|
|
||||||
int filtered_square_free_factorization(
|
|
||||||
Polynomial<Coeff> p,
|
|
||||||
OutputIterator1 factors,
|
|
||||||
OutputIterator2 multiplicities)
|
|
||||||
{
|
|
||||||
if(CGAL::CGALi::may_have_multiple_factor(p)){
|
|
||||||
return CGALi::square_free_factorization(p, factors, multiplicities);
|
|
||||||
}else{
|
|
||||||
*factors++ = canonicalize_polynomial(p);
|
|
||||||
*multiplicities++ = 1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! \brief As NiX::square_free_factorization_utcf, but filtered by
|
|
||||||
* NiX::may_have_multiple_root
|
|
||||||
*
|
|
||||||
* Use this function if the polynomial might be square free.
|
|
||||||
*/
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
|
||||||
inline
|
|
||||||
int filtered_square_free_factorization_utcf( const Polynomial<Coeff>& p,
|
|
||||||
OutputIterator1 factors,
|
|
||||||
OutputIterator2 multiplicities)
|
|
||||||
{
|
|
||||||
return filtered_square_free_factorization(p,factors,multiplicities);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace CGALi
|
|
||||||
CGAL_END_NAMESPACE
|
|
||||||
|
|
||||||
#endif // CGAL_POLYNOMIAL_SQUARE_FREE_FACTORIZATION_H
|
|
||||||
|
|
@ -45,32 +45,32 @@ namespace CGALi {
|
||||||
// Yun's algo (utcf)
|
// Yun's algo (utcf)
|
||||||
|
|
||||||
template <class IC, class OutputIterator1, class OutputIterator2>
|
template <class IC, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization(const IC&, OutputIterator1, OutputIterator2){
|
inline int square_free_factorize(const IC&, OutputIterator1, OutputIterator2){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
template <class IC, class OutputIterator1, class OutputIterator2>
|
template <class IC, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization_for_regular_polynomial(const IC&, OutputIterator1, OutputIterator2){
|
inline int square_free_factorize_for_regular_polynomial(const IC&, OutputIterator1, OutputIterator2){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2);
|
inline int square_free_factorize(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2);
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization_for_regular_polynomial(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2);
|
inline int square_free_factorize_for_regular_polynomial(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2);
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization_for_regular_polynomial_(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2, CGAL::Tag_true);
|
inline int square_free_factorize_for_regular_polynomial_(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2, CGAL::Tag_true);
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization_for_regular_polynomial_(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2, CGAL::Tag_false);
|
inline int square_free_factorize_for_regular_polynomial_(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2, CGAL::Tag_false);
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization_for_regular_polynomial_(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2, Integral_domain_tag);
|
inline int square_free_factorize_for_regular_polynomial_(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2, Integral_domain_tag);
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization_for_regular_polynomial_(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2, Unique_factorization_domain_tag);
|
inline int square_free_factorize_for_regular_polynomial_(const Polynomial<Coeff>&, OutputIterator1, OutputIterator2, Unique_factorization_domain_tag);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization
|
inline int square_free_factorize
|
||||||
(const Polynomial<Coeff>& poly, OutputIterator1 factors, OutputIterator2 multiplicities)
|
(const Polynomial<Coeff>& poly, OutputIterator1 factors, OutputIterator2 multiplicities)
|
||||||
{
|
{
|
||||||
typedef Polynomial<Coeff> POLY;
|
typedef Polynomial<Coeff> POLY;
|
||||||
|
|
@ -83,7 +83,7 @@ inline int square_free_factorization
|
||||||
Coeff ucont_utcf = Ucont_utcf()(poly);
|
Coeff ucont_utcf = Ucont_utcf()(poly);
|
||||||
POLY regular_poly = Idiv_utcf()(poly,ucont_utcf);
|
POLY regular_poly = Idiv_utcf()(poly,ucont_utcf);
|
||||||
|
|
||||||
int result = square_free_factorization_for_regular_polynomial(
|
int result = square_free_factorize_for_regular_polynomial(
|
||||||
regular_poly, factors, multiplicities);
|
regular_poly, factors, multiplicities);
|
||||||
|
|
||||||
if (typename PT::Total_degree()(ucont_utcf) > 0){
|
if (typename PT::Total_degree()(ucont_utcf) > 0){
|
||||||
|
|
@ -91,7 +91,7 @@ inline int square_free_factorization
|
||||||
typedef std::vector< int > Multiplicities_uc;
|
typedef std::vector< int > Multiplicities_uc;
|
||||||
Factors_uc factors_uc;
|
Factors_uc factors_uc;
|
||||||
Multiplicities_uc multiplicities_uc;
|
Multiplicities_uc multiplicities_uc;
|
||||||
result += square_free_factorization( ucont_utcf,
|
result += square_free_factorize( ucont_utcf,
|
||||||
std::back_inserter(factors_uc),
|
std::back_inserter(factors_uc),
|
||||||
std::back_inserter(multiplicities_uc) );
|
std::back_inserter(multiplicities_uc) );
|
||||||
|
|
||||||
|
|
@ -108,15 +108,15 @@ inline int square_free_factorization
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization_for_regular_polynomial
|
inline int square_free_factorize_for_regular_polynomial
|
||||||
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities){
|
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities){
|
||||||
typedef Polynomial<Coeff> POLY;
|
typedef Polynomial<Coeff> POLY;
|
||||||
typedef typename CGAL::Fraction_traits<POLY>::Is_fraction Is_fraction;
|
typedef typename CGAL::Fraction_traits<POLY>::Is_fraction Is_fraction;
|
||||||
return square_free_factorization_for_regular_polynomial_(p,factors,multiplicities,Is_fraction());
|
return square_free_factorize_for_regular_polynomial_(p,factors,multiplicities,Is_fraction());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization_for_regular_polynomial_
|
inline int square_free_factorize_for_regular_polynomial_
|
||||||
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities, CGAL::Tag_true){
|
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities, CGAL::Tag_true){
|
||||||
|
|
||||||
typedef Polynomial<Coeff> POLY;
|
typedef Polynomial<Coeff> POLY;
|
||||||
|
|
@ -128,7 +128,7 @@ inline int square_free_factorization_for_regular_polynomial_
|
||||||
typename FT::Decompose()(p,num,denom);
|
typename FT::Decompose()(p,num,denom);
|
||||||
|
|
||||||
std::vector<typename FT::Numerator_type> ifacs;
|
std::vector<typename FT::Numerator_type> ifacs;
|
||||||
int result = square_free_factorization_for_regular_polynomial(num,std::back_inserter(ifacs),multiplicities);
|
int result = square_free_factorize_for_regular_polynomial(num,std::back_inserter(ifacs),multiplicities);
|
||||||
|
|
||||||
typedef typename std::vector<typename FT::Numerator_type>::iterator Iterator;
|
typedef typename std::vector<typename FT::Numerator_type>::iterator Iterator;
|
||||||
denom = typename FT::Denominator_type(1);
|
denom = typename FT::Denominator_type(1);
|
||||||
|
|
@ -141,15 +141,15 @@ inline int square_free_factorization_for_regular_polynomial_
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization_for_regular_polynomial_
|
inline int square_free_factorize_for_regular_polynomial_
|
||||||
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities, CGAL::Tag_false){
|
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities, CGAL::Tag_false){
|
||||||
typedef Polynomial<Coeff> POLY;
|
typedef Polynomial<Coeff> POLY;
|
||||||
typedef typename Algebraic_structure_traits<POLY>::Algebraic_category Algebraic_category;
|
typedef typename Algebraic_structure_traits<POLY>::Algebraic_category Algebraic_category;
|
||||||
return square_free_factorization_for_regular_polynomial_(p,factors,multiplicities,Algebraic_category());
|
return square_free_factorize_for_regular_polynomial_(p,factors,multiplicities,Algebraic_category());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization_for_regular_polynomial_
|
inline int square_free_factorize_for_regular_polynomial_
|
||||||
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities, Integral_domain_tag){
|
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities, Integral_domain_tag){
|
||||||
// Yun's Square-Free Factorization
|
// Yun's Square-Free Factorization
|
||||||
// see [Geddes et al, 1992], Algorithm 8.2
|
// see [Geddes et al, 1992], Algorithm 8.2
|
||||||
|
|
@ -228,7 +228,7 @@ inline int square_free_factorization_for_regular_polynomial_
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization_for_regular_polynomial_
|
inline int square_free_factorize_for_regular_polynomial_
|
||||||
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities, Unique_factorization_domain_tag){
|
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities, Unique_factorization_domain_tag){
|
||||||
// Yun's Square-Free Factorization
|
// Yun's Square-Free Factorization
|
||||||
// see [Geddes et al, 1992], Algorithm 8.2
|
// see [Geddes et al, 1992], Algorithm 8.2
|
||||||
|
|
@ -289,17 +289,17 @@ inline int square_free_factorization_for_regular_polynomial_
|
||||||
// square-free factorization utcf
|
// square-free factorization utcf
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization_utcf
|
inline int square_free_factorize_utcf
|
||||||
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities)
|
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities)
|
||||||
{
|
{
|
||||||
return square_free_factorization(p,factors,multiplicities);
|
return square_free_factorize(p,factors,multiplicities);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline int square_free_factorization_utcf_for_regular_polynomial
|
inline int square_free_factorize_utcf_for_regular_polynomial
|
||||||
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities)
|
(const Polynomial<Coeff>& p, OutputIterator1 factors, OutputIterator2 multiplicities)
|
||||||
{
|
{
|
||||||
return square_free_factorization_for_regular_polynomial(p,factors,multiplicities);
|
return square_free_factorize_for_regular_polynomial(p,factors,multiplicities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -309,20 +309,20 @@ inline int square_free_factorization_utcf_for_regular_polynomial
|
||||||
|
|
||||||
// ### filtered versions ####
|
// ### filtered versions ####
|
||||||
|
|
||||||
/*! \brief As NiX::square_free_factorization, but filtered by
|
/*! \brief As NiX::square_free_factorize, but filtered by
|
||||||
* NiX::may_have_multiple_root
|
* NiX::may_have_multiple_root
|
||||||
*
|
*
|
||||||
* Use this function if the polynomial might be square free.
|
* Use this function if the polynomial might be square free.
|
||||||
*/
|
*/
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline
|
inline
|
||||||
int filtered_square_free_factorization(
|
int filtered_square_free_factorize(
|
||||||
Polynomial<Coeff> p,
|
Polynomial<Coeff> p,
|
||||||
OutputIterator1 factors,
|
OutputIterator1 factors,
|
||||||
OutputIterator2 multiplicities)
|
OutputIterator2 multiplicities)
|
||||||
{
|
{
|
||||||
if(CGAL::CGALi::may_have_multiple_factor(p)){
|
if(CGAL::CGALi::may_have_multiple_factor(p)){
|
||||||
return CGALi::square_free_factorization(p, factors, multiplicities);
|
return CGALi::square_free_factorize(p, factors, multiplicities);
|
||||||
}else{
|
}else{
|
||||||
*factors++ = canonicalize_polynomial(p);
|
*factors++ = canonicalize_polynomial(p);
|
||||||
*multiplicities++ = 1;
|
*multiplicities++ = 1;
|
||||||
|
|
@ -330,18 +330,18 @@ int filtered_square_free_factorization(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \brief As NiX::square_free_factorization_utcf, but filtered by
|
/*! \brief As NiX::square_free_factorize_utcf, but filtered by
|
||||||
* NiX::may_have_multiple_root
|
* NiX::may_have_multiple_root
|
||||||
*
|
*
|
||||||
* Use this function if the polynomial might be square free.
|
* Use this function if the polynomial might be square free.
|
||||||
*/
|
*/
|
||||||
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
template <class Coeff, class OutputIterator1, class OutputIterator2>
|
||||||
inline
|
inline
|
||||||
int filtered_square_free_factorization_utcf( const Polynomial<Coeff>& p,
|
int filtered_square_free_factorize_utcf( const Polynomial<Coeff>& p,
|
||||||
OutputIterator1 factors,
|
OutputIterator1 factors,
|
||||||
OutputIterator2 multiplicities)
|
OutputIterator2 multiplicities)
|
||||||
{
|
{
|
||||||
return filtered_square_free_factorization(p,factors,multiplicities);
|
return filtered_square_free_factorize(p,factors,multiplicities);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace CGALi
|
} // namespace CGALi
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include <CGAL/Polynomial/resultant.h>
|
#include <CGAL/Polynomial/resultant.h>
|
||||||
#include <CGAL/Polynomial/subresultants.h>
|
#include <CGAL/Polynomial/subresultants.h>
|
||||||
#include <CGAL/Polynomial/sturm_habicht_sequence.h>
|
#include <CGAL/Polynomial/sturm_habicht_sequence.h>
|
||||||
#include <CGAL/Polynomial/square_free_factorization.h>
|
#include <CGAL/Polynomial/square_free_factorize.h>
|
||||||
#include <CGAL/Polynomial/modular_filter.h>
|
#include <CGAL/Polynomial/modular_filter.h>
|
||||||
#include <CGAL/extended_euclidean_algorithm.h>
|
#include <CGAL/extended_euclidean_algorithm.h>
|
||||||
|
|
||||||
|
|
@ -214,7 +214,7 @@ template< class Coefficient_type_, class PolynomialAlgebraicCategory >
|
||||||
class Polynomial_traits_d_base_polynomial_algebraic_category {
|
class Polynomial_traits_d_base_polynomial_algebraic_category {
|
||||||
public:
|
public:
|
||||||
typedef Null_functor Univariate_content;
|
typedef Null_functor Univariate_content;
|
||||||
typedef Null_functor Square_free_factorization;
|
typedef Null_functor Square_free_factorize;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Specializations
|
// Specializations
|
||||||
|
|
@ -250,15 +250,15 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Square_free_factorization;
|
// Square_free_factorize;
|
||||||
struct Square_free_factorization{
|
struct Square_free_factorize{
|
||||||
|
|
||||||
template < class OutputIterator >
|
template < class OutputIterator >
|
||||||
OutputIterator operator()( const Polynomial_d& p, OutputIterator oi) const {
|
OutputIterator operator()( const Polynomial_d& p, OutputIterator oi) const {
|
||||||
std::vector<Polynomial_d> factors;
|
std::vector<Polynomial_d> factors;
|
||||||
std::vector<int> mults;
|
std::vector<int> mults;
|
||||||
|
|
||||||
square_free_factorization
|
square_free_factorize
|
||||||
( p, std::back_inserter(factors), std::back_inserter(mults) );
|
( p, std::back_inserter(factors), std::back_inserter(mults) );
|
||||||
|
|
||||||
CGAL_postcondition( factors.size() == mults.size() );
|
CGAL_postcondition( factors.size() == mults.size() );
|
||||||
|
|
@ -350,7 +350,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Null_functor Square_free_factorization;
|
typedef Null_functor Square_free_factorize;
|
||||||
typedef Null_functor Pseudo_division;
|
typedef Null_functor Pseudo_division;
|
||||||
typedef Null_functor Pseudo_division_remainder;
|
typedef Null_functor Pseudo_division_remainder;
|
||||||
typedef Null_functor Pseudo_division_quotient;
|
typedef Null_functor Pseudo_division_quotient;
|
||||||
|
|
@ -375,7 +375,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Null_functor Square_free_factorization_up_to_constant_factor;
|
typedef Null_functor Square_free_factorize_up_to_constant_factor;
|
||||||
typedef Null_functor Resultant;
|
typedef Null_functor Resultant;
|
||||||
typedef Null_functor Canonicalize;
|
typedef Null_functor Canonicalize;
|
||||||
typedef Null_functor Evaluate_homogeneous;
|
typedef Null_functor Evaluate_homogeneous;
|
||||||
|
|
@ -1165,7 +1165,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Square_free_factorization_up_to_constant_factor {
|
struct Square_free_factorize_up_to_constant_factor {
|
||||||
private:
|
private:
|
||||||
typedef Coefficient_type Coeff;
|
typedef Coefficient_type Coeff;
|
||||||
typedef Innermost_coefficient_type ICoeff;
|
typedef Innermost_coefficient_type ICoeff;
|
||||||
|
|
@ -1183,7 +1183,7 @@ public:
|
||||||
typename First_if_different<Coeff,ICoeff>::Type c,
|
typename First_if_different<Coeff,ICoeff>::Type c,
|
||||||
OutputIterator oi) const {
|
OutputIterator oi) const {
|
||||||
|
|
||||||
typename PTC::Square_free_factorization_up_to_constant_factor sqff;
|
typename PTC::Square_free_factorize_up_to_constant_factor sqff;
|
||||||
std::vector<std::pair<Coefficient_type,int> > fac_mul_pairs;
|
std::vector<std::pair<Coefficient_type,int> > fac_mul_pairs;
|
||||||
sqff(c,std::back_inserter(fac_mul_pairs));
|
sqff(c,std::back_inserter(fac_mul_pairs));
|
||||||
|
|
||||||
|
|
@ -1208,7 +1208,7 @@ public:
|
||||||
p = idiv_utcf( p , Polynomial_d(c));
|
p = idiv_utcf( p , Polynomial_d(c));
|
||||||
std::vector<Polynomial_d> factors;
|
std::vector<Polynomial_d> factors;
|
||||||
std::vector<int> mults;
|
std::vector<int> mults;
|
||||||
square_free_factorization_utcf(
|
square_free_factorize_utcf(
|
||||||
p, std::back_inserter(factors), std::back_inserter(mults));
|
p, std::back_inserter(factors), std::back_inserter(mults));
|
||||||
for(unsigned int i = 0; i < factors.size() ; i++){
|
for(unsigned int i = 0; i < factors.size() ; i++){
|
||||||
*oi++=std::make_pair(factors[i],mults[i]);
|
*oi++=std::make_pair(factors[i],mults[i]);
|
||||||
|
|
|
||||||
|
|
@ -516,7 +516,7 @@ void test_sqff_utcf_(const POLY& poly, int n){
|
||||||
std::back_insert_iterator<std::vector<int> > mul_bi(mul);
|
std::back_insert_iterator<std::vector<int> > mul_bi(mul);
|
||||||
|
|
||||||
assert(n ==
|
assert(n ==
|
||||||
CGAL::CGALi::square_free_factorization_utcf(poly, fac_bi, mul_bi));
|
CGAL::CGALi::square_free_factorize_utcf(poly, fac_bi, mul_bi));
|
||||||
|
|
||||||
assert((int) mul.size() == n);
|
assert((int) mul.size() == n);
|
||||||
assert((int) fac.size() == n);
|
assert((int) fac.size() == n);
|
||||||
|
|
@ -650,7 +650,7 @@ void sqff() {
|
||||||
std::back_insert_iterator<IVEC> mul_bi(mul);
|
std::back_insert_iterator<IVEC> mul_bi(mul);
|
||||||
unsigned n;
|
unsigned n;
|
||||||
NT alpha;
|
NT alpha;
|
||||||
n = CGAL::CGALi::square_free_factorization(p, fac_bi, mul_bi );
|
n = CGAL::CGALi::square_free_factorize(p, fac_bi, mul_bi );
|
||||||
|
|
||||||
// assert(alpha == 3);
|
// assert(alpha == 3);
|
||||||
assert(n == 3);
|
assert(n == 3);
|
||||||
|
|
@ -666,7 +666,7 @@ void sqff() {
|
||||||
mul.clear();
|
mul.clear();
|
||||||
fac_bi = std::back_insert_iterator<PVEC>(fac);
|
fac_bi = std::back_insert_iterator<PVEC>(fac);
|
||||||
mul_bi = std::back_insert_iterator<IVEC>(mul);
|
mul_bi = std::back_insert_iterator<IVEC>(mul);
|
||||||
std::cerr << CGAL::CGALi::square_free_factorization( p, fac_bi, mul_bi ) << std::endl;
|
std::cerr << CGAL::CGALi::square_free_factorize( p, fac_bi, mul_bi ) << std::endl;
|
||||||
std::cerr << fac[0] << std::endl;*/
|
std::cerr << fac[0] << std::endl;*/
|
||||||
//std::cerr << fac[1] << std::endl;
|
//std::cerr << fac[1] << std::endl;
|
||||||
|
|
||||||
|
|
@ -681,7 +681,7 @@ void sqff() {
|
||||||
mul.clear();
|
mul.clear();
|
||||||
std::back_insert_iterator< BPVEC > bfac_bi( bfac );
|
std::back_insert_iterator< BPVEC > bfac_bi( bfac );
|
||||||
mul_bi = std::back_insert_iterator<IVEC>(mul);
|
mul_bi = std::back_insert_iterator<IVEC>(mul);
|
||||||
// std::cerr << CGAL::POLYNOMIAL::square_free_factorization( bp, bfac_bi, mul_bi ) << std::endl;
|
// std::cerr << CGAL::POLYNOMIAL::square_free_factorize( bp, bfac_bi, mul_bi ) << std::endl;
|
||||||
// std::cerr << bfac[0] << std::endl;
|
// std::cerr << bfac[0] << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -737,14 +737,14 @@ void test_make_square_free(const Polynomial_traits_d&){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// // Square_free_factorization;
|
// // Square_free_factorize;
|
||||||
template <class Polynomial_traits_d>
|
template <class Polynomial_traits_d>
|
||||||
void test_square_free_factorization(const Polynomial_traits_d&){
|
void test_square_free_factorize(const Polynomial_traits_d&){
|
||||||
std::cerr << "start test_square_free_factorization "; std::cerr.flush();
|
std::cerr << "start test_square_free_factorize "; std::cerr.flush();
|
||||||
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
|
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
|
||||||
typedef CGAL::Algebraic_structure_traits<Polynomial_d> AST;
|
typedef CGAL::Algebraic_structure_traits<Polynomial_d> AST;
|
||||||
typename AST::Integral_division idiv;
|
typename AST::Integral_division idiv;
|
||||||
typename PT::Square_free_factorization sqff;
|
typename PT::Square_free_factorize sqff;
|
||||||
typename PT::Canonicalize canonicalize;
|
typename PT::Canonicalize canonicalize;
|
||||||
(void) idiv;
|
(void) idiv;
|
||||||
(void) sqff;
|
(void) sqff;
|
||||||
|
|
@ -949,14 +949,14 @@ void test_univariate_content_up_to_constant_factor(const Polynomial_traits_d&){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// // Square_free_factorization_up_to_constant_factor;
|
// // Square_free_factorize_up_to_constant_factor;
|
||||||
template <class Polynomial_traits_d>
|
template <class Polynomial_traits_d>
|
||||||
void test_square_free_factorization_up_to_constant_factor(const Polynomial_traits_d&){
|
void test_square_free_factorize_up_to_constant_factor(const Polynomial_traits_d&){
|
||||||
std::cerr << "start test_square_free_factorization_up_to_constant_factor ";
|
std::cerr << "start test_square_free_factorize_up_to_constant_factor ";
|
||||||
std::cerr.flush();
|
std::cerr.flush();
|
||||||
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
|
CGAL_SNAP_CGALi_TRAITS_D(Polynomial_traits_d);
|
||||||
typename PT::Integral_division_up_to_constant_factor idiv_utcf;
|
typename PT::Integral_division_up_to_constant_factor idiv_utcf;
|
||||||
typename PT::Square_free_factorization_up_to_constant_factor sqff_utcf;
|
typename PT::Square_free_factorize_up_to_constant_factor sqff_utcf;
|
||||||
typename PT::Canonicalize canonicalize;
|
typename PT::Canonicalize canonicalize;
|
||||||
|
|
||||||
(void) idiv_utcf;
|
(void) idiv_utcf;
|
||||||
|
|
@ -1424,7 +1424,7 @@ void test_fundamental_functors(const PT& traits){
|
||||||
test_gcd_up_to_constant_factor(traits);
|
test_gcd_up_to_constant_factor(traits);
|
||||||
test_integral_division_up_to_constant_factor(traits);
|
test_integral_division_up_to_constant_factor(traits);
|
||||||
test_univariate_content_up_to_constant_factor(traits);
|
test_univariate_content_up_to_constant_factor(traits);
|
||||||
test_square_free_factorization_up_to_constant_factor(traits);
|
test_square_free_factorize_up_to_constant_factor(traits);
|
||||||
|
|
||||||
// resultant
|
// resultant
|
||||||
test_resultant(traits);
|
test_resultant(traits);
|
||||||
|
|
@ -1472,13 +1472,13 @@ void test_ac_icoeff_functors(const PT& traits, CGAL::Field_tag){
|
||||||
template< class PT >
|
template< class PT >
|
||||||
void test_ac_poly_functors(const PT&, CGAL::Integral_domain_without_division_tag){
|
void test_ac_poly_functors(const PT&, CGAL::Integral_domain_without_division_tag){
|
||||||
ASSERT_IS_NULL_FUNCTOR(typename PT::Univariate_content);
|
ASSERT_IS_NULL_FUNCTOR(typename PT::Univariate_content);
|
||||||
ASSERT_IS_NULL_FUNCTOR(typename PT::Square_free_factorization);
|
ASSERT_IS_NULL_FUNCTOR(typename PT::Square_free_factorize);
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class PT >
|
template< class PT >
|
||||||
void test_ac_poly_functors(const PT& traits, CGAL::Unique_factorization_domain_tag){
|
void test_ac_poly_functors(const PT& traits, CGAL::Unique_factorization_domain_tag){
|
||||||
test_univariate_content(traits);
|
test_univariate_content(traits);
|
||||||
test_square_free_factorization(traits);
|
test_square_free_factorize(traits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// $URL:$
|
// $URL$
|
||||||
// $Id:$
|
// $Id$
|
||||||
|
|
||||||
#include <CGAL/Cartesian_d.h>
|
#include <CGAL/Cartesian_d.h>
|
||||||
#include <CGAL/Random.h>
|
#include <CGAL/Random.h>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue