39 for (
size_t i = 0; i < dom.size(); ++i) {
46 return complement ?
v ==
Epu8(0xFF) :
v !=
Epu8(0xFF);
49 return simde_mm_movemask_epi8(
domain_mask(complement));
55#ifdef SIMDE_X86_SSE4_2_NATIVE
57 return complement ? _mm_cmpestrm(
v, 16,
one().
v, 16, FIND_IN_VECT)
58 : _mm_cmpestrm(
v, 16,
one().
v, 16, FIND_IN_VECT_COMPL);
66 return complement ?
static_cast<epu8>(!
res) :
res;
70 return simde_mm_movemask_epi8(
image_mask(complement));
77 static_assert(
decltype(
Epu8)
::size == 16,
"Wrong size of EPU8 array");
81 return std::accumulate(tmp.begin(), tmp.end(), uint8_t(0));
89#ifdef SIMDE_X86_SSE4_2_NATIVE
97 return complement ?
v !=
one().
v :
v ==
one().
v;
113 return res == 0 ? 0xFF : 31 - __builtin_clz(
res);
118 return res == 0 ? 0xFF : 31 - __builtin_clz(
res);
125inline static constexpr uint8_t hilo_exchng_fun(uint8_t i) {
126 return i < 8 ? i + 8 : i - 8;
128static constexpr epu8 hilo_exchng =
Epu8(hilo_exchng_fun);
129inline static constexpr uint8_t hilo_mask_fun(uint8_t i) {
130 return i < 8 ? 0x0 : 0xFF;
132static constexpr epu8 hilo_mask =
Epu8(hilo_mask_fun);
135 epu8 res = simde_mm_set_epi64x(compressed, compressed);
136 v = simde_mm_blendv_epi8(
res &
Epu8(0x0F),
res >> 4, hilo_mask);
139inline Transf16::operator uint64_t()
const {
141 static_cast<epu8>(simde_mm_slli_epi32(
static_cast<simde__m128i
>(v), 4));
143 return simde_mm_extract_epi64(
res, 0);
148 for (
size_t i = 0; i < 16; ++i)
154#ifdef SIMDE_X86_SSE4_2_NATIVE
155inline PPerm16 PPerm16::inverse_find()
const {
156 epu8 mask = _mm_cmpestrm(
v, 16,
one(), 16, FIND_IN_VECT);
162 static std::random_device rd;
163 static std::mt19937 g(rd());
166 auto ar =
res.as_array();
168 std::shuffle(ar.begin(), ar.begin() + n, g);
175 std::array<int, 16> dir;
177 for (j = 0; j < n; ++j)
179 for (j = n - 1; j >= 0; --j) {
211 for (
size_t i = 0; i < 16; ++i)
220 for (
size_t i = 0; i < 16; ++i)
230 simde_mm_slli_epi32(
static_cast<simde__m128i
>(
v), 4)) +
237namespace power_helper {
251 Perm16 newpow = pow<8>(*
this);
252 for (
int i = 9; i <= 16; i++) {
254 newpow = oldpow * *
this;
255 res.v = simde_mm_blendv_epi8(
res, oldpow, newpow.
v ==
one().
v);
260static constexpr uint32_t lcm_range(uint8_t n) {
262 for (uint8_t i = 1; i <= n; ++i)
268 return pow<lcm_range(16) - 1>(*this);
273 for (
size_t i = 0; i < 16; i++)
274 for (
size_t j = i + 1; j < 16; j++)
283 for (
size_t i = 0; i < 16; i++)
284 for (
size_t j = i + 1; j < 16; j++)
292 for (
int i = 1; i < 16; i++) {
301 for (
size_t i = 0; i < 16; i++)
302 for (
size_t j = i + 1; j < 16; j++)
311 for (
size_t i = 0; i < 16; i++)
312 for (
size_t j = i + 1; j < 16; j++)
322 for (
size_t i = 0; i < 16 - 1; i++)
328 return __builtin_popcountl(simde_mm_movemask_epi8(
v <
shifted_right(
v)));
332 std::array<bool, 16> b{};
334 for (
size_t i = 0; i < 16; i++) {
336 for (
size_t j = i; !b[j]; j =
v[j])
359 return __builtin_popcountl(simde_mm_movemask_epi8(
res));
363 for (
size_t i = 0; i < 16; i++) {
364 for (
size_t j = i + 1; j < 16; j++) {
365 if ((
v[i] >
v[j]) && (other[i] < other[j]))
373 epu8 srot =
v, orot = other;
374 for (
size_t i = 0; i < 15; i++) {
377 uint64_t sinv = simde_mm_movemask_epi8(
v < srot);
378 uint64_t oinv = simde_mm_movemask_epi8(other.
v < orot);
379 if ((sinv & oinv) != sinv)
const PTransf16 id
Definition RD.cpp:37
#define HPCOMBI_ASSERT(x)
Definition debug.hpp:28
std::array< std::tuple< uint16_t, uint16_t, std::array< uint16_t, gens.size()> >, 65536 > res
Definition image.cpp:66
Perm16 Perm16
Definition perm16_impl.hpp:240
epu8 permuted(epu8 a, epu8 b) noexcept
Permuting a HPCombi::epu8.
Definition epu8.hpp:72
epu8 shifted_right(epu8 a) noexcept
Left shifted of a HPCombi::epu8 inserting a 0.
Definition epu8.hpp:78
epu8 permutation_of(epu8 a, epu8 b) noexcept
Find if a vector is a permutation of one other.
Definition epu8_impl.hpp:303
uint8_t horiz_sum(epu8 v) noexcept
Horizontal sum of a HPCombi::epu8.
Definition epu8.hpp:217
epu8 sorted(epu8 a) noexcept
Return a sorted HPCombi::epu8.
Definition epu8_impl.hpp:203
constexpr TPUBuild< epu8 > Epu8
Factory object acting as a class constructor for type HPCombi::epu8.
Definition epu8.hpp:53
uint8_t __attribute__((vector_size(16))) epu8
SIMD vector of 16 unsigned bytes.
Definition epu8.hpp:45
epu8 shifted_left(epu8 a) noexcept
Right shifted of a HPCombi::epu8 inserting a 0.
Definition epu8.hpp:84
TPUBuild< TPU >::array & as_array(TPU &v) noexcept
Cast a TPU to a c++ std::array.
Definition builder.hpp:139
const T pow(const T x)
A generic compile time exponentiation function.
Definition power.hpp:83
Partial permutation of .
Definition perm16.hpp:149
PPerm16 inverse_ref() const
The inverse of a partial permutation.
Definition perm16_impl.hpp:146
static constexpr PPerm16 one()
The identity partial permutations.
Definition perm16.hpp:166
Partial transformation of .
Definition perm16.hpp:47
uint8_t nb_fix_points() const
Returns the number of fix points of *this.
Definition perm16_impl.hpp:121
uint32_t fix_points_bitset(bool complement=false) const
Returns a bit mask for the fix point of *this.
Definition perm16_impl.hpp:99
static constexpr size_t size()
Definition perm16.hpp:48
static constexpr PTransf16 one()
The identity partial transformation.
Definition perm16.hpp:67
uint8_t largest_moved_point() const
Returns the largest non fix point of *this.
Definition perm16_impl.hpp:116
uint32_t domain_bitset(bool complement=false) const
Returns a bit mask for the domain of *this.
Definition perm16_impl.hpp:48
PTransf16 left_one() const
Returns the partial left identity for *this.
Definition perm16_impl.hpp:72
typename decltype(Epu8)::array array
Definition perm16.hpp:51
uint32_t rank_ref() const
Returns the size of the image of *this.
Definition perm16_impl.hpp:75
PTransf16 right_one() const
Returns the partial right identity for *this.
Definition perm16_impl.hpp:51
uint32_t image_bitset(bool complement=false) const
Returns a bit mask for the image of *this.
Definition perm16_impl.hpp:69
epu8 fix_points_mask(bool complement=false) const
Returns a mask for the fix point of *this.
Definition perm16_impl.hpp:96
uint8_t smallest_fix_point() const
Returns the smallest fix point of *this.
Definition perm16_impl.hpp:103
uint32_t rank_cmpestrm() const
Returns the size of the image of *this.
Definition perm16_impl.hpp:84
epu8 domain_mask(bool complement=false) const
Returns a mask for the domain of *this.
Definition perm16_impl.hpp:45
uint32_t rank() const
Returns the size of the image of *this.
Definition perm16_impl.hpp:88
epu8 image_mask_ref(bool complement=false) const
Returns a mask for the image of *this.
Definition perm16_impl.hpp:61
uint8_t largest_fix_point() const
Returns the largest fix point of *this.
Definition perm16_impl.hpp:111
epu8 image_mask(bool complement=false) const
Definition perm16.hpp:77
epu8 image_mask_cmpestrm(bool complement=false) const
Returns a mask for the image of *this.
uint8_t smallest_moved_point() const
Returns the smallest non fix point of *this.
Definition perm16_impl.hpp:107
Permutations of .
Definition perm16.hpp:208
Perm16 inverse_cycl() const
The inverse permutation.
Definition perm16_impl.hpp:249
Perm16 inverse() const
The inverse permutation.
Definition perm16.hpp:283
epu8 lehmer() const
The Lehmer code of a permutation.
Definition perm16_impl.hpp:290
uint8_t length_ref() const
The Coxeter length (ie: number of inversion) of a permutation.
Definition perm16_impl.hpp:299
epu8 cycles_partition() const
The set partition of the cycles of a permutation.
Definition perm16_impl.hpp:344
bool left_weak_leq_ref(Perm16 other) const
Compare two permutations for the left weak order.
Definition perm16_impl.hpp:362
uint8_t nb_descents_ref() const
The number of descent of a permutation.
Definition perm16_impl.hpp:320
Perm16 inverse_sort() const
The inverse permutation.
Definition perm16_impl.hpp:225
static constexpr Perm16 one()
The identity partial permutation.
Definition perm16.hpp:223
epu8 lehmer_ref() const
The Lehmer code of a permutation.
Definition perm16_impl.hpp:271
bool left_weak_leq_length(Perm16 other) const
Compare two permutations for the left weak order.
Definition perm16_impl.hpp:385
uint8_t length() const
The Coxeter length (ie: number of inversion) of a permutation.
Definition perm16_impl.hpp:318
Perm16 inverse_ref() const
The inverse permutation.
Definition perm16_impl.hpp:209
uint8_t nb_descents() const
The number of descent of a permutation.
Definition perm16_impl.hpp:327
uint8_t nb_cycles_ref() const
The number of cycles of a permutation.
Definition perm16_impl.hpp:331
static Perm16 elementary_transposition(uint64_t i)
The elementary transposition exchanging and .
Definition perm16_impl.hpp:201
epu8 lehmer_arr() const
The Lehmer code of a permutation.
Definition perm16_impl.hpp:280
static Perm16 unrankSJT(int n, int r)
The r -th permutation of size n for the Steinhaus–Johnson–Trotter order.
Definition perm16_impl.hpp:173
bool left_weak_leq(Perm16 other) const
Compare two permutations for the left weak order.
Definition perm16_impl.hpp:372
uint8_t nb_cycles_unroll() const
The number of cycles of a permutation.
Definition perm16_impl.hpp:357
Perm16 inverse_pow() const
The inverse permutation.
Definition perm16_impl.hpp:267
uint8_t length_arr() const
The Coxeter length (ie: number of inversion) of a permutation.
Definition perm16_impl.hpp:308
Perm16 inverse_arr() const
The inverse permutation.
Definition perm16_impl.hpp:216
static Perm16 random(uint64_t n=16)
A random permutation of size .
Definition perm16_impl.hpp:161
array & as_array()
Definition vect16.hpp:45
epu8 v
Definition vect16.hpp:37
static const Perm16 one()
Definition perm16_impl.hpp:243
static Perm16 prod(Perm16 a, Perm16 b)
Definition perm16_impl.hpp:244
Algebraic monoid structure used by default for type T by the pow function and prod function.
Definition power.hpp:103