Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
Eigen::PermutationWrapper< _IndicesType > Class Template Reference

Class to view a vector of integers as a permutation matrix. More...

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

+ Inheritance diagram for Eigen::PermutationWrapper< _IndicesType >:
+ Collaboration diagram for Eigen::PermutationWrapper< _IndicesType >:

Public Types

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

Public Member Functions

 PermutationWrapper (const IndicesType &indices)
 
const internal::remove_all< typenameIndicesType::Nested >::type & indices () const
 
Index rows () const
 
Index cols () const
 
Index size () const
 
void evalTo (MatrixBase< DenseDerived > &other) const
 
template<typename Dest >
EIGEN_DEVICE_FUNC void evalTo (Dest &dst) const
 
DenseMatrixType toDenseMatrix () const
 
IndicesTypeindices ()
 
void resize (Index newSize)
 
void setIdentity ()
 
void setIdentity (Index newSize)
 
PermutationWrapper< _IndicesType > & applyTranspositionOnTheLeft (Index i, Index j)
 
PermutationWrapper< _IndicesType > & applyTranspositionOnTheRight (Index i, Index j)
 
InverseReturnType inverse () const
 
InverseReturnType transpose () const
 
PlainPermutationType operator* (const PermutationBase< Other > &other) const
 
PlainPermutationType operator* (const InverseImpl< Other, PermutationStorage > &other) const
 
Index determinant () const
 
EIGEN_DEVICE_FUNC PermutationWrapper< _IndicesType > & derived ()
 
EIGEN_DEVICE_FUNC const PermutationWrapper< _IndicesType > & 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 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

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

Protected Attributes

IndicesType::Nested m_indices
 

Private Types

typedef PermutationBase< PermutationWrapperBase
 
typedef internal::traits< PermutationWrapperTraits
 

Detailed Description

template<typename _IndicesType>
class Eigen::PermutationWrapper< _IndicesType >

Class to view a vector of integers as a permutation matrix.

Template Parameters
_IndicesTypethe type of the vector of integer (can be any compatible expression)

This class allows to view any vector expression of integers as a permutation matrix.

See also
class PermutationBase, class PermutationMatrix

Member Typedef Documentation

◆ Base

template<typename _IndicesType >
typedef PermutationBase<PermutationWrapper> Eigen::PermutationWrapper< _IndicesType >::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 _IndicesType >
typedef Traits::IndicesType Eigen::PermutationWrapper< _IndicesType >::IndicesType

◆ InverseReturnType

typedef Inverse<PermutationWrapper< _IndicesType > > Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::InverseReturnType
inherited

◆ PlainObject

typedef PlainPermutationType Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::PlainObject
inherited

◆ PlainPermutationType

typedef PermutationMatrix<IndicesType::SizeAtCompileTime,IndicesType::MaxSizeAtCompileTime,StorageIndex> Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::PlainPermutationType
inherited

◆ Scalar

typedef void Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::Scalar
inherited

◆ StorageIndex

typedef Traits::StorageIndex Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::StorageIndex
inherited

◆ StorageKind

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

◆ Traits

template<typename _IndicesType >
typedef internal::traits<PermutationWrapper> Eigen::PermutationWrapper< _IndicesType >::Traits
private

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited
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
@ MaxColsAtCompileTime
Definition PermutationMatrix.h:59

Constructor & Destructor Documentation

◆ PermutationWrapper()

template<typename _IndicesType >
Eigen::PermutationWrapper< _IndicesType >::PermutationWrapper ( const IndicesType indices)
inline
526 {}
const internal::remove_all< typenameIndicesType::Nested >::type & indices() const
Definition PermutationMatrix.h:530
IndicesType::Nested m_indices
Definition PermutationMatrix.h:534

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()

PermutationWrapper< _IndicesType > & Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::applyTranspositionOnTheLeft ( Index  i,
Index  j 
)
inlineinherited

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 PermutationWrapper< _IndicesType > & derived()
Definition EigenBase.h:45
const IndicesType & indices() const
Definition PermutationMatrix.h:130

◆ applyTranspositionOnTheRight()

PermutationWrapper< _IndicesType > & Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::applyTranspositionOnTheRight ( Index  i,
Index  j 
)
inlineinherited

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 }

◆ assignProduct()

void Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::assignProduct ( const Lhs &  lhs,
const Rhs &  rhs 
)
inlineprotectedinherited
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

◆ assignTranspose()

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

◆ cols()

Index Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::cols ( ) const
inlineinherited
Returns
the number of columns
105{ return Index(indices().size()); }
Eigen::Index Index
The interface type of indices.
Definition EigenBase.h:38

◆ 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]

EIGEN_DEVICE_FUNC PermutationWrapper< _IndicesType > & Eigen::EigenBase< PermutationWrapper< _IndicesType > >::derived ( )
inlineinherited
Returns
a reference to the derived object
45{ return *static_cast<Derived*>(this); }

◆ derived() [2/2]

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

◆ determinant()

Index Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::determinant ( ) const
inlineinherited
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 }

◆ 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]

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

◆ indices() [1/2]

IndicesType & Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::indices ( )
inlineinherited
Returns
a reference to the stored array representing the permutation.
132{ return derived().indices(); }

◆ indices() [2/2]

template<typename _IndicesType >
const internal::remove_all< typenameIndicesType::Nested >::type & Eigen::PermutationWrapper< _IndicesType >::indices ( ) const
inline

const version of indices().

530{ return m_indices; }

References Eigen::PermutationWrapper< _IndicesType >::m_indices.

◆ inverse()

InverseReturnType Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::inverse ( ) const
inlineinherited
Returns
the inverse permutation matrix.
Note
\blank \note_try_to_help_rvo
197 { return InverseReturnType(derived()); }
CwiseUnaryOp< internal::scalar_inverse_op< Scalar >, const Derived > InverseReturnType
Definition ArrayCwiseUnaryOps.h:9

◆ operator*() [1/2]

PlainPermutationType Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::operator* ( const InverseImpl< Other, PermutationStorage > &  other) const
inlineinherited
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

◆ operator*() [2/2]

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

◆ resize()

void Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::resize ( Index  newSize)
inlineinherited

Resizes to given size.

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

◆ rows()

Index Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::rows ( ) const
inlineinherited
Returns
the number of rows
102{ return Index(indices().size()); }

◆ setIdentity() [1/2]

void Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::setIdentity ( )
inlineinherited

Sets *this to be the identity permutation matrix

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

◆ setIdentity() [2/2]

void Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::setIdentity ( Index  newSize)
inlineinherited

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
void setIdentity()
Definition PermutationMatrix.h:142

◆ size()

Index Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::size ( ) const
inlineinherited
Returns
the size of a side of the respective square matrix, i.e., the number of indices
108{ return Index(indices().size()); }

◆ 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()

DenseMatrixType Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::toDenseMatrix ( ) const
inlineinherited
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 }

◆ transpose()

InverseReturnType Eigen::PermutationBase< PermutationWrapper< _IndicesType > >::transpose ( ) const
inlineinherited
Returns
the tranpose permutation matrix.
Note
\blank \note_try_to_help_rvo
203 { return InverseReturnType(derived()); }

Member Data Documentation

◆ m_indices

template<typename _IndicesType >
IndicesType::Nested Eigen::PermutationWrapper< _IndicesType >::m_indices
protected

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