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;
27 Derived& derived() {
return *
static_cast<Derived*
>(
this); }
29 const Derived& derived()
const {
return *
static_cast<const Derived*
>(
this); }
32 template<
typename OtherDerived>
33 Derived& operator=(
const TranspositionsBase<OtherDerived>& other)
35 indices() = other.indices();
41 Index size()
const {
return indices().size(); }
44 Index rows()
const {
return indices().size(); }
47 Index cols()
const {
return indices().size(); }
51 inline const StorageIndex& coeff(Index i)
const {
return indices().coeff(i); }
53 inline StorageIndex& coeffRef(Index i) {
return indices().coeffRef(i); }
55 inline const StorageIndex& operator()(Index i)
const {
return indices()(i); }
57 inline StorageIndex& operator()(Index i) {
return indices()(i); }
59 inline const StorageIndex& operator[](Index i)
const {
return indices()(i); }
61 inline StorageIndex& operator[](Index i) {
return indices()(i); }
65 const IndicesType& indices()
const {
return derived().indices(); }
68 IndicesType& indices() {
return derived().indices(); }
71 inline void resize(Index newSize)
73 indices().resize(newSize);
79 for(StorageIndex i = 0; i < indices().size(); ++i)
105 inline Transpose<TranspositionsBase>
inverse()
const 106 {
return Transpose<TranspositionsBase>(derived()); }
109 inline Transpose<TranspositionsBase> transpose()
const 110 {
return Transpose<TranspositionsBase>(derived()); }
116 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename _StorageIndex>
117 struct traits<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >
118 : traits<PermutationMatrix<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >
120 typedef Matrix<_StorageIndex, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType;
121 typedef TranspositionsStorage StorageKind;
154 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename _StorageIndex>
155 class Transpositions :
public TranspositionsBase<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >
157 typedef internal::traits<Transpositions> Traits;
160 typedef TranspositionsBase<Transpositions> Base;
161 typedef typename Traits::IndicesType IndicesType;
162 typedef typename IndicesType::Scalar StorageIndex;
167 template<
typename OtherDerived>
169 : m_indices(other.indices()) {}
172 template<
typename Other>
177 template<
typename OtherDerived>
180 return Base::operator=(other);
190 const IndicesType&
indices()
const {
return m_indices; }
197 IndicesType m_indices;
202 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename _StorageIndex,
int _PacketAccess>
203 struct traits<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,_PacketAccess> >
204 : traits<PermutationMatrix<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >
207 typedef _StorageIndex StorageIndex;
212 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename _StorageIndex,
int PacketAccess>
213 class Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,PacketAccess>
214 :
public TranspositionsBase<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,PacketAccess> >
216 typedef internal::traits<Map> Traits;
219 typedef TranspositionsBase<Map> Base;
220 typedef typename Traits::IndicesType IndicesType;
221 typedef typename IndicesType::Scalar StorageIndex;
223 explicit inline Map(
const StorageIndex* indicesPtr)
224 : m_indices(indicesPtr)
227 inline Map(
const StorageIndex* indicesPtr, Index size)
228 : m_indices(indicesPtr,size)
232 template<
typename OtherDerived>
233 Map& operator=(
const TranspositionsBase<OtherDerived>& other)
235 return Base::operator=(other);
238 #ifndef EIGEN_PARSED_BY_DOXYGEN 242 Map& operator=(
const Map& other)
244 m_indices = other.m_indices;
251 const IndicesType& indices()
const {
return m_indices; }
255 IndicesType& indices() {
return m_indices; }
259 IndicesType m_indices;
263 template<
typename _IndicesType>
264 struct traits<TranspositionsWrapper<_IndicesType> >
265 : traits<PermutationWrapper<_IndicesType> >
271 template<
typename _IndicesType>
272 class TranspositionsWrapper
273 :
public TranspositionsBase<TranspositionsWrapper<_IndicesType> >
275 typedef internal::traits<TranspositionsWrapper> Traits;
278 typedef TranspositionsBase<TranspositionsWrapper> Base;
279 typedef typename Traits::IndicesType IndicesType;
280 typedef typename IndicesType::Scalar StorageIndex;
282 explicit inline TranspositionsWrapper(IndicesType& indices)
287 template<
typename OtherDerived>
288 TranspositionsWrapper& operator=(
const TranspositionsBase<OtherDerived>& other)
290 return Base::operator=(other);
295 const IndicesType& indices()
const {
return m_indices; }
299 IndicesType& indices() {
return m_indices; }
303 typename IndicesType::Nested m_indices;
310 template<
typename MatrixDerived,
typename TranspositionsDerived>
314 const TranspositionsBase<TranspositionsDerived>& transpositions)
317 (matrix.
derived(), transpositions.derived());
322 template<
typename TranspositionsDerived,
typename MatrixDerived>
325 operator*(
const TranspositionsBase<TranspositionsDerived> &transpositions,
329 (transpositions.derived(), matrix.
derived());
336 template<
typename Derived>
337 struct traits<Transpose<TranspositionsBase<Derived> > >
343 template<
typename TranspositionsDerived>
344 class Transpose<TranspositionsBase<TranspositionsDerived> >
346 typedef TranspositionsDerived TranspositionType;
347 typedef typename TranspositionType::IndicesType IndicesType;
350 explicit Transpose(
const TranspositionType& t) : m_transpositions(t) {}
352 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
353 Index size()
const EIGEN_NOEXCEPT {
return m_transpositions.size(); }
354 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
355 Index rows()
const EIGEN_NOEXCEPT {
return m_transpositions.size(); }
356 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
357 Index cols()
const EIGEN_NOEXCEPT {
return m_transpositions.size(); }
361 template<
typename OtherDerived>
friend 370 template<
typename OtherDerived>
378 const TranspositionType& nestedExpression()
const {
return m_transpositions; }
381 const TranspositionType& m_transpositions;
386 #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:94
Expression of the transpose of a matrix.
Definition: Transpose.h:52
Namespace containing all symbols from the Eigen library.
Definition: Core:141
Derived & derived()
Definition: EigenBase.h:46
Transpositions(const TranspositionsBase< OtherDerived > &other)
Definition: Transpositions.h:168
const IndicesType & indices() const
Definition: Transpositions.h:190
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:515
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Transpositions(Index size)
Definition: Transpositions.h:185
Transpositions(const MatrixBase< Other > &indices)
Definition: Transpositions.h:173
Definition: Eigen_Colamd.h:50
Transpositions & operator=(const TranspositionsBase< OtherDerived > &other)
Definition: Transpositions.h:178
Definition: Constants.h:519
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Represents a sequence of transpositions (row/column interchange)
Definition: Transpositions.h:155
IndicesType & indices()
Definition: Transpositions.h:193