This commit is contained in:
Danny Robson 2015-01-29 15:38:53 +11:00
parent 4d12dabb5f
commit 0f19eaf6e1
2 changed files with 6 additions and 0 deletions

View File

@ -79,6 +79,9 @@ namespace util { namespace polynomial {
const float _c = coeffs[2];
const float _d = coeffs[3];
// Take care of degenerate quadratic cases. We can also pass off if 'd'
// is zero, but the benefit isn't clear given we have to merge results
// at the end anyway.
if (almost_zero (_a)) {
auto s = solve<2> ({_b, _c, _d});
return {s[0], s[1], std::numeric_limits<float>::quiet_NaN () };

View File

@ -25,6 +25,9 @@
namespace util {
namespace polynomial {
// Invalid solutions are represented by NaN. They are guaranteed to
// be at the end of the solution list, so they are safe to skip on the
// first instance.
template <size_t S>
std::array<float,S>
solve (std::array<float,S+1>);