polynomial: use correct degree in template param
This commit is contained in:
parent
dd098943cf
commit
b9f38eb4a9
@ -52,7 +52,7 @@ namespace util { namespace polynomial {
|
|||||||
const float c = coeff[2];
|
const float c = coeff[2];
|
||||||
|
|
||||||
if (almost_zero (a)) {
|
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 () };
|
return { s[0], std::numeric_limits<float>::quiet_NaN () };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ namespace util { namespace polynomial {
|
|||||||
const float _d = coeffs[3];
|
const float _d = coeffs[3];
|
||||||
|
|
||||||
if (almost_zero (_a)) {
|
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 () };
|
return {s[0], s[1], std::numeric_limits<float>::quiet_NaN () };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
namespace util {
|
namespace util {
|
||||||
namespace polynomial {
|
namespace polynomial {
|
||||||
template <size_t S>
|
template <size_t S>
|
||||||
std::array<float,S-1>
|
std::array<float,S>
|
||||||
solve (std::array<float,S>);
|
solve (std::array<float,S+1>);
|
||||||
|
|
||||||
template <size_t S>
|
template <size_t S>
|
||||||
float
|
float
|
||||||
|
@ -28,7 +28,7 @@ main (int, char**)
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (auto &i: CUBICS) {
|
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 ());
|
std::sort (s.begin (), s.end ());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user