HPCombi
High Performance Combinatorics in C++ using vector instructions v1.1.2
Toggle main menu visibility
Loading...
Searching...
No Matches
include
hpcombi
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
22
23
#ifndef HPCOMBI_PERM_GENERIC_HPP_
24
#define HPCOMBI_PERM_GENERIC_HPP_
25
26
#include <algorithm>
// for shuffle
27
#include <array>
// for array
28
#include <cstddef>
// for size_t
29
#include <cstdint>
// for uint64_t, uint8_t
30
#include <functional>
// for hash
31
#include <initializer_list>
// for initializer_list
32
#include <memory>
// for hash
33
#include <random>
// for mt19937
34
#include <type_traits>
// for is_trivial
35
36
#include "
debug.hpp
"
// for HPCOMBI_ASSERT
37
#include "
vect_generic.hpp
"
// for VectGeneric
38
39
namespace
HPCombi
{
40
49
template
<
size_t
Size,
typename
Expo = u
int
8_t>
50
struct
PermGeneric
:
public
VectGeneric
<Size, Expo> {
51
using
vect
=
VectGeneric<Size, Expo>
;
52
53
static
constexpr
size_t
size
() {
return
Size; }
54
55
PermGeneric
() =
default
;
56
PermGeneric
(
const
vect
v
) :
vect
(
v
) {}
// NOLINT
57
// Not marked explicit because we want to be able to pass non-initializer
58
// lists here
59
PermGeneric
(std::initializer_list<Expo> il);
// NOLINT
60
61
PermGeneric
operator*
(
const
PermGeneric
&p)
const
{
62
return
this->
permuted
(p);
63
}
64
static
PermGeneric
one
() {
return
PermGeneric
({}); }
65
static
PermGeneric
elementary_transposition
(uint64_t i);
66
67
PermGeneric
inverse
()
const
;
68
static
PermGeneric
random
();
69
70
vect
lehmer
()
const
;
71
uint64_t
length
()
const
;
72
uint64_t
nb_descents
()
const
;
73
uint64_t
nb_cycles
()
const
;
74
75
bool
left_weak_leq
(
PermGeneric
other)
const
;
76
};
77
79
// Memory layout concepts check //////////////////////////////////////////////
81
82
static_assert
(
sizeof
(VectGeneric<12>) ==
sizeof
(PermGeneric<12>),
83
"VectGeneric and PermGeneric have a different memory layout !"
);
84
static_assert
(std::is_trivial<PermGeneric<12>>(),
85
"PermGeneric is not trivial !"
);
86
87
}
// namespace HPCombi
88
89
#include "
perm_generic_impl.hpp
"
90
91
#endif
// HPCOMBI_PERM_GENERIC_HPP_
debug.hpp
defines the macro HPCOMBI_ASSERT
HPCombi
Definition
bmat16.hpp:39
perm_generic_impl.hpp
implementation of perm_generic.hpp ; this file should not be included directly.
HPCombi::PermGeneric
Vanilla (ie NOT optimized) implementation of a permutation, used to check for test correctness and as...
Definition
perm_generic.hpp:50
HPCombi::PermGeneric::length
uint64_t length() const
Definition
perm_generic_impl.hpp:75
HPCombi::PermGeneric::PermGeneric
PermGeneric(const vect v)
Definition
perm_generic.hpp:56
HPCombi::PermGeneric::left_weak_leq
bool left_weak_leq(PermGeneric other) const
Definition
perm_generic_impl.hpp:108
HPCombi::PermGeneric::vect
VectGeneric< Size, Expo > vect
Definition
perm_generic.hpp:51
HPCombi::PermGeneric::PermGeneric
PermGeneric()=default
HPCombi::PermGeneric::operator*
PermGeneric operator*(const PermGeneric &p) const
Definition
perm_generic.hpp:61
HPCombi::PermGeneric::elementary_transposition
static PermGeneric elementary_transposition(uint64_t i)
Definition
perm_generic_impl.hpp:38
HPCombi::PermGeneric::random
static PermGeneric random()
Definition
perm_generic_impl.hpp:55
HPCombi::PermGeneric::size
static constexpr size_t size()
Definition
perm_generic.hpp:53
HPCombi::PermGeneric::inverse
PermGeneric inverse() const
Definition
perm_generic_impl.hpp:47
HPCombi::PermGeneric::nb_cycles
uint64_t nb_cycles() const
Definition
perm_generic_impl.hpp:94
HPCombi::PermGeneric::lehmer
vect lehmer() const
Definition
perm_generic_impl.hpp:65
HPCombi::PermGeneric::one
static PermGeneric one()
Definition
perm_generic.hpp:64
HPCombi::PermGeneric::nb_descents
uint64_t nb_descents() const
Definition
perm_generic_impl.hpp:85
HPCombi::VectGeneric< Size, uint8_t >::v
array v
Definition
vect_generic.hpp:59
HPCombi::VectGeneric< Size, uint8_t >::permuted
VectGeneric permuted(const VectGeneric &u) const
Definition
vect_generic.hpp:114
HPCombi::VectGeneric< Size, uint8_t >::VectGeneric
VectGeneric()=default
vect_generic.hpp
HPCombi::VectGeneric.
Generated by
1.17.0