Skip to content

Commit 6091fc8

Browse files
Konieczny: modernise tests
1 parent 917ea85 commit 6091fc8

File tree

9 files changed

+328
-280
lines changed

9 files changed

+328
-280
lines changed

docs/pictures/to-table.tex

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
\begin{document}
1111

1212
\begin{tabular}{l|c|c|c|c|c|c|c|c|c|c|c|c}
13-
&
13+
&
1414
\rotatebox{90}{\texttt{Congruence}} &
1515
\rotatebox{90}{\texttt{FroidurePin}} &
1616
\rotatebox{90}{\texttt{InversePresentation}} &
@@ -23,16 +23,26 @@
2323
\rotatebox{90}{\texttt{ToddCoxeter}}
2424
\\
2525
\midrule
26-
\texttt{to<Congruence>} & \xmark & \cmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
27-
\texttt{to<FroidurePin>} & \cmark & \xmark & \xmark & \cmark & \cmark & \xmark & \xmark & \xmark & \xmark & \cmark \\\hline
28-
\texttt{to<InversePresentation>} & \xmark & \xmark & \cmark & \xmark & \xmark & \xmark & \cmark & \xmark & \xmark & \xmark \\\hline
29-
\texttt{to<Kambites>} & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
30-
\texttt{to<KnuthBendix>} & \xmark & \cmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \cmark \\\hline
31-
\texttt{to<Konieczny>} & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
32-
\texttt{to<Presentation>} & \xmark & \cmark & \xmark & \xmark & \cmark & \xmark & \cmark & \xmark & \xmark & \xmark \\\hline
33-
\texttt{to<SchreierSims>} & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
34-
\texttt{to<Stephen>} & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
35-
\texttt{to<ToddCoxeter>} & \xmark & \cmark & \xmark & \xmark & \cmark & \xmark & \xmark & \xmark & \xmark & \xmark \\
26+
\texttt{to<Congruence>} & \xmark & \cmark &
27+
\xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
28+
\texttt{to<FroidurePin>} & \cmark & \xmark &
29+
\xmark & \cmark & \cmark & \cmark & \xmark & \xmark & \xmark & \cmark \\\hline
30+
\texttt{to<InversePresentation>} & \xmark & \xmark &
31+
\cmark & \xmark & \xmark & \xmark & \cmark & \xmark & \xmark & \xmark \\\hline
32+
\texttt{to<Kambites>} & \xmark & \xmark &
33+
\xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
34+
\texttt{to<KnuthBendix>} & \xmark & \cmark &
35+
\xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \cmark \\\hline
36+
\texttt{to<Konieczny>} & \xmark & \xmark &
37+
\xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
38+
\texttt{to<Presentation>} & \xmark & \cmark &
39+
\xmark & \xmark & \cmark & \xmark & \cmark & \xmark & \xmark & \xmark \\\hline
40+
\texttt{to<SchreierSims>} & \xmark & \xmark &
41+
\xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
42+
\texttt{to<Stephen>} & \xmark & \xmark &
43+
\xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark & \xmark \\\hline
44+
\texttt{to<ToddCoxeter>} & \xmark & \cmark &
45+
\xmark & \xmark & \cmark & \xmark & \xmark & \xmark & \xmark & \xmark \\
3646
\end{tabular}
3747
% \cmark = implemented, \xmark = not yet implemented, -
3848
% = not applicable

include/libsemigroups/konieczny.hpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,13 +1819,19 @@ namespace libsemigroups {
18191819
mutable lambda_value_type _tmp_lambda_value2;
18201820
mutable rho_value_type _tmp_rho_value1;
18211821
mutable rho_value_type _tmp_rho_value2;
1822-
};
1822+
}; // class Konieczny
18231823

18241824
template <typename Element, typename Traits>
18251825
bool Konieczny<Element, Traits>::finished_impl() const {
18261826
return _ranks.empty() && _run_initialised;
18271827
}
18281828

1829+
template <typename Element>
1830+
Konieczny(std::vector<Element> const&) -> Konieczny<Element>;
1831+
1832+
template <typename Element>
1833+
Konieczny(std::initializer_list<Element> const&) -> Konieczny<Element>;
1834+
18291835
//! \ingroup konieczny_group
18301836
//!
18311837
//! \brief Return a human readable representation of a Konieczny object.
@@ -1894,8 +1900,7 @@ namespace libsemigroups {
18941900
Konieczny<Element, Traits>& K,
18951901
std::initializer_list<
18961902
typename Konieczny<Element, Traits>::const_element_type> coll) {
1897-
K.template add_generators<std::initializer_list<
1898-
typename Konieczny<Element, Traits>::const_element_type>>(coll);
1903+
K.add_generators(coll.begin(), coll.end());
18991904
}
19001905
} // namespace konieczny
19011906

include/libsemigroups/to-froidure-pin.hpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "froidure-pin.hpp" // for FroidurePin
2828
#include "kambites-class.hpp" // for Kambites
2929
#include "knuth-bendix-class.hpp" // for KnuthBendix
30+
#include "konieczny.hpp" // for Konieczny
3031
#include "todd-coxeter-class.hpp" // for ToddCoxeter
3132

3233
#include "detail/kbe.hpp" // for KBE
@@ -181,6 +182,36 @@ namespace libsemigroups {
181182
FroidurePin<
182183
detail::KBE<detail::KnuthBendixImpl<Rewriter, ReductionOrder>>>>;
183184

185+
//! \ingroup to_froidure_pin_group
186+
//!
187+
//! \brief Convert a \ref Konieczny object to a FroidurePin object.
188+
//!
189+
//! Defined in \c to-froidure-pin.hpp
190+
//!
191+
//! Despite the hideous signature, this function should be invoked as follows:
192+
//!
193+
//! \code
194+
//! to<FroidurePin>(k);
195+
//! \endcode
196+
//!
197+
//! where \p k is a \ref Konieczny instance. The returned FroidurePin
198+
//! object is isomorphic to the semigroup or monoid represented by \p
199+
//! k.
200+
//!
201+
//! \tparam Thing used for SFINAE should be FroidurePin.
202+
//! \tparam Element the element type of the Konieczny object.
203+
//! \tparam Traits the traits type of the Konieczny object.
204+
//!
205+
//! \param k the \ref Konieczny instance to convert.
206+
//!
207+
//! \returns A FroidurePin instance.
208+
template <template <typename...> typename Thing,
209+
typename Element,
210+
typename Traits>
211+
auto to(Konieczny<Element, Traits> const& k)
212+
-> std::enable_if_t<std::is_same_v<Thing<int>, FroidurePin<int>>,
213+
FroidurePin<Element>>;
214+
184215
////////////////////////////////////////////////////////////////////////
185216
// ToddCoxeter
186217
////////////////////////////////////////////////////////////////////////

include/libsemigroups/to-froidure-pin.tpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace libsemigroups {
3030
-> FroidurePin<
3131
detail::KBE<detail::KnuthBendixImpl<Rewriter, ReductionOrder>>>;
3232

33-
FroidurePin(detail::ToddCoxeterImpl const&)->FroidurePin<detail::TCE>;
33+
FroidurePin(detail::ToddCoxeterImpl const&) -> FroidurePin<detail::TCE>;
3434

3535
////////////////////////////////////////////////////////////////////////
3636
// Congruence
@@ -117,6 +117,19 @@ namespace libsemigroups {
117117
return result;
118118
}
119119

120+
////////////////////////////////////////////////////////////////////////
121+
// Konieczny
122+
////////////////////////////////////////////////////////////////////////
123+
124+
template <template <typename...> typename Thing,
125+
typename Element,
126+
typename Traits>
127+
auto to(Konieczny<Element, Traits> const& k)
128+
-> std::enable_if_t<std::is_same_v<Thing<int>, FroidurePin<int>>,
129+
FroidurePin<Element>> {
130+
return FroidurePin(k.cbegin_generators(), k.cend_generators());
131+
}
132+
120133
////////////////////////////////////////////////////////////////////////
121134
// ToddCoxeter
122135
////////////////////////////////////////////////////////////////////////

tests/test-konieczny-bmat.cpp

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ namespace libsemigroups {
3333
"[quick][bmat]",
3434
BMat<>,
3535
BMat<4>) {
36-
auto rg = ReportGuard(false);
37-
std::vector<TestType> gens
38-
= {TestType({{0, 1, 0, 1}, {1, 0, 0, 0}, {0, 1, 1, 1}, {0, 1, 1, 0}}),
39-
TestType({{0, 1, 1, 1}, {1, 1, 0, 0}, {0, 0, 0, 0}, {1, 1, 1, 1}}),
40-
TestType({{0, 1, 1, 0}, {0, 1, 1, 0}, {0, 1, 1, 1}, {1, 1, 1, 1}})};
36+
auto rg = ReportGuard(false);
37+
38+
Konieczny S(
39+
{TestType({{0, 1, 0, 1}, {1, 0, 0, 0}, {0, 1, 1, 1}, {0, 1, 1, 0}}),
40+
TestType({{0, 1, 1, 1}, {1, 1, 0, 0}, {0, 0, 0, 0}, {1, 1, 1, 1}}),
41+
TestType({{0, 1, 1, 0}, {0, 1, 1, 0}, {0, 1, 1, 1}, {1, 1, 1, 1}})});
4142

42-
Konieczny<TestType> S(gens);
4343
REQUIRE(S.size() == 26);
4444
}
4545

@@ -49,15 +49,14 @@ namespace libsemigroups {
4949
"[quick][bmat][no-valgrind]",
5050
BMat<>,
5151
BMat<4>) {
52-
auto rg = ReportGuard(false);
53-
std::vector<TestType> gens
54-
= {TestType({{1, 0, 0, 0}, {0, 0, 1, 0}, {1, 0, 0, 1}, {0, 1, 0, 0}}),
55-
TestType({{1, 0, 0, 1}, {1, 0, 0, 1}, {1, 1, 1, 1}, {0, 1, 1, 0}}),
56-
TestType({{1, 0, 1, 0}, {1, 0, 1, 1}, {0, 0, 1, 1}, {0, 1, 0, 1}}),
57-
TestType({{0, 0, 0, 0}, {0, 1, 0, 1}, {1, 1, 1, 0}, {1, 0, 0, 1}}),
58-
TestType({{0, 0, 0, 1}, {0, 0, 1, 0}, {1, 0, 0, 1}, {1, 1, 0, 0}})};
52+
auto rg = ReportGuard(false);
5953

60-
Konieczny<TestType> S(gens);
54+
Konieczny S(
55+
{TestType({{1, 0, 0, 0}, {0, 0, 1, 0}, {1, 0, 0, 1}, {0, 1, 0, 0}}),
56+
TestType({{1, 0, 0, 1}, {1, 0, 0, 1}, {1, 1, 1, 1}, {0, 1, 1, 0}}),
57+
TestType({{1, 0, 1, 0}, {1, 0, 1, 1}, {0, 0, 1, 1}, {0, 1, 0, 1}}),
58+
TestType({{0, 0, 0, 0}, {0, 1, 0, 1}, {1, 1, 1, 0}, {1, 0, 0, 1}}),
59+
TestType({{0, 0, 0, 1}, {0, 0, 1, 0}, {1, 0, 0, 1}, {1, 1, 0, 0}})});
6160
REQUIRE(S.size() == 415);
6261
}
6362

@@ -78,14 +77,19 @@ namespace libsemigroups {
7877
REQUIRE(S.size() == 248'017);
7978
}
8079

81-
LIBSEMIGROUPS_TEST_CASE("Konieczny", "003", "exceptions", "[quick][bmat]") {
80+
LIBSEMIGROUPS_TEMPLATE_TEST_CASE("Konieczny",
81+
"003",
82+
"exceptions",
83+
"[quick][bmat]",
84+
BMat<>,
85+
BMat<4>) {
8286
auto rg = ReportGuard(false);
8387
REQUIRE_THROWS_AS(
84-
Konieczny<BMat<>>(
85-
{BMat<>({{1, 0, 0, 0}, {0, 0, 1, 0}, {1, 0, 0, 1}, {0, 1, 0, 0}}),
86-
BMat<>({{1, 0, 0}, {1, 0, 0}, {1, 1, 1}})}),
88+
Konieczny(
89+
{make<TestType>(
90+
{{1, 0, 0, 0}, {0, 0, 1, 0}, {1, 0, 0, 1}, {0, 1, 0, 0}}),
91+
make<TestType>({{1, 0, 0}, {1, 0, 0}, {1, 1, 1}})}),
8792
LibsemigroupsException);
88-
// This doesn't throw when using BMat<4>, so there's no test for that
8993
}
9094

9195
LIBSEMIGROUPS_TEMPLATE_TEST_CASE("Konieczny",

0 commit comments

Comments
 (0)