Skip to content

Permutation

Permutations of indices or lattice sites

Source permutation.hpp

Constructors

Creates an Permutation out of an array of integers, e.g. [0, 2, 1, 3]. If the input array is of size N then every number between 0 and N-1 must occur exactly once, otherwise the Permutation is invalid.

Permutation(array::Vector{Int64})
Permutation(std::vector<int64_t> const &array);

1-indexing in Julia / 0-indexing in C++

To enumerate the sites of a Permutation, we start counting at 1 in Julia and 0 in C++.

Methods

inverse

Computes the inverse permutation.

inverse(perm::Permutation)
// As a member function
Permutation inverse() const;

// As a non-member function
Permutation inverse(Permutation const &p);

"*" operator

Concatenates two permutations by overloading the * operator.

Base.:*(p1::Permutation, p2::Permutation)
Permutation operator*(Permutation const &p1, Permutation const &p2);

size

Returns the size of the permutation, i.e. the number of indices being permuted.

size(perm::Permutation)
// As a member function
int64_t size() const;

// As a non-member function
int64_t size(Permutation const &p);

Usage Example

p1 = Permutation([1, 3, 2, 4])
p2 = Permutation([3, 1, 2, 4])

@show inverse(p1)
@show p1 * p2
Permutation p1 = {0, 2, 1, 3};
Permutation p2 = {2, 0, 1, 3};

XDIAG_SHOW(inverse(p1));
XDIAG_SHOW(p1*p2);