|
TRIQS/nda 1.3.0
Multi-dimensional array library for C++
|
Tools to create and work with permutations.
Functions | |
| template<typename T, std::integral Int, size_t N> | |
| constexpr std::array< T, N > | nda::permutations::apply (std::array< Int, N > const &p, std::array< T, N > const &a) |
| Apply a permutation to a std::array. | |
| template<typename T, std::integral Int, size_t N> | |
| constexpr std::array< T, N > | nda::permutations::apply_inverse (std::array< Int, N > const &p, std::array< T, N > const &a) |
| Apply the inverse of a permutation to a std::array. | |
| template<std::integral Int, size_t N> | |
| constexpr std::array< Int, N > | nda::permutations::compose (std::array< Int, N > const &p1, std::array< Int, N > const &p2) |
| Composition of two permutations. | |
| template<size_t N> | |
| constexpr std::array< int, N > | nda::permutations::cycle (int p, int pos=N) |
| Perform a forward (partial) cyclic permutation of the identity p times. | |
| template<size_t N> | |
| constexpr std::array< int, N > | nda::decode (uint64_t binary_representation) |
| Decode a uint64_t into a std::array<int, N>. | |
| template<size_t N> | |
| constexpr uint64_t | nda::encode (std::array< int, N > const &a) |
| Encode a std::array<int, N> in a uint64_t. | |
| template<size_t N> | |
| constexpr std::array< int, N > | nda::permutations::identity () |
| Get the identity permutation. | |
| template<std::integral Int, size_t N> | |
| constexpr std::array< Int, N > | nda::permutations::inverse (std::array< Int, N > const &p) |
| Inverse of a permutation. | |
| template<std::integral Int, size_t N> | |
| constexpr bool | nda::permutations::is_valid (std::array< Int, N > const &p) |
| Check if a given array is a valid permutation. | |
| template<size_t N> | |
| constexpr std::array< int, N > | nda::permutations::reverse_identity () |
| Get the reverse identity permutation. | |
| template<size_t N> | |
| constexpr std::array< int, N > | nda::permutations::transposition (int i, int j) |
| Get the permutation representing a single given transposition. | |
|
constexpr |
#include <nda/layout/permutation.hpp>
Apply a permutation to a std::array.
The application of a permutation p to an array a results in a new array b such that b[i] = a[p[i]].
| T | Value type of the array. |
| Int | Integral type. |
| N | Size/Degree of the array/permutation. |
| p | Permutation to apply. |
| a | std::array to apply the permutation to. |
Definition at line 175 of file permutation.hpp.
|
constexpr |
#include <nda/layout/permutation.hpp>
Apply the inverse of a permutation to a std::array.
See also nda::permutations::apply and nda::permutations::inverse.
| T | Value type of the array. |
| Int | Integral type. |
| N | Size/Degree of the array/permutation. |
| p | Permutation to invert and apply. |
| a | std::array to apply the inverse permutation to. |
Definition at line 154 of file permutation.hpp.
|
constexpr |
#include <nda/layout/permutation.hpp>
Composition of two permutations.
The second argument is applied first. Composition is not commutative in general, i.e. compose(p1, p2) != compose(p2, p1).
| Int | Integral type. |
| N | Degree of the permutations. |
| p1 | Permutation to apply second. |
| p2 | Permutation to apply first. |
Definition at line 114 of file permutation.hpp.
|
constexpr |
#include <nda/layout/permutation.hpp>
Perform a forward (partial) cyclic permutation of the identity p times.
The permutation is partial if pos >= 0 && pos < N. In this case, only the first pos elements are permuted, while the rest is left unchanged w.r.t the identity.
| N | Degree of the permutation. |
| p | Number of times to perform the cyclic permutation. |
| pos | Number of elements to permute. If pos < N, the permutation is partial. |
Definition at line 238 of file permutation.hpp.
|
constexpr |
#include <nda/layout/permutation.hpp>
Decode a uint64_t into a std::array<int, N>.
The 64-bit code is split into 4-bit chunks, and each chunk is then decoded into a value in the range [0, 15]. The 4 least significant bits are decoded into the first element, the next 4-bits into second element, and so on.
| N | Size of the array. |
| binary_representation | 64-bit code. |
Definition at line 43 of file permutation.hpp.
|
constexpr |
#include <nda/layout/permutation.hpp>
Encode a std::array<int, N> in a uint64_t.
The values in the array are assumed to be in the range [0, 15]. Then each value is encoded in 4 bits, i.e. the first element is encoded in the 4 least significant bits, the second element in the next 4 bits, and so on.
| N | Size of the array. |
| a | std::array<int, N> to encode. |
Definition at line 60 of file permutation.hpp.
|
constexpr |
#include <nda/layout/permutation.hpp>
Get the identity permutation.
| N | Degree of the permutation. |
Definition at line 189 of file permutation.hpp.
|
constexpr |
#include <nda/layout/permutation.hpp>
Inverse of a permutation.
The inverse, inv, of a permutation p is defined such that compose(p, inv) == compose(inv, p) == identity.
| Int | Integral type. |
| N | Degree of the permutations. |
| p | Permutation to invert. |
Definition at line 134 of file permutation.hpp.
|
constexpr |
#include <nda/layout/permutation.hpp>
Check if a given array is a valid permutation.
A valid permutation is an array of integers with values in the range [0, N - 1] where each value appears exactly once.
| Int | Integral type. |
| N | Degree of the permutation. |
| p | std:::array to check. |
Definition at line 92 of file permutation.hpp.
|
constexpr |
#include <nda/layout/permutation.hpp>
Get the reverse identity permutation.
| N | Degree of the permutation. |
Definition at line 202 of file permutation.hpp.
|
constexpr |
#include <nda/layout/permutation.hpp>
Get the permutation representing a single given transposition.
A transposition is a permutation in which only two elements are different from the identity permutation.
| N | Degree of the permutation. |
| i | First index to transpose. |
| j | Second index to transpose. |
Definition at line 219 of file permutation.hpp.