diff --git a/src/lol/math/polynomial.h b/src/lol/math/polynomial.h index 162185cb..ad062209 100644 --- a/src/lol/math/polynomial.h +++ b/src/lol/math/polynomial.h @@ -286,9 +286,9 @@ struct polynomial for (int n = remainder.degree() - p.degree(); n >= 0; --n) { quotient.set(n, remainder.leading()); - remainder.m_coefficients.Pop(); for (int i = 0; i < p.degree(); ++i) remainder.m_coefficients[n + i] -= remainder.leading() * p[i]; + remainder.m_coefficients.Pop(); } return ret; diff --git a/src/t/math/polynomial.cpp b/src/t/math/polynomial.cpp index 706d406f..9651eefa 100644 --- a/src/t/math/polynomial.cpp +++ b/src/t/math/polynomial.cpp @@ -190,6 +190,9 @@ lolunit_declare_fixture(PolynomialTest) polynomial p { -4.f, 0.f, -2.f, 1.f }; polynomial q { -3.f, 1.f }; + /* p(x) = r(x) q(x) + s(x) + * r(x) = 3 + x + x² + * s(x) = 5 */ auto r = p / q; lolunit_assert_equal(r.m1.degree(), 2); lolunit_assert_doubles_equal(r.m1[0], 3.f, 1e-5f);