HPCombi
High Performance Combinatorics in C++ using vector instructions v1.0.0
Loading...
Searching...
No Matches
perm_generic.hpp
Go to the documentation of this file.
1//****************************************************************************//
2// Copyright (C) 2016-2024 Florent Hivert <Florent.Hivert@lisn.fr>, //
3// //
4// This file is part of HP-Combi <https://github.com/libsemigroups/HPCombi> //
5// //
6// HP-Combi is free software: you can redistribute it and/or modify it //
7// under the terms of the GNU General Public License as published by the //
8// Free Software Foundation, either version 3 of the License, or //
9// (at your option) any later version. //
10// //
11// HP-Combi is distributed in the hope that it will be useful, but WITHOUT //
12// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //
13// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License //
14// for more details. //
15// //
16// You should have received a copy of the GNU General Public License along //
17// with HP-Combi. If not, see <https://www.gnu.org/licenses/>. //
18//****************************************************************************//
19
20#ifndef HPCOMBI_PERM_GENERIC_HPP_
21#define HPCOMBI_PERM_GENERIC_HPP_
22
23#include <algorithm> // for shuffle
24#include <array> // for array
25#include <cstddef> // for size_t
26#include <cstdint> // for uint64_t, uint8_t
27#include <functional> // for hash
28#include <initializer_list> // for initializer_list
29#include <memory> // for hash
30#include <random> // for mt19937
31#include <type_traits> // for is_trivial
32
33#include "debug.hpp" // for HPCOMBI_ASSERT
34#include "vect_generic.hpp" // for VectGeneric
35
36namespace HPCombi {
37
38template <size_t Size, typename Expo = uint8_t>
39struct PermGeneric : public VectGeneric<Size, Expo> {
41
42 static constexpr size_t size() { return Size; }
43
44 PermGeneric() = default;
45 PermGeneric(const vect v) : vect(v) {} // NOLINT
46 // Not marked explicit because we want to be able to pass non-initializer
47 // lists here
48 PermGeneric(std::initializer_list<Expo> il); // NOLINT
49
51 return this->permuted(p);
52 }
53 static PermGeneric one() { return PermGeneric({}); }
54 static PermGeneric elementary_transposition(uint64_t i);
55
56 PermGeneric inverse() const;
57 static PermGeneric random();
58
59 vect lehmer() const;
60 uint64_t length() const;
61 uint64_t nb_descents() const;
62 uint64_t nb_cycles() const;
63
64 bool left_weak_leq(PermGeneric other) const;
65};
66
68// Memory layout concepts check //////////////////////////////////////////////
70
71static_assert(sizeof(VectGeneric<12>) == sizeof(PermGeneric<12>),
72 "VectGeneric and PermGeneric have a different memory layout !");
73static_assert(std::is_trivial<PermGeneric<12>>(),
74 "PermGeneric is not trivial !");
75
76} // namespace HPCombi
77
78#include "perm_generic_impl.hpp"
79
80#endif // HPCOMBI_PERM_GENERIC_HPP_
Definition bmat8.hpp:41
Definition perm_generic.hpp:39
uint64_t length() const
Definition perm_generic_impl.hpp:71
PermGeneric(const vect v)
Definition perm_generic.hpp:45
bool left_weak_leq(PermGeneric other) const
Definition perm_generic_impl.hpp:104
VectGeneric< Size, Expo > vect
Definition perm_generic.hpp:40
PermGeneric operator*(const PermGeneric &p) const
Definition perm_generic.hpp:50
static PermGeneric elementary_transposition(uint64_t i)
Definition perm_generic_impl.hpp:34
static PermGeneric random()
Definition perm_generic_impl.hpp:51
static constexpr size_t size()
Definition perm_generic.hpp:42
PermGeneric inverse() const
Definition perm_generic_impl.hpp:43
uint64_t nb_cycles() const
Definition perm_generic_impl.hpp:90
vect lehmer() const
Definition perm_generic_impl.hpp:61
static PermGeneric one()
Definition perm_generic.hpp:53
uint64_t nb_descents() const
Definition perm_generic_impl.hpp:81
A generic class for combinatorial integer vectors.
Definition vect_generic.hpp:48
array v
Definition vect_generic.hpp:51
VectGeneric permuted(const VectGeneric &u) const
Definition vect_generic.hpp:106