PermutationBase< Derived > Class Template Reference

Base class for permutations. More...

#include <PermutationMatrix.h>

+ Inheritance diagram for PermutationBase< Derived >:

Public Member Functions

Derived & applyTranspositionOnTheLeft (Index i, Index j)
 
Derived & applyTranspositionOnTheRight (Index i, Index j)
 
Index cols () const
 
Derived & derived ()
 
const Derived & derived () const
 
IndicesType & indices ()
 
const IndicesType & indices () const
 
Transpose< PermutationBaseinverse () const
 
template<typename Other>
PlainPermutationType operator* (const PermutationBase< Other > &other) const
 
template<typename Other>
PlainPermutationType operator* (const Transpose< PermutationBase< Other > > &other) const
 
template<typename OtherDerived>
Derived & operator= (const PermutationBase< OtherDerived > &other)
 
template<typename OtherDerived>
Derived & operator= (const TranspositionsBase< OtherDerived > &tr)
 
void resize (Index size)
 
Index rows () const
 
void setIdentity ()
 
void setIdentity (Index size)
 
Index size () const
 
DenseMatrixType toDenseMatrix () const
 
Transpose< PermutationBasetranspose () const
 

Detailed Description

template<typename Derived>
class Eigen::PermutationBase< Derived >

Base class for permutations.

Parameters
Derivedthe derived class

This class is the base class for all expressions representing a permutation matrix, internally stored as a vector of integers. The convention followed here is that if $ \sigma $ is a permutation, the corresponding permutation matrix $ P_\sigma $ is such that if $ (e_1,\ldots,e_p) $ is the canonical basis, we have:

\[ P_\sigma(e_i) = e_{\sigma(i)}. \]

This convention ensures that for any two permutations $ \sigma, \tau $, we have:

\[ P_{\sigma\circ\tau} = P_\sigma P_\tau. \]

Permutation matrices are square and invertible.

Notice that in addition to the member functions and operators listed here, there also are non-member operator* to multiply any kind of permutation object with any kind of matrix expression (MatrixBase) on either side.

See also
class PermutationMatrix, class PermutationWrapper

Member Function Documentation

◆ applyTranspositionOnTheLeft()

template<typename Derived>
Derived & applyTranspositionOnTheLeft ( Index i,
Index j )
inline

Multiplies *this by the transposition $(ij)$ on the left.

Returns
a reference to *this.
Warning
This is much slower than applyTranspositionOnTheRight(int,int): this has linear complexity and requires a lot of branching.
See also
applyTranspositionOnTheRight(int,int)

◆ applyTranspositionOnTheRight()

template<typename Derived>
Derived & applyTranspositionOnTheRight ( Index i,
Index j )
inline

Multiplies *this by the transposition $(ij)$ on the right.

Returns
a reference to *this.

This is a fast operation, it only consists in swapping two indices.

See also
applyTranspositionOnTheLeft(int,int)

Referenced by PermutationBase< PermutationMatrix >::operator=().

◆ cols()

template<typename Derived>
Index cols ( ) const
inline
Returns
the number of columns

◆ derived() [1/2]

template<typename Derived>
Derived & derived ( )
inlineinherited
Returns
a reference to the derived object

Referenced by MatrixBase< Derived >::applyOnTheLeft(), MatrixBase< Derived >::applyOnTheRight(), PermutationBase< PermutationMatrix >::applyTranspositionOnTheLeft(), PermutationBase< PermutationMatrix >::applyTranspositionOnTheRight(), SparseMatrixBase< SparseDenseOuterProduct >::binaryExpr(), cols(), SparseMatrixBase< SparseDenseOuterProduct >::imag(), PermutationBase< PermutationMatrix >::indices(), PermutationBase< PermutationMatrix >::indices(), SparseMatrixBase< Derived >::innerVector(), SparseMatrixBase< Derived >::innerVector(), SparseMatrixBase< SparseDenseOuterProduct >::innerVector(), SparseMatrixBase< Derived >::innerVectors(), SparseMatrixBase< Derived >::innerVectors(), PermutationBase< PermutationMatrix >::inverse(), PermutationBase< PermutationMatrix >::operator*(), RotationBase< AngleAxis< _Scalar >, 3 >::operator*(), RotationBase< AngleAxis< _Scalar >, 3 >::operator*, SparseMatrixBase< Derived >::operator*(), SparseMatrixBase< Derived >::operator*(), SparseMatrixBase< SparseDenseOuterProduct >::operator*, Transform< Scalar, Dim, Mode, Options >::operator*, Transform< Scalar, Dim, Mode, Options >::operator*(), Translation< _Scalar, _Dim >::operator*(), Translation< Scalar, Dim >::operator*, MatrixBase< Derived >::operator*=(), DenseBase< Derived >::operator=(), PermutationBase< PermutationMatrix >::operator=(), PermutationBase< PermutationMatrix >::operator=(), PlainObjectBase< Array >::operator=(), Transform< Scalar, Dim, Mode, Options >::operator=(), PlainObjectBase< Array >::PlainObjectBase(), PlainObjectBase< Array >::resizeLike(), rows(), CholmodBase< _MatrixType, _UpLo, CholmodSimplicialLLT >::solve(), IterativeSolverBase< BiCGSTAB >::solve(), SimplicialCholeskyBase< SimplicialLLT >::solve(), SparseMatrix< Scalar, RowMajor >::SparseMatrix(), SparseMatrix< Scalar, RowMajor >::SparseMatrix(), PermutationBase< PermutationMatrix >::toDenseMatrix(), Transform< Scalar, Dim, Mode, Options >::Transform(), PermutationBase< PermutationMatrix >::transpose(), and SparseMatrixBase< SparseDenseOuterProduct >::unaryExpr().

◆ derived() [2/2]

template<typename Derived>
const Derived & derived ( ) const
inlineinherited
Returns
a const reference to the derived object

◆ indices() [1/2]

template<typename Derived>
IndicesType & indices ( )
inline
Returns
a reference to the stored array representing the permutation.

◆ indices() [2/2]

◆ inverse()

template<typename Derived>
Transpose< PermutationBase > inverse ( ) const
inline
Returns
the inverse permutation matrix.
Note
This function returns the result by value. In order to make that efficient, it is implemented as just a return statement using a special constructor, hopefully allowing the compiler to perform a RVO (return value optimization).

◆ operator*() [1/2]

template<typename Derived>
template<typename Other>
PlainPermutationType operator* ( const PermutationBase< Other > & other) const
inline
Returns
the product permutation matrix.
Note
This function returns the result by value. In order to make that efficient, it is implemented as just a return statement using a special constructor, hopefully allowing the compiler to perform a RVO (return value optimization).

◆ operator*() [2/2]

template<typename Derived>
template<typename Other>
PlainPermutationType operator* ( const Transpose< PermutationBase< Other > > & other) const
inline
Returns
the product of a permutation with another inverse permutation.
Note
This function returns the result by value. In order to make that efficient, it is implemented as just a return statement using a special constructor, hopefully allowing the compiler to perform a RVO (return value optimization).

◆ operator=() [1/2]

template<typename Derived>
template<typename OtherDerived>
Derived & operator= ( const PermutationBase< OtherDerived > & other)
inline

Copies the other permutation into *this

◆ operator=() [2/2]

template<typename Derived>
template<typename OtherDerived>
Derived & operator= ( const TranspositionsBase< OtherDerived > & tr)
inline

Assignment from the Transpositions tr

◆ resize()

template<typename Derived>
void resize ( Index size)
inline

Resizes to given size.

Referenced by PermutationBase< PermutationMatrix >::setIdentity().

◆ rows()

template<typename Derived>
Index rows ( ) const
inline
Returns
the number of rows

◆ setIdentity() [1/2]

template<typename Derived>
void setIdentity ( )
inline

Sets *this to be the identity permutation matrix

Referenced by PermutationBase< PermutationMatrix >::operator=(), and PermutationBase< PermutationMatrix >::setIdentity().

◆ setIdentity() [2/2]

template<typename Derived>
void setIdentity ( Index size)
inline

Sets *this to be the identity permutation matrix of given size.

◆ size()

◆ toDenseMatrix()

template<typename Derived>
DenseMatrixType toDenseMatrix ( ) const
inline
Returns
a Matrix object initialized from this permutation matrix. Notice that it is inefficient to return this Matrix object by value. For efficiency, favor using the Matrix constructor taking EigenBase objects.

◆ transpose()

template<typename Derived>
Transpose< PermutationBase > transpose ( ) const
inline
Returns
the tranpose permutation matrix.
Note
This function returns the result by value. In order to make that efficient, it is implemented as just a return statement using a special constructor, hopefully allowing the compiler to perform a RVO (return value optimization).

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