11 #ifndef EIGEN_PERMUTATIONMATRIX_H
12 #define EIGEN_PERMUTATIONMATRIX_H
47 template<
typename Derived>
50 typedef internal::traits<Derived>
Traits;
54 #ifndef EIGEN_PARSED_BY_DOXYGEN
55 typedef typename Traits::IndicesType IndicesType;
57 Flags = Traits::Flags,
58 RowsAtCompileTime = Traits::RowsAtCompileTime,
59 ColsAtCompileTime = Traits::ColsAtCompileTime,
60 MaxRowsAtCompileTime = Traits::MaxRowsAtCompileTime,
61 MaxColsAtCompileTime = Traits::MaxColsAtCompileTime
63 typedef typename Traits::StorageIndex StorageIndex;
68 typedef PlainPermutationType PlainObject;
75 template<
typename OtherDerived>
83 template<
typename OtherDerived>
101 #ifndef EIGEN_PARSED_BY_DOXYGEN
102 template<
typename DenseDerived>
135 StorageIndex
n = StorageIndex(
size());
136 for(StorageIndex
i = 0;
i <
n; ++
i)
199 #ifndef EIGEN_PARSED_BY_DOXYGEN
201 template<
typename OtherDerived>
206 template<
typename Lhs,
typename Rhs>
207 void assignProduct(
const Lhs& lhs,
const Rhs& rhs)
220 template<
typename Other>
228 template<
typename Other>
236 template<
typename Other>
friend
254 while(r<
n && mask[r]) r++;
274 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename StorageIndex_>
275 struct traits<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, StorageIndex_> >
276 : traits<Matrix<StorageIndex_,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
278 typedef PermutationStorage StorageKind;
279 typedef Matrix<StorageIndex_, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType;
280 typedef StorageIndex_ StorageIndex;
298 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename StorageIndex_>
302 typedef internal::traits<PermutationMatrix>
Traits;
307 #ifndef EIGEN_PARSED_BY_DOXYGEN
308 typedef typename Traits::IndicesType IndicesType;
309 typedef typename Traits::StorageIndex StorageIndex;
323 template<
typename OtherDerived>
334 template<
typename Other>
339 template<
typename Other>
347 template<
typename Other>
355 template<
typename Other>
369 #ifndef EIGEN_PARSED_BY_DOXYGEN
370 template<
typename Other>
376 for (StorageIndex
i=0;
i<
end;++
i)
377 m_indices.coeffRef(other.derived().nestedExpression().indices().
coeff(
i)) =
i;
379 template<
typename Lhs,
typename Rhs>
383 Base::assignProduct(lhs,rhs);
394 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename StorageIndex_,
int PacketAccess_>
395 struct traits<
Map<
PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, StorageIndex_>,PacketAccess_> >
396 : traits<Matrix<StorageIndex_,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
400 typedef StorageIndex_ StorageIndex;
405 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename StorageIndex_,
int PacketAccess_>
407 :
public PermutationBase<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, StorageIndex_>,PacketAccess_> >
413 #ifndef EIGEN_PARSED_BY_DOXYGEN
414 typedef typename Traits::IndicesType IndicesType;
415 typedef typename IndicesType::Scalar StorageIndex;
418 inline Map(
const StorageIndex* indicesPtr)
419 : m_indices(indicesPtr)
423 : m_indices(indicesPtr,
size)
427 template<
typename Other>
429 {
return Base::operator=(other.
derived()); }
432 template<
typename Other>
434 {
return Base::operator=(tr.
derived()); }
436 #ifndef EIGEN_PARSED_BY_DOXYGEN
440 Map& operator=(
const Map& other)
442 m_indices = other.m_indices;
448 const IndicesType&
indices()
const {
return m_indices; }
459 template<
typename IndicesType_>
464 typedef typename IndicesType_::Scalar StorageIndex;
465 typedef IndicesType_ IndicesType;
467 RowsAtCompileTime = IndicesType_::SizeAtCompileTime,
468 ColsAtCompileTime = IndicesType_::SizeAtCompileTime,
469 MaxRowsAtCompileTime = IndicesType::MaxSizeAtCompileTime,
470 MaxColsAtCompileTime = IndicesType::MaxSizeAtCompileTime,
487 template<
typename IndicesType_>
491 typedef internal::traits<PermutationWrapper>
Traits;
494 #ifndef EIGEN_PARSED_BY_DOXYGEN
495 typedef typename Traits::IndicesType IndicesType;
514 template<
typename MatrixDerived,
typename PermutationDerived>
526 template<
typename PermutationDerived,
typename MatrixDerived>
528 const Product<PermutationDerived, MatrixDerived, AliasFreeProduct>
537 template<
typename PermutationType>
539 :
public EigenBase<Inverse<PermutationType> >
549 #ifndef EIGEN_PARSED_BY_DOXYGEN
550 typedef typename PermutationType::DenseMatrixType DenseMatrixType;
552 RowsAtCompileTime = PermTraits::RowsAtCompileTime,
553 ColsAtCompileTime = PermTraits::ColsAtCompileTime,
554 MaxRowsAtCompileTime = PermTraits::MaxRowsAtCompileTime,
555 MaxColsAtCompileTime = PermTraits::MaxColsAtCompileTime
559 #ifndef EIGEN_PARSED_BY_DOXYGEN
560 template<
typename DenseDerived>
564 for (
Index i=0;
i<derived().rows();++
i)
565 other.
coeffRef(
i, derived().nestedExpression().indices().coeff(
i)) =
typename DenseDerived::Scalar(1);
576 template<
typename OtherDerived>
friend
585 template<
typename OtherDerived>
593 template<
typename Derived>
CwiseUnaryOp< internal::scalar_inverse_op< Scalar >, const Derived > InverseReturnType
#define eigen_internal_assert(x)
#define EIGEN_DEVICE_FUNC
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
void fill(const Scalar &value)
Scalar & coeffRef(Index row, Index col)
DenseMatrixType toDenseMatrix() const
friend const Product< OtherDerived, InverseType, AliasFreeProduct > operator*(const MatrixBase< OtherDerived > &matrix, const InverseType &trPerm)
PlainPermutationType eval() const
Inverse< PermutationType > InverseType
internal::traits< PermutationType > PermTraits
const Product< InverseType, OtherDerived, AliasFreeProduct > operator*(const MatrixBase< OtherDerived > &matrix) const
PermutationType::PlainPermutationType PlainPermutationType
Scalar coeff(Index row, Index col) const
Expression of the inverse of another expression.
PermutationBase< Map > Base
Map(const StorageIndex *indicesPtr, Index size)
Map & operator=(const PermutationBase< Other > &other)
Map(const StorageIndex *indicesPtr)
internal::traits< Map > Traits
Map & operator=(const TranspositionsBase< Other > &tr)
const IndicesType & indices() const
A matrix or vector expression mapping an existing array of data.
Base class for all dense matrices, vectors, and expressions.
const PermutationWrapper< const Derived > asPermutation() const
The matrix class, also used for vectors and row-vectors.
Base class for permutations.
InverseReturnType transpose() const
void resize(Index newSize)
Index determinant() const
friend PlainPermutationType operator*(const InverseImpl< Other, PermutationStorage > &other, const PermutationBase &perm)
Derived & applyTranspositionOnTheLeft(Index i, Index j)
Derived & applyTranspositionOnTheRight(Index i, Index j)
void setIdentity(Index newSize)
PlainPermutationType operator*(const InverseImpl< Other, PermutationStorage > &other) const
Derived & operator=(const PermutationBase< OtherDerived > &other)
EigenBase< Derived > Base
internal::traits< Derived > Traits
Derived & operator=(const TranspositionsBase< OtherDerived > &tr)
InverseReturnType inverse() const
DenseMatrixType toDenseMatrix() const
const IndicesType & indices() const
PlainPermutationType operator*(const PermutationBase< Other > &other) const
PermutationMatrix & operator=(const TranspositionsBase< Other > &tr)
PermutationMatrix(const PermutationBase< OtherDerived > &other)
PermutationMatrix(const TranspositionsBase< Other > &tr)
internal::traits< PermutationMatrix > Traits
const IndicesType & indices() const
PermutationMatrix(const MatrixBase< Other > &indices)
const PermutationMatrix & Nested
PermutationMatrix(Index size)
PermutationMatrix & operator=(const PermutationBase< Other > &other)
PermutationBase< PermutationMatrix > Base
Class to view a vector of integers as a permutation matrix.
PermutationWrapper(const IndicesType &indices)
PermutationBase< PermutationWrapper > Base
const internal::remove_all_t< typename IndicesType::Nested > & indices() const
IndicesType::Nested m_indices
internal::traits< PermutationWrapper > Traits
constexpr Scalar & coeffRef(Index rowId, Index colId)
Expression of the product of two arbitrary matrices or vectors.
const StorageIndex & coeff(Index i) const
static const lastp1_t end
typename remove_all< T >::type remove_all_t
void swap(scoped_array< T > &a, scoped_array< T > &b)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
const Product< MatrixDerived, PermutationDerived, AliasFreeProduct > operator*(const MatrixBase< MatrixDerived > &matrix, const PermutationBase< PermutationDerived > &permutation)
void evalTo(Dest &dst) const
Eigen::Index Index
The interface type of indices.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.