Public Types | Public Member Functions | Protected Member Functions | Friends

PermutationBase< Derived > Class Template Reference

Base class for permutations. More...

#include <PermutationMatrix.h>

Inheritance diagram for PermutationBase< Derived >:
EigenBase< Derived >

List of all members.

Public Types

enum  {
  Flags = Traits::Flags, CoeffReadCost = Traits::CoeffReadCost, RowsAtCompileTime = Traits::RowsAtCompileTime, ColsAtCompileTime = Traits::ColsAtCompileTime,
  MaxRowsAtCompileTime = Traits::MaxRowsAtCompileTime, MaxColsAtCompileTime = Traits::MaxColsAtCompileTime
}
typedef Traits::IndicesType IndicesType
typedef Traits::Scalar Scalar
typedef Traits::Index Index
typedef Matrix< Scalar,
RowsAtCompileTime,
ColsAtCompileTime,
0, MaxRowsAtCompileTime,
MaxColsAtCompileTime > 
DenseMatrixType
typedef PermutationMatrix
< IndicesType::SizeAtCompileTime,
IndicesType::MaxSizeAtCompileTime,
Index
PlainPermutationType

Public Member Functions

template<typename OtherDerived >
Derived & operator= (const PermutationBase< OtherDerived > &other)
template<typename OtherDerived >
Derived & operator= (const TranspositionsBase< OtherDerived > &tr)
Derived & operator= (const PermutationBase &other)
Index rows () const
Index cols () const
Index size () const
template<typename DenseDerived >
void evalTo (MatrixBase< DenseDerived > &other) const
DenseMatrixType toDenseMatrix () const
const IndicesTypeindices () const
IndicesTypeindices ()
void resize (Index size)
void setIdentity ()
void setIdentity (Index size)
Derived & applyTranspositionOnTheLeft (Index i, Index j)
Derived & applyTranspositionOnTheRight (Index i, Index j)
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

Protected Member Functions

template<typename OtherDerived >
void assignTranspose (const PermutationBase< OtherDerived > &other)
template<typename Lhs , typename Rhs >
void assignProduct (const Lhs &lhs, const Rhs &rhs)

Friends

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

Detailed Description

template<typename Derived>
class PermutationBase< Derived >

Base class for permutations.

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.

See also:
class PermutationMatrix, class PermutationWrapper

Member Typedef Documentation

template<typename Derived>
typedef Matrix<Scalar,RowsAtCompileTime,ColsAtCompileTime,0,MaxRowsAtCompileTime,MaxColsAtCompileTime> PermutationBase< Derived >::DenseMatrixType
template<typename Derived>
typedef Traits::Index PermutationBase< Derived >::Index
template<typename Derived>
typedef PermutationMatrix<IndicesType::SizeAtCompileTime,IndicesType::MaxSizeAtCompileTime,Index> PermutationBase< Derived >::PlainPermutationType
template<typename Derived>
typedef Traits::Scalar PermutationBase< Derived >::Scalar

Member Enumeration Documentation

template<typename Derived>
anonymous enum
Enumerator:
Flags 
CoeffReadCost 
RowsAtCompileTime 
ColsAtCompileTime 
MaxRowsAtCompileTime 
MaxColsAtCompileTime 

Member Function Documentation

template<typename Derived>
Derived& PermutationBase< 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)
template<typename Derived>
Derived& PermutationBase< 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)
template<typename Derived>
template<typename Lhs , typename Rhs >
void PermutationBase< Derived >::assignProduct ( const Lhs &  lhs,
const Rhs &  rhs 
) [inline, protected]
template<typename Derived>
template<typename OtherDerived >
void PermutationBase< Derived >::assignTranspose ( const PermutationBase< OtherDerived > &  other  )  [inline, protected]
template<typename Derived>
Index PermutationBase< Derived >::cols ( void   )  const [inline]
Returns:
the number of columns

Reimplemented from EigenBase< Derived >.

template<typename Derived>
template<typename DenseDerived >
void PermutationBase< Derived >::evalTo ( MatrixBase< DenseDerived > &  other  )  const [inline]
template<typename Derived>
Transpose<PermutationBase> PermutationBase< Derived >::inverse (  )  const [inline]
Returns:
the inverse permutation matrix.
Note:
template<typename Derived>
template<typename Other >
PlainPermutationType PermutationBase< Derived >::operator* ( const PermutationBase< Other > &  other  )  const [inline]
Returns:
the product permutation matrix.
Note:
template<typename Derived>
template<typename Other >
PlainPermutationType PermutationBase< Derived >::operator* ( const Transpose< PermutationBase< Other > > &  other  )  const [inline]
Returns:
the product of a permutation with another inverse permutation.
Note:
template<typename Derived>
template<typename OtherDerived >
Derived& PermutationBase< Derived >::operator= ( const PermutationBase< OtherDerived > &  other  )  [inline]

Copies the other permutation into *this

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

Assignment from the Transpositions tr

template<typename Derived>
Derived& PermutationBase< Derived >::operator= ( const PermutationBase< Derived > &  other  )  [inline]

This is a special case of the templated operator=. Its purpose is to prevent a default operator= from hiding the templated operator=.

template<typename Derived>
void PermutationBase< Derived >::resize ( Index  size  )  [inline]

Resizes to given size.

template<typename Derived>
Index PermutationBase< Derived >::rows ( void   )  const [inline]
Returns:
the number of rows

Reimplemented from EigenBase< Derived >.

template<typename Derived>
void PermutationBase< Derived >::setIdentity (  )  [inline]

Sets *this to be the identity permutation matrix

template<typename Derived>
void PermutationBase< Derived >::setIdentity ( Index  size  )  [inline]

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

template<typename Derived>
Index PermutationBase< Derived >::size (  )  const [inline]
Returns:
the size of a side of the respective square matrix, i.e., the number of indices

Reimplemented from EigenBase< Derived >.

template<typename Derived>
DenseMatrixType PermutationBase< Derived >::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.
template<typename Derived>
Transpose<PermutationBase> PermutationBase< Derived >::transpose (  )  const [inline]
Returns:
the tranpose permutation matrix.
Note:

Friends And Related Function Documentation

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

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