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();
38 Index size()
const {
return indices().size(); }
40 Index rows()
const {
return indices().size(); }
42 Index cols()
const {
return indices().size(); }
45 inline const StorageIndex& coeff(
Index i)
const {
return indices().coeff(i); }
47 inline StorageIndex& coeffRef(
Index i) {
return indices().coeffRef(i); }
49 inline const StorageIndex& operator()(
Index i)
const {
return indices()(i); }
51 inline StorageIndex& operator()(
Index i) {
return indices()(i); }
53 inline const StorageIndex& operator[](
Index i)
const {
return indices()(i); }
55 inline StorageIndex& operator[](
Index i) {
return indices()(i); }
58 const IndicesType& indices()
const {
return derived().indices(); }
60 IndicesType& indices() {
return derived().indices(); }
63 inline void resize(
Index newSize)
65 indices().resize(newSize);
71 for(StorageIndex i = 0; i < indices().size(); ++i)
97 inline Transpose<TranspositionsBase>
inverse()
const 98 {
return Transpose<TranspositionsBase>(derived()); }
101 inline Transpose<TranspositionsBase> transpose()
const 102 {
return Transpose<TranspositionsBase>(derived()); }
108 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename _StorageIndex>
109 struct traits<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >
110 : traits<PermutationMatrix<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >
112 typedef Matrix<_StorageIndex, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType;
113 typedef TranspositionsStorage StorageKind;
146 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename _StorageIndex>
147 class Transpositions :
public TranspositionsBase<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >
149 typedef internal::traits<Transpositions> Traits;
152 typedef TranspositionsBase<Transpositions> Base;
153 typedef typename Traits::IndicesType IndicesType;
154 typedef typename IndicesType::Scalar StorageIndex;
159 template<
typename OtherDerived>
161 : m_indices(other.
indices()) {}
164 template<
typename Other>
169 template<
typename OtherDerived>
172 return Base::operator=(other);
181 const IndicesType&
indices()
const {
return m_indices; }
187 IndicesType m_indices;
192 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename _StorageIndex,
int _PacketAccess>
193 struct traits<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,_PacketAccess> >
194 : traits<PermutationMatrix<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> >
196 typedef Map<const Matrix<_StorageIndex,SizeAtCompileTime,1,0,MaxSizeAtCompileTime,1>, _PacketAccess> IndicesType;
197 typedef _StorageIndex StorageIndex;
198 typedef TranspositionsStorage StorageKind;
202 template<
int SizeAtCompileTime,
int MaxSizeAtCompileTime,
typename _StorageIndex,
int PacketAccess>
203 class Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,PacketAccess>
204 :
public TranspositionsBase<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,PacketAccess> >
206 typedef internal::traits<Map> Traits;
209 typedef TranspositionsBase<Map> Base;
210 typedef typename Traits::IndicesType IndicesType;
211 typedef typename IndicesType::Scalar StorageIndex;
213 explicit inline Map(
const StorageIndex* indicesPtr)
214 : m_indices(indicesPtr)
217 inline Map(
const StorageIndex* indicesPtr,
Index size)
218 : m_indices(indicesPtr,size)
222 template<
typename OtherDerived>
223 Map& operator=(
const TranspositionsBase<OtherDerived>& other)
225 return Base::operator=(other);
228 #ifndef EIGEN_PARSED_BY_DOXYGEN 232 Map& operator=(
const Map& other)
234 m_indices = other.m_indices;
240 const IndicesType& indices()
const {
return m_indices; }
243 IndicesType& indices() {
return m_indices; }
247 IndicesType m_indices;
251 template<
typename _IndicesType>
252 struct traits<TranspositionsWrapper<_IndicesType> >
253 : traits<PermutationWrapper<_IndicesType> >
255 typedef TranspositionsStorage StorageKind;
259 template<
typename _IndicesType>
260 class TranspositionsWrapper
261 :
public TranspositionsBase<TranspositionsWrapper<_IndicesType> >
263 typedef internal::traits<TranspositionsWrapper> Traits;
266 typedef TranspositionsBase<TranspositionsWrapper> Base;
267 typedef typename Traits::IndicesType IndicesType;
268 typedef typename IndicesType::Scalar StorageIndex;
270 explicit inline TranspositionsWrapper(IndicesType& indices)
275 template<
typename OtherDerived>
276 TranspositionsWrapper& operator=(
const TranspositionsBase<OtherDerived>& other)
278 return Base::operator=(other);
282 const IndicesType& indices()
const {
return m_indices; }
285 IndicesType& indices() {
return m_indices; }
289 typename IndicesType::Nested m_indices;
296 template<
typename MatrixDerived,
typename TranspositionsDerived>
298 const Product<MatrixDerived, TranspositionsDerived, AliasFreeProduct>
300 const TranspositionsBase<TranspositionsDerived>& transpositions)
303 (matrix.
derived(), transpositions.derived());
308 template<
typename TranspositionsDerived,
typename MatrixDerived>
310 const Product<TranspositionsDerived, MatrixDerived, AliasFreeProduct>
311 operator*(
const TranspositionsBase<TranspositionsDerived> &transpositions,
315 (transpositions.derived(), matrix.
derived());
322 template<
typename Derived>
323 struct traits<Transpose<TranspositionsBase<Derived> > >
329 template<
typename TranspositionsDerived>
330 class Transpose<TranspositionsBase<TranspositionsDerived> >
332 typedef TranspositionsDerived TranspositionType;
333 typedef typename TranspositionType::IndicesType IndicesType;
336 explicit Transpose(
const TranspositionType& t) : m_transpositions(t) {}
338 Index size()
const {
return m_transpositions.size(); }
339 Index rows()
const {
return m_transpositions.size(); }
340 Index cols()
const {
return m_transpositions.size(); }
344 template<
typename OtherDerived>
friend 345 const Product<OtherDerived, Transpose, AliasFreeProduct>
346 operator*(
const MatrixBase<OtherDerived>& matrix,
const Transpose& trt)
348 return Product<OtherDerived, Transpose, AliasFreeProduct>(matrix.derived(), trt);
353 template<
typename OtherDerived>
354 const Product<Transpose, OtherDerived, AliasFreeProduct>
355 operator*(
const MatrixBase<OtherDerived>& matrix)
const 357 return Product<Transpose, OtherDerived, AliasFreeProduct>(*
this, matrix.derived());
360 const TranspositionType&
nestedExpression()
const {
return m_transpositions; }
363 const TranspositionType& m_transpositions;
368 #endif // EIGEN_TRANSPOSITIONS_H Expression of the product of two arbitrary matrices or vectors.
Definition: Product.h:71
Namespace containing all symbols from the Eigen library.
Definition: Core:309
Transpositions(const TranspositionsBase< OtherDerived > &other)
Definition: Transpositions.h:160
Map(PointerArgType dataPtr, const StrideType &stride=StrideType())
Definition: Map.h:129
const IndicesType & indices() const
Definition: Transpositions.h:181
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_inverse_op< typename Derived::Scalar >, const Derived > inverse(const Eigen::ArrayBase< Derived > &x)
Derived & derived()
Definition: EigenBase.h:45
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:33
Transpositions(Index size)
Definition: Transpositions.h:177
const internal::remove_all< MatrixTypeNested >::type & nestedExpression() const
Definition: Transpose.h:74
Transpositions(const MatrixBase< Other > &indices)
Definition: Transpositions.h:165
Definition: Eigen_Colamd.h:50
Transpositions & operator=(const TranspositionsBase< OtherDerived > &other)
Definition: Transpositions.h:170
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Represents a sequence of transpositions (row/column interchange)
Definition: Transpositions.h:147
IndicesType & indices()
Definition: Transpositions.h:183