22#ifndef LIBSEMIGROUPS_ACTION_HPP_
23#define LIBSEMIGROUPS_ACTION_HPP_
28#include <unordered_map>
32#include "adapters.hpp"
33#include "constants.hpp"
35#include "exception.hpp"
39#include "word-graph.hpp"
41#include "detail/bruidhinn-traits.hpp"
42#include "detail/report.hpp"
169 template <
typename Element,
179 using internal_point_type =
180 typename detail::BruidhinnTraits<Point>::internal_value_type;
181 using internal_const_point_type =
182 typename detail::BruidhinnTraits<Point>::internal_const_value_type;
183 using internal_const_reference =
184 typename detail::BruidhinnTraits<Point>::internal_const_reference;
186 struct InternalEqualTo :
private detail::BruidhinnTraits<Point> {
187 using EqualTo =
typename Traits::EqualTo;
188 bool operator()(internal_const_point_type x,
189 internal_const_point_type y)
const {
190 return EqualTo()(this->to_external_const(x),
191 this->to_external_const(y));
195 struct InternalHash :
private detail::BruidhinnTraits<Point> {
196 using Hash =
typename Traits::Hash;
197 size_t operator()(internal_const_point_type x)
const {
198 return Hash()(this->to_external_const(x));
203 class MultiplierCache;
209 internal_const_point_type>::type>::value,
210 "internal_const_element_type must be const or pointer to const");
252 template <
typename Elment,
266 os << detail::to_string(action);
287 typename detail::BruidhinnTraits<Point>::const_reference;
294 typename detail::BruidhinnTraits<Point>::const_pointer;
301 using ActionOp = Func;
302 using One =
typename Traits::One;
303 using Product =
typename Traits::Product;
304 using Swap =
typename Traits::Swap;
307 "the 3rd template parameter Func is not trivially "
308 "default constructible");
339 MultiplierCache _multipliers_from_scc_root;
340 MultiplierCache _multipliers_to_scc_root;
343 internal_point_type _tmp_point;
344 bool _tmp_point_init;
445 _gens.push_back(gen);
506 [[nodiscard]]
bool empty() const noexcept {
525 LIBSEMIGROUPS_ASSERT(pos < _orb.size());
526 return this->to_external_const(_orb[pos]);
543 return this->to_external_const(_orb.at(pos));
558 [[nodiscard]]
size_t size() {
616 [[nodiscard]]
auto range() const noexcept {
617 return rx::iterator_range(_orb.cbegin(), _orb.cend())
618 | rx::transform([
this](
auto const& pt) {
619 return this->to_external_const(pt);
666 return _options._cache_scc_multipliers;
686 _options._cache_scc_multipliers = val;
709 return multiplier_private<true>(
710 _multipliers_from_scc_root, _scc.spanning_forest(), pos);
732 return multiplier_private<false>(
733 _multipliers_to_scc_root, _scc.reverse_spanning_forest(), pos);
777 return this->to_external_const(_orb[_scc.root_of(pos)]);
821 [[nodiscard]]
bool finished_impl()
const override {
825 void run_impl()
override;
831 template <
bool Forward>
836 void throw_if_index_out_of_range(
index_type i)
const;
837 void throw_if_no_generators()
const;
848 template <
typename Element,
typename Po
int>
866 template <
typename Element,
876 template <
typename Element,
Class for generating the action of a semigroup.
Definition action.hpp:174
index_type position(const_reference_point_type pt) const
Returns the position of a point in the so far discovered points.
size_t size()
Returns the size of the fully enumerated action.
Definition action.hpp:557
auto range() const noexcept
Returns a range object containing the current points in the action.
Definition action.hpp:615
Action & init()
Initialize an existing Action object.
Action & operator=(Action const &)
Default copy assignment operator.
typename detail::BruidhinnTraits< Point >::const_reference const_reference_point_type
The type of a const reference to a point_type.
Definition action.hpp:285
const_iterator begin() const noexcept
Returns a const_iterator (random access iterator) pointing at the first point.
Definition action.hpp:597
friend std::ostringstream & operator<<(std::ostringstream &os, Action< Elment, Pint, Fnc, Trits, LftOrRight > const &action)
Insertion operator.
bool empty() const noexcept
Checks if the Action contains any points.
Definition action.hpp:505
Func action_type
Type of the action of element_type on point_type.
Definition action.hpp:246
Element element_type
The template parameter Element.
Definition action.hpp:221
typename detail::BruidhinnTraits< Point >::const_pointer const_pointer_point_type
The type of a const pointer to a point_type.
Definition action.hpp:292
element_type multiplier_from_scc_root(index_type pos)
Returns a multiplier from a scc root to a given index.
Definition action.hpp:707
const_iterator end() const noexcept
Returns a const_iterator (random access iterator) pointing one past the last point.
Definition action.hpp:642
Action & add_generator(element_type const &gen)
Add a generator to the action.
Definition action.hpp:441
element_type multiplier_to_scc_root(index_type pos)
Returns a multiplier from a given index to a scc root.
Definition action.hpp:730
size_t number_of_generators() const noexcept
Returns the number of generators.
Definition action.hpp:461
Action & reserve(size_t val)
Increase the capacity to a value that is greater or equal to val.
size_t index_type
The type of the index of a point.
Definition action.hpp:234
Point point_type
The template parameter Point.
Definition action.hpp:227
detail::BruidhinnConstIterator< point_type, std::vector< internal_point_type > > const_iterator
The type of a const iterator pointing to a point_type.
Definition action.hpp:278
const_iterator cend() const noexcept
Returns a const_iterator (random access iterator) pointing one past the last point.
Definition action.hpp:637
Action()
Default constructor.
Gabow< uint32_t > const & scc()
Returns a reference to a Gabow object for strongly connected components.
Definition action.hpp:810
size_t current_size() const noexcept
Returns the number of points found so far.
Definition action.hpp:574
std::vector< Element > const & generators() const noexcept
Returns a const reference to the vector of generators.
Definition action.hpp:474
const_reference_point_type root_of_scc(const_reference_point_type x)
Returns a const reference to the root point of a strongly connected component.
Definition action.hpp:753
const_iterator cbegin() const noexcept
Returns a const_iterator (random access iterator) pointing at the first point.
Definition action.hpp:592
Action & add_seed(const_reference_point_type seed)
Add a seed to the action.
WordGraph< uint32_t > const & word_graph()
Definition action.hpp:790
friend std::ostream & operator<<(std::ostream &os, Action const &action)
Definition action.hpp:265
bool cache_scc_multipliers() const noexcept
Returns whether or not we are caching scc multipliers.
Definition action.hpp:664
const_reference_point_type at(index_type pos) const
Returns a const reference to the point in a given position.
Definition action.hpp:541
const_reference_point_type operator[](index_type pos) const noexcept
Returns a const reference to the point in a given position.
Definition action.hpp:523
Class implementing Gabow's algorithm for computing strongly connected components of a WordGraph.
Definition gabow.hpp:61
void run()
Run until finished.
Runner()
Default constructor.
Class for representing word graphs.
Definition word-graph.hpp:82
size_type out_degree() const noexcept
Returns the out-degree.
Definition word-graph.hpp:823
Action< Element, Point, Func, Traits, side::right > RightAction
Definition action.hpp:870
Action< Element, Point, Func, Traits, side::left > LeftAction
Definition action.hpp:880
side
Enum class indicating the handedness or side of an action.
Definition action.hpp:89
@ right
Definition action.hpp:95
@ left
Definition action.hpp:92
Namespace for everything in the libsemigroups library.
Definition action.hpp:44
Definition action.hpp:849
::libsemigroups::Hash< Point > Hash
Adapter for hashing.
Definition action.hpp:851
::libsemigroups::Swap< Element > Swap
Adapter for swapping.
Definition action.hpp:855
::libsemigroups::EqualTo< Point > EqualTo
Adapter for testing equality.
Definition action.hpp:853
::libsemigroups::Product< Element > Product
Adapter for the product of two elements.
Definition action.hpp:859
::libsemigroups::One< Element > One
Adapter for the identity element of the given type.
Definition action.hpp:857
Adapter for testing equality.
Definition adapters.hpp:413
Adapter for hashing.
Definition adapters.hpp:446
Adapter for the identity element of the given type.
Definition adapters.hpp:246
Adapter for the product of two elements.
Definition adapters.hpp:284
Adapter for swapping.
Definition adapters.hpp:666