Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <permutation.h>
Public Member Functions | |
Permutation () | |
Permutation (IndexType size) | |
Permutation (const Permutation &)=delete | |
This type is neither copyable nor movable. | |
Permutation & | operator= (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 |
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.
|
inline |
Definition at line 46 of file permutation.h.
|
inlineexplicit |
Definition at line 48 of file permutation.h.
|
delete |
This type is neither copyable nor movable.
|
inline |
Definition at line 63 of file permutation.h.
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.
|
inline |
Definition at line 57 of file permutation.h.
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.
|
inline |
Definition at line 55 of file permutation.h.
|
delete |
|
inline |
Definition at line 67 of file permutation.h.
|
inline |
Definition at line 69 of file permutation.h.
void operations_research::glop::Permutation< IndexType >::PopulateFromIdentity | ( | ) |
Populates the calling object with the identity permutation.
Definition at line 148 of file permutation.h.
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.
void operations_research::glop::Permutation< IndexType >::PopulateRandomly | ( | ) |
Populates the calling object with a random permutation.
Definition at line 157 of file permutation.h.
|
inline |
Definition at line 59 of file permutation.h.
|
inline |
Definition at line 54 of file permutation.h.