From fc202bab398ed9b78ef8452f8e4ef35e233965f6 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Fri, 13 Feb 2015 18:57:41 +0100 Subject: Index refactoring: StorageIndex must be used for storage only (and locally when it make sense). In all other cases use the global Index type. --- Eigen/src/Core/PermutationMatrix.h | 64 +++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 35 deletions(-) (limited to 'Eigen/src/Core/PermutationMatrix.h') diff --git a/Eigen/src/Core/PermutationMatrix.h b/Eigen/src/Core/PermutationMatrix.h index 886d59a2c..1da27c06c 100644 --- a/Eigen/src/Core/PermutationMatrix.h +++ b/Eigen/src/Core/PermutationMatrix.h @@ -66,11 +66,10 @@ class PermutationBase : public EigenBase MaxRowsAtCompileTime = Traits::MaxRowsAtCompileTime, MaxColsAtCompileTime = Traits::MaxColsAtCompileTime }; - typedef typename Traits::StorageIndexType StorageIndexType; typedef typename Traits::StorageIndex StorageIndex; - typedef Matrix + typedef Matrix DenseMatrixType; - typedef PermutationMatrix + typedef PermutationMatrix PlainPermutationType; using Base::derived; typedef Transpose TransposeReturnType; @@ -148,7 +147,7 @@ class PermutationBase : public EigenBase /** Sets *this to be the identity permutation matrix */ void setIdentity() { - for(StorageIndexType i = 0; i < size(); ++i) + for(Index i = 0; i < size(); ++i) indices().coeffRef(i) = i; } @@ -174,8 +173,8 @@ class PermutationBase : public EigenBase eigen_assert(i>=0 && j>=0 && i * * \param SizeAtCompileTime the number of rows/cols, or Dynamic * \param MaxSizeAtCompileTime the maximum number of rows/cols, or Dynamic. This optional parameter defaults to SizeAtCompileTime. Most of the time, you should not have to specify it. - * \param StorageIndexType the integer type of the indices + * \param StorageIndex the integer type of the indices * * This class represents a permutation matrix, internally stored as a vector of integers. * @@ -271,19 +270,18 @@ class PermutationBase : public EigenBase */ namespace internal { -template -struct traits > - : traits > +template +struct traits > + : traits > { typedef PermutationStorage StorageKind; - typedef Matrix<_StorageIndexType, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType; - typedef typename IndicesType::StorageIndex StorageIndex; - typedef _StorageIndexType StorageIndexType; + typedef Matrix<_StorageIndex, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType; + typedef _StorageIndex StorageIndex; }; } -template -class PermutationMatrix : public PermutationBase > +template +class PermutationMatrix : public PermutationBase > { typedef PermutationBase Base; typedef internal::traits Traits; @@ -293,7 +291,6 @@ class PermutationMatrix : public PermutationBase::highest()); + eigen_internal_assert(size <= NumTraits::highest()); } /** Copy constructor. */ @@ -376,9 +373,9 @@ class PermutationMatrix : public PermutationBase >& other) : m_indices(other.nestedPermutation().size()) { - eigen_internal_assert(m_indices.size() <= NumTraits::highest()); - StorageIndexType end = StorageIndexType(m_indices.size()); - for (StorageIndexType i=0; i::highest()); + StorageIndex end = StorageIndex(m_indices.size()); + for (StorageIndex i=0; i @@ -396,20 +393,19 @@ class PermutationMatrix : public PermutationBase -struct traits,_PacketAccess> > - : traits > +template +struct traits,_PacketAccess> > + : traits > { typedef PermutationStorage StorageKind; - typedef Map, _PacketAccess> IndicesType; - typedef typename IndicesType::StorageIndex StorageIndex; - typedef _StorageIndexType StorageIndexType; + typedef Map, _PacketAccess> IndicesType; + typedef _StorageIndex StorageIndex; }; } -template -class Map,_PacketAccess> - : public PermutationBase,_PacketAccess> > +template +class Map,_PacketAccess> + : public PermutationBase,_PacketAccess> > { typedef PermutationBase Base; typedef internal::traits Traits; @@ -417,15 +413,14 @@ class Map > { typedef PermutationStorage StorageKind; typedef typename _IndicesType::Scalar Scalar; - typedef typename _IndicesType::Scalar StorageIndexType; - typedef typename _IndicesType::StorageIndex StorageIndex; + typedef typename _IndicesType::Scalar StorageIndex; typedef _IndicesType IndicesType; enum { RowsAtCompileTime = _IndicesType::SizeAtCompileTime, -- cgit v1.2.3