From 3b97f56eadbd010cbd4cbb34894a13030d189500 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 6 Jul 2015 21:41:03 +1000 Subject: [PATCH] polynomial: rename solve as roots --- bezier.cpp | 4 ++-- polynomial.cpp | 10 +++++----- polynomial.hpp | 2 +- test/polynomial.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bezier.cpp b/bezier.cpp index 97bc899a..da33be70 100644 --- a/bezier.cpp +++ b/bezier.cpp @@ -191,7 +191,7 @@ util::bezier::intersections (point2f p0, point2f p1) const pcoeff[i] = A * bcoeff[i].x + B * bcoeff[i].y; pcoeff.back () += C; - const auto r = polynomial::solve (pcoeff); + const auto r = polynomial::roots (pcoeff); // The curve and line are colinear if (std::all_of (r.begin (), r.end (), [] (auto i) { return std::isnan (i); })) @@ -261,7 +261,7 @@ namespace util { float d = dot (M_, A); // We have our cubic, so pass off to the solver - auto solutions = util::polynomial::solve<3> ({a, b, c, d}); + auto solutions = util::polynomial::roots<3> ({a, b, c, d}); // Find the smallest distance and return float dist = std::numeric_limits::infinity (); diff --git a/polynomial.cpp b/polynomial.cpp index 0334f6b6..367ab6f5 100644 --- a/polynomial.cpp +++ b/polynomial.cpp @@ -30,7 +30,7 @@ static const size_t NEWTON_ITERATIONS = 1u; namespace util { namespace polynomial { template <> std::array - solve (std::array coeff) + roots (std::array coeff) { const float a = coeff[0]; const float b = coeff[1]; @@ -46,14 +46,14 @@ namespace util { namespace polynomial { namespace util { namespace polynomial { template <> std::array - solve (std::array coeff) + roots (std::array coeff) { const float a = coeff[0]; const float b = coeff[1]; const float c = coeff[2]; if (almost_zero (a)) { - auto s = solve<1> ({b, c}); + auto s = roots<1> ({b, c}); return { s[0], std::numeric_limits::quiet_NaN () }; } @@ -69,7 +69,7 @@ namespace util { namespace polynomial { namespace util { namespace polynomial { template <> std::array - solve (std::array coeffs) + roots (std::array coeffs) { const float _a = coeffs[0]; const float _b = coeffs[1]; @@ -80,7 +80,7 @@ namespace util { namespace polynomial { // 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}); + auto s = roots<2> ({_b, _c, _d}); return {s[0], s[1], std::numeric_limits::quiet_NaN () }; } diff --git a/polynomial.hpp b/polynomial.hpp index bbafe92c..1a6283af 100644 --- a/polynomial.hpp +++ b/polynomial.hpp @@ -27,7 +27,7 @@ namespace util { // first instance. template std::array - solve (std::array); + roots (std::array); template T diff --git a/test/polynomial.cpp b/test/polynomial.cpp index 576a3d97..ebedf182 100644 --- a/test/polynomial.cpp +++ b/test/polynomial.cpp @@ -34,7 +34,7 @@ main (int, char**) util::TAP::logger test; for (auto &i: CUBICS) { - std::array s = util::polynomial::solve<3> (i.coeffs); + std::array s = util::polynomial::roots<3> (i.coeffs); std::sort (s.begin (), s.end ());