11#ifndef EIGEN_PERMUTATIONMATRIX_H
12#define EIGEN_PERMUTATIONMATRIX_H
42enum PermPermProduct_t {PermPermProduct};
46template<
typename Derived>
53 #ifndef EIGEN_PARSED_BY_DOXYGEN
54 typedef typename Traits::IndicesType IndicesType;
56 Flags = Traits::Flags,
57 RowsAtCompileTime = Traits::RowsAtCompileTime,
58 ColsAtCompileTime = Traits::ColsAtCompileTime,
59 MaxRowsAtCompileTime = Traits::MaxRowsAtCompileTime,
60 MaxColsAtCompileTime = Traits::MaxColsAtCompileTime
62 typedef typename Traits::StorageIndex StorageIndex;
74 template<
typename OtherDerived>
82 template<
typename OtherDerived>
91 #ifndef EIGEN_PARSED_BY_DOXYGEN
111 #ifndef EIGEN_PARSED_BY_DOXYGEN
112 template<
typename DenseDerived>
116 for (Index i=0; i<
rows(); ++i)
117 other.coeffRef(
indices().coeff(i),i) =
typename DenseDerived::Scalar(1);
145 StorageIndex n = StorageIndex(
size());
146 for(StorageIndex i = 0; i < n; ++i)
169 eigen_assert(i>=0 &&
j>=0 && i<
size() &&
j<
size());
173 else if(
indices().coeff(k) ==
j)
indices().coeffRef(k) = StorageIndex(i);
188 eigen_assert(i>=0 &&
j>=0 && i<
size() &&
j<
size());
209#ifndef EIGEN_PARSED_BY_DOXYGEN
211 template<
typename OtherDerived>
214 for (Index i=0; i<
rows();++i)
indices().coeffRef(other.indices().coeff(i)) = i;
216 template<
typename Lhs,
typename Rhs>
217 void assignProduct(
const Lhs& lhs,
const Rhs& rhs)
219 eigen_assert(lhs.cols() == rhs.rows());
220 for (
Index i=0; i<
rows();++i)
indices().coeffRef(i) = lhs.indices().coeff(rhs.indices().coeff(i));
230 template<
typename Other>
238 template<
typename Other>
246 template<
typename Other>
friend
264 while(r<n &&
mask[r]) r++;
272 mask.coeffRef(k) =
true;
298template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename _StorageIndex>
300 :
traits<Matrix<_StorageIndex,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
304 typedef _StorageIndex StorageIndex;
309template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename _StorageIndex>
318 #ifndef EIGEN_PARSED_BY_DOXYGEN
319 typedef typename Traits::IndicesType IndicesType;
320 typedef typename Traits::StorageIndex StorageIndex;
334 template<
typename OtherDerived>
336 : m_indices(other.
indices()) {}
338 #ifndef EIGEN_PARSED_BY_DOXYGEN
351 template<
typename Other>
356 template<
typename Other>
364 template<
typename Other>
367 m_indices = other.indices();
372 template<
typename Other>
375 return Base::operator=(
tr.derived());
378 #ifndef EIGEN_PARSED_BY_DOXYGEN
384 m_indices = other.m_indices;
390 const IndicesType&
indices()
const {
return m_indices; }
397#ifndef EIGEN_PARSED_BY_DOXYGEN
398 template<
typename Other>
400 : m_indices(other.
derived().nestedExpression().
size())
403 StorageIndex end = StorageIndex(m_indices.size());
404 for (StorageIndex i=0; i<end;++i)
405 m_indices.coeffRef(other.derived().nestedExpression().indices().coeff(i)) = i;
407 template<
typename Lhs,
typename Rhs>
408 PermutationMatrix(internal::PermPermProduct_t,
const Lhs& lhs,
const Rhs& rhs)
411 Base::assignProduct(lhs,rhs);
417 IndicesType m_indices;
422template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename _StorageIndex,
int _PacketAccess>
424 :
traits<Matrix<_StorageIndex,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> >
428 typedef _StorageIndex StorageIndex;
433template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename _StorageIndex,
int _PacketAccess>
435 :
public PermutationBase<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndex>,_PacketAccess> >
441 #ifndef EIGEN_PARSED_BY_DOXYGEN
442 typedef typename Traits::IndicesType IndicesType;
443 typedef typename IndicesType::Scalar StorageIndex;
455 template<
typename Other>
457 {
return Base::operator=(other.derived()); }
460 template<
typename Other>
462 {
return Base::operator=(
tr.derived()); }
464 #ifndef EIGEN_PARSED_BY_DOXYGEN
470 m_indices = other.m_indices;
476 const IndicesType&
indices()
const {
return m_indices; }
482 IndicesType m_indices;
497template<
typename _IndicesType>
class TranspositionsWrapper;
499template<
typename _IndicesType>
504 typedef typename _IndicesType::Scalar StorageIndex;
507 RowsAtCompileTime = _IndicesType::SizeAtCompileTime,
508 ColsAtCompileTime = _IndicesType::SizeAtCompileTime,
509 MaxRowsAtCompileTime = IndicesType::MaxSizeAtCompileTime,
510 MaxColsAtCompileTime = IndicesType::MaxSizeAtCompileTime,
516template<
typename _IndicesType>
523 #ifndef EIGEN_PARSED_BY_DOXYGEN
524 typedef typename Traits::IndicesType IndicesType;
537 typename IndicesType::Nested m_indices;
543template<
typename MatrixDerived,
typename PermutationDerived>
545const Product<MatrixDerived, PermutationDerived, AliasFreeProduct>
546operator*(
const MatrixBase<MatrixDerived> &matrix,
547 const PermutationBase<PermutationDerived>& permutation)
549 return Product<MatrixDerived, PermutationDerived, AliasFreeProduct>
550 (matrix.derived(), permutation.derived());
555template<
typename PermutationDerived,
typename MatrixDerived>
557const Product<PermutationDerived, MatrixDerived, AliasFreeProduct>
558operator*(
const PermutationBase<PermutationDerived> &permutation,
559 const MatrixBase<MatrixDerived>& matrix)
561 return Product<PermutationDerived, MatrixDerived, AliasFreeProduct>
562 (permutation.derived(), matrix.derived());
566template<
typename PermutationType>
568 :
public EigenBase<Inverse<PermutationType> >
570 typedef typename PermutationType::PlainPermutationType PlainPermutationType;
578 #ifndef EIGEN_PARSED_BY_DOXYGEN
579 typedef typename PermutationType::DenseMatrixType DenseMatrixType;
581 RowsAtCompileTime = PermTraits::RowsAtCompileTime,
582 ColsAtCompileTime = PermTraits::ColsAtCompileTime,
583 MaxRowsAtCompileTime = PermTraits::MaxRowsAtCompileTime,
584 MaxColsAtCompileTime = PermTraits::MaxColsAtCompileTime
588 #ifndef EIGEN_PARSED_BY_DOXYGEN
589 template<
typename DenseDerived>
593 for (
Index i=0; i<derived().rows();++i)
594 other.coeffRef(i, derived().nestedExpression().indices().coeff(i)) =
typename DenseDerived::Scalar(1);
599 PlainPermutationType
eval()
const {
return derived(); }
601 DenseMatrixType toDenseMatrix()
const {
return derived(); }
605 template<
typename OtherDerived>
friend
606 const Product<OtherDerived, InverseType, AliasFreeProduct>
614 template<
typename OtherDerived>
622template<
typename Derived>
623const PermutationWrapper<const Derived> MatrixBase<Derived>::asPermutation()
const
PlainPermutationType eval() const
Definition PermutationMatrix.h:599
const Product< InverseType, OtherDerived, AliasFreeProduct > operator*(const MatrixBase< OtherDerived > &matrix) const
Definition PermutationMatrix.h:616
friend const Product< OtherDerived, InverseType, AliasFreeProduct > operator*(const MatrixBase< OtherDerived > &matrix, const InverseType &trPerm)
Definition PermutationMatrix.h:607
Map & operator=(const Map &other)
This is a special case of the templated operator=.
Definition PermutationMatrix.h:468
Map & operator=(const TranspositionsBase< Other > &tr)
Assignment from the Transpositions tr.
Definition PermutationMatrix.h:461
IndicesType & indices()
Definition PermutationMatrix.h:478
Map & operator=(const PermutationBase< Other > &other)
Copies the other permutation into *this.
Definition PermutationMatrix.h:456
const IndicesType & indices() const
const version of indices().
Definition PermutationMatrix.h:476
A matrix or vector expression mapping an existing array of data.
Definition Map.h:91
Base class for permutations.
Definition PermutationMatrix.h:48
InverseReturnType transpose() const
Definition PermutationMatrix.h:203
Derived & applyTranspositionOnTheLeft(Index i, Index j)
Multiplies *this by the transposition on the left.
Definition PermutationMatrix.h:167
void resize(Index newSize)
Resizes to given size.
Definition PermutationMatrix.h:137
Index determinant() const
Definition PermutationMatrix.h:254
Index size() const
Definition PermutationMatrix.h:109
Index cols() const
Definition PermutationMatrix.h:106
Derived & applyTranspositionOnTheRight(Index i, Index j)
Multiplies *this by the transposition on the right.
Definition PermutationMatrix.h:186
friend PlainPermutationType operator*(const InverseImpl< Other, PermutationStorage > &other, const PermutationBase &perm)
Definition PermutationMatrix.h:247
void setIdentity()
Sets *this to be the identity permutation matrix.
Definition PermutationMatrix.h:143
Derived & operator=(const PermutationBase &other)
This is a special case of the templated operator=.
Definition PermutationMatrix.h:95
Derived & operator=(const PermutationBase< OtherDerived > &other)
Copies the other permutation into *this.
Definition PermutationMatrix.h:75
IndicesType & indices()
Definition PermutationMatrix.h:133
void setIdentity(Index newSize)
Sets *this to be the identity permutation matrix of given size.
Definition PermutationMatrix.h:152
PlainPermutationType operator*(const InverseImpl< Other, PermutationStorage > &other) const
Definition PermutationMatrix.h:239
EIGEN_DEVICE_FUNC Derived & derived()
Definition EigenBase.h:44
const IndicesType & indices() const
const version of indices().
Definition PermutationMatrix.h:131
Index rows() const
Definition PermutationMatrix.h:103
InverseReturnType inverse() const
Definition PermutationMatrix.h:197
DenseMatrixType toDenseMatrix() const
Definition PermutationMatrix.h:125
Derived & operator=(const TranspositionsBase< OtherDerived > &tr)
Assignment from the Transpositions tr.
Definition PermutationMatrix.h:83
PlainPermutationType operator*(const PermutationBase< Other > &other) const
Definition PermutationMatrix.h:231
Permutation matrix.
Definition PermutationMatrix.h:311
PermutationMatrix(const TranspositionsBase< Other > &tr)
Convert the Transpositions tr to a permutation matrix.
Definition PermutationMatrix.h:357
PermutationMatrix(const MatrixBase< Other > &indices)
Generic constructor from expression of the indices.
Definition PermutationMatrix.h:352
PermutationMatrix(const PermutationMatrix &other)
Standard copy constructor.
Definition PermutationMatrix.h:341
PermutationMatrix(const PermutationBase< OtherDerived > &other)
Copy constructor.
Definition PermutationMatrix.h:335
PermutationMatrix & operator=(const PermutationBase< Other > &other)
Copies the other permutation into *this.
Definition PermutationMatrix.h:365
PermutationMatrix & operator=(const PermutationMatrix &other)
This is a special case of the templated operator=.
Definition PermutationMatrix.h:382
const IndicesType & indices() const
const version of indices().
Definition PermutationMatrix.h:390
IndicesType & indices()
Definition PermutationMatrix.h:392
PermutationMatrix & operator=(const TranspositionsBase< Other > &tr)
Assignment from the Transpositions tr.
Definition PermutationMatrix.h:373
PermutationMatrix(Index size)
Constructs an uninitialized permutation matrix of given size.
Definition PermutationMatrix.h:328
Class to view a vector of integers as a permutation matrix.
Definition PermutationMatrix.h:518
const internal::remove_all< typenameIndicesType::Nested >::type & indices() const
const version of indices().
Definition PermutationMatrix.h:533
Pseudo expression representing a solving operation.
Definition Solve.h:63
NLOHMANN_BASIC_JSON_TPL_DECLARATION void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL &j1, nlohmann::NLOHMANN_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::NLOHMANN_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition json.hpp:24418
Definition Constants.h:511
Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor Matrix...
Definition EigenBase.h:29
Eigen::Index Index
The interface type of indices.
Definition EigenBase.h:37
EIGEN_DEVICE_FUNC Derived & derived()
Definition EigenBase.h:44
Holds information about the various numeric (i.e.
Definition NumTraits.h:108
Definition Constants.h:518
The type used to identify a permutation storage.
Definition Constants.h:499
Definition AssignEvaluator.h:677
Definition AssignEvaluator.h:675
Definition ForwardDeclarations.h:17