24#ifndef LIBSEMIGROUPS_BMAT8_HPP_
25#define LIBSEMIGROUPS_BMAT8_HPP_
38#include "adapters.hpp"
85 constexpr BitRef(uint64_t& data,
size_t index) noexcept
86 : _data(data), _mask(
static_cast<uint64_t
>(1) << (63 - index)) {}
89 constexpr BitRef&
operator=(
bool val)
noexcept {
90 _data ^= (-val ^ _data) & _mask;
95 [[nodiscard]]
constexpr operator bool()
const {
124 constexpr explicit
BMat8(uint64_t mat) noexcept : _data(mat) {}
195 [[nodiscard]] constexpr
bool operator==(
BMat8 const& that) const noexcept {
196 return _data == that._data;
195 [[nodiscard]] constexpr
bool operator==(
BMat8 const& that) const noexcept {
…}
214 return _data != that._data;
232 return _data < that._data;
250 return *
this < that || *
this == that;
268 return _data > that._data;
286 return *
this > that || *
this == that;
315 [[nodiscard]]
constexpr bool operator()(
size_t r,
size_t c)
const noexcept {
316 LIBSEMIGROUPS_ASSERT(r < 8);
317 LIBSEMIGROUPS_ASSERT(c < 8);
318 return (_data << (8 * r + c)) >> 63;
315 [[nodiscard]]
constexpr bool operator()(
size_t r,
size_t c)
const noexcept {
…}
346 [[nodiscard]]
constexpr uint8_t
operator()(
size_t r)
const noexcept {
347 LIBSEMIGROUPS_ASSERT(r < 8);
348 return static_cast<uint8_t
>(
to_int() << 8 * r >> 56);
346 [[nodiscard]]
constexpr uint8_t
operator()(
size_t r)
const noexcept {
…}
374 [[nodiscard]] uint8_t
at(
size_t r)
const;
403 [[nodiscard]]
constexpr BitRef
operator()(
size_t r,
size_t c) {
404 return BitRef(_data, 8 * r + c);
421 [[nodiscard]]
bool at(
size_t r,
size_t c)
const;
437 [[nodiscard]] BitRef
at(
size_t r,
size_t c);
454 [[nodiscard]]
constexpr inline uint64_t
to_int() const noexcept {
454 [[nodiscard]]
constexpr inline uint64_t
to_int() const noexcept {
…}
536 return BMat8(_data | that._data);
625 template <
typename T>
626 [[nodiscard]]
constexpr T
one(
size_t dim = 8) noexcept {
627 LIBSEMIGROUPS_ASSERT(dim <= 8);
626 [[nodiscard]]
constexpr T
one(
size_t dim = 8) noexcept {
…}
656 [[nodiscard]]
constexpr BMat8 one(
size_t dim = 8) noexcept {
656 [[nodiscard]]
constexpr BMat8 one(
size_t dim = 8) noexcept {
…}
705 uint64_t y = x.to_int();
706 uint64_t z = (y ^ (y >> 7)) & 0xAA00AA00AA00AA;
707 y = y ^ z ^ (z << 7);
708 z = (y ^ (y >> 14)) & 0xCCCC0000CCCC;
709 y = y ^ z ^ (z << 14);
710 z = (y ^ (y >> 28)) & 0xF0F0F0F0;
711 y = y ^ z ^ (z << 28);
771 for (
size_t i = 0; i < 8; ++i) {
772 if (x.to_int() << (8 * i) >> 56 > 0) {
890 template <
typename Container>
892 static_assert(std::is_same_v<typename Container::value_type, uint8_t>);
893 for (
size_t i = 0; i < 8; ++i) {
894 rows.push_back(x(i));
969 BMat8 const& x)
noexcept {
980 struct hash<libsemigroups::BMat8> {
981 size_t operator()(libsemigroups::BMat8
const& bm)
const {
1004 [[nodiscard]]
constexpr inline size_t
1018 [[nodiscard]]
constexpr inline size_t
1064 size_t = 0) const noexcept {
1081 BMat8 const& x)
const noexcept {
1098 BMat8 const& x)
const noexcept {
Fast boolean matrices of dimension up to 8 x 8.
Definition bmat8.hpp:74
BMat8() noexcept=default
Default constructor.
constexpr bool operator>=(BMat8 const &that) const noexcept
Greater than or equal operator.
Definition bmat8.hpp:285
BitRef at(size_t r, size_t c)
Access entries in a matrix (with bound checks).
constexpr uint64_t to_int() const noexcept
Returns the integer representation of this.
Definition bmat8.hpp:454
constexpr BMat8(BMat8 &&) noexcept=default
Default move constructor.
BMat8 & operator*=(BMat8 const &that) noexcept
Multiply this by that in-place.
constexpr bool operator<(BMat8 const &that) const noexcept
Less than operator.
Definition bmat8.hpp:231
BMat8 operator*(BMat8 const &that) const noexcept
Returns the matrix product of this and that.
constexpr BMat8 & operator+=(BMat8 const &that) noexcept
Sum BMat8 objects (in-place).
Definition bmat8.hpp:553
constexpr BMat8 operator+(BMat8 const &that) const noexcept
Sum BMat8 objects.
Definition bmat8.hpp:535
constexpr BMat8 & operator*=(bool scalar) noexcept
Multiply a BMat8 by a scalar (in-place).
Definition bmat8.hpp:514
constexpr uint8_t operator()(size_t r) const noexcept
Access a row of a BMat8 (no bound checks).
Definition bmat8.hpp:346
constexpr bool operator!=(BMat8 const &that) const noexcept
Inequality operator.
Definition bmat8.hpp:213
constexpr bool operator()(size_t r, size_t c) const noexcept
Access entries in a matrix (no bound checks).
Definition bmat8.hpp:315
uint8_t at(size_t r) const
Access a row of a BMat8 (with bound checks).
BMat8(std::vector< std::vector< bool > > const &mat)
A constructor.
constexpr bool operator<=(BMat8 const &that) const noexcept
Less than or equal operator.
Definition bmat8.hpp:249
constexpr BMat8 & operator=(BMat8 const &) noexcept=default
Default copy assignment operator.
void swap(BMat8 &that) noexcept
Swaps this with that.
Definition bmat8.hpp:586
constexpr BMat8 operator*(bool scalar) const noexcept
Multiply a BMat8 by a scalar.
Definition bmat8.hpp:491
bool at(size_t r, size_t c) const
Access entries in a matrix (with bound checks).
constexpr BitRef operator()(size_t r, size_t c)
Access entries in a matrix (no bound checks).
Definition bmat8.hpp:403
constexpr BMat8(BMat8 const &) noexcept=default
Default copy constructor.
constexpr bool operator>(BMat8 const &that) const noexcept
Greater than operator.
Definition bmat8.hpp:267
std::string to_human_readable_repr(AhoCorasick const &ac)
Return a string representation.
Bipartition operator*(Bipartition const &x, Bipartition const &y)
Multiply two bipartitions.
std::ostringstream & operator<<(std::ostringstream &os, BMat8 const &x)
Insertion operator.
Namespace for BMat8 helper functions.
Definition bmat8.hpp:603
std::vector< bool > to_vector(uint8_t row)
Convert a uint8_t to a vector.
size_t minimum_dim(BMat8 const &x) noexcept
Returns the minimum dimension of a BMat8.
constexpr T one(size_t dim=8) noexcept
Returns the identity boolean matrix of a given dimension.
Definition bmat8.hpp:626
bool is_regular_element(BMat8 const &x) noexcept
Checks whether a BMat8 is regular in the monoid of all BMat8 objects.
BMat8 random()
Construct a random BMat8.
void push_back_rows(Container &rows, BMat8 const &x)
Push the rows of a BMat8 into the back of a container.
Definition bmat8.hpp:891
BMat8 col_space_basis(BMat8 const &x) noexcept
Find a basis for the column space of a BMat8.
Definition bmat8.hpp:747
size_t row_space_size(BMat8 const &x)
Returns the size of the row space of a BMat8.
std::vector< uint8_t > rows(BMat8 const &x)
Returns a vector of the rows of a BMat8.
constexpr BMat8 transpose(BMat8 const &x) noexcept
Returns the transpose of a BMat8.
Definition bmat8.hpp:704
size_t col_space_size(BMat8 const &x)
Returns the size of the column space of a BMat8.
Definition bmat8.hpp:835
constexpr size_t number_of_cols(BMat8 const &x) noexcept
Returns the number of non-zero columns in a BMat8.
Definition bmat8.hpp:800
constexpr size_t number_of_rows(BMat8 const &x) noexcept
Returns the number of non-zero rows in a BMat8.
Definition bmat8.hpp:769
BMat8 row_space_basis(BMat8 const &x) noexcept
Find a basis for the row space of a BMat8.
Namespace for everything in the libsemigroups library.
Definition action.hpp:44
constexpr size_t operator()(BMat8 const &) const noexcept
Returns 0; BMat8 multiplication is constant complexity.
Definition bmat8.hpp:1005
Adapter for the complexity of multiplication.
Definition adapters.hpp:121
constexpr size_t operator()(BMat8 const &) const noexcept
Returns 8; all BMat8s have degree 8.
Definition bmat8.hpp:1019
Adapter for the degree of an element.
Definition adapters.hpp:159
void operator()(BMat8 &res, BMat8 const &pt, BMat8 const &x) const noexcept
Definition bmat8.hpp:1096
Adapter for the value of a left action.
Definition adapters.hpp:350
void operator()(BMat8 &res, BMat8 const &pt, BMat8 const &x) const noexcept
Definition bmat8.hpp:1079
Adapter for the value of a right action.
Definition adapters.hpp:392
void operator()(BMat8 const &, size_t) const noexcept
Does nothing.
Definition bmat8.hpp:1033
Adapter for increasing the degree of an element.
Definition adapters.hpp:199
BMat8 operator()(BMat8 const &x) const noexcept
Returns the group inverse of x.
Definition bmat8.hpp:1111
Adapter for the inverse of an element.
Definition adapters.hpp:319
void operator()(BMat8 &res, BMat8 const &x) const noexcept
Definition bmat8.hpp:1151
Adapter for the action on LambdaValue's.
Definition adapters.hpp:833
BMat8 type
Definition bmat8.hpp:1126
Adapter for lambda functions.
Definition adapters.hpp:793
BMat8 operator()(size_t dim=8) const noexcept
Returns bmat8::one(dim)
Definition bmat8.hpp:1048
BMat8 operator()(BMat8 const &) const noexcept
Returns x.one()
Definition bmat8.hpp:1044
Adapter for the identity element of the given type.
Definition adapters.hpp:246
void operator()(BMat8 &xy, BMat8 const &x, BMat8 const &y, size_t=0) const noexcept
Changes xy in place to hold the product of x and y.
Definition bmat8.hpp:1061
Adapter for the product of two elements.
Definition adapters.hpp:284
size_t operator()(BMat8 const &x) const noexcept
Definition bmat8.hpp:1179
Adapter for calculating ranks.
Definition adapters.hpp:930
void operator()(BMat8 &res, BMat8 const &x) const noexcept
Definition bmat8.hpp:1165
Adapter for the action on RhoValue's.
Definition adapters.hpp:854
BMat8 type
Definition bmat8.hpp:1138
Adapter for rho functions.
Definition adapters.hpp:812