CASM  1.1.0
A Clusters Approach to Statistical Mechanics
CASM::Permutation Class Reference

#include <Permutation.hh>

Detailed Description

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 Indexoperator[] (Index i) const
 const access of m_perm_array for doing low-level permutation algebra More...
 
Indexset (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< Indexm_perm_array
 

Constructor & Destructor Documentation

◆ Permutation() [1/4]

CASM::Permutation::Permutation ( Index  N)
inlineexplicit

Definition at line 49 of file Permutation.hh.

◆ Permutation() [2/4]

template<typename Iterator >
CASM::Permutation::Permutation ( Iterator  begin,
Iterator  end 
)
inline

Definition at line 54 of file Permutation.hh.

◆ Permutation() [3/4]

CASM::Permutation::Permutation ( const std::vector< Index > &  init_perm)
inlineexplicit

Definition at line 55 of file Permutation.hh.

◆ Permutation() [4/4]

CASM::Permutation::Permutation ( std::vector< Index > &&  init_perm)
inlineexplicit

Definition at line 57 of file Permutation.hh.

Member Function Documentation

◆ append_fixed_points()

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.

◆ character()

Index CASM::Permutation::character ( ) const

Character of permutation is number of fixed points.

Definition at line 68 of file Permutation.cc.

◆ has_fixed_points()

bool CASM::Permutation::has_fixed_points ( ) const

Checks whether any indices remain unchanged by permutation.

Definition at line 79 of file Permutation.cc.

◆ inverse()

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.

◆ ipermute()

template<typename Container >
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.

◆ is_identity()

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.

◆ is_perm()

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.

◆ make_block_permutation()

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.

◆ operator*() [1/2]

template<typename Container >
Container CASM::Permutation::operator* ( const Container &  _before) const
inline

Definition at line 108 of file Permutation.hh.

◆ operator*() [2/2]

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.

◆ operator[]()

const Index& CASM::Permutation::operator[] ( Index  i) const
inline

const access of m_perm_array for doing low-level permutation algebra

Definition at line 94 of file Permutation.hh.

◆ perm_array()

const std::vector<Index>& CASM::Permutation::perm_array ( ) const
inline

Definition at line 62 of file Permutation.hh.

◆ permute()

template<typename Container >
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.

◆ set()

Index& CASM::Permutation::set ( Index  i)
inline

non-const access of m_perm_array for doing low-level permutation algebra

Definition at line 97 of file Permutation.hh.

◆ size()

Index CASM::Permutation::size ( ) const
inline

Definition at line 60 of file Permutation.hh.

◆ transformed_by()

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.

Member Data Documentation

◆ m_perm_array

std::vector<Index> CASM::Permutation::m_perm_array
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.


The documentation for this class was generated from the following files: