28static_assert(std::is_trivial<BMat8>(),
"BMat8 is not a trivial class!");
30static const constexpr std::array<uint64_t, 8> ROW_MASK = {
31 {0xff00000000000000, 0xff000000000000, 0xff0000000000, 0xff00000000,
32 0xff000000, 0xff0000, 0xff00, 0xff}};
34static const constexpr std::array<uint64_t, 8> COL_MASK = {
35 0x8080808080808080, 0x4040404040404040, 0x2020202020202020,
36 0x1010101010101010, 0x808080808080808, 0x404040404040404,
37 0x202020202020202, 0x101010101010101};
39static const constexpr std::array<uint64_t, 64> BIT_MASK = {{0x8000000000000000,
107 return (_data << (8 * i + j)) >> 63;
113 _data ^= (-
val ^ _data) & BIT_MASK[8 * i + j];
122 for (
auto const &
row :
mat) {
135 static std::random_device
_rd;
136 static std::mt19937
_gen(
_rd());
137 static std::uniform_int_distribution<uint64_t>
_dist(0, 0xffffffffffffffff);
145 for (
size_t i =
dim; i < 8; ++i) {
155 x =
x ^
y ^ (
y << 7);
156 y = (
x ^ (
x >> 14)) & 0xCCCC0000CCCC;
157 x =
x ^
y ^ (
y << 14);
158 y = (
x ^ (
x >> 28)) & 0xF0F0F0F0;
159 x =
x ^
y ^ (
y << 28);
191 epu64 y = (
x ^ (
x >> 7)) & (
epu64{0xAA00AA00AA00AA, 0xAA00AA00AA00AA});
192 x =
x ^
y ^ (
y << 7);
193 y = (
x ^ (
x >> 14)) & (
epu64{0xCCCC0000CCCC, 0xCCCC0000CCCC});
194 x =
x ^
y ^ (
y << 14);
195 y = (
x ^ (
x >> 28)) & (
epu64{0xF0F0F0F0, 0xF0F0F0F0});
196 x =
x ^
y ^ (
y << 28);
201static constexpr epu8 rotlow{7, 0, 1, 2, 3, 4, 5, 6};
202static constexpr epu8 rothigh{0, 1, 2, 3, 4, 5, 6, 7,
203 15, 8, 9, 10, 11, 12, 13, 14};
204static constexpr epu8 rotboth{7, 0, 1, 2, 3, 4, 5, 6,
205 15, 8, 9, 10, 11, 12, 13, 14};
206static constexpr epu8 rot2{6, 7, 0, 1, 2, 3, 4, 5,
207 14, 15, 8, 9, 10, 11, 12, 13};
214 epu8 diag{0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
215 0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40};
216 for (
int i = 0; i < 4; ++i) {
230 for (
int i = 0; i < 7; i++) {
244#error FF is defined !
248constexpr std::array<epu8, 4>
masks{{
250 {
FF, 0,
FF, 0,
FF, 0,
FF, 0,
FF, 0,
FF, 0,
FF, 0,
FF, 0},
251 {
FF,
FF, 1, 1,
FF,
FF, 1, 1,
FF,
FF, 1, 1,
FF,
FF, 1, 1},
252 {
FF,
FF,
FF,
FF, 2, 2, 2, 2,
FF,
FF,
FF,
FF, 2, 2, 2, 2},
253 {
FF,
FF,
FF,
FF,
FF,
FF,
FF,
FF, 3, 3, 3, 3, 3, 3, 3, 3}
257static const epu8 shiftres{1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
285 for (
size_t r = 0;
r < 16;
r++) {
304 for (
size_t r = 0;
r < 16;
r++) {
306 for (
int i = 0; i < 8; i++) {
320 for (
size_t r = 0;
r < 16;
r++) {
322 for (
int i = 0; i < 7; i++) {
344 for (
int i = 0; i < 7; i++) {
354 for (
int i = 0; i < 7; i++) {
366 for (
int i = 0; i < 7; i++) {
385 for (
size_t i = 0; i <
row_space.size(); ++i) {
398 std::bitset<256>
thisspace = row_space_bitset_ref();
408 std::vector<uint8_t>
rows;
409 for (
size_t i = 0; i < 8; ++i) {
421static constexpr epu8 rev8{7, 6, 5, 4, 3, 2, 1, 0,
422 8, 9, 10, 11, 12, 13, 14, 15};
446 std::vector<uint8_t>
rows = this->
rows();
452 std::vector<uint8_t>
perm(8);
453 for (
size_t i = 0; i <
nr_rows(); ++i) {
461#pragma GCC diagnostic push
462#pragma GCC diagnostic ignored "-Wstringop-overflow"
466#pragma GCC diagnostic pop
470 for (
size_t i = 0; i < 8; i++)
489 for (
size_t i = 0; i < 8; ++i) {
490 for (
size_t j = 0; j < 8; ++j) {
#define FF
Definition bmat8_impl.hpp:246
Class for fast boolean matrices of dimension up to 8 x 8.
Definition bmat8.hpp:52
uint64_t row_space_size_incl() const noexcept
Returns the cardinality of the row space of this.
Definition bmat8_impl.hpp:316
BMat8 row_space_basis() const noexcept
Returns a canonical basis of the row space of this.
Definition bmat8_impl.hpp:238
static std::pair< bool, bool > row_space_included2(BMat8 a1, BMat8 b1, BMat8 a2, BMat8 b2)
Returns inclusion of row spaces.
Definition bmat8_impl.hpp:361
static void transpose2(BMat8 &, BMat8 &) noexcept
Transpose two matrices at once.
Definition bmat8_impl.hpp:189
uint64_t row_space_size_bitset() const noexcept
Returns the cardinality of the row space of this.
Definition bmat8_impl.hpp:291
static BMat8 row_permutation_matrix(Perm16 p) noexcept
Returns the matrix associated to the permutation p by rows.
Definition bmat8_impl.hpp:436
BMat8 mult_transpose(BMat8 const &that) const noexcept
Returns the matrix product of this and the transpose of that.
Definition bmat8_impl.hpp:209
BMat8 transpose_maskd() const noexcept
Returns the transpose of this.
Definition bmat8_impl.hpp:175
bool row_space_included_bitset(BMat8 other) const noexcept
Returns whether the row space of this is included in other's.
Definition bmat8_impl.hpp:332
BMat8 transpose() const noexcept
Returns the transpose of this.
Definition bmat8_impl.hpp:152
static BMat8 col_permutation_matrix(Perm16 p) noexcept
Returns the matrix associated to the permutation p by columns.
Definition bmat8_impl.hpp:440
epu8 row_space_mask(epu8 vects) const noexcept
Returns a mask for which vectors of a 16 rows epu8 are in the row space of this.
Definition bmat8_impl.hpp:351
BMat8 row_permuted(Perm16 p) const noexcept
Returns the matrix whose rows have been permuted according to p.
Definition bmat8_impl.hpp:424
BMat8() noexcept=default
A default constructor.
bool row_space_included(BMat8 other) const noexcept
Returns whether the row space of this is included in other's.
Definition bmat8_impl.hpp:340
std::ostream & write(std::ostream &os) const
Write this on os.
Definition bmat8_impl.hpp:485
void row_space_bitset(epu8 &res1, epu8 &res2) const noexcept
Returns the the row space of this as 256 bits.
Definition bmat8_impl.hpp:276
Perm16 right_perm_action_on_basis(BMat8) const noexcept
Give the permutation whose right multiplication change *this to other.
Definition bmat8_impl.hpp:475
std::bitset< 256 > row_space_bitset_ref() const
Returns the the row space of this.
Definition bmat8_impl.hpp:375
BMat8 col_permuted(Perm16 p) const noexcept
Returns the matrix whose columns have been permuted according to p.
Definition bmat8_impl.hpp:432
uint64_t row_space_size_ref() const
Returns the cardinality of the row space of this.
Definition bmat8_impl.hpp:403
BMat8 transpose_mask() const noexcept
Returns the transpose of this.
Definition bmat8_impl.hpp:163
std::vector< uint8_t > rows() const
Returns a std::vector for rows of this.
Definition bmat8_impl.hpp:407
size_t nr_rows() const noexcept
Returns the number of non-zero rows of this.
Definition bmat8_impl.hpp:416
void set(size_t i, size_t j, bool val) noexcept
Sets the (i, j)th position to val.
Definition bmat8_impl.hpp:110
static BMat8 random()
Returns a random BMat8.
Definition bmat8_impl.hpp:134
bool operator()(size_t i, size_t j) const noexcept
Returns the entry in the (i, j)th position.
Definition bmat8_impl.hpp:104
uint64_t row_space_size_incl1() const noexcept
Returns the cardinality of the row space of this.
Definition bmat8_impl.hpp:300
bool row_space_included_ref(BMat8 other) const noexcept
Returns whether the row space of this is included in other's.
Definition bmat8_impl.hpp:397
Perm16 right_perm_action_on_basis_ref(BMat8) const
Give the permutation whose right multiplication change *this to other.
Definition bmat8_impl.hpp:444
#define HPCOMBI_ASSERT(x)
Definition debug.hpp:28
const Transf16 a1
Definition image.cpp:52
std::array< std::tuple< uint16_t, uint16_t, std::array< uint16_t, gens.size()> >, 65536 > res
Definition image.cpp:66
void row_space_update_bitset(epu8 block, epu8 &set0, epu8 &set1) noexcept
Definition bmat8_impl.hpp:261
epu8 permuted(epu8 a, epu8 b) noexcept
Permuting a HPCombi::epu8.
Definition epu8.hpp:72
uint64_t __attribute__((__vector_size__(16), __may_alias__)) epu64
Definition bmat8_impl.hpp:187
epu8 remove_dups(epu8 a, uint8_t repl=0) noexcept
Remove duplicates in a sorted HPCombi::epu8.
Definition epu8_impl.hpp:260
epu8 revsorted8(epu8 a) noexcept
Return a HPCombi::epu8 with the two half reverse sorted.
Definition epu8_impl.hpp:212
epu8 permutation_of(epu8 a, epu8 b) noexcept
Find if a vector is a permutation of one other.
Definition epu8_impl.hpp:303
bool equal(epu8 a, epu8 b) noexcept
Equality of HPCombi::epu8.
Definition epu8.hpp:63
epu8 sorted8(epu8 a) noexcept
Return a HPCombi::epu8 with the two half sorted.
Definition epu8_impl.hpp:206
constexpr TPUBuild< epu8 > Epu8
Factory object acting as a class constructor for type HPCombi::epu8.
Definition epu8.hpp:53
constexpr std::array< epu8, 4 > masks
Definition bmat8_impl.hpp:248
uint8_t __attribute__((vector_size(16))) epu8
SIMD vector of 16 unsigned bytes.
Definition epu8.hpp:45
const T pow(const T x)
A generic compile time exponentiation function.
Definition power.hpp:83
std::ostream & operator<<(std::ostream &os, HPCombi::BMat8 const &bm)
Definition bmat8_impl.hpp:508
Permutations of .
Definition perm16.hpp:208
static constexpr Perm16 one()
The identity partial permutation.
Definition perm16.hpp:223