From 25ed0ffbca580f5efcdf5dfd2c6a10743a4d4829 Mon Sep 17 00:00:00 2001 From: "Jeremy W. Murphy" Date: Sun, 13 Dec 2015 12:15:09 +1100 Subject: [PATCH] Negation depends only on negation, not on multiplication. --- include/boost/math/tools/polynomial.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/boost/math/tools/polynomial.hpp b/include/boost/math/tools/polynomial.hpp index d9064e1e4..5ebc85205 100644 --- a/include/boost/math/tools/polynomial.hpp +++ b/include/boost/math/tools/polynomial.hpp @@ -558,9 +558,10 @@ bool operator == (const polynomial &a, const polynomial &b) // Unary minus (negate). template -polynomial operator - (const polynomial& a) +polynomial operator - (polynomial a) { - return a * T(-1); + std::transform(a.data().begin(), a.data().end(), a.data().begin(), std::negate()); + return a; } template