libsemigroups  v3.3.0
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
froidure-pin-base.hpp
1//
2// libsemigroups - C++ library for semigroups and monoids
3// Copyright (C) 2019-2025 James D. Mitchell
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17//
18
19#ifndef LIBSEMIGROUPS_FROIDURE_PIN_BASE_HPP_
20#define LIBSEMIGROUPS_FROIDURE_PIN_BASE_HPP_
21
22#include <array> // for array
23#include <cstddef> // for size_t
24#include <cstdint> // for uint32_t
25#include <initializer_list> // for initializer_list
26#include <iterator> // for forward_iterator_tag
27#include <utility> // for swap
28#include <vector> // for vector, allocator
29
30#include "constants.hpp" // for UNDEFINED
31#include "ranges.hpp" // for iterator_range
32#include "runner.hpp" // for Runner
33#include "types.hpp" // for word_type, generator_index_type, tril
34#include "word-graph-helpers.hpp" // for word_graph
35#include "word-graph.hpp" // for WordGraph
36
37#include "detail/containers.hpp" // for DynamicArray2
38
39namespace libsemigroups {
40
50
67 class FroidurePinBase : public Runner {
68 template <typename Element, typename Traits>
69 friend class FroidurePin;
70
71 public:
73 // It should be possible to change this type and everything will just work,
74 // provided the size of the semigroup is less than the maximum value of
75 // this type of integer.
76 using size_type = uint32_t;
77
83
89
92
93 private:
94 // See comments in FroidurePin
95 using enumerate_index_type = size_type;
96
98 // FroidurePin - data members - private
100
101#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
102 // This now only contains a single data member, which might make it a bit
103 // redundant.
104 struct Settings {
105 Settings() noexcept : _batch_size(8'192) {}
106 Settings(Settings const&) noexcept = default;
107 Settings(Settings&&) noexcept = default;
108 Settings& operator=(Settings const&) noexcept = default;
109 Settings& operator=(Settings&&) noexcept = default;
110 ~Settings() = default;
111
112 size_t _batch_size;
113 } _settings;
114#endif
115
116 size_t _degree;
118 _duplicate_gens;
119 std::vector<element_index_type> _enumerate_order;
122 bool _found_one;
123 bool _idempotents_found;
124 std::vector<int> _is_idempotent;
125 cayley_graph_type _left;
128 std::vector<element_index_type> _letter_to_pos;
129 size_type _nr;
130 size_t _nr_products;
131 size_t _nr_rules;
132 enumerate_index_type _pos;
133 element_index_type _pos_one;
135 detail::DynamicArray2<bool> _reduced;
136 cayley_graph_type _right;
138 size_t _wordlen;
139
140 public:
142 // FroidurePinBase - constructors - public
144
149
160
165
170
175
180
181 virtual ~FroidurePinBase();
182
184 // FroidurePinBase - settings - public
186
208 _settings._batch_size = batch_size;
209 return *this;
210 }
211
226 [[nodiscard]] size_t batch_size() const noexcept {
227 return _settings._batch_size;
228 }
229
230#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
232 // FroidurePinBase - pure virtual member functions - public
234
235 [[nodiscard]] virtual size_t number_of_generators() const = 0;
236 [[nodiscard]] virtual tril is_finite() const = 0;
237
238#endif // LIBSEMIGROUPS_PARSED_BY_DOXYGEN not defined
239
241 // FroidurePinBase - member functions - public
243
275 template <typename Iterator1, typename Iterator2>
276 [[nodiscard]] element_index_type
277 current_position_no_checks(Iterator1 first, Iterator2 last) const;
278
310 template <typename Iterator1, typename Iterator2>
311 [[nodiscard]] element_index_type current_position(Iterator1 first,
312 Iterator2 last) const {
314 return current_position_no_checks(first, last);
315 }
316
347 template <typename Iterator1, typename Iterator2>
348 [[nodiscard]] element_index_type position_no_checks(Iterator1 first,
349 Iterator2 last) {
350 run();
351 return current_position_no_checks(first, last);
352 }
353
385 template <typename Iterator1, typename Iterator2>
386 [[nodiscard]] element_index_type position(Iterator1 first, Iterator2 last) {
387 run();
388 return current_position(first, last);
389 }
390
413 [[nodiscard]] element_index_type
415 LIBSEMIGROUPS_ASSERT(i < _letter_to_pos.size());
416 return _letter_to_pos[i];
417 }
418
441 [[nodiscard]] element_index_type
446
466 [[nodiscard]] size_t current_max_word_length() const noexcept {
467 return _length[_enumerate_order.back()];
468 }
469
485 [[nodiscard]] size_t degree() const noexcept {
486 return _degree;
487 }
488
505 [[nodiscard]] size_t current_size() const noexcept {
506 return _nr;
507 }
508
523 [[nodiscard]] size_t current_number_of_rules() const noexcept {
524 return _nr_rules;
525 }
526
545 LIBSEMIGROUPS_ASSERT(pos < _prefix.size());
546 return _prefix[pos];
547 }
548
569
587 [[nodiscard]] element_index_type
589 LIBSEMIGROUPS_ASSERT(pos < _suffix.size());
590 return _suffix[pos];
591 }
592
612 return suffix_no_checks(pos);
613 }
614
640 [[nodiscard]] generator_index_type
642 LIBSEMIGROUPS_ASSERT(pos < _first.size());
643 return _first[pos];
644 }
645
669 [[nodiscard]] generator_index_type
674
701 [[nodiscard]] generator_index_type
703 LIBSEMIGROUPS_ASSERT(pos < _final.size());
704 return _final[pos];
705 }
706
730 [[nodiscard]] generator_index_type
735
756 [[nodiscard]] size_t
758 LIBSEMIGROUPS_ASSERT(pos < _length.size());
759 return _length[pos];
760 }
761
781 [[nodiscard]] size_t current_length(element_index_type pos) const {
783 return current_length_no_checks(pos);
784 }
785
806 // This function could be a helper, but current_length cannot be, so keeping
807 // this as a mem fn.
808 [[nodiscard]] size_t length(element_index_type pos);
809
830 // This function could be a helper, but current_length cannot be, so keeping
831 // this as a mem fn.
832 [[nodiscard]] size_t length_no_checks(element_index_type pos);
833
851 [[nodiscard]] size_t size() {
852 run();
853 return current_size();
854 }
855
873 [[nodiscard]] bool contains_one();
874
896 [[nodiscard]] bool currently_contains_one() const noexcept {
897 return _found_one;
898 }
899
918 [[nodiscard]] size_t number_of_rules() {
919 run();
920 return _nr_rules;
921 }
922
938 [[nodiscard]] cayley_graph_type const& right_cayley_graph() {
939 run();
940 return _right;
941 }
942
957 [[nodiscard]] cayley_graph_type const&
958 current_right_cayley_graph() const noexcept {
959 return _right;
960 }
961
976 [[nodiscard]] cayley_graph_type const& left_cayley_graph() {
977 run();
978 return _left;
979 }
980
996 [[nodiscard]] cayley_graph_type const&
997 current_left_cayley_graph() const noexcept {
998 return _left;
999 }
1000
1001 // Here's a little summary of the functions for minimal_factorisation:
1002 // [x] current_minimal_factorisation_no_checks(2 args)
1003 // [x] current_minimal_factorisation(2 args)
1004 // [x] minimal_factorisation(2 args)
1005
1025 template <typename Iterator>
1027 element_index_type pos) const {
1028 LIBSEMIGROUPS_ASSERT(pos < current_size());
1029 while (pos != UNDEFINED) {
1030 *d_first = first_letter_no_checks(pos);
1031 pos = suffix_no_checks(pos);
1032 }
1033 }
1034
1054 template <typename Iterator>
1055 void current_minimal_factorisation(Iterator d_first,
1056 element_index_type pos) const {
1059 }
1060
1082 //
1083 // Note: There's no no_check version of this function because it doesn't
1084 // make sense (see the impl of minimal_factorisation(word_type&,
1085 // element_index_type)
1086 template <typename Iterator>
1087 void minimal_factorisation(Iterator d_first, element_index_type pos) {
1088 if (pos >= current_size() && !finished()) {
1089 enumerate(pos + 1);
1090 }
1093 }
1094
1095 // Here's a little summary of the functions for (non-minimal) factorisation:
1096 // [x] current_factorisation_no_checks(2 args)
1097 // [ ] current_factorisation(2 args) TODO(1)
1098 // [x] factorisation(2 args)
1099
1123 // TODO(1) check that all _no_checks functions have this warning
1124 template <typename Iterator>
1125 void current_factorisation_no_checks(Iterator d_first,
1126 element_index_type pos) const {
1128 }
1129
1151 //
1152 // Note: There's no no_check version of this function because it doesn't
1153 // make sense (see the impl of minimal_factorisation(word_type&,
1154 // element_index_type)
1155 template <typename Iterator>
1156 void factorisation(Iterator d_first, element_index_type pos) {
1157 minimal_factorisation(d_first, pos);
1158 }
1159
1177 void enumerate(size_t limit);
1178
1198 [[nodiscard]] size_t number_of_elements_of_length(size_t min,
1199 size_t max) const;
1200
1219 [[nodiscard]] size_t number_of_elements_of_length(size_t len) const;
1220
1226#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
1227
1228 public:
1230 using difference_type =
1232 using const_pointer = typename std::vector<relation_type>::const_pointer;
1233 using pointer = typename std::vector<relation_type>::pointer;
1234 using const_reference =
1236 using reference = typename std::vector<relation_type>::reference;
1237 using value_type = relation_type;
1238 using iterator_category = std::forward_iterator_tag;
1239
1240 const_rule_iterator() = default;
1241 const_rule_iterator(const_rule_iterator const&) = default;
1245
1247 enumerate_index_type pos,
1249
1250 ~const_rule_iterator() = default;
1251
1252 [[nodiscard]] bool
1253 operator==(const_rule_iterator const& that) const noexcept {
1254 return _gen == that._gen && _pos == that._pos;
1255 }
1256
1257 [[nodiscard]] bool
1258 operator!=(const_rule_iterator const& that) const noexcept {
1259 return !(this->operator==(that));
1260 }
1261
1262 [[nodiscard]] const_reference operator*() const {
1263 populate_relation();
1264 return _relation;
1265 }
1266
1267 [[nodiscard]] const_pointer operator->() const {
1268 populate_relation();
1269 return &_relation;
1270 }
1271
1272 // prefix
1273 const_rule_iterator const& operator++() noexcept;
1274
1275 // postfix
1276 [[nodiscard]] const_rule_iterator operator++(int) noexcept {
1277 const_rule_iterator copy(*this);
1278 ++(*this);
1279 return copy;
1280 }
1281
1282 void swap(const_rule_iterator& that) noexcept {
1283 _current.swap(that._current);
1284 std::swap(_froidure_pin, that._froidure_pin);
1285 std::swap(_gen, that._gen);
1286 std::swap(_pos, that._pos);
1287 }
1288#endif // LIBSEMIGROUPS_PARSED_BY_DOXYGEN not defined
1289
1290 private:
1291 void populate_relation() const;
1292
1294 FroidurePinBase const* _froidure_pin;
1296 enumerate_index_type _pos;
1297 mutable relation_type _relation;
1298 }; // const_rule_iterator
1299
1300 // Assert that the forward iterator requirements are met
1301 static_assert(std::is_default_constructible_v<const_rule_iterator>,
1302 "forward iterator requires default-constructible");
1303 static_assert(std::is_copy_constructible_v<const_rule_iterator>,
1304 "forward iterator requires copy-constructible");
1305 static_assert(std::is_copy_assignable_v<const_rule_iterator>,
1306 "forward iterator requires copy-assignable");
1307 static_assert(std::is_destructible_v<const_rule_iterator>,
1308 "forward iterator requires destructible");
1309
1335 // clang-format off
1375 // clang-format on
1377 return const_rule_iterator(this, UNDEFINED, 0);
1378 }
1379
1407 run();
1408 return const_rule_iterator(this, UNDEFINED, 0);
1409 }
1410
1439 // clang-format off
1478 // clang-format on
1480 return const_rule_iterator(this, current_size(), 0);
1481 }
1482
1511 run();
1512 return const_rule_iterator(this, current_size(), 0);
1513 }
1514
1515 // TODO(later) it'd be more efficient to have this be a forward
1516 // iterator only (i.e. as is done in the GAP version of FroidurePin)
1524#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
1525 // Private data
1526 mutable FroidurePinBase const* _froidure_pin;
1527 enumerate_index_type _pos;
1528 mutable word_type _word;
1529
1530 public:
1532 using difference_type = typename std::vector<word_type>::difference_type;
1533 using const_pointer = typename std::vector<word_type>::const_pointer;
1534 using pointer = typename std::vector<word_type>::pointer;
1535 using const_reference = typename std::vector<word_type>::const_reference;
1536 using reference = typename std::vector<word_type>::reference;
1537 using value_type = word_type;
1538 using iterator_category = std::random_access_iterator_tag;
1539
1540 const_normal_form_iterator() = default;
1544 = default;
1546 = default;
1547
1548 ~const_normal_form_iterator() = default;
1549
1551 enumerate_index_type pos)
1552 : _froidure_pin(ptr), _pos(pos), _word() {}
1553
1554 [[nodiscard]] bool
1555 operator==(const_normal_form_iterator const& that) const noexcept {
1556 return _pos == that._pos;
1557 }
1558
1559 [[nodiscard]] bool
1560 operator!=(const_normal_form_iterator const& that) const noexcept {
1561 return !(*this == that);
1562 }
1563
1564 [[nodiscard]] bool
1565 operator<(const_normal_form_iterator const& that) const noexcept {
1566 return _pos < that._pos;
1567 }
1568
1569 [[nodiscard]] bool
1570 operator>(const_normal_form_iterator const& that) const noexcept {
1571 return _pos > that._pos;
1572 }
1573
1574 [[nodiscard]] bool
1575 operator<=(const_normal_form_iterator const& that) const noexcept {
1576 return _pos < that._pos;
1577 }
1578
1579 [[nodiscard]] bool
1580 operator>=(const_normal_form_iterator const& that) const noexcept {
1581 return _pos > that._pos;
1582 }
1583
1584 [[nodiscard]] const_reference operator*() const noexcept {
1585 populate_word();
1586 return _word;
1587 }
1588
1589 [[nodiscard]] const_pointer operator->() const noexcept {
1590 populate_word();
1591 return &_word;
1592 }
1593
1594 [[nodiscard]] const_reference operator[](size_type index) const {
1595 const_cast<const_normal_form_iterator*>(this)->_pos += index;
1596 populate_word();
1597 const_cast<const_normal_form_iterator*>(this)->_pos -= index;
1598 return _word;
1599 }
1600
1601 // prefix
1602 const_normal_form_iterator const& operator++() noexcept {
1603 _pos++;
1604 return *this;
1605 }
1606
1607 [[nodiscard]] const_normal_form_iterator operator++(int) noexcept {
1608 const_normal_form_iterator copy(*this);
1609 ++(*this);
1610 return copy;
1611 }
1612
1613 const_normal_form_iterator const& operator--() noexcept {
1614 _pos--;
1615 return *this;
1616 }
1617
1618 [[nodiscard]] const_normal_form_iterator operator--(int) noexcept {
1619 const_normal_form_iterator copy(*this);
1620 --(*this);
1621 return copy;
1622 }
1623
1624 void operator+=(size_type val) noexcept {
1625 _pos += val;
1626 }
1627
1628 void operator-=(size_type val) noexcept {
1629 _pos -= val;
1630 }
1631
1632 [[nodiscard]] const_normal_form_iterator
1633 operator+(size_type val) const noexcept {
1634 const_normal_form_iterator copy(*this);
1635 copy += val;
1636 return copy;
1637 }
1638
1639 [[nodiscard]] const_normal_form_iterator
1640 operator-(size_type val) const noexcept {
1641 const_normal_form_iterator copy(*this);
1642 copy -= val;
1643 return copy;
1644 }
1645
1646 [[nodiscard]] difference_type
1647 operator-(const_normal_form_iterator const& that) const noexcept {
1648 return _pos - that._pos;
1649 }
1650
1651 void swap(const_normal_form_iterator& that) noexcept {
1652 std::swap(_froidure_pin, that._froidure_pin);
1653 std::swap(_pos, that._pos);
1654 std::swap(_word, that._word);
1655 }
1656
1657 private:
1658 void populate_word() const {
1659 _word.clear();
1661 std::back_inserter(_word), _pos);
1662 }
1663#endif // LIBSEMIGROUPS_PARSED_BY_DOXYGEN not defined
1664 };
1665
1685 [[nodiscard]] const_normal_form_iterator
1687 return const_normal_form_iterator(this, 0);
1688 }
1689
1713
1735 run();
1736 return const_normal_form_iterator(this, 0);
1737 }
1738
1761 run();
1762 return const_normal_form_iterator(this, size());
1763 }
1764
1766 // FroidurePin - validation member functions - public
1768
1778
1789
1805 template <typename Iterator1, typename Iterator2>
1807 Iterator2 last) const {
1808 for (auto it = first; it != last; ++it) {
1810 }
1811 }
1812
1813 private:
1815 // FroidurePinBase - member functions - private
1817 void partial_copy(FroidurePinBase const& S);
1818 }; // class FroidurePinBase
1819
1821 // Implementations of mem fn templates for FroidurePinBase
1823
1824 template <typename Iterator1, typename Iterator2>
1827 Iterator2 last) const {
1828 if (first == last) {
1829 if (_found_one) {
1830 return _pos_one;
1831 } else {
1832 return UNDEFINED;
1833 }
1834 }
1836 return v4::word_graph::follow_path_no_checks(
1837 current_right_cayley_graph(), s, first + 1, last);
1838 }
1839
1844 namespace froidure_pin {
1871 FroidurePinBase const& fpb,
1874
1898 [[nodiscard]] typename FroidurePinBase::element_index_type
1902
1904 // Position helper functions
1906
1932 template <typename Word>
1934 current_position_no_checks(FroidurePinBase const& fpb, Word const& w) {
1936 }
1937
1939 [[nodiscard]] static inline FroidurePinBase::element_index_type
1944
1967 template <typename Word>
1969 current_position(FroidurePinBase const& fpb, Word const& w) {
1970 return fpb.current_position(std::begin(w), std::end(w));
1971 }
1972
1974 [[nodiscard]] static inline FroidurePinBase::element_index_type
1979
2003 template <typename Word>
2006 return fpb.position_no_checks(std::begin(w), std::end(w));
2007 }
2008
2010 [[nodiscard]] static inline FroidurePinBase::element_index_type
2015
2038 template <typename Word>
2040 position(FroidurePinBase& fpb, Word const& w) {
2041 return fpb.position(std::begin(w), std::end(w));
2042 }
2043
2045 [[nodiscard]] static inline FroidurePinBase::element_index_type
2049
2051 // Minimal factorisation helper functions
2053
2074 template <typename Word>
2076 FroidurePinBase const& fpb,
2077 Word& word,
2079 // TODO(1) remove the clear (makes the functions more flexible), but will
2080 // require care
2081 word.clear();
2083 pos);
2084 }
2085
2110 template <typename Word = word_type>
2112 FroidurePinBase const& fpb,
2114 Word word;
2116 return word;
2117 }
2118
2138 template <typename Word>
2139 void
2141 Word& word,
2143 // TODO(1) remove the clear (makes the functions more flexible), but will
2144 // require care
2145 word.clear();
2147 }
2148
2172 template <typename Word = word_type>
2173 [[nodiscard]] Word
2176 Word word;
2177 current_minimal_factorisation(fpb, word, pos);
2178 return word;
2179 }
2180
2201 // Note: there's no no_check version of this function because it doesn't
2202 // make sense (see the impl of minimal_factorisation(word_type&,
2203 // FroidurePinBase::element_index_type);
2204 template <typename Word>
2206 Word& word,
2208 // TODO(1) remove the clear (makes the functions more flexible), but will
2209 // require care
2210 word.clear();
2212 }
2213
2238 // Notes:
2239 // * There's no no_check version of this function because it doesn't make
2240 // sense (see the impl of minimal_factorisation(word_type&,
2241 // FroidurePinBase::element_index_type);
2242 template <typename Word = word_type>
2243 [[nodiscard]] Word
2246 Word word;
2247 minimal_factorisation(fpb, word, pos);
2248 return word;
2249 }
2250
2252 // (Non-minimal) factorisation helper functions
2254
2275 template <typename Word>
2276 void
2282
2304 template <typename Word>
2306 Word& word,
2308 return minimal_factorisation<Word>(fpb, word, pos);
2309 }
2310
2334 template <typename Word = word_type>
2335 [[nodiscard]] Word factorisation(FroidurePinBase& fpb,
2337 return minimal_factorisation<Word>(fpb, pos);
2338 }
2339
2354 // TODO(1) complexity?
2355 [[nodiscard]] rx::iterator_range<
2358
2377 [[nodiscard]] rx::iterator_range<
2380
2397 // TODO(1) complexity?
2398 [[nodiscard]] rx::iterator_range<FroidurePinBase::const_rule_iterator>
2400
2418 [[nodiscard]] rx::iterator_range<FroidurePinBase::const_rule_iterator>
2420
2421 } // namespace froidure_pin
2422} // namespace libsemigroups
2423#endif // LIBSEMIGROUPS_FROIDURE_PIN_BASE_HPP_
T back_inserter(T... args)
T begin(T... args)
Return type of cbegin_normal_forms and cend_normal_forms.
Definition froidure-pin-base.hpp:1523
Return type of cbegin_rules and cend_rules.
Definition froidure-pin-base.hpp:1225
Base class for FroidurePin containing non-element specific data and member functions.
Definition froidure-pin-base.hpp:67
size_t number_of_rules()
Returns the total number of relations in the presentation.
Definition froidure-pin-base.hpp:918
cayley_graph_type const & left_cayley_graph()
Returns a const reference to the left Cayley graph.
Definition froidure-pin-base.hpp:976
element_index_type position_no_checks(Iterator1 first, Iterator2 last)
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:348
const_rule_iterator cend_rules()
Returns a forward iterator pointing one past the last rule (if any).
Definition froidure-pin-base.hpp:1510
size_t size()
Returns the size of a FroidurePin instance.
Definition froidure-pin-base.hpp:851
const_normal_form_iterator cbegin_current_normal_forms() const
Returns an iterator pointing at the first normal form (if any).
Definition froidure-pin-base.hpp:1686
void enumerate(size_t limit)
Enumerate until at least a specified number of elements are found.
size_t batch_size() const noexcept
Returns the current value of the batch size.
Definition froidure-pin-base.hpp:226
size_t current_number_of_rules() const noexcept
Returns the number of rules that have been found so far.
Definition froidure-pin-base.hpp:523
const_rule_iterator cbegin_rules()
Returns a forward iterator pointing to the first rule (if any).
Definition froidure-pin-base.hpp:1406
element_index_type current_position(Iterator1 first, Iterator2 last) const
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:311
cayley_graph_type const & current_left_cayley_graph() const noexcept
Returns a const reference to the left Cayley graph.
Definition froidure-pin-base.hpp:997
const_normal_form_iterator cend_current_normal_forms() const
Returns an iterator pointing one beyond the last normal form (if any).
Definition froidure-pin-base.hpp:1710
element_index_type prefix(element_index_type pos) const
Returns the position of the longest proper prefix.
Definition froidure-pin-base.hpp:565
FroidurePinBase(FroidurePinBase &&other)=default
Default move constructor.
FroidurePinBase & operator=(FroidurePinBase const &)
Copy assignment operator.
size_t current_max_word_length() const noexcept
Returns the maximum length of a word in the generators so far computed.
Definition froidure-pin-base.hpp:466
size_t current_length(element_index_type pos) const
Returns the length of the short-lex least word equal to the element with given index.
Definition froidure-pin-base.hpp:781
FroidurePinBase & batch_size(size_t batch_size) noexcept
Set a new value for the batch size.
Definition froidure-pin-base.hpp:207
size_t number_of_elements_of_length(size_t min, size_t max) const
Returns the number of elements so far enumerated with length in a given range.
element_index_type position_of_generator(generator_index_type i) const
Returns the position of the generator with specified index.
Definition froidure-pin-base.hpp:442
size_t degree() const noexcept
Returns the degree of any and all elements.
Definition froidure-pin-base.hpp:485
size_t number_of_elements_of_length(size_t len) const
Returns the number of elements so far enumerated with given length.
FroidurePinBase()
Default constructor.
generator_index_type first_letter_no_checks(element_index_type pos) const
Returns the first letter of the element with specified index.
Definition froidure-pin-base.hpp:641
size_t length(element_index_type pos)
Returns the length of the short-lex least word equal to the element with given index.
element_index_type prefix_no_checks(element_index_type pos) const
Returns the position of the longest proper prefix.
Definition froidure-pin-base.hpp:544
const_rule_iterator cbegin_current_rules() const
Returns a forward iterator pointing to the first rule (if any).
Definition froidure-pin-base.hpp:1376
void current_factorisation_no_checks(Iterator d_first, element_index_type pos) const
Output to an iterator a word representing an element given by index.
Definition froidure-pin-base.hpp:1125
element_index_type suffix_no_checks(element_index_type pos) const
Returns the position of the longest proper suffix.
Definition froidure-pin-base.hpp:588
element_index_type position_of_generator_no_checks(generator_index_type i) const
Returns the position of the generator with specified index.
Definition froidure-pin-base.hpp:414
const_normal_form_iterator cend_normal_forms()
Returns an iterator pointing one beyond the last normal form (if any).
Definition froidure-pin-base.hpp:1760
element_index_type current_position_no_checks(Iterator1 first, Iterator2 last) const
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:1826
const_normal_form_iterator cbegin_normal_forms()
Returns an iterator pointing at the first normal form (if any).
Definition froidure-pin-base.hpp:1734
void minimal_factorisation(Iterator d_first, element_index_type pos)
Output to an iterator the short-lex least word representing an element given by index.
Definition froidure-pin-base.hpp:1087
size_t current_size() const noexcept
Returns the number of elements so far enumerated.
Definition froidure-pin-base.hpp:505
FroidurePinBase(FroidurePinBase const &S)
Copy constructor.
void throw_if_element_index_out_of_range(element_index_type i) const
Throw an exception if an index is out of range.
size_type element_index_type
Alias for the index of an element.
Definition froidure-pin-base.hpp:88
void factorisation(Iterator d_first, element_index_type pos)
Output to an iterator a word representing an element given by index.
Definition froidure-pin-base.hpp:1156
bool contains_one()
Check if the categorical multiplicative identity is an element.
generator_index_type final_letter(element_index_type pos) const
Returns the last letter of the element with specified index.
Definition froidure-pin-base.hpp:731
void throw_if_any_generator_index_out_of_range(Iterator1 first, Iterator2 last) const
Throw an exception if any generator index is out of range.
Definition froidure-pin-base.hpp:1806
cayley_graph_type const & right_cayley_graph()
Returns a const reference to the right Cayley graph.
Definition froidure-pin-base.hpp:938
cayley_graph_type const & current_right_cayley_graph() const noexcept
Returns a const reference to the right Cayley graph.
Definition froidure-pin-base.hpp:958
FroidurePinBase & init()
Reinitialize a FroidurePinBase object.
void current_minimal_factorisation_no_checks(Iterator d_first, element_index_type pos) const
Output to an iterator the short-lex least word representing an element given by index.
Definition froidure-pin-base.hpp:1026
size_t current_length_no_checks(element_index_type pos) const
Returns the length of the short-lex least word equal to the element with given index.
Definition froidure-pin-base.hpp:757
size_t length_no_checks(element_index_type pos)
Returns the length of the short-lex least word equal to the element with given index.
void throw_if_generator_index_out_of_range(generator_index_type i) const
Throw an exception if a generator index is out of range.
generator_index_type final_letter_no_checks(element_index_type pos) const
Returns the first letter of the element with specified index.
Definition froidure-pin-base.hpp:702
generator_index_type first_letter(element_index_type pos) const
Returns the first letter of the element with specified index.
Definition froidure-pin-base.hpp:670
FroidurePinBase & operator=(FroidurePinBase &&)=default
Move assignment operator.
size_type generator_index_type
Alias for the index of a generator.
Definition froidure-pin-base.hpp:82
WordGraph< element_index_type > cayley_graph_type
Alias for the types of the left and right Cayley graphs.
Definition froidure-pin-base.hpp:91
void current_minimal_factorisation(Iterator d_first, element_index_type pos) const
Output to an iterator the short-lex least word representing an element given by index.
Definition froidure-pin-base.hpp:1055
uint32_t size_type
Alias for the type of the size of the enumerated semigroup.
Definition froidure-pin-base.hpp:76
const_rule_iterator cend_current_rules() const
Returns a forward iterator pointing one past the last rule (if any).
Definition froidure-pin-base.hpp:1479
bool currently_contains_one() const noexcept
Check if the categorical multiplicative identity is known to be an element.
Definition froidure-pin-base.hpp:896
element_index_type position(Iterator1 first, Iterator2 last)
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:386
element_index_type suffix(element_index_type pos) const
Returns the position of the longest proper suffix.
Definition froidure-pin-base.hpp:610
void run()
Run until finished.
Runner()
Default constructor.
bool finished() const
Check if run has been run to completion or not.
Class for representing word graphs.
Definition word-graph.hpp:83
T clear(T... args)
T end(T... args)
bool operator<=(Bipartition const &x, Bipartition const &y)
Compare bipartitions.
Definition bipart.hpp:1737
bool operator>=(Bipartition const &x, Bipartition const &y)
Compare bipartitions.
Definition bipart.hpp:1759
bool operator>(Bipartition const &x, Bipartition const &y)
Compare bipartitions.
Definition bipart.hpp:1748
Bipartition operator*(Bipartition const &x, Bipartition const &y)
Multiply two bipartitions.
bool operator!=(Bipartition const &x, Bipartition const &y)
Check bipartitions for inequality.
Definition bipart.hpp:1727
Undefined const UNDEFINED
Value for something undefined.
auto operator+(typename Mat::scalar_type a, Mat const &x) -> std::enable_if_t< IsMatrix< Mat >, Mat >
Add a scalar to a matrix.
Definition matrix.hpp:7946
bool operator==(Presentation< Word > const &lhop, Presentation< Word > const &rhop)
Compare for equality.
Definition presentation.hpp:2893
std::vector< letter_type > word_type
Type for a word over the generators of a semigroup.
Definition types.hpp:99
std::pair< word_type, word_type > relation_type
Type for a pair of word_type (a relation) of a semigroup.
Definition types.hpp:102
tril
Enum to indicate true, false or not currently knowable.
Definition types.hpp:54
This namespace contains helper functions for the FroidurePin class template.
Definition froidure-pin-base.hpp:1844
FroidurePinBase::element_index_type position(FroidurePinBase &fpb, Word const &w)
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:2040
FroidurePinBase::element_index_type product_by_reduction(FroidurePinBase const &fpb, typename FroidurePinBase::element_index_type i, typename FroidurePinBase::element_index_type j)
Compute a product using the Cayley graph.
FroidurePinBase::element_index_type current_position(FroidurePinBase const &fpb, Word const &w)
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:1969
void current_minimal_factorisation(FroidurePinBase const &fpb, Word &word, FroidurePinBase::element_index_type pos)
Modify a word to contain the short-lex least word representing an element given by index.
Definition froidure-pin-base.hpp:2140
rx::iterator_range< FroidurePinBase::const_normal_form_iterator > normal_forms(FroidurePinBase &fpb)
Returns a range object containing normal forms for all the elements.
rx::iterator_range< FroidurePinBase::const_rule_iterator > current_rules(FroidurePinBase const &fpb)
Returns a range object containing the so-far enumerated rules.
FroidurePinBase::element_index_type product_by_reduction_no_checks(FroidurePinBase const &fpb, typename FroidurePinBase::element_index_type i, typename FroidurePinBase::element_index_type j)
Compute a product using the Cayley graph.
rx::iterator_range< FroidurePinBase::const_normal_form_iterator > current_normal_forms(FroidurePinBase const &fpb)
Returns a range object containing normal forms for the so-far enumerated elements.
void current_minimal_factorisation_no_checks(FroidurePinBase const &fpb, Word &word, FroidurePinBase::element_index_type pos)
Modify a word to contain the short-lex least word representing an element given by index.
Definition froidure-pin-base.hpp:2075
void current_factorisation_no_checks(FroidurePinBase const &fpb, Word &word, FroidurePinBase::element_index_type pos)
Modify a word to contain a word representing an element given by index.
Definition froidure-pin-base.hpp:2277
FroidurePinBase::element_index_type current_position_no_checks(FroidurePinBase const &fpb, Word const &w)
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:1934
void factorisation(FroidurePinBase &fpb, Word &word, FroidurePinBase::element_index_type pos)
Modify a word to contain a word representing an element given by index.
Definition froidure-pin-base.hpp:2305
void minimal_factorisation(FroidurePinBase &fpb, Word &word, FroidurePinBase::element_index_type pos)
Modify a word to contain the short-lex least word representing an element given by index.
Definition froidure-pin-base.hpp:2205
rx::iterator_range< FroidurePinBase::const_rule_iterator > rules(FroidurePinBase &fpb)
Returns a range object containing all of the rules.
FroidurePinBase::element_index_type position_no_checks(FroidurePinBase &fpb, Word const &w)
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:2005
Namespace for everything in the libsemigroups library.
Definition action.hpp:44
T swap(T... args)