Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::glop::Permutation< IndexType > Class Template Reference

#include <permutation.h>

Public Member Functions

 Permutation ()
 
 Permutation (IndexType size)
 
 Permutation (const Permutation &)=delete
 This type is neither copyable nor movable.
 
Permutationoperator= (const Permutation &)=delete
 
IndexType size () const
 
bool empty () const
 
void clear ()
 
void resize (IndexType size, IndexType value)
 
void assign (IndexType size, IndexType value)
 
IndexType & operator[] (IndexType i)
 
IndexType operator[] (IndexType i) const
 
void PopulateFromInverse (const Permutation &inverse)
 
void PopulateFromIdentity ()
 Populates the calling object with the identity permutation.
 
void PopulateRandomly ()
 Populates the calling object with a random permutation.
 
bool Check () const
 Returns true if the calling object contains a permutation, false otherwise.
 
int ComputeSignature () const
 

Detailed Description

template<typename IndexType>
class operations_research::glop::Permutation< IndexType >

Permutation<IndexType> is a template class for storing and using row- and column- permutations, when instantiated with RowIndex and ColIndex respectively.

By a row permutation we mean a permutation that maps the row 'i' of a matrix (or column vector) to the row 'permutation[i]' and in a similar fashion by a column permutation we mean a permutation that maps the column 'j' of a matrix (or row vector) to the column 'permutation[j]'.

A permutation can be represented as a matrix P, but it gets a bit tricky here: P.x permutes the rows of x according to the permutation P but x^T.P permutes the columns of x^T (a row vector) using the INVERSE permutation. That is, to permute the columns of x^T using P, one has to compute x^T.P^{-1} but P^{-1} = P^T so the notation is consistent: If P.x permutes x, then (P.x)^T = x^T.P^T permutes x^T with the same permutation.

So to be clear, if P and Q are permutation matrices, the matrix P.A.Q^{-1} is the image of A through the row permutation P and column permutation Q.

Definition at line 44 of file permutation.h.

Constructor & Destructor Documentation

◆ Permutation() [1/3]

template<typename IndexType >
operations_research::glop::Permutation< IndexType >::Permutation ( )
inline

Definition at line 46 of file permutation.h.

◆ Permutation() [2/3]

template<typename IndexType >
operations_research::glop::Permutation< IndexType >::Permutation ( IndexType size)
inlineexplicit

Definition at line 48 of file permutation.h.

◆ Permutation() [3/3]

template<typename IndexType >
operations_research::glop::Permutation< IndexType >::Permutation ( const Permutation< IndexType > & )
delete

This type is neither copyable nor movable.

Member Function Documentation

◆ assign()

template<typename IndexType >
void operations_research::glop::Permutation< IndexType >::assign ( IndexType size,
IndexType value )
inline

Definition at line 63 of file permutation.h.

◆ Check()

template<typename IndexType >
bool operations_research::glop::Permutation< IndexType >::Check ( ) const

Returns true if the calling object contains a permutation, false otherwise.

Definition at line 163 of file permutation.h.

◆ clear()

template<typename IndexType >
void operations_research::glop::Permutation< IndexType >::clear ( )
inline

Definition at line 57 of file permutation.h.

◆ ComputeSignature()

template<typename IndexType >
int operations_research::glop::Permutation< IndexType >::ComputeSignature ( ) const

Returns the signature of a permutation in O(n), where n is the permutation size. The signature of a permutation is the product of the signature of the cycles defining the permutation. The signature of an odd cycle is 1, while the signature of an even cycle is -1. (Remembering hint: the signature of a swap (a 2-cycle) is -1.)

Definition at line 181 of file permutation.h.

◆ empty()

template<typename IndexType >
bool operations_research::glop::Permutation< IndexType >::empty ( ) const
inline

Definition at line 55 of file permutation.h.

◆ operator=()

template<typename IndexType >
Permutation & operations_research::glop::Permutation< IndexType >::operator= ( const Permutation< IndexType > & )
delete

◆ operator[]() [1/2]

template<typename IndexType >
IndexType & operations_research::glop::Permutation< IndexType >::operator[] ( IndexType i)
inline

Definition at line 67 of file permutation.h.

◆ operator[]() [2/2]

template<typename IndexType >
IndexType operations_research::glop::Permutation< IndexType >::operator[] ( IndexType i) const
inline

Definition at line 69 of file permutation.h.

◆ PopulateFromIdentity()

template<typename IndexType >
void operations_research::glop::Permutation< IndexType >::PopulateFromIdentity ( )

Populates the calling object with the identity permutation.

Definition at line 148 of file permutation.h.

◆ PopulateFromInverse()

template<typename IndexType >
void operations_research::glop::Permutation< IndexType >::PopulateFromInverse ( const Permutation< IndexType > & inverse)

Populates the calling object with the inverse permutation of the parameter inverse.

Implementation

Definition at line 139 of file permutation.h.

◆ PopulateRandomly()

template<typename IndexType >
void operations_research::glop::Permutation< IndexType >::PopulateRandomly ( )

Populates the calling object with a random permutation.

Definition at line 157 of file permutation.h.

◆ resize()

template<typename IndexType >
void operations_research::glop::Permutation< IndexType >::resize ( IndexType size,
IndexType value )
inline

Definition at line 59 of file permutation.h.

◆ size()

template<typename IndexType >
IndexType operations_research::glop::Permutation< IndexType >::size ( ) const
inline

Definition at line 54 of file permutation.h.


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