include/geometry/polynomial.hpp
author Dmitriy Morozov <morozov@cs.duke.edu>
Fri, 14 Sep 2007 05:51:51 -0400
changeset 30 6d4e450015e4
parent 19 efa14432761a
child 58 b3b810b64a79
permissions -rw-r--r--
Fixed logging and counters

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);
}