CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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 Array<THINGS> before;

A Permutation Permutation my_perm;

and an output array after permutation Array<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 35 of file Permutation.hh.

Public Member Functions

 Permutation (Index N)
 
 Permutation (const std::vector< Index > &init_perm)
 
 Permutation (const Array< Index > &init_perm)
 
 Permutation (ReturnArray< Index > &init_perm)
 
Index size () const
 
const Array< Index > & perm_array () const
 
bool is_perm () const
 Checks that m_perm_array contains values from 0 to m_perm_array.size()-1 and that no value is repeated. More...
 
bool has_fixed_points () const
 Checks whether any indices remain unchanged by permutation. 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 Array< 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...
 
const Indexat (Index i) const
 const access of m_perm_array for doing low-level permutation algebra More...
 
template<typename T >
ReturnArray< T > permute (const Array< T > &before_array) const
 Generate permuted copy of type-T Array. More...
 
template<typename T >
std::vector< T > permute (const std::vector< T > &before_array) const
 Generate permuted copy of type-T vector. More...
 
template<typename T >
ReturnArray< T > ipermute (const Array< T > &before_array) const
 Generate inversely permuted copy of type-T Array. More...
 
template<typename T >
ReturnArray< T > operator* (const Array< T > &before_array) const
 
Permutation operator* (const Permutation &RHS) const
 
jsonParserto_json (jsonParser &json) const
 
void from_json (const jsonParser &json)
 

Private Attributes

Array< Indexm_perm_array
 

Constructor & Destructor Documentation

CASM::Permutation::Permutation ( Index  N)
inline

Definition at line 43 of file Permutation.hh.

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

Definition at line 45 of file Permutation.hh.

CASM::Permutation::Permutation ( const Array< Index > &  init_perm)
inline

Definition at line 50 of file Permutation.hh.

CASM::Permutation::Permutation ( ReturnArray< Index > &  init_perm)
inline

Definition at line 51 of file Permutation.hh.

Member Function Documentation

void CASM::Permutation::append_fixed_points ( Index  N_new)

Add new indices that remain unchanged by permutation.

Definition at line 74 of file Permutation.cc.

const Index& CASM::Permutation::at ( Index  i) const
inline

const access of m_perm_array for doing low-level permutation algebra

Definition at line 87 of file Permutation.hh.

void CASM::Permutation::from_json ( const jsonParser json)

re-throw exceptions

Definition at line 149 of file Permutation.cc.

bool CASM::Permutation::has_fixed_points ( ) const

Checks whether any indices remain unchanged by permutation.

Definition at line 64 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 84 of file Permutation.cc.

template<typename T >
ReturnArray< T > CASM::Permutation::ipermute ( const Array< T > &  before_array) const

Generate inversely permuted copy of type-T Array.

Generate inversely permuted copy of type-T Array THIS IMPLEMENTATION DEPENDS ON DEFINITION OF PERMUTATION CONVENTION Note: To switch conventions, swap names of permute and ipermute

Definition at line 163 of file Permutation.hh.

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 52 of file Permutation.cc.

Permutation CASM::Permutation::make_block_permutation ( const Array< 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_dims[i] (N=size()==block_dims.size())

Definition at line 95 of file Permutation.cc.

template<typename T >
ReturnArray<T> CASM::Permutation::operator* ( const Array< T > &  before_array) const
inline

Definition at line 104 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 131 of file Permutation.cc.

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

const access of m_perm_array for doing low-level permutation algebra

Definition at line 82 of file Permutation.hh.

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

Definition at line 57 of file Permutation.hh.

template<typename T >
ReturnArray< T > CASM::Permutation::permute ( const Array< T > &  before_array) const

Generate permuted copy of type-T Array.

Generate permuted copy of type-T Array THIS IMPLEMENTATION DEPENDS ON DEFINITION OF PERMUTATION CONVENTION Note: To switch conventions, swap names of permute and ipermute

Definition at line 126 of file Permutation.hh.

template<typename T >
std::vector< T > CASM::Permutation::permute ( const std::vector< T > &  before_vec) const

Generate permuted copy of type-T vector.

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 145 of file Permutation.hh.

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

Definition at line 53 of file Permutation.hh.

jsonParser & CASM::Permutation::to_json ( jsonParser json) const

Definition at line 138 of file Permutation.cc.

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 118 of file Permutation.cc.

Member Data Documentation

Array<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 40 of file Permutation.hh.


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