From 0f19eaf6e11a7bac704563960c1fe1423ebaa8cf Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 29 Jan 2015 15:38:53 +1100 Subject: [PATCH] comments --- polynomial.cpp | 3 +++ polynomial.hpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/polynomial.cpp b/polynomial.cpp index 194a5f0b..dc761a91 100644 --- a/polynomial.cpp +++ b/polynomial.cpp @@ -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::quiet_NaN () }; diff --git a/polynomial.hpp b/polynomial.hpp index 29f61cdc..b7490178 100644 --- a/polynomial.hpp +++ b/polynomial.hpp @@ -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 std::array solve (std::array);