Skip to content

Commit

Permalink
Fix some issues from rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
reiniscirpons committed Dec 4, 2024
1 parent 720038f commit 53bcc24
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
30 changes: 21 additions & 9 deletions include/libsemigroups/sims.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2946,12 +2946,14 @@ namespace libsemigroups {
using node_type = uint32_t;
using KnuthBendix_ = KnuthBendix<>;
std::vector<KnuthBendix_> _knuth_bendices;
Presentation<word_type> _presentation;

public:
//! Default constructor.
explicit SimsRefinerIdeals()
: _knuth_bendices(std::thread::hardware_concurrency() + 1,
KnuthBendix_()) {
KnuthBendix_()),
_presentation() {
init();
}

Expand All @@ -2962,6 +2964,7 @@ namespace libsemigroups {
//!
//! \returns A reference to \c *this.
SimsRefinerIdeals& init() {
_presentation.init();
_knuth_bendices[0].init();
std::fill(_knuth_bendices.begin() + 1,
_knuth_bendices.end(),
Expand All @@ -2981,7 +2984,8 @@ namespace libsemigroups {
template <typename Word>
explicit SimsRefinerIdeals(Presentation<Word> const& p)
: _knuth_bendices(std::thread::hardware_concurrency() + 1,
KnuthBendix_(congruence_kind::twosided, p)) {
KnuthBendix_()),
_presentation() {
init(p);
}

Expand All @@ -3006,9 +3010,18 @@ namespace libsemigroups {
//! terminate on certain inputs.
//!
//! \sa presentation(Presentation<std::string> const&)
template <typename Word>
SimsRefinerIdeals& init(Presentation<Word> const& p) {
_knuth_bendices[0].init(congruence_kind::twosided, p).run();
SimsRefinerIdeals& init(Presentation<word_type> const& p) {
_presentation = p;
_knuth_bendices[0].init(congruence_kind::twosided, _presentation).run();
std::fill(_knuth_bendices.begin() + 1,
_knuth_bendices.end(),
_knuth_bendices[0]);
return *this;
}

SimsRefinerIdeals& init(Presentation<std::string> const& p) {
_presentation = to_presentation<word_type>(p);
_knuth_bendices[0].init(congruence_kind::twosided, _presentation).run();
std::fill(_knuth_bendices.begin() + 1,
_knuth_bendices.end(),
_knuth_bendices[0]);
Expand All @@ -3024,13 +3037,12 @@ namespace libsemigroups {
//! This function returns the defining presentation of a SimsRefinerIdeals
//! instance.
//!
//! \returns A const reference to `Presentation<std::string>`.
//! \returns A const reference to `Presentation<word_type>`.
//!
//! \exceptions
//! \noexcept
[[nodiscard]] Presentation<std::string> const&
presentation() const noexcept {
return _knuth_bendices[0].presentation();
[[nodiscard]] Presentation<word_type> const& presentation() const noexcept {
return _presentation;
}

//! \brief Check if a word graph can be extended to one defining a Rees
Expand Down
13 changes: 6 additions & 7 deletions include/libsemigroups/sims.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,18 @@ namespace libsemigroups {
// TODO(2) avoid the copy here
copy.induced_subgraph_no_checks(static_cast<Node>(0),
wg.number_of_active_nodes());
tc.init(congruence_kind::onesided, copy)
.add_generating_pair_no_checks(
wx.cbegin(), wx.cend(), wy.cbegin(), wy.cend());
LIBSEMIGROUPS_ASSERT(tc.word_graph().number_of_nodes()
== wg.number_of_active_nodes());
tc.init(congruence_kind::onesided, copy);
todd_coxeter::add_generating_pair(tc, wx, wy);
// LIBSEMIGROUPS_ASSERT(tc.word_graph().number_of_nodes()
// == wg.number_of_active_nodes());
// fmt::print("x = {}, y = {}\n", x, y);
// fmt::print("wx = {}, wy = {}\n", wx, wy);
// std::cout << copy << std::endl;
// fmt::print("tc.number_of_classes() == {}\n",
// tc.number_of_classes()); fmt::print("copy.number_of_nodes() ==
// {}\n", copy.number_of_nodes());
LIBSEMIGROUPS_ASSERT(tc.number_of_classes()
< wg.number_of_active_nodes());
// LIBSEMIGROUPS_ASSERT(tc.number_of_classes()
// < wg.number_of_active_nodes());
if (tc.number_of_classes() > 1) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/sims.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@ namespace libsemigroups {
auto const& v = p.second;
// TODO(1) change this to be const_contains for knuth
// bendix when we have it
if (!kb.contains(u.cbegin(), u.cend(), v.cbegin(), v.cend())) {
if (!knuth_bendix::contains(kb, u, v)) {
auto beta
= word_graph::follow_path_no_checks(wg, 0, u.cbegin(), u.cend());
if (sink == UNDEFINED) {
Expand Down
4 changes: 2 additions & 2 deletions tests/test-sims.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4242,7 +4242,7 @@ namespace libsemigroups {
LIBSEMIGROUPS_TEST_CASE("Sims2",
"119",
"2-sided ideals Jura's example",
"[fail][sims1][no-valgrind]") {
"[quick][sims1][no-valgrind]") {
// TODO(0) change category back to quick, these fail
// currently because of changes to the api in
// ToddCoxeter
Expand Down Expand Up @@ -4404,7 +4404,7 @@ namespace libsemigroups {
LIBSEMIGROUPS_TEST_CASE("Sims2",
"123",
"Adding and removing pruners",
"[fail][low-index]") {
"[quick][low-index]") {
// TODO(0) change category back to quick, these fail
// currently because of changes to the api in
// ToddCoxeter
Expand Down

0 comments on commit 53bcc24

Please sign in to comment.