From 29d7a5ba5ff719d9ab8b32fe5564257bbe09f845 Mon Sep 17 00:00:00 2001 From: Yuya Asano <64895419+sukeya@users.noreply.github.com> Date: Sun, 23 Nov 2025 14:43:58 +0900 Subject: [PATCH 1/2] Fix size type. --- include/mvPolynomial/index_comparer.hpp | 4 ++-- include/mvPolynomial/mvPolynomial.hpp | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/mvPolynomial/index_comparer.hpp b/include/mvPolynomial/index_comparer.hpp index 130b635..78ecf96 100644 --- a/include/mvPolynomial/index_comparer.hpp +++ b/include/mvPolynomial/index_comparer.hpp @@ -30,7 +30,7 @@ class IndexComparer final { * \param[in] rhd an index */ static constexpr std::strong_ordering Compare(const Index& lhd, const Index& rhd) { - for (std::size_t i = 0; i < lhd.size(); ++i) { + for (int i = 0; i < lhd.size(); ++i) { auto comp = lhd[i] <=> rhd[i]; if (comp < 0) { return std::strong_ordering::greater; @@ -48,7 +48,7 @@ class IndexComparer final { * \param[in] rhd an index */ bool operator()(const Index& lhd, const Index& rhd) const { - for (std::size_t i = 0; i < lhd.size(); ++i) { + for (int i = 0; i < lhd.size(); ++i) { if (lhd[i] < rhd[i]) { return true; } else if (lhd[i] > rhd[i]) { diff --git a/include/mvPolynomial/mvPolynomial.hpp b/include/mvPolynomial/mvPolynomial.hpp index df346d9..ba2ad70 100644 --- a/include/mvPolynomial/mvPolynomial.hpp +++ b/include/mvPolynomial/mvPolynomial.hpp @@ -311,12 +311,14 @@ class MVPolynomial final { // friend functions friend bool operator==(const MVPolynomial& l, const MVPolynomial& r) { + using size_type = typename MVPolynomial::size_type; + if (l.size() != r.size()) { return false; } auto l_it = l.cbegin(); auto r_it = r.cbegin(); - for (std::size_t i = 0; i != l.size(); ++i) { + for (size_type i = 0; i != l.size(); ++i) { const auto& [l_idx, l_coeff] = *l_it; const auto& [r_idx, r_coeff] = *r_it; if ((l_idx != r_idx).any()) { From f4c443f140dcbc86ff0dec89b631a1a90ffb6add Mon Sep 17 00:00:00 2001 From: Yuya Asano <64895419+sukeya@users.noreply.github.com> Date: Sun, 23 Nov 2025 14:44:26 +0900 Subject: [PATCH 2/2] Add name to unnamed namespace. --- include/mvPolynomial/mvPolynomial.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/mvPolynomial/mvPolynomial.hpp b/include/mvPolynomial/mvPolynomial.hpp index ba2ad70..af04513 100644 --- a/include/mvPolynomial/mvPolynomial.hpp +++ b/include/mvPolynomial/mvPolynomial.hpp @@ -13,7 +13,7 @@ #include "platanus/btree_map.hpp" namespace mvPolynomial { -namespace { +namespace details { void CheckAxis(int dim, int axis) { if (axis < 0 || axis >= dim) { throw std::runtime_error( @@ -60,7 +60,7 @@ auto OfImpl(Iterator begin, Iterator end, int dim, int axis, const Coord& x) { return sum; } } -} // namespace +} // namespace details template < std::signed_integral IntType, @@ -258,7 +258,7 @@ class MVPolynomial final { return index2value_.upper_bound(i); } - R operator()(const coord_type& x) const { return OfImpl(crbegin(), crend(), dim, 0, x); } + R operator()(const coord_type& x) const { return details::OfImpl(crbegin(), crend(), dim, 0, x); } MVPolynomial operator+() const { return *this; } @@ -404,7 +404,7 @@ auto D(const MVPolynomial& p, int axis) { using Index = typename MP::index_type; using IndexAndCoeff = typename MP::value_type; - CheckAxis(MP::dim, axis); + details::CheckAxis(MP::dim, axis); auto dp = MP{p.get_allocator()}; auto p_it = p.begin(); @@ -433,7 +433,7 @@ template && p, int axis) { using MP = MVPolynomial; - CheckAxis(D, axis); + details::CheckAxis(D, axis); for (auto& index_and_value : p) { auto& value = index_and_value.second;