20#ifndef HPCOMBI_VECT_GENERIC_HPP_
21#define HPCOMBI_VECT_GENERIC_HPP_
29#include <initializer_list>
40template <
size_t Size,
typename Expo = u
int8_t>
42 std::sort(v.begin(), v.end());
48template <
size_t Size,
typename Expo = u
int8_t>
struct VectGeneric {
49 static constexpr size_t size() {
return Size; }
50 using array = std::array<Expo, Size>;
58 std::copy(il.begin(), il.end(),
v.begin());
59 std::fill(
v.begin() + il.size(),
v.end(), def);
66 for (
size_t i = 0; i < bound; i++)
75 if (u[bound] !=
v[bound])
98 return (diff != Size) &&
v[diff] < u[diff];
103 return (diff == Size) ? 0 : int8_t(
v[diff]) - int8_t(u[diff]);
108 for (uint64_t i = 0; i < Size; i++) {
115 void sort() { std::sort(
v.begin(),
v.end()); }
118 for (uint64_t i = 1; i < Size; i++)
125 static std::random_device rd;
126 static std::mt19937 g(rd());
129 std::shuffle(
res.begin(),
res.end(), g);
134 for (uint64_t i = 0; i < bound; i++)
140 for (uint64_t i = 0; i < bound; i++)
146 for (int64_t i = bound - 1; i >= 0; i--)
152 for (int64_t i = bound - 1; i >= 0; i--)
160 std::sort(temp.begin(), temp.end());
161 for (uint64_t i = 0; i < Size; i++)
164 for (uint64_t i = k; i < Size; i++)
172 for (uint64_t i = 0; i < Size; i++)
179 for (uint64_t i = 1; i < Size; i++)
185 for (uint64_t i = 1; i < Size; i++)
191 for (uint64_t i = 1; i < Size; i++)
197 for (uint64_t i = 1; i < Size; i++)
198 v[i] = std::max(
v[i],
v[i - 1]);
203 for (uint64_t i = 1; i < Size; i++)
209 for (uint64_t i = 1; i < Size; i++)
210 v[i] = std::min(
v[i],
v[i - 1]);
215 for (
size_t i = 0; i < Size; i++)
222static_assert(std::is_trivial<VectGeneric<12>>(),
223 "VectGeneric is not a trivial class !");
229template <
size_t Size,
typename Expo>
232 stream <<
"{" << std::setw(2) << unsigned(v[0]);
233 for (
unsigned i = 1; i < Size; ++i)
234 stream <<
"," << std::setw(2) << unsigned(v[i]);
239template <
size_t Size,
typename Expo>
240struct hash<
HPCombi::VectGeneric<Size, Expo>> {
243 for (
size_t i = 0; i < Size; i++)
244 h = hash<Expo>()(ar[i]) + (h << 6) + (h << 16) - h;
#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
std::array< Expo, Size > sorted_vect(std::array< Expo, Size > v)
Definition vect_generic.hpp:41
std::ostream & operator<<(std::ostream &os, HPCombi::BMat8 const &bm)
Definition bmat8_impl.hpp:508
A generic class for combinatorial integer vectors.
Definition vect_generic.hpp:48
const_iterator end() const
Definition vect_generic.hpp:87
bool operator<(const VectGeneric &u) const
Definition vect_generic.hpp:96
Expo value_type
Definition vect_generic.hpp:81
bool operator==(const VectGeneric &u) const
Definition vect_generic.hpp:89
int8_t less_partial(const VectGeneric &u, int k) const
Definition vect_generic.hpp:101
uint64_t last_zero(size_t bound=Size) const
Definition vect_generic.hpp:151
Expo & operator[](uint64_t i)
Definition vect_generic.hpp:63
void sort()
Definition vect_generic.hpp:115
array v
Definition vect_generic.hpp:51
uint64_t last_non_zero(size_t bound=Size) const
Definition vect_generic.hpp:145
uint64_t first_zero(size_t bound=Size) const
Definition vect_generic.hpp:139
uint64_t first_non_zero(size_t bound=Size) const
Definition vect_generic.hpp:133
static VectGeneric random()
Definition vect_generic.hpp:124
bool is_sorted() const
Definition vect_generic.hpp:117
bool is_permutation(const size_t k=Size) const
Definition vect_generic.hpp:158
typename array::iterator iterator
Definition vect_generic.hpp:82
VectGeneric permuted(const VectGeneric &u) const
Definition vect_generic.hpp:106
static constexpr size_t size()
Definition vect_generic.hpp:49
uint64_t horiz_sum() const noexcept
Definition vect_generic.hpp:170
size_t first_diff(const VectGeneric &u, size_t bound=Size) const
Definition vect_generic.hpp:65
typename array::const_iterator const_iterator
Definition vect_generic.hpp:83
void partial_min_inplace()
Definition vect_generic.hpp:208
iterator begin()
Definition vect_generic.hpp:84
VectGeneric(const array &_v)
Definition vect_generic.hpp:55
iterator end()
Definition vect_generic.hpp:85
void partial_sums_inplace()
Definition vect_generic.hpp:184
size_t last_diff(const VectGeneric &u, size_t bound=Size) const
Definition vect_generic.hpp:72
void partial_max_inplace()
Definition vect_generic.hpp:196
Expo horiz_min() const
Definition vect_generic.hpp:201
std::array< Expo, Size > array
Definition vect_generic.hpp:50
const_iterator begin() const
Definition vect_generic.hpp:86
VectGeneric eval() const
Definition vect_generic.hpp:213
bool operator!=(const VectGeneric &u) const
Definition vect_generic.hpp:92
VectGeneric partial_sums() const noexcept
Definition vect_generic.hpp:177
Expo operator[](uint64_t i) const
Definition vect_generic.hpp:62
VectGeneric(std::initializer_list< Expo > il, Expo def=0)
Definition vect_generic.hpp:56
Expo horiz_max() const
Definition vect_generic.hpp:189
size_t operator()(const HPCombi::VectGeneric< Size, Expo > &ar) const
Definition vect_generic.hpp:241