Esempio n. 1
0
ScalarList NewtonPolySolve::FindRoots(const CPolynomial& poly, const ScalarList& guessListIn) {
	
	if (poly.Degree() == 0) {
		if (poly[0] == Scalar(0))
			return ScalarList(1,0);
		else 
			throw Exception("No solution");
	}
		
	Scalar x(0);
	
	ScalarList guessList = guessListIn;

	if (!guessList.empty()) {
		x = guessList.back();
		guessList.pop_back();
	}
	
	bool converged;
	x = NextRoot(poly, x, &converged);
	
	ScalarList answers;
	if (poly.Degree() > 1)
		ScalarList answers = FindRoots(poly.RemoveRoot(x), guessList);

	answers.push_back(x);
	return answers;
}