Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions GNUmakefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
KEXT_NAME = semigroups

KEXT_CXXFLAGS = @LIBSEMIGROUPS_CFLAGS@ -std=gnu++14 -O3
KEXT_CXXFLAGS = @LIBSEMIGROUPS_CFLAGS@ -std=gnu++17 -O3
KEXT_LDFLAGS = @LIBSEMIGROUPS_RPATH@ @LIBSEMIGROUPS_LIBS@

# configure settings
Expand Down Expand Up @@ -46,10 +46,11 @@ ifdef WITH_INCLUDED_LIBSEMIGROUPS
# FIXME(later) all the include paths should point into bin/include/ and not to
# the sources, or otherwise we should stop make installing into bin
ifdef LIBSEMIGROUPS_HPCOMBI_ENABLED
KEXT_CPPFLAGS += -Ilibsemigroups/extern/HPCombi/include
KEXT_CPPFLAGS += -Ilibsemigroups/extern/HPCombi/include/fallback
KEXT_CPPFLAGS += -Ilibsemigroups/third_party/HPCombi/include
KEXT_CPPFLAGS += -Ilibsemigroups/third_party/HPCombi/third_party/
endif
KEXT_CPPFLAGS += -Ilibsemigroups/extern/fmt-8.0.1/include
KEXT_CPPFLAGS += -Ilibsemigroups/third_party/fmt-11.1.4/include
KEXT_CPPFLAGS += -Ilibsemigroups/third_party/magic_enum-0.9.7/include
KEXT_CPPFLAGS += -Ilibsemigroups/include
endif
KEXT_CPPFLAGS += -DFMT_HEADER_ONLY
Expand Down Expand Up @@ -101,7 +102,7 @@ lint:
etc/cpplint.sh

format:
clang-format -i src/*.*pp
clang-format -i src/*.[hc]

.PHONY: lint format

Expand Down
27 changes: 27 additions & 0 deletions gapbind14/include/gapbind14/cpp_fn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ namespace gapbind14 {
// Overloading
////////////////////////////////////////////////////////////////////////

static constexpr auto const_ = std::true_type{};

template <typename... TArgs>
struct overload_cast_impl {
constexpr overload_cast_impl() {}
Expand Down Expand Up @@ -94,6 +96,11 @@ namespace gapbind14 {
using type = R(A...);
};

template <typename C, typename R, typename... A>
struct remove_class<R (C::*)(A...) const noexcept> {
using type = R(A...);
};

template <typename F>
struct strip_function_object {
using type = typename remove_class<decltype(&F::operator())>::type;
Expand Down Expand Up @@ -186,11 +193,21 @@ namespace gapbind14 {
struct CppFunction<TReturnType(TArgs...)>
: CppFunctionBase<TReturnType, TArgs...> {};

// noexcept free functions
template <typename TReturnType, typename... TArgs>
struct CppFunction<TReturnType(TArgs...) noexcept>
: CppFunctionBase<TReturnType, TArgs...> {};

// Function pointers . . .
template <typename TReturnType, typename... TArgs>
struct CppFunction<TReturnType (*)(TArgs...)>
: CppFunctionBase<TReturnType, TArgs...> {};

// noexcept function pointer
template <typename TReturnType, typename... TArgs>
struct CppFunction<TReturnType (*)(TArgs...) noexcept>
: CppFunctionBase<TReturnType, TArgs...> {};

// Member functions . . .
template <typename TClass, typename TReturnType, typename... TArgs>
struct CppFunction<TReturnType (TClass::*)(TArgs...)>
Expand All @@ -201,6 +218,16 @@ namespace gapbind14 {
struct CppFunction<TReturnType (TClass::*)(TArgs...) const>
: CppMemFnBase<TClass, TReturnType, TArgs...> {};

// Const noexcept member functions
template <typename TClass, typename TReturnType, typename... TArgs>
struct CppFunction<TReturnType (TClass::*)(TArgs...) const noexcept>
: CppMemFnBase<TClass, TReturnType, TArgs...> {};

// Non-const noexcept member functions
template <typename TClass, typename TReturnType, typename... TArgs>
struct CppFunction<TReturnType (TClass::*)(TArgs...) noexcept>
: CppMemFnBase<TClass, TReturnType, TArgs...> {};

// std::function objects
template <typename TReturnType, typename... TArgs>
struct CppFunction<std::function<TReturnType(TArgs...)>>
Expand Down
41 changes: 20 additions & 21 deletions src/bipart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@
#include "compiled.h"

// libsemigroups headers
#include "libsemigroups/bipart.hpp" // for Blocks, Bipartition, validate
#include "libsemigroups/report.hpp" // for Reporter, etc
#include "libsemigroups/timer.hpp" // for Timer
#include "semigroups-config.hpp" // for SEMIGROUPS_KERNEL_DEBUG
#include "libsemigroups/bipart.hpp" // for Blocks, Bipartition, validate
#include "libsemigroups/detail/report.hpp" // for Reporter, etc
#include "libsemigroups/detail/timer.hpp" // for Timer
#include "semigroups-config.hpp" // for SEMIGROUPS_KERNEL_DEBUG

#include "gapbind14/gapbind14.hpp" // for GAPBIND14_TRY

using libsemigroups::Bipartition;
using libsemigroups::Blocks;
using libsemigroups::REPORTER;
using libsemigroups::detail::Timer;

// Global variables
Expand Down Expand Up @@ -277,7 +276,7 @@ Obj BIPART_PROD(Obj x, Obj y) {
Bipartition* yy = bipart_get_cpp(y);

Bipartition* z = new Bipartition(xx->degree());
z->product_inplace(*xx, *yy);
z->product_inplace_no_checks(*xx, *yy);

return bipart_new_obj(static_cast<Bipartition*>(z));
}
Expand Down Expand Up @@ -706,11 +705,11 @@ Obj BLOCKS_NC(Obj self, Obj gap_blocks) {
SEMIGROUPS_ASSERT(IS_INTOBJ(ELM_LIST(block, j)));
int jj = INT_INTOBJ(ELM_LIST(block, j));
if (jj < 0) {
blocks->set_block(-jj - 1, i - 1);
blocks->set_is_transverse_block(i - 1, false);
blocks->block(-jj - 1, i - 1);
blocks->is_transverse_block(i - 1, false);
} else {
blocks->set_block(jj - 1, i - 1);
blocks->set_is_transverse_block(i - 1, true);
blocks->block(jj - 1, i - 1);
blocks->is_transverse_block(i - 1, true);
}
}
}
Expand Down Expand Up @@ -1000,8 +999,8 @@ Obj BLOCKS_LEFT_ACT(Obj self, Obj blocks_gap, Obj x_gap) {
tab[j] = next;
next++;
}
out_blocks->set_block(i, tab[j]);
out_blocks->set_is_transverse_block(tab[j], _BUFFER_bool[j]);
out_blocks->block(i, tab[j]);
out_blocks->is_transverse_block(tab[j], _BUFFER_bool[j]);
}

#ifdef SEMIGROUPS_KERNEL_DEBUG
Expand Down Expand Up @@ -1055,8 +1054,8 @@ Obj BLOCKS_RIGHT_ACT(Obj self, Obj blocks_gap, Obj x_gap) {
tab[j] = next;
next++;
}
out_blocks->set_block(i - n, tab[j]);
out_blocks->set_is_transverse_block(tab[j], _BUFFER_bool[j]);
out_blocks->block(i - n, tab[j]);
out_blocks->is_transverse_block(tab[j], _BUFFER_bool[j]);
}
#ifdef SEMIGROUPS_KERNEL_DEBUG
libsemigroups::validate(*out_blocks);
Expand Down Expand Up @@ -1210,7 +1209,7 @@ Obj BLOCKS_INV_RIGHT(Obj self, Obj blocks_gap, Obj x_gap) {
continue;
}
}
if (junk == static_cast<uint32_t>(-1)) {
if (junk == (uint32_t) -1) {
junk = next;
next++;
}
Expand Down Expand Up @@ -1399,10 +1398,10 @@ class IdempotentCounter {
}

std::vector<size_t> count() {
libsemigroups::THREAD_ID_MANAGER.reset();
REPORT_DEFAULT("using %llu / %llu additional threads",
_nr_threads,
std::thread::hardware_concurrency());
libsemigroups::detail::reset_thread_ids();
libsemigroups::report_default("using {} / {} additional threads",
_nr_threads,
std::thread::hardware_concurrency());
Timer timer;

for (size_t i = 0; i < _nr_threads; i++) {
Expand All @@ -1414,7 +1413,7 @@ class IdempotentCounter {
_threads[i].join();
}

REPORT_TIME(timer);
libsemigroups::report_elapsed_time("", timer);

size_t max = *max_element(_ranks.begin(), _ranks.end()) + 1;
std::vector<size_t> out = std::vector<size_t>(max, 0);
Expand Down Expand Up @@ -1450,7 +1449,7 @@ class IdempotentCounter {
}
}
}
REPORT_DEFAULT("finished in %llu", timer.string().c_str());
libsemigroups::report_default("finished in {}", timer);
}

// This is basically the same as BLOCKS_E_TESTER, but is required because we
Expand Down
101 changes: 7 additions & 94 deletions src/cong.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,111 +36,24 @@
#include "gapbind14/gapbind14.hpp" // for class_ etc

// libsemigroups headers
#include "libsemigroups/bipart.hpp" // for Bipartition
#include "libsemigroups/cong-intf.hpp" // for congruence_kind
#include "libsemigroups/cong.hpp" // for Congruence
#include "libsemigroups/constants.hpp" // for UNDEFINED etc
#include "libsemigroups/froidure-pin.hpp" // for FroidurePin
#include "libsemigroups/matrix.hpp" // for BMat etc
#include "libsemigroups/todd-coxeter.hpp" // for ToddCoxeter
#include "libsemigroups/transf.hpp" // for PPerm etc
#include "libsemigroups/presentation.hpp" // for Presentation
#include "libsemigroups/types.hpp" // for word_type

// Forward decls
namespace libsemigroups {
class FpSemigroup;
class PBR;
} // namespace libsemigroups

namespace gapbind14 {
template <>
struct IsGapBind14Type<libsemigroups::Congruence> : std::true_type {};
struct IsGapBind14Type<libsemigroups::Congruence<libsemigroups::word_type>>
: std::true_type {
static constexpr std::string_view name = "Congruence";
};

} // namespace gapbind14

// TODO rm this file
////////////////////////////////////////////////////////////////////////
// Congruence
////////////////////////////////////////////////////////////////////////

using gapbind14::overload_cast;

void init_cong(gapbind14::Module& m) {
using libsemigroups::Congruence;
using libsemigroups::congruence_kind;
using libsemigroups::FpSemigroup;
using libsemigroups::FroidurePin;
using libsemigroups::FroidurePinBase;
using libsemigroups::word_type;

using libsemigroups::Bipartition;
using libsemigroups::BMat;
using libsemigroups::IntMat;
using libsemigroups::LeastPPerm;
using libsemigroups::LeastTransf;
using libsemigroups::MaxPlusMat;
using libsemigroups::MaxPlusTruncMat;
using libsemigroups::MinPlusMat;
using libsemigroups::MinPlusTruncMat;
using libsemigroups::NTPMat;
using libsemigroups::PBR;
using libsemigroups::PPerm;
using libsemigroups::ProjMaxPlusMat;
using libsemigroups::Transf;

// Cannot use FroidurePinBase rather than the specialisations because there's
// no constructor for a Congruence from a FroidurePinBase&.
gapbind14::class_<Congruence>("Congruence")
.def(gapbind14::init<congruence_kind, FroidurePin<Bipartition> const&>{},
"make_from_froidurepin_bipartition")
.def(gapbind14::init<congruence_kind, FroidurePin<BMat<>> const&>{},
"make_from_froidurepin_bmat")
.def(gapbind14::init<congruence_kind, FroidurePin<WBMat8> const&>{},
"make_from_froidurepin_bmat8")
.def(gapbind14::init<congruence_kind, FroidurePin<PBR> const&>{},
"make_from_froidurepin_pbr")
#ifdef LIBSEMIGROUPS_HPCOMBI_ENABLED
.def(gapbind14::init<congruence_kind,
FroidurePin<LeastPPerm<16>> const&>{},
"make_from_froidurepin_leastpperm")
.def(gapbind14::init<congruence_kind,
FroidurePin<LeastTransf<16>> const&>{},
"make_from_froidurepin_leasttransf")
#endif
.def(gapbind14::init<congruence_kind,
FroidurePin<Transf<0, UInt2>> const&>{},
"make_from_froidurepin_transfUInt2")
.def(gapbind14::init<congruence_kind,
FroidurePin<Transf<0, UInt4>> const&>{},
"make_from_froidurepin_transfUInt4")
.def(gapbind14::init<congruence_kind,
FroidurePin<PPerm<0, UInt2>> const&>{},
"make_from_froidurepin_ppermUInt2")
.def(gapbind14::init<congruence_kind,
FroidurePin<PPerm<0, UInt4>> const&>{},
"make_from_froidurepin_ppermUInt4")
.def(gapbind14::init<congruence_kind, FpSemigroup&>{},
"make_from_fpsemigroup")
.def(gapbind14::init<congruence_kind, std::shared_ptr<FroidurePinBase>>{},
"make_from_froidurepinbase")
.def(gapbind14::init<congruence_kind, Congruence::options::runners>{},
"make_from_table")
.def("set_number_of_generators", &Congruence::set_number_of_generators)
.def("number_of_pairs", &Congruence::number_of_generating_pairs)
.def("add_pair",
overload_cast<word_type const&, word_type const&>(
&Congruence::add_pair))
.def("number_of_classes", &Congruence::number_of_classes)
.def("word_to_class_index", &Congruence::word_to_class_index)
.def("class_index_to_word", &Congruence::class_index_to_word)
.def("contains", &Congruence::contains)
.def("less", &Congruence::less)
.def("add_runner",
&Congruence::add_runner<libsemigroups::congruence::ToddCoxeter>)
.def("is_quotient_obviously_infinite",
&Congruence::is_quotient_obviously_infinite)
.def("ntc",
[](Congruence& C) {
return gapbind14::make_iterator(C.cbegin_ntc(), C.cend_ntc());
})
.def("quotient_froidure_pin", &Congruence::quotient_froidure_pin);
}
void init_cong(gapbind14::Module& m) {}
1 change: 1 addition & 0 deletions src/cong.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//
// TODO rm this file
// Semigroups package for GAP
// Copyright (C) 2021 James D. Mitchell
//
Expand Down
6 changes: 3 additions & 3 deletions src/conglatt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

// libsemigroups headers
#include "libsemigroups/adapters.hpp" // for Hash
#include "libsemigroups/report.hpp" // for should_report
#include "libsemigroups/string.hpp" // for group_digits
#include "libsemigroups/detail/report.hpp" // for should_report
#include "libsemigroups/detail/string.hpp" // for group_digits
//

namespace semigroups {
Expand Down Expand Up @@ -215,7 +215,7 @@ namespace semigroups {
auto start_time = std::chrono::high_resolution_clock::now();
auto last_report = start_time;
uint32_t last_count = 1;
bool report = libsemigroups::report::should_report();
bool report = libsemigroups::reporting_enabled();

std::vector<UF> gens;
gens.reserve(LEN_LIST(list));
Expand Down
12 changes: 8 additions & 4 deletions src/froidure-pin-base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,20 @@ void init_froidure_pin_base(gapbind14::Module& m) {
return S->right_cayley_graph();
})
.def("factorisation",
[](FroidurePin_ S, size_t i) { return S->factorisation(i); })
[](FroidurePin_ S, size_t i) {
return libsemigroups::froidure_pin::factorisation(*S, i);
})
.def("minimal_factorisation",
[](FroidurePin_ S, size_t i) { return S->minimal_factorisation(i); })
[](FroidurePin_ S, size_t i) {
return libsemigroups::froidure_pin::minimal_factorisation(*S, i);
})
.def("product_by_reduction",
[](FroidurePin_ S, size_t i, size_t j) {
return S->product_by_reduction(i, j);
return libsemigroups::froidure_pin::product_by_reduction(*S, i, j);
})
.def("current_position",
[](FroidurePin_ S, libsemigroups::word_type const& w) {
return S->current_position(w);
return libsemigroups::froidure_pin::current_position(*S, w);
})
.def("current_size", [](FroidurePin_ S) { return S->current_size(); })
.def("size", [](FroidurePin_ S) { return S->size(); })
Expand Down
4 changes: 2 additions & 2 deletions src/froidure-pin-fallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
#include "semigroups-debug.hpp" // for SEMIGROUPS_ASSERT

// libsemigroups headers
#include "libsemigroups/report.hpp" // for REPORTER, Reporter
#include "libsemigroups/timer.hpp" // for Timer
#include "libsemigroups/detail/report.hpp" // for REPORTER, Reporter
#include "libsemigroups/detail/timer.hpp" // for Timer

using libsemigroups::detail::Timer;

Expand Down
Loading
Loading