include/geometry/polynomial.hpp
author Dmitriy Morozov <morozov@cs.duke.edu>
Fri, 17 Aug 2007 15:04:28 -0400
changeset 56 f480ec018512
parent 19 efa14432761a
child 58 b3b810b64a79
permissions -rw-r--r--
Work in progress on ARVineyard and KineticSort. Commit to merge in CGAL 3.3 changes.

template<class T>
void
UPolynomial<T>::
solve(const RationalFunction& rf, RootStack& stack)
{
	typedef SYNAPS::Seq<RootType>		RootSeq;

	RootSeq seq_num = SYNAPS::solve(rf.numerator(), Solver());
	RootSeq seq_den = SYNAPS::solve(rf.denominator(), Solver());

	// TODO: assert that all roots in seq_den have positive multiplicity
	// TODO: deal with multiplicities for the numerator
	for (typename RootSeq::const_reverse_iterator cur = seq_num.rbegin(); 
												  cur != seq_num.rend(); 
												  ++cur)
	{
		if (SynapsTraits<T>::multiplicity(*cur) % 2 != 0)
		{		
			if (!stack.empty() && stack.top() == *cur)			// get rid of even multiplicities
				// TODO: add logging information for this
				stack.pop();
			else
				stack.push(*cur);
		}
	}
}

template<class T>
int
UPolynomial<T>::
sign_at(const RationalFunction& rf, const RootType& r)
{
	return SynapsTraits<T>::sign_at(rf.numerator(), r) * SynapsTraits<T>::sign_at(rf.denominator(), r);
}