10 #ifndef EIGEN_TRANSPOSITIONS_H 11 #define EIGEN_TRANSPOSITIONS_H 15 template<
typename Derived>
16 class TranspositionsBase
18 typedef internal::traits<Derived> Traits;
22 typedef typename Traits::IndicesType IndicesType;
23 typedef typename IndicesType::Scalar StorageIndex;
26 Derived& derived() {
return *
static_cast<Derived*
>(
this); }
27 const Derived& derived()
const {
return *
static_cast<const Derived*
>(
this); }
30 template<
typename OtherDerived>
31 Derived& operator=(
const TranspositionsBase<OtherDerived>& other)
33 indices() = other.indices();
37 #ifndef EIGEN_PARSED_BY_DOXYGEN 41 Derived& operator=(
const TranspositionsBase& other)
43 indices() = other.indices();
49 Index size()
const {
return indices().size(); }
51 Index rows()
const {
return indices().size(); }
53 Index cols()
const {
return indices().size(); }
56 inline const StorageIndex& coeff(Index i)
const {
return indices().coeff(i); }
58 inline StorageIndex& coeffRef(Index i) {
return indices().coeffRef(i); }
60 inline const StorageIndex& operator()(Index i)
const {
return indices()(i); }
62 inline StorageIndex& operator()(Index i) {
return indices()(i); }
64 inline const StorageIndex& operator[](Index i)
const {
return indices()(i); }
66 inline StorageIndex& operator[](Index i) {
return indices()(i); }
69 const IndicesType& indices()
const {
return derived().indices(); }
71 IndicesType& indices() {
return derived().indices(); }
74 inline void resize(Index newSize)
76 indices().resize(newSize);
82 for(StorageIndex i = 0; i < indices().size(); ++i)
108 inline Transpose<TranspositionsBase>
inverse()
const 109 {
return Transpose<TranspositionsBase>(derived()); }
112 inline Transpose<TranspositionsBase> transpose()
const 113 {
return Transpose<TranspositionsBase>(derived()); }
119 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename _StorageIndex>
120 struct traits<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >
121 : traits<PermutationMatrix<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >
123 typedef Matrix<_StorageIndex, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType;
124 typedef TranspositionsStorage StorageKind;
157 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename _StorageIndex>
158 class Transpositions :
public TranspositionsBase<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >
160 typedef internal::traits<Transpositions> Traits;
163 typedef TranspositionsBase<Transpositions> Base;
164 typedef typename Traits::IndicesType IndicesType;
165 typedef typename IndicesType::Scalar StorageIndex;
170 template<
typename OtherDerived>
172 : m_indices(other.indices()) {}
174 #ifndef EIGEN_PARSED_BY_DOXYGEN 181 template<
typename Other>
186 template<
typename OtherDerived>
189 return Base::operator=(other);
192 #ifndef EIGEN_PARSED_BY_DOXYGEN 198 m_indices = other.m_indices;
209 const IndicesType&
indices()
const {
return m_indices; }
215 IndicesType m_indices;
220 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename _StorageIndex,
int _PacketAccess>
221 struct traits<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,_PacketAccess> >
222 : traits<PermutationMatrix<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >
225 typedef _StorageIndex StorageIndex;
230 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename _StorageIndex,
int PacketAccess>
231 class Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,PacketAccess>
232 :
public TranspositionsBase<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,PacketAccess> >
234 typedef internal::traits<Map> Traits;
237 typedef TranspositionsBase<Map> Base;
238 typedef typename Traits::IndicesType IndicesType;
239 typedef typename IndicesType::Scalar StorageIndex;
241 explicit inline Map(
const StorageIndex* indicesPtr)
242 : m_indices(indicesPtr)
245 inline Map(
const StorageIndex* indicesPtr, Index size)
246 : m_indices(indicesPtr,size)
250 template<
typename OtherDerived>
251 Map& operator=(
const TranspositionsBase<OtherDerived>& other)
253 return Base::operator=(other);
256 #ifndef EIGEN_PARSED_BY_DOXYGEN 260 Map& operator=(
const Map& other)
262 m_indices = other.m_indices;
268 const IndicesType& indices()
const {
return m_indices; }
271 IndicesType& indices() {
return m_indices; }
275 IndicesType m_indices;
279 template<
typename _IndicesType>
280 struct traits<TranspositionsWrapper<_IndicesType> >
281 : traits<PermutationWrapper<_IndicesType> >
287 template<
typename _IndicesType>
288 class TranspositionsWrapper
289 :
public TranspositionsBase<TranspositionsWrapper<_IndicesType> >
291 typedef internal::traits<TranspositionsWrapper> Traits;
294 typedef TranspositionsBase<TranspositionsWrapper> Base;
295 typedef typename Traits::IndicesType IndicesType;
296 typedef typename IndicesType::Scalar StorageIndex;
298 explicit inline TranspositionsWrapper(IndicesType& indices)
303 template<
typename OtherDerived>
304 TranspositionsWrapper& operator=(
const TranspositionsBase<OtherDerived>& other)
306 return Base::operator=(other);
309 #ifndef EIGEN_PARSED_BY_DOXYGEN 313 TranspositionsWrapper& operator=(
const TranspositionsWrapper& other)
315 m_indices = other.m_indices;
321 const IndicesType& indices()
const {
return m_indices; }
324 IndicesType& indices() {
return m_indices; }
328 typename IndicesType::Nested m_indices;
335 template<
typename MatrixDerived,
typename TranspositionsDerived>
339 const TranspositionsBase<TranspositionsDerived>& transpositions)
342 (matrix.
derived(), transpositions.derived());
347 template<
typename TranspositionsDerived,
typename MatrixDerived>
350 operator*(
const TranspositionsBase<TranspositionsDerived> &transpositions,
354 (transpositions.derived(), matrix.
derived());
361 template<
typename Derived>
362 struct traits<Transpose<TranspositionsBase<Derived> > >
368 template<
typename TranspositionsDerived>
369 class Transpose<TranspositionsBase<TranspositionsDerived> >
371 typedef TranspositionsDerived TranspositionType;
372 typedef typename TranspositionType::IndicesType IndicesType;
375 explicit Transpose(
const TranspositionType& t) : m_transpositions(t) {}
377 Index size()
const {
return m_transpositions.size(); }
378 Index rows()
const {
return m_transpositions.size(); }
379 Index cols()
const {
return m_transpositions.size(); }
383 template<
typename OtherDerived>
friend 392 template<
typename OtherDerived>
399 const TranspositionType& nestedExpression()
const {
return m_transpositions; }
402 const TranspositionType& m_transpositions;
407 #endif // EIGEN_TRANSPOSITIONS_H Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:71
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:88
Expression of the transpose of a matrix.
Definition: Transpose.h:52
Namespace containing all symbols from the Eigen library.
Definition: Core:287
Derived & derived()
Definition: EigenBase.h:45
Transpositions(const TranspositionsBase< OtherDerived > &other)
Definition: Transpositions.h:171
const IndicesType & indices() const
Definition: Transpositions.h:209
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_inverse_op< typename Derived::Scalar >, const Derived > inverse(const Eigen::ArrayBase< Derived > &x)
const Product< MatrixDerived, PermutationDerived, AliasFreeProduct > operator*(const MatrixBase< MatrixDerived > &matrix, const PermutationBase< PermutationDerived > &permutation)
Definition: PermutationMatrix.h:543
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33
Transpositions(Index size)
Definition: Transpositions.h:205
Transpositions(const MatrixBase< Other > &indices)
Definition: Transpositions.h:182
Definition: Eigen_Colamd.h:50
Transpositions & operator=(const TranspositionsBase< OtherDerived > &other)
Definition: Transpositions.h:187
Definition: Constants.h:503
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Represents a sequence of transpositions (row/column interchange)
Definition: Transpositions.h:158
IndicesType & indices()
Definition: Transpositions.h:211