diff options
author | 2015-02-16 15:29:00 +0100 | |
---|---|---|
committer | 2015-02-16 15:29:00 +0100 | |
commit | 98604576d1d4ef3d768b1cc08b4ccedbf16816ab (patch) | |
tree | dc570ba8d010e3b74550671039bf1548d11289d1 /Eigen/src/SparseCore/SparseMatrixBase.h | |
parent | bd511dde9da3a1f147b3d0d70e76298f759c4420 (diff) | |
parent | 45cbb0bbb1f66bbc923dd4dd1034b919f6b4a191 (diff) |
Merged in chtz/eigen-indexconversion (pull request PR-92)
bug #877, bug #572: Get rid of Index conversion warnings, summary of changes:
- Introduce a global typedef Eigen::Index making Eigen::DenseIndex and AnyExpr<>::Index deprecated (default is std::ptrdiff_t).
- Eigen::Index is used throughout the API to represent indices, offsets, and sizes.
- Classes storing an array of indices uses the type StorageIndex to store them. This is a template parameter of the class. Default is int.
- Methods that *explicitly* set or return an element of such an array take or return a StorageIndex type. In all other cases, the Index type is used.
Diffstat (limited to 'Eigen/src/SparseCore/SparseMatrixBase.h')
-rw-r--r-- | Eigen/src/SparseCore/SparseMatrixBase.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Eigen/src/SparseCore/SparseMatrixBase.h b/Eigen/src/SparseCore/SparseMatrixBase.h index 04baabe4f..9039ebcec 100644 --- a/Eigen/src/SparseCore/SparseMatrixBase.h +++ b/Eigen/src/SparseCore/SparseMatrixBase.h @@ -30,13 +30,15 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived> typedef typename internal::traits<Derived>::Scalar Scalar; typedef typename internal::packet_traits<Scalar>::type PacketScalar; typedef typename internal::traits<Derived>::StorageKind StorageKind; - typedef typename internal::traits<Derived>::Index Index; + typedef typename internal::traits<Derived>::StorageIndex StorageIndex; typedef typename internal::add_const_on_value_type_if_arithmetic< typename internal::packet_traits<Scalar>::type >::type PacketReturnType; typedef SparseMatrixBase StorageBaseType; typedef EigenBase<Derived> Base; + typedef Matrix<StorageIndex,Dynamic,1> IndexVector; + typedef Matrix<Scalar,Dynamic,1> ScalarVector; template<typename OtherDerived> Derived& operator=(const EigenBase<OtherDerived> &other); @@ -99,7 +101,7 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived> typedef typename internal::add_const<Transpose<const Derived> >::type ConstTransposeReturnType; // FIXME storage order do not match evaluator storage order - typedef SparseMatrix<Scalar, Flags&RowMajorBit ? RowMajor : ColMajor, Index> PlainObject; + typedef SparseMatrix<Scalar, Flags&RowMajorBit ? RowMajor : ColMajor, StorageIndex> PlainObject; #ifndef EIGEN_PARSED_BY_DOXYGEN /** This is the "real scalar" type; if the \a Scalar type is already real numbers @@ -227,8 +229,8 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived> } else { - SparseMatrix<Scalar, RowMajorBit, Index> trans = m; - s << static_cast<const SparseMatrixBase<SparseMatrix<Scalar, RowMajorBit, Index> >&>(trans); + SparseMatrix<Scalar, RowMajorBit, StorageIndex> trans = m; + s << static_cast<const SparseMatrixBase<SparseMatrix<Scalar, RowMajorBit, StorageIndex> >&>(trans); } } return s; @@ -288,7 +290,7 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived> { return Product<OtherDerived,Derived>(lhs.derived(), rhs.derived()); } /** \returns an expression of P H P^-1 where H is the matrix represented by \c *this */ - SparseSymmetricPermutationProduct<Derived,Upper|Lower> twistedBy(const PermutationMatrix<Dynamic,Dynamic,Index>& perm) const + SparseSymmetricPermutationProduct<Derived,Upper|Lower> twistedBy(const PermutationMatrix<Dynamic,Dynamic,StorageIndex>& perm) const { return SparseSymmetricPermutationProduct<Derived,Upper|Lower>(derived(), perm); } @@ -352,6 +354,10 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived> protected: bool m_isRValue; + + static inline StorageIndex convert_index(const Index idx) { + return internal::convert_index<StorageIndex>(idx); + } }; } // end namespace Eigen |