template<typename Derived>
Eigen::PermutationBase class

Base class for permutations.

Template parameters
Derived the 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.

Base classes

template<typename Derived>
class EigenBase

Derived classes

template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex>
class PermutationMatrix
Permutation matrix.

Public functions

auto applyTranspositionOnTheLeft(Index i, Index j) -> Derived&
auto applyTranspositionOnTheRight(Index i, Index j) -> Derived&
auto cols() const -> Index
auto determinant() const -> Index
auto indices() const -> const IndicesType&
auto indices() -> IndicesType&
auto inverse() const -> InverseReturnType
template<typename Other>
auto operator*(const PermutationBase<Other>& other) const -> PlainPermutationType
template<typename Other>
auto operator*(const InverseImpl<Other, PermutationStorage>& other) const -> PlainPermutationType
template<typename OtherDerived>
auto operator=(const PermutationBase<OtherDerived>& other) -> Derived&
template<typename OtherDerived>
auto operator=(const TranspositionsBase<OtherDerived>& tr) -> Derived&
void resize(Index newSize)
auto rows() const -> Index
void setIdentity()
void setIdentity(Index newSize)
auto size() const -> Index
auto toDenseMatrix() const -> DenseMatrixType
auto transpose() const -> InverseReturnType

Friends

template<typename Other>
auto operator*(const InverseImpl<Other, PermutationStorage>& other, const PermutationBase& perm) -> PlainPermutationType

Function documentation

template<typename Derived>
Derived& Eigen::PermutationBase<Derived>::applyTranspositionOnTheLeft(Index i, Index j)

Returns a reference to *this.

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

template<typename Derived>
Derived& Eigen::PermutationBase<Derived>::applyTranspositionOnTheRight(Index i, Index j)

Returns a reference to *this.

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

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

template<typename Derived>
Index Eigen::PermutationBase<Derived>::cols() const

Returns the number of columns

template<typename Derived>
Index Eigen::PermutationBase<Derived>::determinant() const

Returns the determinant of the permutation matrix, which is either 1 or -1 depending on the parity of the permutation.

This function is O(n) procedure allocating a buffer of n booleans.

template<typename Derived>
const IndicesType& Eigen::PermutationBase<Derived>::indices() const

const version of indices().

template<typename Derived>
IndicesType& Eigen::PermutationBase<Derived>::indices()

Returns a reference to the stored array representing the permutation.

template<typename Derived>
InverseReturnType Eigen::PermutationBase<Derived>::inverse() const

Returns the inverse permutation matrix.

template<typename Derived> template<typename Other>
PlainPermutationType Eigen::PermutationBase<Derived>::operator*(const PermutationBase<Other>& other) const

Returns the product permutation matrix.

template<typename Derived> template<typename Other>
PlainPermutationType Eigen::PermutationBase<Derived>::operator*(const InverseImpl<Other, PermutationStorage>& other) const

Returns the product of a permutation with another inverse permutation.

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

Copies the other permutation into *this

template<typename Derived> template<typename OtherDerived>
Derived& Eigen::PermutationBase<Derived>::operator=(const TranspositionsBase<OtherDerived>& tr)

Assignment from the Transpositions tr

template<typename Derived>
void Eigen::PermutationBase<Derived>::resize(Index newSize)

Resizes to given size.

template<typename Derived>
Index Eigen::PermutationBase<Derived>::rows() const

Returns the number of rows

template<typename Derived>
void Eigen::PermutationBase<Derived>::setIdentity()

Sets *this to be the identity permutation matrix

template<typename Derived>
void Eigen::PermutationBase<Derived>::setIdentity(Index newSize)

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

template<typename Derived>
Index Eigen::PermutationBase<Derived>::size() const

Returns the size of a side of the respective square matrix, i.e., the number of indices

template<typename Derived>
DenseMatrixType Eigen::PermutationBase<Derived>::toDenseMatrix() const

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.

template<typename Derived>
InverseReturnType Eigen::PermutationBase<Derived>::transpose() const

Returns the tranpose permutation matrix.

template<typename Derived> template<typename Other>
PlainPermutationType operator*(const InverseImpl<Other, PermutationStorage>& other, const PermutationBase& perm)

Returns the product of an inverse permutation with another permutation.