20#ifndef HPCOMBI_BUILDER_HPP_
21#define HPCOMBI_BUILDER_HPP_
25#include <initializer_list>
45 using type_elem =
typename std::remove_reference_t<
decltype((TPU{})[0])>;
54 using array = std::array<type_elem, size>;
56 template <
class Fun,
decltype(
size)... Is>
57 static constexpr TPU
make_helper(Fun f, std::index_sequence<Is...>) {
58 static_assert(std::is_invocable_v<Fun, type_elem>);
63 inline constexpr TPU
operator()(std::initializer_list<type_elem> il,
67 std::copy(il.begin(), il.end(),
res.begin());
68 std::fill(
res.begin() + il.size(),
res.end(), def);
69 return reinterpret_cast<const TPU &
>(
res);
73 template <
class Fun>
inline constexpr TPU
operator()(Fun f)
const {
74 static_assert(std::is_invocable_v<Fun, type_elem>);
75 return make_helper(f, std::make_index_sequence<size>{});
96 return reinterpret_cast<const TPU &
>(a);
100 constexpr TPU
id()
const {
104 constexpr TPU
rev()
const {
117 return (*
this)([](
type_elem i) {
return i == 15 ? 15 : i + 1; });
121 return (*
this)([](
type_elem i) {
return i == 0 ? 0 : i - 1; });
126 return (((i & 0x01) != 0 ? 1 : 0) + ((i & 0x02) != 0 ? 1 : 0) +
127 ((i & 0x04) != 0 ? 1 : 0) + ((i & 0x08) != 0 ? 1 : 0) +
128 ((i & 0x10) != 0 ? 1 : 0) + ((i & 0x20) != 0 ? 1 : 0) +
129 ((i & 0x40) != 0 ? 1 : 0) + ((i & 0x80) != 0 ? 1 : 0));
#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
VectGeneric< TPUBuild< TPU >::size > & as_VectGeneric(TPU &v)
Cast a HPCombi::epu8 to a c++ HPCombi::VectGeneric.
Definition builder.hpp:156
TPUBuild< TPU >::array & as_array(TPU &v) noexcept
Cast a TPU to a c++ std::array.
Definition builder.hpp:139
Class for factory object associated to a SIMD packed unsigned integers.
Definition builder.hpp:43
constexpr TPU popcount() const
Popcount TPU: the ith entry contains the number of bits set in i.
Definition builder.hpp:124
static constexpr size_t size_elem
Size of the elements.
Definition builder.hpp:48
constexpr TPU left_dup() const
Left shift TPU, duplicating the rightmost entry.
Definition builder.hpp:116
constexpr TPU operator()(int c) const
explicit overloading for int constants
Definition builder.hpp:83
constexpr TPU right_dup() const
Right shift TPU, duplicating the leftmost entry.
Definition builder.hpp:120
constexpr TPU operator()(size_t c) const
explicit overloading for size_t constants
Definition builder.hpp:87
constexpr TPU rev() const
Return the reversed element of type TPU.
Definition builder.hpp:104
constexpr TPU operator()(std::initializer_list< type_elem > il, type_elem def) const
Construct a TPU from an std::initializer_list and a default value.
Definition builder.hpp:63
constexpr TPU operator()(array a) const
explicit overloading for array
Definition builder.hpp:95
constexpr TPU operator()(Fun f) const
Construct a TPU from a function giving the values at .
Definition builder.hpp:73
constexpr TPU right_cycle() const
Right cycle TPU permutation.
Definition builder.hpp:112
constexpr TPU left_cycle() const
Left cycle TPU permutation.
Definition builder.hpp:108
constexpr TPU operator()(type_elem c) const
Construct a constant TPU.
Definition builder.hpp:79
static constexpr TPU make_helper(Fun f, std::index_sequence< Is... >)
Definition builder.hpp:57
constexpr TPU id() const
Return the identity element of type TPU.
Definition builder.hpp:100
typename std::remove_reference_t< decltype((TPU{})[0])> type_elem
Type of the elements.
Definition builder.hpp:45
static constexpr size_t size
Number of elements.
Definition builder.hpp:51
std::array< type_elem, size > array
Array equivalent type.
Definition builder.hpp:54
A generic class for combinatorial integer vectors.
Definition vect_generic.hpp:48