From cd29f907d128bf0a3498469b80f54900017e29b9 Mon Sep 17 00:00:00 2001 From: Yuya Asano <64895419+sukeya@users.noreply.github.com> Date: Fri, 8 May 2026 09:40:26 +0900 Subject: [PATCH 1/3] Fix operator*(scalar). --- include/mvPolynomial/mvPolynomial.hpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/mvPolynomial/mvPolynomial.hpp b/include/mvPolynomial/mvPolynomial.hpp index 2c993f1..9e8bd25 100644 --- a/include/mvPolynomial/mvPolynomial.hpp +++ b/include/mvPolynomial/mvPolynomial.hpp @@ -371,10 +371,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; } From ed6e033f8cef408e7abb2b6fb237fcfa8a04c2bb Mon Sep 17 00:00:00 2001 From: Yuya Asano <64895419+sukeya@users.noreply.github.com> Date: Fri, 8 May 2026 09:43:22 +0900 Subject: [PATCH 2/3] Remove operator[] const. --- include/mvPolynomial/mvPolynomial.hpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/include/mvPolynomial/mvPolynomial.hpp b/include/mvPolynomial/mvPolynomial.hpp index 9e8bd25..9e80c8d 100644 --- a/include/mvPolynomial/mvPolynomial.hpp +++ b/include/mvPolynomial/mvPolynomial.hpp @@ -188,13 +188,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); } From bbe31b786813c4bcda32091de4cbe09a0cad31fd Mon Sep 17 00:00:00 2001 From: Yuya Asano <64895419+sukeya@users.noreply.github.com> Date: Fri, 8 May 2026 09:48:09 +0900 Subject: [PATCH 3/3] Fix operator= to clear before assigning. --- include/mvPolynomial/mvPolynomial.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/mvPolynomial/mvPolynomial.hpp b/include/mvPolynomial/mvPolynomial.hpp index 9e80c8d..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;