diff --git a/include/mvPolynomial/mvPolynomial.hpp b/include/mvPolynomial/mvPolynomial.hpp index 2c993f1..c574bba 100644 --- a/include/mvPolynomial/mvPolynomial.hpp +++ b/include/mvPolynomial/mvPolynomial.hpp @@ -151,6 +151,7 @@ class MVPolynomial final { : index2value_(std::move(m.index2value_), a) {} MVPolynomial& operator=(std::initializer_list l) { + index2value_.clear(); index2value_.insert(l.begin(), l.end()); CheckSelfIndexes(); return *this; @@ -188,13 +189,6 @@ class MVPolynomial final { mapped_type& operator[](const key_type& index) { return index2value_[index]; } mapped_type& operator[](key_type&& index) { return index2value_[index]; } - const mapped_type& operator[](const key_type& index) const { - return const_cast(this)->operator[](index); - } - const mapped_type& operator[](key_type&& index) const { - return const_cast(this)->operator[](index); - } - mapped_type& at(const key_type& i) { return index2value_.at(i); } const mapped_type& at(const key_type& i) const { return index2value_.at(i); } @@ -371,10 +365,9 @@ class MVPolynomial final { MVPolynomial& operator*=(mapped_type r) { auto idx = index_type::Zero(); - if (contains(idx)) { - (*this)[idx] *= r; - } else { - (*this)[idx] = r; + for (auto& index_and_coeff : *this) { + auto& coeff = index_and_coeff.second; + coeff *= 2; } return *this; }