Eigne Matrix Class Library

Dependents:   Eigen_test Odometry_test AttitudeEstimation_usingTicker MPU9250_Quaternion_Binary_Serial ... more

Embed: (wiki syntax)

« Back to documentation index

PermutationBase< Derived > Class Template Reference

PermutationBase< Derived > Class Template Reference
[Core module]

Base class for permutations. More...

#include <PermutationMatrix.h>

Inherits Eigen::EigenBase< Derived >.

Public Member Functions

template<typename OtherDerived >
Derived & operator= (const PermutationBase< OtherDerived > &other)
 Copies the other permutation into *this.
template<typename OtherDerived >
Derived & operator= (const TranspositionsBase< OtherDerived > &tr)
 Assignment from the Transpositions tr.
Derived & operator= (const PermutationBase &other)
 This is a special case of the templated operator=.
Index rows () const
Index cols () const
Index size () const
DenseMatrixType toDenseMatrix () const
const IndicesType & indices () const
 const version of indices().
IndicesType & indices ()
void resize (Index newSize)
 Resizes to given size.
void setIdentity ()
 Sets *this to be the identity permutation matrix.
void setIdentity (Index newSize)
 Sets *this to be the identity permutation matrix of given size.
Derived & applyTranspositionOnTheLeft (Index i, Index j)
 Multiplies *this by the transposition $(ij)$ on the left.
Derived & applyTranspositionOnTheRight (Index i, Index j)
 Multiplies *this by the transposition $(ij)$ on the right.
Transpose< PermutationBaseinverse () const
Transpose< PermutationBasetranspose () const
template<typename Other >
PlainPermutationType operator* (const PermutationBase< Other > &other) const
template<typename Other >
PlainPermutationType operator* (const Transpose< PermutationBase< Other > > &other) const
Index determinant () const
Derived & derived ()
const Derived & derived () const

Friends

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

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

Definition at line 53 of file PermutationMatrix.h.


Member Function Documentation

Derived& applyTranspositionOnTheLeft ( Index  i,
Index  j 
)

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)

Definition at line 171 of file PermutationMatrix.h.

Derived& applyTranspositionOnTheRight ( Index  i,
Index  j 
)

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)

Definition at line 190 of file PermutationMatrix.h.

Index cols ( void   ) const
Returns:
the number of columns

Reimplemented from EigenBase< Derived >.

Definition at line 111 of file PermutationMatrix.h.

Derived& derived (  ) [inherited]
Returns:
a reference to the derived object

Definition at line 34 of file EigenBase.h.

const Derived& derived (  ) const [inherited]
Returns:
a const reference to the derived object

Definition at line 36 of file EigenBase.h.

Index 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.

Definition at line 258 of file PermutationMatrix.h.

IndicesType& indices (  )
Transpose<PermutationBase> inverse (  ) const
Returns:
the inverse permutation matrix.
Note:

Definition at line 201 of file PermutationMatrix.h.

PlainPermutationType operator* ( const PermutationBase< Other > &  other ) const
Returns:
the product permutation matrix.
Note:

Definition at line 235 of file PermutationMatrix.h.

PlainPermutationType operator* ( const Transpose< PermutationBase< Other > > &  other ) const
Returns:
the product of a permutation with another inverse permutation.
Note:

Definition at line 243 of file PermutationMatrix.h.

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

Copies the other permutation into *this.

Definition at line 80 of file PermutationMatrix.h.

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

Assignment from the Transpositions tr.

Definition at line 88 of file PermutationMatrix.h.

Derived& operator= ( const PermutationBase< Derived > &  other )

This is a special case of the templated operator=.

Its purpose is to prevent a default operator= from hiding the templated operator=.

Definition at line 100 of file PermutationMatrix.h.

void resize ( Index  newSize )

Resizes to given size.

Definition at line 142 of file PermutationMatrix.h.

Index rows ( void   ) const
Returns:
the number of rows

Reimplemented from EigenBase< Derived >.

Definition at line 108 of file PermutationMatrix.h.

void setIdentity (  )

Sets *this to be the identity permutation matrix.

Definition at line 148 of file PermutationMatrix.h.

void setIdentity ( Index  newSize )

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

Definition at line 156 of file PermutationMatrix.h.

Index size (  ) const
Returns:
the size of a side of the respective square matrix, i.e., the number of indices

Reimplemented from EigenBase< Derived >.

Definition at line 114 of file PermutationMatrix.h.

DenseMatrixType 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.

Definition at line 130 of file PermutationMatrix.h.

Transpose<PermutationBase> transpose (  ) const
Returns:
the tranpose permutation matrix.
Note:

Definition at line 207 of file PermutationMatrix.h.


Friends And Related Function Documentation

PlainPermutationType operator* ( const Transpose< PermutationBase< Other > > &  other,
const PermutationBase< Derived > &  perm 
) [friend]
Returns:
the product of an inverse permutation with another permutation.
Note:

Definition at line 251 of file PermutationMatrix.h.