From 698ca0f834e4951bd6fdd4a2eaffad52b6d79063 Mon Sep 17 00:00:00 2001 From: Joseph Edwards Date: Wed, 13 Nov 2024 12:10:05 +0000 Subject: [PATCH] Add current size --- include/libsemigroups/schreier-sims.hpp | 2 ++ include/libsemigroups/schreier-sims.tpp | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/libsemigroups/schreier-sims.hpp b/include/libsemigroups/schreier-sims.hpp index 540c5496e..f1bbe1f1d 100644 --- a/include/libsemigroups/schreier-sims.hpp +++ b/include/libsemigroups/schreier-sims.hpp @@ -667,6 +667,8 @@ namespace libsemigroups { // not noexcept because run isn't [[nodiscard]] uint64_t size(); + [[nodiscard]] uint64_t current_size() const; + //! \brief Sift an element through the stabiliser chain in-place. //! //! Sift an element through the stabiliser chain in-place. diff --git a/include/libsemigroups/schreier-sims.tpp b/include/libsemigroups/schreier-sims.tpp index 4237a59a2..03dcb1d92 100644 --- a/include/libsemigroups/schreier-sims.tpp +++ b/include/libsemigroups/schreier-sims.tpp @@ -182,6 +182,19 @@ namespace libsemigroups { return out; } + template + uint64_t SchreierSims::current_size() const { + // TODO(later) check if product overflows? + if (empty()) { + return 1; + } + uint64_t out = 1; + for (index_type i = 0; i < _base_size; i++) { + out *= _orbits.size(i); + } + return out; + } + template bool SchreierSims::currently_contains( const_element_reference x) const { @@ -652,7 +665,7 @@ namespace libsemigroups { } if (S.finished()) { - size_t size = const_cast&>(S).size(); + size_t size = S.current_size(); out = fmt::format("", nr_generators,