Added functor Sturm_habicht_sequence_with_cofactors in Polynomial_traits

This commit is contained in:
Michael Kerber 2008-06-27 10:17:54 +00:00
parent acbb15c13f
commit 239c86d7ca
3 changed files with 47 additions and 1 deletions

View File

@ -97,6 +97,15 @@ template <typename OutputIterator, typename NT > inline
template<typename OutputIterator, typename NT> OutputIterator
sturm_habicht_sequence(CGAL::Polynomial<NT> P, OutputIterator out);
template<typename OutputIterator1,
typename OutputIterator2,
typename OutputIterator3,
typename NT> OutputIterator1
sturm_habicht_sequence_with_cofactors(CGAL::Polynomial<NT> P,
OutputIterator1 out_stha,
OutputIterator2 out_f,
OutputIterator3 out_fx);
} // namespace CGALi

View File

@ -1381,8 +1381,28 @@ public:
out);
}
};
// Sturm-Habicht sequence with cofactors
struct Sturm_habicht_sequence_with_cofactors {
template<typename OutputIterator1,
typename OutputIterator2,
typename OutputIterator3>
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<typename OutputIterator>

View File

@ -207,6 +207,23 @@ template<typename ArithmeticKernel> 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<PNT_1>
::Sturm_habicht_sequence_with_cofactors()(f,
std::back_inserter(stha),
std::back_inserter(co_f),
std::back_inserter(co_fx)
);
n = static_cast<int>(stha.size());
assert(n == static_cast<int>(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