![]() |
Google OR-Tools v9.12
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 |
const IndexType * | data () const |
StrictITISpan< IndexType, const IndexType > | const_view () 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 47 of file permutation.h.
|
inline |
Definition at line 49 of file permutation.h.
|
inlineexplicit |
Definition at line 51 of file permutation.h.
|
delete |
This type is neither copyable nor movable.
|
inline |
Definition at line 66 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 177 of file permutation.h.
|
inline |
Definition at line 60 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 195 of file permutation.h.
|
inline |
Definition at line 97 of file permutation.h.
|
inline |
For hot-loops it might be slighlty faster to cache the pointer and avoid bound checking on each [] access.
Definition at line 95 of file permutation.h.
|
inline |
Definition at line 58 of file permutation.h.
|
delete |
|
inline |
Definition at line 68 of file permutation.h.
|
inline |
Definition at line 70 of file permutation.h.
void operations_research::glop::Permutation< IndexType >::PopulateFromIdentity | ( | ) |
Populates the calling object with the identity permutation.
Definition at line 162 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 153 of file permutation.h.
void operations_research::glop::Permutation< IndexType >::PopulateRandomly | ( | ) |
Populates the calling object with a random permutation.
Definition at line 171 of file permutation.h.
|
inline |
Definition at line 62 of file permutation.h.
|
inline |
Definition at line 57 of file permutation.h.