diff --git a/Polynomial/include/CGAL/Polynomial/fwd.h b/Polynomial/include/CGAL/Polynomial/fwd.h index 31ea2545dc2..fea83b67710 100644 --- a/Polynomial/include/CGAL/Polynomial/fwd.h +++ b/Polynomial/include/CGAL/Polynomial/fwd.h @@ -97,6 +97,15 @@ template inline template OutputIterator sturm_habicht_sequence(CGAL::Polynomial P, OutputIterator out); + template OutputIterator1 + sturm_habicht_sequence_with_cofactors(CGAL::Polynomial P, + OutputIterator1 out_stha, + OutputIterator2 out_f, + OutputIterator3 out_fx); + } // namespace CGALi diff --git a/Polynomial/include/CGAL/Polynomial_traits_d.h b/Polynomial/include/CGAL/Polynomial_traits_d.h index 9d8e5eef7a9..36a88e9149b 100644 --- a/Polynomial/include/CGAL/Polynomial_traits_d.h +++ b/Polynomial/include/CGAL/Polynomial_traits_d.h @@ -1381,8 +1381,28 @@ public: out); } }; + + // Sturm-Habicht sequence with cofactors + struct Sturm_habicht_sequence_with_cofactors { + template + OutputIterator1 operator()( + const Polynomial_d& p, + OutputIterator1 out_stha, + OutputIterator2 out_f, + OutputIterator3 out_fx, + int i = (d-1) ) const { + if(i == (d-1) ) + return CGAL::CGALi::sturm_habicht_sequence_with_cofactors + (p,out_stha,out_f,out_fx); + else + return CGAL::CGALi::sturm_habicht_sequence_with_cofactors + (Move()(p,i),out_stha,out_f,out_fx); + } + }; - // Sturm-Habicht sequence + // Principal Sturm-Habicht sequence struct Principal_sturm_habicht_sequence { template diff --git a/Polynomial/test/Polynomial/sturm_habicht_sequence.cpp b/Polynomial/test/Polynomial/sturm_habicht_sequence.cpp index 7f05e5cff9c..180f4aa949d 100644 --- a/Polynomial/test/Polynomial/sturm_habicht_sequence.cpp +++ b/Polynomial/test/Polynomial/sturm_habicht_sequence.cpp @@ -207,6 +207,23 @@ template void test_routine() { assert(stha[i]==co_f[i]*f + co_fx[i]*fx); } + stha.clear(); + co_f.clear(); + co_fx.clear(); + typename CGAL::Polynomial_traits_d + ::Sturm_habicht_sequence_with_cofactors()(f, + std::back_inserter(stha), + std::back_inserter(co_f), + std::back_inserter(co_fx) + ); + + n = static_cast(stha.size()); + assert(n == static_cast(stha_check.size())); + for(int i = 0; i < n; i++) { + assert(stha[i]==stha_check[i]); + assert(stha[i]==co_f[i]*f + co_fx[i]*fx); + } + } { // Cofactors, defective case