23#ifndef HPCOMBI_VECT_GENERIC_HPP_
24#define HPCOMBI_VECT_GENERIC_HPP_
32#include <initializer_list>
43template <
size_t Size,
typename Expo = u
int8_t>
45 std::sort(v.begin(), v.end());
56template <
size_t Size,
typename Expo = u
int8_t>
struct VectGeneric {
57 static constexpr size_t size() {
return Size; }
58 using array = std::array<Expo, Size>;
66 std::copy(il.begin(), il.end(),
v.begin());
67 std::fill(
v.begin() + il.size(),
v.end(), def);
74 for (
size_t i = 0; i < bound; i++)
83 if (u[bound] !=
v[bound])
106 return (diff != Size) &&
v[diff] < u[diff];
111 return (diff == Size) ? 0 : int8_t(
v[diff]) - int8_t(u[diff]);
116 for (uint64_t i = 0; i < Size; i++) {
123 void sort() { std::sort(
v.begin(),
v.end()); }
126 for (uint64_t i = 1; i < Size; i++)
133 static std::random_device rd;
134 static std::mt19937 g(rd());
137 std::shuffle(
res.begin(),
res.end(), g);
142 for (uint64_t i = 0; i < bound; i++)
148 for (uint64_t i = 0; i < bound; i++)
154 for (int64_t i = bound - 1; i >= 0; i--)
160 for (int64_t i = bound - 1; i >= 0; i--)
168 std::sort(temp.begin(), temp.end());
169 for (uint64_t i = 0; i < Size; i++)
172 for (uint64_t i = k; i < Size; i++)
180 for (uint64_t i = 0; i < Size; i++)
187 for (uint64_t i = 1; i < Size; i++)
193 for (uint64_t i = 1; i < Size; i++)
199 for (uint64_t i = 1; i < Size; i++)
205 for (uint64_t i = 1; i < Size; i++)
206 v[i] = std::max(
v[i],
v[i - 1]);
211 for (uint64_t i = 1; i < Size; i++)
217 for (uint64_t i = 1; i < Size; i++)
218 v[i] = std::min(
v[i],
v[i - 1]);
223 for (
size_t i = 0; i < Size; i++)
230static_assert(std::is_trivial<VectGeneric<12>>(),
231 "VectGeneric is not a trivial class !");
237template <
size_t Size,
typename Expo>
240 stream <<
"{" << std::setw(2) << unsigned(v[0]);
241 for (
unsigned i = 1; i < Size; ++i)
242 stream <<
"," << std::setw(2) << unsigned(v[i]);
249template <
size_t Size,
typename Expo>
250struct hash<
HPCombi::VectGeneric<Size, Expo>> {
253 for (
size_t i = 0; i < Size; i++)
254 h = hash<Expo>()(ar[i]) + (h << 6) + (h << 16) - h;
defines the macro HPCOMBI_ASSERT
#define HPCOMBI_ASSERT(x)
Definition debug.hpp:31
std::array< std::tuple< uint16_t, uint16_t, std::array< uint16_t, gens.size()> >, 65536 > res
Definition image.cpp:66
std::array< Expo, Size > sorted_vect(std::array< Expo, Size > v)
Definition vect_generic.hpp:44
Definition bmat16_impl.hpp:362
std::ostream & operator<<(std::ostream &os, HPCombi::BMat16 const &bm)
Definition bmat16_impl.hpp:365
VectGeneric is to Vect16 what PermGeneric is to Perm16; see PermGeneric.
Definition vect_generic.hpp:56
const_iterator end() const
Definition vect_generic.hpp:95
bool operator<(const VectGeneric &u) const
Definition vect_generic.hpp:104
Expo value_type
Definition vect_generic.hpp:89
bool operator==(const VectGeneric &u) const
Definition vect_generic.hpp:97
int8_t less_partial(const VectGeneric &u, int k) const
Definition vect_generic.hpp:109
uint64_t last_zero(size_t bound=Size) const
Definition vect_generic.hpp:159
Expo & operator[](uint64_t i)
Definition vect_generic.hpp:71
void sort()
Definition vect_generic.hpp:123
array v
Definition vect_generic.hpp:59
uint64_t last_non_zero(size_t bound=Size) const
Definition vect_generic.hpp:153
uint64_t first_zero(size_t bound=Size) const
Definition vect_generic.hpp:147
uint64_t first_non_zero(size_t bound=Size) const
Definition vect_generic.hpp:141
static VectGeneric random()
Definition vect_generic.hpp:132
bool is_sorted() const
Definition vect_generic.hpp:125
bool is_permutation(const size_t k=Size) const
Definition vect_generic.hpp:166
typename array::iterator iterator
Definition vect_generic.hpp:90
VectGeneric permuted(const VectGeneric &u) const
Definition vect_generic.hpp:114
static constexpr size_t size()
Definition vect_generic.hpp:57
uint64_t horiz_sum() const noexcept
Definition vect_generic.hpp:178
size_t first_diff(const VectGeneric &u, size_t bound=Size) const
Definition vect_generic.hpp:73
typename array::const_iterator const_iterator
Definition vect_generic.hpp:91
void partial_min_inplace()
Definition vect_generic.hpp:216
iterator begin()
Definition vect_generic.hpp:92
VectGeneric(const array &_v)
Definition vect_generic.hpp:63
iterator end()
Definition vect_generic.hpp:93
void partial_sums_inplace()
Definition vect_generic.hpp:192
size_t last_diff(const VectGeneric &u, size_t bound=Size) const
Definition vect_generic.hpp:80
void partial_max_inplace()
Definition vect_generic.hpp:204
Expo horiz_min() const
Definition vect_generic.hpp:209
std::array< Expo, Size > array
Definition vect_generic.hpp:58
const_iterator begin() const
Definition vect_generic.hpp:94
VectGeneric eval() const
Definition vect_generic.hpp:221
bool operator!=(const VectGeneric &u) const
Definition vect_generic.hpp:100
VectGeneric partial_sums() const noexcept
Definition vect_generic.hpp:185
Expo operator[](uint64_t i) const
Definition vect_generic.hpp:70
VectGeneric(std::initializer_list< Expo > il, Expo def=0)
Definition vect_generic.hpp:64
Expo horiz_max() const
Definition vect_generic.hpp:197
size_t operator()(const HPCombi::VectGeneric< Size, Expo > &ar) const
Definition vect_generic.hpp:251