polynomial: use correct degree in template param

This commit is contained in:
Danny Robson 2015-01-22 14:57:16 +11:00
parent dd098943cf
commit b9f38eb4a9
3 changed files with 5 additions and 5 deletions

View File

@ -52,7 +52,7 @@ namespace util { namespace polynomial {
const float c = coeff[2];
if (almost_zero (a)) {
auto s = solve<2> ({b, c});
auto s = solve<1> ({b, c});
return { s[0], std::numeric_limits<float>::quiet_NaN () };
}
@ -76,7 +76,7 @@ namespace util { namespace polynomial {
const float _d = coeffs[3];
if (almost_zero (_a)) {
auto s = solve<3> ({_b, _c, _d});
auto s = solve<2> ({_b, _c, _d});
return {s[0], s[1], std::numeric_limits<float>::quiet_NaN () };
}

View File

@ -26,8 +26,8 @@
namespace util {
namespace polynomial {
template <size_t S>
std::array<float,S-1>
solve (std::array<float,S>);
std::array<float,S>
solve (std::array<float,S+1>);
template <size_t S>
float

View File

@ -28,7 +28,7 @@ main (int, char**)
};
for (auto &i: CUBICS) {
auto s = util::polynomial::solve (i.coeffs);
std::array<float,3> s = util::polynomial::solve<3> (i.coeffs);
std::sort (s.begin (), s.end ());