CASM
1.1.0
A Clusters Approach to Statistical Mechanics
|
#include <Permutation.hh>
Permutation is a an operator that permutes indices or items in a list. Permutations are defined such that for an initial array std::vector<THINGS> before;
A Permutation Permutation my_perm;
and an output array after permutation std::vector<THINGS> after = my_perm.permute(before);
The following relation is satisfied after[i] = before[my_perm[i]];
This is written after = my_perm*before
Permutations combine after = perm2*perm1*before after = comb_perm*before; comb_perm = perm2*perm1
Which satisfies after[i] = before[perm1[perm2[i]]] after[i] = before[comb_perm[i]]; comb_perm[i] = perm1[perm2[i]]
Definition at line 40 of file Permutation.hh.
Public Member Functions | |
Permutation (Index N) | |
template<typename Iterator > | |
Permutation (Iterator begin, Iterator end) | |
Permutation (const std::vector< Index > &init_perm) | |
Permutation (std::vector< Index > &&init_perm) | |
Index | size () const |
const std::vector< Index > & | perm_array () const |
bool | is_perm () const |
bool | has_fixed_points () const |
Checks whether any indices remain unchanged by permutation. More... | |
Index | character () const |
Character of permutation is number of fixed points. More... | |
bool | is_identity () const |
Checks whether permutation is identity (i.e., m_perm_aray[i]==i for all i) More... | |
void | append_fixed_points (Index N_new) |
Add new indices that remain unchanged by permutation. More... | |
Permutation | inverse () const |
Construct permutation that undoes the permutation performed by 'this'. More... | |
Permutation | make_block_permutation (const std::vector< Index > &block_dims) const |
Permutation | transformed_by (const Permutation &trans_perm) const |
const Index & | operator[] (Index i) const |
const access of m_perm_array for doing low-level permutation algebra More... | |
Index & | set (Index i) |
non-const access of m_perm_array for doing low-level permutation algebra More... | |
template<typename Container > | |
Container | permute (const Container &_before) const |
Generate permuted copy of indexed container. More... | |
template<typename Container > | |
Container | ipermute (const Container &_before) const |
Generate inversely permuted copy of type-T std::vector. More... | |
template<typename Container > | |
Container | operator* (const Container &_before) const |
Permutation | operator* (const Permutation &RHS) const |
Private Attributes | |
std::vector< Index > | m_perm_array |
|
inlineexplicit |
Definition at line 49 of file Permutation.hh.
|
inline |
Definition at line 54 of file Permutation.hh.
|
inlineexplicit |
Definition at line 55 of file Permutation.hh.
|
inlineexplicit |
Definition at line 57 of file Permutation.hh.
void CASM::Permutation::append_fixed_points | ( | Index | N_new | ) |
Add new indices that remain unchanged by permutation.
Definition at line 98 of file Permutation.cc.
Index CASM::Permutation::character | ( | ) | const |
Character of permutation is number of fixed points.
Definition at line 68 of file Permutation.cc.
bool CASM::Permutation::has_fixed_points | ( | ) | const |
Checks whether any indices remain unchanged by permutation.
Definition at line 79 of file Permutation.cc.
Permutation CASM::Permutation::inverse | ( | ) | const |
Construct permutation that undoes the permutation performed by 'this'.
Construct permutation that undoes the permutation performed by 'this' Inverse operation is calculated the same, regardless of permutation convention
Definition at line 111 of file Permutation.cc.
Container CASM::Permutation::ipermute | ( | const Container & | before_array | ) | const |
Generate inversely permuted copy of type-T std::vector.
Generate inversely permuted copy of type-T std::vector THIS IMPLEMENTATION DEPENDS ON DEFINITION OF PERMUTATION CONVENTION Note: To switch conventions, swap names of permute and ipermute
Definition at line 144 of file Permutation.hh.
bool CASM::Permutation::is_identity | ( | ) | const |
Checks whether permutation is identity (i.e., m_perm_aray[i]==i for all i)
Checks whether any indices remain unchanged by permutation.
Definition at line 89 of file Permutation.cc.
bool CASM::Permutation::is_perm | ( | ) | const |
Checks that m_perm_array contains values from 0 to m_perm_array.size()-1 and that no value is repeated
Checks that m_perm_array contains values from 0 to m_perm_array.size()-1 and that no value is repeated does not depend on definition of permutation convention
Definition at line 57 of file Permutation.cc.
Permutation CASM::Permutation::make_block_permutation | ( | const std::vector< Index > & | block_dims | ) | const |
Construct permutation of dimension size()*block_dims.sum() that describes the effect of permuting N blocks, where the i'th block has dimension block_dimsi
Construct permutation of dimension size()*sum(block_dims) that describes the effect of permuting N blocks, where the i'th block has dimension block_dimsi
Definition at line 123 of file Permutation.cc.
|
inline |
Definition at line 108 of file Permutation.hh.
Permutation CASM::Permutation::operator* | ( | const Permutation & | RHS | ) | const |
Get the effective Permutation induced by applying RHS, followed by *this I don't think this depends on definition of permutation convention
Definition at line 163 of file Permutation.cc.
const access of m_perm_array for doing low-level permutation algebra
Definition at line 94 of file Permutation.hh.
|
inline |
Definition at line 62 of file Permutation.hh.
Container CASM::Permutation::permute | ( | const Container & | before_vec | ) | const |
Generate permuted copy of indexed container.
Generate permuted copy of type-T std::vector THIS IMPLEMENTATION DEPENDS ON DEFINITION OF PERMUTATION CONVENTION Note: To switch conventions, swap names of permute and ipermute
Definition at line 124 of file Permutation.hh.
non-const access of m_perm_array for doing low-level permutation algebra
Definition at line 97 of file Permutation.hh.
|
inline |
Definition at line 60 of file Permutation.hh.
Permutation CASM::Permutation::transformed_by | ( | const Permutation & | trans_perm | ) | const |
Rearrange 'this' permutation to form an equivalent permutation for any list that has already been permuted by trans_perm.
Given N distinct objects labeled from 0 to N-1, a permutation 'P_permute' that physically permutes the objects (with labels) in terms of their labels, and a permutation 'L_permute' that permutes their labels only, rewrite 'P_permute' in terms of the relabeling induced by 'L_permute' Rearrange 'this' permutation to form an equivalent permutation for any list that has already been permuted by trans_perm. Does not (nearly certain of this) depend on permutation convention
Definition at line 149 of file Permutation.cc.
|
private |
Permutation array. If m_perm_array[i]==j, then an entry at index 'j' before permutation goes to index 'i' after permutation. Put another way, m_perm_array IS the result of performing the permutation to the list {0,1,2,...,size()-1}
Definition at line 46 of file Permutation.hh.