Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Eigen::PermutationBase< Derived > Class Template Reference

Base class for permutations. More...

#include <src/eigen/Eigen/src/Core/PermutationMatrix.h>

+ Inheritance diagram for Eigen::PermutationBase< Derived >:
+ Collaboration diagram for Eigen::PermutationBase< Derived >:

Public Types

enum  {
  Flags = Traits::Flags , RowsAtCompileTime = Traits::RowsAtCompileTime , ColsAtCompileTime = Traits::ColsAtCompileTime , MaxRowsAtCompileTime = Traits::MaxRowsAtCompileTime ,
  MaxColsAtCompileTime = Traits::MaxColsAtCompileTime
}
 
typedef Traits::IndicesType IndicesType
 
typedef Traits::StorageIndex StorageIndex
 
typedef Matrix< StorageIndex, RowsAtCompileTime, ColsAtCompileTime, 0, MaxRowsAtCompileTime, MaxColsAtCompileTimeDenseMatrixType
 
typedef PermutationMatrix< IndicesType::SizeAtCompileTime, IndicesType::MaxSizeAtCompileTime, StorageIndexPlainPermutationType
 
typedef PlainPermutationType PlainObject
 
typedef Inverse< Derived > InverseReturnType
 
typedef void Scalar
 
typedef Eigen::Index Index
 The interface type of indices.
 
typedef internal::traits< Derived >::StorageKind StorageKind
 

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 newSize)
 
void setIdentity ()
 
void setIdentity (Index newSize)
 
Derived & applyTranspositionOnTheLeft (Index i, Index j)
 
Derived & applyTranspositionOnTheRight (Index i, Index j)
 
InverseReturnType inverse () const
 
InverseReturnType transpose () const
 
template<typename Other >
PlainPermutationType operator* (const PermutationBase< Other > &other) const
 
template<typename Other >
PlainPermutationType operator* (const InverseImpl< Other, PermutationStorage > &other) const
 
Index determinant () const
 
EIGEN_DEVICE_FUNC Derived & derived ()
 
EIGEN_DEVICE_FUNC const Derived & derived () const
 
EIGEN_DEVICE_FUNC Derived & const_cast_derived () const
 
EIGEN_DEVICE_FUNC const Derived & const_derived () const
 
template<typename Dest >
EIGEN_DEVICE_FUNC void evalTo (Dest &dst) const
 
template<typename Dest >
EIGEN_DEVICE_FUNC void addTo (Dest &dst) const
 
template<typename Dest >
EIGEN_DEVICE_FUNC void subTo (Dest &dst) const
 
template<typename Dest >
EIGEN_DEVICE_FUNC void applyThisOnTheRight (Dest &dst) const
 
template<typename Dest >
EIGEN_DEVICE_FUNC void applyThisOnTheLeft (Dest &dst) 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)
 

Private Types

typedef internal::traits< Derived > Traits
 
typedef EigenBase< Derived > Base
 

Friends

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

Detailed Description

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

Base class for permutations.

Template 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 Typedef Documentation

◆ Base

template<typename Derived >
typedef EigenBase<Derived> Eigen::PermutationBase< Derived >::Base
private

◆ DenseMatrixType

◆ Index

template<typename Derived >
typedef Eigen::Index Eigen::EigenBase< Derived >::Index
inherited

The interface type of indices.

To change this, #define the preprocessor symbol EIGEN_DEFAULT_DENSE_INDEX_TYPE.

See also
StorageIndex, TopicPreprocessorDirectives.

◆ IndicesType

template<typename Derived >
typedef Traits::IndicesType Eigen::PermutationBase< Derived >::IndicesType

◆ InverseReturnType

template<typename Derived >
typedef Inverse<Derived> Eigen::PermutationBase< Derived >::InverseReturnType

◆ PlainObject

template<typename Derived >
typedef PlainPermutationType Eigen::PermutationBase< Derived >::PlainObject

◆ PlainPermutationType

template<typename Derived >
typedef PermutationMatrix<IndicesType::SizeAtCompileTime,IndicesType::MaxSizeAtCompileTime,StorageIndex> Eigen::PermutationBase< Derived >::PlainPermutationType

◆ Scalar

template<typename Derived >
typedef void Eigen::PermutationBase< Derived >::Scalar

◆ StorageIndex

template<typename Derived >
typedef Traits::StorageIndex Eigen::PermutationBase< Derived >::StorageIndex

◆ StorageKind

template<typename Derived >
typedef internal::traits<Derived>::StorageKind Eigen::EigenBase< Derived >::StorageKind
inherited

◆ Traits

template<typename Derived >
typedef internal::traits<Derived> Eigen::PermutationBase< Derived >::Traits
private

Member Enumeration Documentation

◆ anonymous enum

template<typename Derived >
anonymous enum
Enumerator
Flags 
RowsAtCompileTime 
ColsAtCompileTime 
MaxRowsAtCompileTime 
MaxColsAtCompileTime 
54 {
55 Flags = Traits::Flags,
56 RowsAtCompileTime = Traits::RowsAtCompileTime,
57 ColsAtCompileTime = Traits::ColsAtCompileTime,
58 MaxRowsAtCompileTime = Traits::MaxRowsAtCompileTime,
59 MaxColsAtCompileTime = Traits::MaxColsAtCompileTime
60 };
@ MaxRowsAtCompileTime
Definition PermutationMatrix.h:58
@ RowsAtCompileTime
Definition PermutationMatrix.h:56
@ MaxColsAtCompileTime
Definition PermutationMatrix.h:59
@ Flags
Definition PermutationMatrix.h:55
@ ColsAtCompileTime
Definition PermutationMatrix.h:57

Member Function Documentation

◆ addTo()

template<typename Derived >
template<typename Dest >
EIGEN_DEVICE_FUNC void Eigen::EigenBase< Derived >::addTo ( Dest &  dst) const
inlineinherited
78 {
79 // This is the default implementation,
80 // derived class can reimplement it in a more optimized way.
81 typename Dest::PlainObject res(rows(),cols());
82 evalTo(res);
83 dst += res;
84 }
EIGEN_DEVICE_FUNC Index cols() const
Definition EigenBase.h:62
EIGEN_DEVICE_FUNC Index rows() const
Definition EigenBase.h:59
EIGEN_DEVICE_FUNC void evalTo(Dest &dst) const
Definition EigenBase.h:71

◆ applyThisOnTheLeft()

template<typename Derived >
template<typename Dest >
EIGEN_DEVICE_FUNC void Eigen::EigenBase< Derived >::applyThisOnTheLeft ( Dest &  dst) const
inlineinherited
110 {
111 // This is the default implementation,
112 // derived class can reimplement it in a more optimized way.
113 dst = this->derived() * dst;
114 }
EIGEN_DEVICE_FUNC Derived & derived()
Definition EigenBase.h:45

References Eigen::EigenBase< Derived >::derived().

+ Here is the call graph for this function:

◆ applyThisOnTheRight()

template<typename Derived >
template<typename Dest >
EIGEN_DEVICE_FUNC void Eigen::EigenBase< Derived >::applyThisOnTheRight ( Dest &  dst) const
inlineinherited
101 {
102 // This is the default implementation,
103 // derived class can reimplement it in a more optimized way.
104 dst = dst * this->derived();
105 }

References Eigen::EigenBase< Derived >::derived().

+ Here is the call graph for this function:

◆ applyTranspositionOnTheLeft()

template<typename Derived >
Derived & Eigen::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(Index,Index): this has linear complexity and requires a lot of branching.
See also
applyTranspositionOnTheRight(Index,Index)
167 {
168 eigen_assert(i>=0 && j>=0 && i<size() && j<size());
169 for(Index k = 0; k < size(); ++k)
170 {
171 if(indices().coeff(k) == i) indices().coeffRef(k) = StorageIndex(j);
172 else if(indices().coeff(k) == j) indices().coeffRef(k) = StorageIndex(i);
173 }
174 return derived();
175 }
#define eigen_assert(x)
Definition Macros.h:579
Traits::StorageIndex StorageIndex
Definition PermutationMatrix.h:61
Index size() const
Definition PermutationMatrix.h:108
EIGEN_DEVICE_FUNC Derived & derived()
Definition EigenBase.h:45
const IndicesType & indices() const
Definition PermutationMatrix.h:130
Eigen::Index Index
The interface type of indices.
Definition EigenBase.h:38

References Eigen::PermutationBase< Derived >::derived(), eigen_assert, Eigen::PermutationBase< Derived >::indices(), and Eigen::PermutationBase< Derived >::size().

+ Here is the call graph for this function:

◆ applyTranspositionOnTheRight()

template<typename Derived >
Derived & Eigen::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(Index,Index)
186 {
187 eigen_assert(i>=0 && j>=0 && i<size() && j<size());
188 std::swap(indices().coeffRef(i), indices().coeffRef(j));
189 return derived();
190 }

References Eigen::PermutationBase< Derived >::derived(), eigen_assert, Eigen::PermutationBase< Derived >::indices(), and Eigen::PermutationBase< Derived >::size().

Referenced by Eigen::PermutationBase< Derived >::operator=().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assignProduct()

template<typename Derived >
template<typename Lhs , typename Rhs >
void Eigen::PermutationBase< Derived >::assignProduct ( const Lhs &  lhs,
const Rhs &  rhs 
)
inlineprotected
217 {
218 eigen_assert(lhs.cols() == rhs.rows());
219 for (Index i=0; i<rows();++i) indices().coeffRef(i) = lhs.indices().coeff(rhs.indices().coeff(i));
220 }
Index rows() const
Definition PermutationMatrix.h:102

References eigen_assert, Eigen::PermutationBase< Derived >::indices(), and Eigen::PermutationBase< Derived >::rows().

Referenced by Eigen::PermutationMatrix< SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndex >::PermutationMatrix().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assignTranspose()

template<typename Derived >
template<typename OtherDerived >
void Eigen::PermutationBase< Derived >::assignTranspose ( const PermutationBase< OtherDerived > &  other)
inlineprotected
212 {
213 for (Index i=0; i<rows();++i) indices().coeffRef(other.indices().coeff(i)) = i;
214 }

References Eigen::PermutationBase< Derived >::indices(), and Eigen::PermutationBase< Derived >::rows().

+ Here is the call graph for this function:

◆ cols()

template<typename Derived >
Index Eigen::PermutationBase< Derived >::cols ( ) const
inline
Returns
the number of columns
105{ return Index(indices().size()); }

References Eigen::PermutationBase< Derived >::indices(), and Eigen::PermutationBase< Derived >::size().

+ Here is the call graph for this function:

◆ const_cast_derived()

template<typename Derived >
EIGEN_DEVICE_FUNC Derived & Eigen::EigenBase< Derived >::const_cast_derived ( ) const
inlineinherited
52 { return *static_cast<Derived*>(const_cast<EigenBase*>(this)); }

Referenced by Eigen::TriangularViewImpl< _MatrixType, _Mode, Dense >::swap().

+ Here is the caller graph for this function:

◆ const_derived()

template<typename Derived >
EIGEN_DEVICE_FUNC const Derived & Eigen::EigenBase< Derived >::const_derived ( ) const
inlineinherited
55 { return *static_cast<const Derived*>(this); }

◆ derived() [1/2]

◆ derived() [2/2]

template<typename Derived >
EIGEN_DEVICE_FUNC const Derived & Eigen::EigenBase< Derived >::derived ( ) const
inline
Returns
a const reference to the derived object
48{ return *static_cast<const Derived*>(this); }

◆ determinant()

template<typename Derived >
Index Eigen::PermutationBase< Derived >::determinant ( ) const
inline
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.

254 {
255 Index res = 1;
256 Index n = size();
257 Matrix<bool,RowsAtCompileTime,1,0,MaxRowsAtCompileTime> mask(n);
258 mask.fill(false);
259 Index r = 0;
260 while(r < n)
261 {
262 // search for the next seed
263 while(r<n && mask[r]) r++;
264 if(r>=n)
265 break;
266 // we got one, let's follow it until we are back to the seed
267 Index k0 = r++;
268 mask.coeffRef(k0) = true;
269 for(Index k=indices().coeff(k0); k!=k0; k=indices().coeff(k))
270 {
271 mask.coeffRef(k) = true;
272 res = -res;
273 }
274 }
275 return res;
276 }

References Eigen::PermutationBase< Derived >::size().

+ Here is the call graph for this function:

◆ evalTo() [1/2]

template<typename Derived >
template<typename Dest >
EIGEN_DEVICE_FUNC void Eigen::EigenBase< Derived >::evalTo ( Dest &  dst) const
inlineinherited
72 { derived().evalTo(dst); }

Referenced by Eigen::EigenBase< Derived >::subTo().

+ Here is the caller graph for this function:

◆ evalTo() [2/2]

template<typename Derived >
template<typename DenseDerived >
void Eigen::PermutationBase< Derived >::evalTo ( MatrixBase< DenseDerived > &  other) const
inline
113 {
114 other.setZero();
115 for (Index i=0; i<rows(); ++i)
116 other.coeffRef(indices().coeff(i),i) = typename DenseDerived::Scalar(1);
117 }

References Eigen::PermutationBase< Derived >::indices(), Eigen::PermutationBase< Derived >::rows(), and Eigen::DenseBase< Derived >::setZero().

+ Here is the call graph for this function:

◆ indices() [1/2]

template<typename Derived >
IndicesType & Eigen::PermutationBase< Derived >::indices ( )
inline
Returns
a reference to the stored array representing the permutation.
132{ return derived().indices(); }

References Eigen::PermutationBase< Derived >::derived().

+ Here is the call graph for this function:

◆ indices() [2/2]

◆ inverse()

template<typename Derived >
InverseReturnType Eigen::PermutationBase< Derived >::inverse ( ) const
inline
Returns
the inverse permutation matrix.
Note
\blank \note_try_to_help_rvo
197 { return InverseReturnType(derived()); }
Inverse< Derived > InverseReturnType
Definition PermutationMatrix.h:68

References Eigen::PermutationBase< Derived >::derived().

Referenced by Eigen::SparseLU< _MatrixType, _OrderingType >::_solve_impl(), and Eigen::FullPivLU< _MatrixType >::_solve_impl_transposed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator*() [1/2]

template<typename Derived >
template<typename Other >
PlainPermutationType Eigen::PermutationBase< Derived >::operator* ( const InverseImpl< Other, PermutationStorage > &  other) const
inline
Returns
the product of a permutation with another inverse permutation.
Note
\blank \note_try_to_help_rvo
239 { return PlainPermutationType(internal::PermPermProduct, *this, other.eval()); }
PermutationMatrix< IndicesType::SizeAtCompileTime, IndicesType::MaxSizeAtCompileTime, StorageIndex > PlainPermutationType
Definition PermutationMatrix.h:65
@ PermPermProduct
Definition PermutationMatrix.h:18

References Eigen::internal::PermPermProduct.

◆ operator*() [2/2]

template<typename Derived >
template<typename Other >
PlainPermutationType Eigen::PermutationBase< Derived >::operator* ( const PermutationBase< Other > &  other) const
inline
Returns
the product permutation matrix.
Note
\blank \note_try_to_help_rvo
231 { return PlainPermutationType(internal::PermPermProduct, derived(), other.derived()); }

References Eigen::PermutationBase< Derived >::derived(), and Eigen::internal::PermPermProduct.

+ Here is the call graph for this function:

◆ operator=() [1/3]

template<typename Derived >
Derived & Eigen::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=.

95 {
96 indices() = other.indices();
97 return derived();
98 }

References Eigen::PermutationBase< Derived >::derived(), and Eigen::PermutationBase< Derived >::indices().

+ Here is the call graph for this function:

◆ operator=() [2/3]

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

Copies the other permutation into *this

75 {
76 indices() = other.indices();
77 return derived();
78 }

References Eigen::PermutationBase< Derived >::derived(), and Eigen::PermutationBase< Derived >::indices().

Referenced by Eigen::PermutationMatrix< SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndex >::operator=().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=() [3/3]

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

Assignment from the Transpositions tr

83 {
84 setIdentity(tr.size());
85 for(Index k=size()-1; k>=0; --k)
86 applyTranspositionOnTheRight(k,tr.coeff(k));
87 return derived();
88 }
Derived & applyTranspositionOnTheRight(Index i, Index j)
Definition PermutationMatrix.h:185
void setIdentity()
Definition PermutationMatrix.h:142

References Eigen::PermutationBase< Derived >::applyTranspositionOnTheRight(), Eigen::TranspositionsBase< Derived >::coeff(), Eigen::PermutationBase< Derived >::derived(), Eigen::PermutationBase< Derived >::setIdentity(), Eigen::PermutationBase< Derived >::size(), and Eigen::TranspositionsBase< Derived >::size().

+ Here is the call graph for this function:

◆ resize()

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

Resizes to given size.

137 {
138 indices().resize(newSize);
139 }

References Eigen::PermutationBase< Derived >::indices().

Referenced by Eigen::internal::minimum_degree_ordering(), Eigen::NaturalOrdering< StorageIndex >::operator()(), Eigen::MetisOrdering< StorageIndex >::operator()(), Eigen::COLAMDOrdering< StorageIndex >::operator()(), and Eigen::PermutationBase< Derived >::setIdentity().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rows()

template<typename Derived >
Index Eigen::PermutationBase< Derived >::rows ( ) const
inline
Returns
the number of rows
102{ return Index(indices().size()); }

References Eigen::PermutationBase< Derived >::indices(), and Eigen::PermutationBase< Derived >::size().

Referenced by Eigen::PermutationBase< Derived >::assignProduct(), Eigen::PermutationBase< Derived >::assignTranspose(), and Eigen::PermutationBase< Derived >::evalTo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setIdentity() [1/2]

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

Sets *this to be the identity permutation matrix

143 {
145 for(StorageIndex i = 0; i < n; ++i)
146 indices().coeffRef(i) = i;
147 }

References Eigen::PermutationBase< Derived >::indices(), and Eigen::PermutationBase< Derived >::size().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setIdentity() [2/2]

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

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

152 {
153 resize(newSize);
154 setIdentity();
155 }
void resize(Index newSize)
Definition PermutationMatrix.h:136

References Eigen::PermutationBase< Derived >::resize(), and Eigen::PermutationBase< Derived >::setIdentity().

+ Here is the call graph for this function:

◆ size()

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

◆ subTo()

template<typename Derived >
template<typename Dest >
EIGEN_DEVICE_FUNC void Eigen::EigenBase< Derived >::subTo ( Dest &  dst) const
inlineinherited
90 {
91 // This is the default implementation,
92 // derived class can reimplement it in a more optimized way.
93 typename Dest::PlainObject res(rows(),cols());
94 evalTo(res);
95 dst -= res;
96 }

References Eigen::EigenBase< Derived >::cols(), Eigen::EigenBase< Derived >::evalTo(), and Eigen::EigenBase< Derived >::rows().

+ Here is the call graph for this function:

◆ toDenseMatrix()

template<typename Derived >
DenseMatrixType Eigen::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.
125 {
126 return derived();
127 }

References Eigen::PermutationBase< Derived >::derived().

+ Here is the call graph for this function:

◆ transpose()

template<typename Derived >
InverseReturnType Eigen::PermutationBase< Derived >::transpose ( ) const
inline
Returns
the tranpose permutation matrix.
Note
\blank \note_try_to_help_rvo
203 { return InverseReturnType(derived()); }

References Eigen::PermutationBase< Derived >::derived().

Referenced by Eigen::PartialPivLU< _MatrixType >::_solve_impl_transposed(), and Eigen::internal::permutation_matrix_product< ExpressionType, Side, Transposed, SparseShape >::run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator*

template<typename Derived >
template<typename Other >
PlainPermutationType operator* ( const InverseImpl< Other, PermutationStorage > &  other,
const PermutationBase< Derived > &  perm 
)
friend
Returns
the product of an inverse permutation with another permutation.
Note
\blank \note_try_to_help_rvo
247 { return PlainPermutationType(internal::PermPermProduct, other.eval(), perm); }

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