diff options
author | 2015-02-16 15:29:00 +0100 | |
---|---|---|
committer | 2015-02-16 15:29:00 +0100 | |
commit | 98604576d1d4ef3d768b1cc08b4ccedbf16816ab (patch) | |
tree | dc570ba8d010e3b74550671039bf1548d11289d1 /Eigen | |
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')
155 files changed, 1317 insertions, 1459 deletions
diff --git a/Eigen/src/Cholesky/LDLT.h b/Eigen/src/Cholesky/LDLT.h index 5acbf4651..f46f7b758 100644 --- a/Eigen/src/Cholesky/LDLT.h +++ b/Eigen/src/Cholesky/LDLT.h @@ -59,7 +59,8 @@ template<typename _MatrixType, int _UpLo> class LDLT }; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar; - typedef typename MatrixType::Index Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef typename MatrixType::StorageIndex StorageIndex; typedef Matrix<Scalar, RowsAtCompileTime, 1, Options, MaxRowsAtCompileTime, 1> TmpMatrixType; typedef Transpositions<RowsAtCompileTime, MaxRowsAtCompileTime> TranspositionType; @@ -251,8 +252,7 @@ template<> struct ldlt_inplace<Lower> using std::abs; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; - typedef typename TranspositionType::StorageIndexType IndexType; + typedef typename TranspositionType::StorageIndex IndexType; eigen_assert(mat.rows()==mat.cols()); const Index size = mat.rows(); @@ -342,7 +342,6 @@ template<> struct ldlt_inplace<Lower> using numext::isfinite; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; const Index size = mat.rows(); eigen_assert(mat.cols() == size && w.size()==size); @@ -450,7 +449,7 @@ template<typename MatrixType, int _UpLo> template<typename Derived> LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::rankUpdate(const MatrixBase<Derived>& w, const typename NumTraits<typename MatrixType::Scalar>::Real& sigma) { - typedef typename TranspositionType::StorageIndexType IndexType; + typedef typename TranspositionType::StorageIndex IndexType; const Index size = w.rows(); if (m_isInitialized) { diff --git a/Eigen/src/Cholesky/LLT.h b/Eigen/src/Cholesky/LLT.h index 90194e64d..629c87161 100644 --- a/Eigen/src/Cholesky/LLT.h +++ b/Eigen/src/Cholesky/LLT.h @@ -59,7 +59,8 @@ template<typename _MatrixType, int _UpLo> class LLT }; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar; - typedef typename MatrixType::Index Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 + typedef typename MatrixType::StorageIndex StorageIndex; enum { PacketSize = internal::packet_traits<Scalar>::size, @@ -183,12 +184,11 @@ namespace internal { template<typename Scalar, int UpLo> struct llt_inplace; template<typename MatrixType, typename VectorType> -static typename MatrixType::Index llt_rank_update_lower(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) +static Index llt_rank_update_lower(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) { using std::sqrt; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; typedef typename MatrixType::ColXpr ColXpr; typedef typename internal::remove_all<ColXpr>::type ColXprCleaned; typedef typename ColXprCleaned::SegmentReturnType ColXprSegment; @@ -257,10 +257,9 @@ template<typename Scalar> struct llt_inplace<Scalar, Lower> { typedef typename NumTraits<Scalar>::Real RealScalar; template<typename MatrixType> - static typename MatrixType::Index unblocked(MatrixType& mat) + static Index unblocked(MatrixType& mat) { using std::sqrt; - typedef typename MatrixType::Index Index; eigen_assert(mat.rows()==mat.cols()); const Index size = mat.rows(); @@ -284,9 +283,8 @@ template<typename Scalar> struct llt_inplace<Scalar, Lower> } template<typename MatrixType> - static typename MatrixType::Index blocked(MatrixType& m) + static Index blocked(MatrixType& m) { - typedef typename MatrixType::Index Index; eigen_assert(m.rows()==m.cols()); Index size = m.rows(); if(size<32) @@ -317,7 +315,7 @@ template<typename Scalar> struct llt_inplace<Scalar, Lower> } template<typename MatrixType, typename VectorType> - static typename MatrixType::Index rankUpdate(MatrixType& mat, const VectorType& vec, const RealScalar& sigma) + static Index rankUpdate(MatrixType& mat, const VectorType& vec, const RealScalar& sigma) { return Eigen::internal::llt_rank_update_lower(mat, vec, sigma); } @@ -328,19 +326,19 @@ template<typename Scalar> struct llt_inplace<Scalar, Upper> typedef typename NumTraits<Scalar>::Real RealScalar; template<typename MatrixType> - static EIGEN_STRONG_INLINE typename MatrixType::Index unblocked(MatrixType& mat) + static EIGEN_STRONG_INLINE Index unblocked(MatrixType& mat) { Transpose<MatrixType> matt(mat); return llt_inplace<Scalar, Lower>::unblocked(matt); } template<typename MatrixType> - static EIGEN_STRONG_INLINE typename MatrixType::Index blocked(MatrixType& mat) + static EIGEN_STRONG_INLINE Index blocked(MatrixType& mat) { Transpose<MatrixType> matt(mat); return llt_inplace<Scalar, Lower>::blocked(matt); } template<typename MatrixType, typename VectorType> - static typename MatrixType::Index rankUpdate(MatrixType& mat, const VectorType& vec, const RealScalar& sigma) + static Index rankUpdate(MatrixType& mat, const VectorType& vec, const RealScalar& sigma) { Transpose<MatrixType> matt(mat); return llt_inplace<Scalar, Lower>::rankUpdate(matt, vec.conjugate(), sigma); diff --git a/Eigen/src/Cholesky/LLT_MKL.h b/Eigen/src/Cholesky/LLT_MKL.h index 64daa445c..09bf59d43 100644 --- a/Eigen/src/Cholesky/LLT_MKL.h +++ b/Eigen/src/Cholesky/LLT_MKL.h @@ -46,7 +46,7 @@ template<typename Scalar> struct mkl_llt; template<> struct mkl_llt<EIGTYPE> \ { \ template<typename MatrixType> \ - static inline typename MatrixType::Index potrf(MatrixType& m, char uplo) \ + static inline Index potrf(MatrixType& m, char uplo) \ { \ lapack_int matrix_order; \ lapack_int size, lda, info, StorageOrder; \ @@ -67,23 +67,23 @@ template<> struct mkl_llt<EIGTYPE> \ template<> struct llt_inplace<EIGTYPE, Lower> \ { \ template<typename MatrixType> \ - static typename MatrixType::Index blocked(MatrixType& m) \ + static Index blocked(MatrixType& m) \ { \ return mkl_llt<EIGTYPE>::potrf(m, 'L'); \ } \ template<typename MatrixType, typename VectorType> \ - static typename MatrixType::Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \ + static Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \ { return Eigen::internal::llt_rank_update_lower(mat, vec, sigma); } \ }; \ template<> struct llt_inplace<EIGTYPE, Upper> \ { \ template<typename MatrixType> \ - static typename MatrixType::Index blocked(MatrixType& m) \ + static Index blocked(MatrixType& m) \ { \ return mkl_llt<EIGTYPE>::potrf(m, 'U'); \ } \ template<typename MatrixType, typename VectorType> \ - static typename MatrixType::Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \ + static Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \ { \ Transpose<MatrixType> matt(mat); \ return llt_inplace<EIGTYPE, Lower>::rankUpdate(matt, vec.conjugate(), sigma); \ diff --git a/Eigen/src/CholmodSupport/CholmodSupport.h b/Eigen/src/CholmodSupport/CholmodSupport.h index 3eadb83a0..3ce3e99d3 100644 --- a/Eigen/src/CholmodSupport/CholmodSupport.h +++ b/Eigen/src/CholmodSupport/CholmodSupport.h @@ -48,8 +48,8 @@ void cholmod_configure_matrix(CholmodType& mat) /** Wraps the Eigen sparse matrix \a mat into a Cholmod sparse matrix object. * Note that the data are shared. */ -template<typename _Scalar, int _Options, typename _Index> -cholmod_sparse viewAsCholmod(SparseMatrix<_Scalar,_Options,_Index>& mat) +template<typename _Scalar, int _Options, typename _StorageIndex> +cholmod_sparse viewAsCholmod(SparseMatrix<_Scalar,_Options,_StorageIndex>& mat) { cholmod_sparse res; res.nzmax = mat.nonZeros(); @@ -74,11 +74,11 @@ cholmod_sparse viewAsCholmod(SparseMatrix<_Scalar,_Options,_Index>& mat) res.dtype = 0; res.stype = -1; - if (internal::is_same<_Index,int>::value) + if (internal::is_same<_StorageIndex,int>::value) { res.itype = CHOLMOD_INT; } - else if (internal::is_same<_Index,UF_long>::value) + else if (internal::is_same<_StorageIndex,UF_long>::value) { res.itype = CHOLMOD_LONG; } @@ -138,12 +138,12 @@ cholmod_dense viewAsCholmod(MatrixBase<Derived>& mat) /** Returns a view of the Cholmod sparse matrix \a cm as an Eigen sparse matrix. * The data are not copied but shared. */ -template<typename Scalar, int Flags, typename Index> -MappedSparseMatrix<Scalar,Flags,Index> viewAsEigen(cholmod_sparse& cm) +template<typename Scalar, int Flags, typename StorageIndex> +MappedSparseMatrix<Scalar,Flags,StorageIndex> viewAsEigen(cholmod_sparse& cm) { - return MappedSparseMatrix<Scalar,Flags,Index> - (cm.nrow, cm.ncol, static_cast<Index*>(cm.p)[cm.ncol], - static_cast<Index*>(cm.p), static_cast<Index*>(cm.i),static_cast<Scalar*>(cm.x) ); + return MappedSparseMatrix<Scalar,Flags,StorageIndex> + (cm.nrow, cm.ncol, static_cast<StorageIndex*>(cm.p)[cm.ncol], + static_cast<StorageIndex*>(cm.p), static_cast<StorageIndex*>(cm.i),static_cast<Scalar*>(cm.x) ); } enum CholmodMode { @@ -169,7 +169,7 @@ class CholmodBase : public SparseSolverBase<Derived> typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; typedef MatrixType CholMatrixType; - typedef typename MatrixType::Index Index; + typedef typename MatrixType::StorageIndex StorageIndex; public: @@ -195,8 +195,8 @@ class CholmodBase : public SparseSolverBase<Derived> cholmod_finish(&m_cholmod); } - inline Index cols() const { return m_cholmodFactor->n; } - inline Index rows() const { return m_cholmodFactor->n; } + inline StorageIndex cols() const { return internal::convert_index<StorageIndex, Index>(m_cholmodFactor->n); } + inline StorageIndex rows() const { return internal::convert_index<StorageIndex, Index>(m_cholmodFactor->n); } /** \brief Reports whether previous computation was successful. * diff --git a/Eigen/src/Core/ArrayBase.h b/Eigen/src/Core/ArrayBase.h index d42693d4b..82c12076e 100644 --- a/Eigen/src/Core/ArrayBase.h +++ b/Eigen/src/Core/ArrayBase.h @@ -50,7 +50,6 @@ template<typename Derived> class ArrayBase typename NumTraits<typename internal::traits<Derived>::Scalar>::Real>::operator*; typedef typename internal::traits<Derived>::StorageKind StorageKind; - typedef typename internal::traits<Derived>::Index Index; typedef typename internal::traits<Derived>::Scalar Scalar; typedef typename internal::packet_traits<Scalar>::type PacketScalar; typedef typename NumTraits<Scalar>::Real RealScalar; diff --git a/Eigen/src/Core/AssignEvaluator.h b/Eigen/src/Core/AssignEvaluator.h index 4db10e697..506bace69 100644 --- a/Eigen/src/Core/AssignEvaluator.h +++ b/Eigen/src/Core/AssignEvaluator.h @@ -179,20 +179,20 @@ struct copy_using_evaluator_DefaultTraversal_CompleteUnrolling<Kernel, Stop, Sto EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel&) { } }; -template<typename Kernel, int Index, int Stop> +template<typename Kernel, int Index_, int Stop> struct copy_using_evaluator_DefaultTraversal_InnerUnrolling { - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel, typename Kernel::Index outer) + EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel, Index outer) { - kernel.assignCoeffByOuterInner(outer, Index); - copy_using_evaluator_DefaultTraversal_InnerUnrolling<Kernel, Index+1, Stop>::run(kernel, outer); + kernel.assignCoeffByOuterInner(outer, Index_); + copy_using_evaluator_DefaultTraversal_InnerUnrolling<Kernel, Index_+1, Stop>::run(kernel, outer); } }; template<typename Kernel, int Stop> struct copy_using_evaluator_DefaultTraversal_InnerUnrolling<Kernel, Stop, Stop> { - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel&, typename Kernel::Index) { } + EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel&, Index) { } }; /*********************** @@ -246,13 +246,13 @@ struct copy_using_evaluator_innervec_CompleteUnrolling<Kernel, Stop, Stop> EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel&) { } }; -template<typename Kernel, int Index, int Stop> +template<typename Kernel, int Index_, int Stop> struct copy_using_evaluator_innervec_InnerUnrolling { - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel, typename Kernel::Index outer) + EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel, Index outer) { - kernel.template assignPacketByOuterInner<Aligned, Aligned>(outer, Index); - enum { NextIndex = Index + packet_traits<typename Kernel::Scalar>::size }; + kernel.template assignPacketByOuterInner<Aligned, Aligned>(outer, Index_); + enum { NextIndex = Index_ + packet_traits<typename Kernel::Scalar>::size }; copy_using_evaluator_innervec_InnerUnrolling<Kernel, NextIndex, Stop>::run(kernel, outer); } }; @@ -260,7 +260,7 @@ struct copy_using_evaluator_innervec_InnerUnrolling template<typename Kernel, int Stop> struct copy_using_evaluator_innervec_InnerUnrolling<Kernel, Stop, Stop> { - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &, typename Kernel::Index) { } + EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &, Index) { } }; /*************************************************************************** @@ -283,8 +283,6 @@ struct dense_assignment_loop<Kernel, DefaultTraversal, NoUnrolling> { EIGEN_DEVICE_FUNC static void run(Kernel &kernel) { - typedef typename Kernel::Index Index; - for(Index outer = 0; outer < kernel.outerSize(); ++outer) { for(Index inner = 0; inner < kernel.innerSize(); ++inner) { kernel.assignCoeffByOuterInner(outer, inner); @@ -306,7 +304,7 @@ struct dense_assignment_loop<Kernel, DefaultTraversal, CompleteUnrolling> template<typename Kernel> struct dense_assignment_loop<Kernel, DefaultTraversal, InnerUnrolling> { - typedef typename Kernel::Index Index; + typedef typename Kernel::StorageIndex StorageIndex; EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel) { typedef typename Kernel::DstEvaluatorType::XprType DstXprType; @@ -330,7 +328,7 @@ struct unaligned_dense_assignment_loop { // if IsAligned = true, then do nothing template <typename Kernel> - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel&, typename Kernel::Index, typename Kernel::Index) {} + EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel&, Index, Index) {} }; template <> @@ -342,16 +340,16 @@ struct unaligned_dense_assignment_loop<false> #if EIGEN_COMP_MSVC template <typename Kernel> static EIGEN_DONT_INLINE void run(Kernel &kernel, - typename Kernel::Index start, - typename Kernel::Index end) + Index start, + Index end) #else template <typename Kernel> EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel, - typename Kernel::Index start, - typename Kernel::Index end) + Index start, + Index end) #endif { - for (typename Kernel::Index index = start; index < end; ++index) + for (Index index = start; index < end; ++index) kernel.assignCoeff(index); } }; @@ -361,8 +359,6 @@ struct dense_assignment_loop<Kernel, LinearVectorizedTraversal, NoUnrolling> { EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel) { - typedef typename Kernel::Index Index; - const Index size = kernel.size(); typedef packet_traits<typename Kernel::Scalar> PacketTraits; enum { @@ -386,7 +382,7 @@ struct dense_assignment_loop<Kernel, LinearVectorizedTraversal, NoUnrolling> template<typename Kernel> struct dense_assignment_loop<Kernel, LinearVectorizedTraversal, CompleteUnrolling> { - typedef typename Kernel::Index Index; + typedef typename Kernel::StorageIndex StorageIndex; EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel) { typedef typename Kernel::DstEvaluatorType::XprType DstXprType; @@ -409,8 +405,6 @@ struct dense_assignment_loop<Kernel, InnerVectorizedTraversal, NoUnrolling> { EIGEN_DEVICE_FUNC static inline void run(Kernel &kernel) { - typedef typename Kernel::Index Index; - const Index innerSize = kernel.innerSize(); const Index outerSize = kernel.outerSize(); const Index packetSize = packet_traits<typename Kernel::Scalar>::size; @@ -433,7 +427,7 @@ struct dense_assignment_loop<Kernel, InnerVectorizedTraversal, CompleteUnrolling template<typename Kernel> struct dense_assignment_loop<Kernel, InnerVectorizedTraversal, InnerUnrolling> { - typedef typename Kernel::Index Index; + typedef typename Kernel::StorageIndex StorageIndex; EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void run(Kernel &kernel) { typedef typename Kernel::DstEvaluatorType::XprType DstXprType; @@ -452,7 +446,6 @@ struct dense_assignment_loop<Kernel, LinearTraversal, NoUnrolling> { EIGEN_DEVICE_FUNC static inline void run(Kernel &kernel) { - typedef typename Kernel::Index Index; const Index size = kernel.size(); for(Index i = 0; i < size; ++i) kernel.assignCoeff(i); @@ -478,7 +471,6 @@ struct dense_assignment_loop<Kernel, SliceVectorizedTraversal, NoUnrolling> { EIGEN_DEVICE_FUNC static inline void run(Kernel &kernel) { - typedef typename Kernel::Index Index; typedef packet_traits<typename Kernel::Scalar> PacketTraits; enum { packetSize = PacketTraits::size, @@ -533,7 +525,7 @@ public: typedef DstEvaluatorTypeT DstEvaluatorType; typedef SrcEvaluatorTypeT SrcEvaluatorType; typedef typename DstEvaluatorType::Scalar Scalar; - typedef typename DstEvaluatorType::Index Index; + typedef typename DstEvaluatorType::StorageIndex StorageIndex; typedef copy_using_evaluator_traits<DstEvaluatorTypeT, SrcEvaluatorTypeT, Functor> AssignmentTraits; @@ -731,8 +723,8 @@ EIGEN_DEVICE_FUNC void call_assignment_no_alias(Dst& dst, const Src& src, const && int(Dst::SizeAtCompileTime) != 1 }; - typename Dst::Index dstRows = NeedToTranspose ? src.cols() : src.rows(); - typename Dst::Index dstCols = NeedToTranspose ? src.rows() : src.cols(); + Index dstRows = NeedToTranspose ? src.cols() : src.rows(); + Index dstCols = NeedToTranspose ? src.rows() : src.cols(); if((dst.rows()!=dstRows) || (dst.cols()!=dstCols)) dst.resize(dstRows, dstCols); diff --git a/Eigen/src/Core/Assign_MKL.h b/Eigen/src/Core/Assign_MKL.h index 97134ffd7..a7b9e9293 100644 --- a/Eigen/src/Core/Assign_MKL.h +++ b/Eigen/src/Core/Assign_MKL.h @@ -84,7 +84,6 @@ template<typename Derived1, typename Derived2, typename UnaryOp, int Traversal, struct vml_assign_impl<Derived1, Derived2, UnaryOp, Traversal, Unrolling, InnerVectorizedTraversal> { typedef typename Derived1::Scalar Scalar; - typedef typename Derived1::Index Index; static inline void run(Derived1& dst, const CwiseUnaryOp<UnaryOp, Derived2>& src) { // in case we want to (or have to) skip VML at runtime we can call: diff --git a/Eigen/src/Core/BandMatrix.h b/Eigen/src/Core/BandMatrix.h index e59ee3da9..87c124fdf 100644 --- a/Eigen/src/Core/BandMatrix.h +++ b/Eigen/src/Core/BandMatrix.h @@ -32,7 +32,7 @@ class BandMatrixBase : public EigenBase<Derived> }; typedef typename internal::traits<Derived>::Scalar Scalar; typedef Matrix<Scalar,RowsAtCompileTime,ColsAtCompileTime> DenseMatrixType; - typedef typename DenseMatrixType::Index Index; + typedef typename DenseMatrixType::StorageIndex StorageIndex; typedef typename internal::traits<Derived>::CoefficientsType CoefficientsType; typedef EigenBase<Derived> Base; @@ -179,7 +179,7 @@ struct traits<BandMatrix<_Scalar,_Rows,_Cols,_Supers,_Subs,_Options> > { typedef _Scalar Scalar; typedef Dense StorageKind; - typedef DenseIndex Index; + typedef Eigen::Index StorageIndex; enum { CoeffReadCost = NumTraits<Scalar>::ReadCost, RowsAtCompileTime = _Rows, @@ -201,7 +201,7 @@ class BandMatrix : public BandMatrixBase<BandMatrix<_Scalar,Rows,Cols,Supers,Sub public: typedef typename internal::traits<BandMatrix>::Scalar Scalar; - typedef typename internal::traits<BandMatrix>::Index Index; + typedef typename internal::traits<BandMatrix>::StorageIndex StorageIndex; typedef typename internal::traits<BandMatrix>::CoefficientsType CoefficientsType; explicit inline BandMatrix(Index rows=Rows, Index cols=Cols, Index supers=Supers, Index subs=Subs) @@ -241,7 +241,7 @@ struct traits<BandMatrixWrapper<_CoefficientsType,_Rows,_Cols,_Supers,_Subs,_Opt { typedef typename _CoefficientsType::Scalar Scalar; typedef typename _CoefficientsType::StorageKind StorageKind; - typedef typename _CoefficientsType::Index Index; + typedef typename _CoefficientsType::StorageIndex StorageIndex; enum { CoeffReadCost = internal::traits<_CoefficientsType>::CoeffReadCost, RowsAtCompileTime = _Rows, @@ -264,7 +264,7 @@ class BandMatrixWrapper : public BandMatrixBase<BandMatrixWrapper<_CoefficientsT typedef typename internal::traits<BandMatrixWrapper>::Scalar Scalar; typedef typename internal::traits<BandMatrixWrapper>::CoefficientsType CoefficientsType; - typedef typename internal::traits<BandMatrixWrapper>::Index Index; + typedef typename internal::traits<BandMatrixWrapper>::StorageIndex StorageIndex; explicit inline BandMatrixWrapper(const CoefficientsType& coeffs, Index rows=_Rows, Index cols=_Cols, Index supers=_Supers, Index subs=_Subs) : m_coeffs(coeffs), @@ -312,7 +312,7 @@ template<typename Scalar, int Size, int Options> class TridiagonalMatrix : public BandMatrix<Scalar,Size,Size,Options&SelfAdjoint?0:1,1,Options|RowMajor> { typedef BandMatrix<Scalar,Size,Size,Options&SelfAdjoint?0:1,1,Options|RowMajor> Base; - typedef typename Base::Index Index; + typedef typename Base::StorageIndex StorageIndex; public: explicit TridiagonalMatrix(Index size = Size) : Base(size,size,Options&SelfAdjoint?0:1,1) {} diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index 5f6307206..2ef37ca1c 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -154,7 +154,7 @@ class BlockImpl<XprType, BlockRows, BlockCols, InnerPanel, Dense> : public internal::BlockImpl_dense<XprType, BlockRows, BlockCols, InnerPanel> { typedef internal::BlockImpl_dense<XprType, BlockRows, BlockCols, InnerPanel> Impl; - typedef typename XprType::Index Index; + typedef typename XprType::StorageIndex StorageIndex; public: typedef Impl Base; EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl) @@ -306,13 +306,13 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H } EIGEN_DEVICE_FUNC - Index startRow() const + StorageIndex startRow() const { return m_startRow.value(); } EIGEN_DEVICE_FUNC - Index startCol() const + StorageIndex startCol() const { return m_startCol.value(); } @@ -320,10 +320,10 @@ template<typename XprType, int BlockRows, int BlockCols, bool InnerPanel, bool H protected: const typename XprType::Nested m_xpr; - const internal::variable_if_dynamic<Index, XprType::RowsAtCompileTime == 1 ? 0 : Dynamic> m_startRow; - const internal::variable_if_dynamic<Index, XprType::ColsAtCompileTime == 1 ? 0 : Dynamic> m_startCol; - const internal::variable_if_dynamic<Index, RowsAtCompileTime> m_blockRows; - const internal::variable_if_dynamic<Index, ColsAtCompileTime> m_blockCols; + const internal::variable_if_dynamic<StorageIndex, XprType::RowsAtCompileTime == 1 ? 0 : Dynamic> m_startRow; + const internal::variable_if_dynamic<StorageIndex, XprType::ColsAtCompileTime == 1 ? 0 : Dynamic> m_startCol; + const internal::variable_if_dynamic<StorageIndex, RowsAtCompileTime> m_blockRows; + const internal::variable_if_dynamic<StorageIndex, ColsAtCompileTime> m_blockCols; }; /** \internal Internal implementation of dense Blocks in the direct access case.*/ diff --git a/Eigen/src/Core/BooleanRedux.h b/Eigen/src/Core/BooleanRedux.h index dac1887e0..31fbb9214 100644 --- a/Eigen/src/Core/BooleanRedux.h +++ b/Eigen/src/Core/BooleanRedux.h @@ -130,7 +130,7 @@ inline bool DenseBase<Derived>::any() const * \sa all(), any() */ template<typename Derived> -inline typename DenseBase<Derived>::Index DenseBase<Derived>::count() const +inline Eigen::Index DenseBase<Derived>::count() const { return derived().template cast<bool>().template cast<Index>().sum(); } diff --git a/Eigen/src/Core/CommaInitializer.h b/Eigen/src/Core/CommaInitializer.h index 70cbfeff5..808f3977c 100644 --- a/Eigen/src/Core/CommaInitializer.h +++ b/Eigen/src/Core/CommaInitializer.h @@ -28,7 +28,6 @@ template<typename XprType> struct CommaInitializer { typedef typename XprType::Scalar Scalar; - typedef typename XprType::Index Index; EIGEN_DEVICE_FUNC inline CommaInitializer(XprType& xpr, const Scalar& s) diff --git a/Eigen/src/Core/CoreEvaluators.h b/Eigen/src/Core/CoreEvaluators.h index 1c7123b85..9485080d3 100644 --- a/Eigen/src/Core/CoreEvaluators.h +++ b/Eigen/src/Core/CoreEvaluators.h @@ -111,7 +111,8 @@ struct evaluator_base typedef evaluator<ExpressionType> type; typedef evaluator<ExpressionType> nestedType; - typedef typename traits<ExpressionType>::Index Index; + // FIXME is it really usefull? + typedef typename traits<ExpressionType>::StorageIndex StorageIndex; // TODO that's not very nice to have to propagate all these traits. They are currently only needed to handle outer,inner indices. typedef traits<ExpressionType> ExpressionTraits; }; @@ -128,7 +129,6 @@ struct evaluator<PlainObjectBase<Derived> > : evaluator_base<Derived> { typedef PlainObjectBase<Derived> PlainObjectType; - typedef typename PlainObjectType::Index Index; typedef typename PlainObjectType::Scalar Scalar; typedef typename PlainObjectType::CoeffReturnType CoeffReturnType; typedef typename PlainObjectType::PacketScalar PacketScalar; @@ -264,7 +264,6 @@ struct unary_evaluator<Transpose<ArgType>, IndexBased> EIGEN_DEVICE_FUNC explicit unary_evaluator(const XprType& t) : m_argImpl(t.nestedExpression()) {} - typedef typename XprType::Index Index; typedef typename XprType::Scalar Scalar; typedef typename XprType::CoeffReturnType CoeffReturnType; typedef typename XprType::PacketScalar PacketScalar; @@ -343,7 +342,6 @@ struct evaluator<CwiseNullaryOp<NullaryOp,PlainObjectType> > : m_functor(n.functor()) { } - typedef typename XprType::Index Index; typedef typename XprType::CoeffReturnType CoeffReturnType; typedef typename XprType::PacketScalar PacketScalar; @@ -394,7 +392,6 @@ struct unary_evaluator<CwiseUnaryOp<UnaryOp, ArgType>, IndexBased > m_argImpl(op.nestedExpression()) { } - typedef typename XprType::Index Index; typedef typename XprType::CoeffReturnType CoeffReturnType; typedef typename XprType::PacketScalar PacketScalar; @@ -469,7 +466,6 @@ struct binary_evaluator<CwiseBinaryOp<BinaryOp, Lhs, Rhs>, IndexBased, IndexBase m_rhsImpl(xpr.rhs()) { } - typedef typename XprType::Index Index; typedef typename XprType::CoeffReturnType CoeffReturnType; typedef typename XprType::PacketScalar PacketScalar; @@ -522,7 +518,6 @@ struct unary_evaluator<CwiseUnaryView<UnaryOp, ArgType>, IndexBased> m_argImpl(op.nestedExpression()) { } - typedef typename XprType::Index Index; typedef typename XprType::Scalar Scalar; typedef typename XprType::CoeffReturnType CoeffReturnType; @@ -563,7 +558,6 @@ struct mapbase_evaluator : evaluator_base<Derived> { typedef Derived XprType; typedef typename XprType::PointerType PointerType; - typedef typename XprType::Index Index; typedef typename XprType::Scalar Scalar; typedef typename XprType::CoeffReturnType CoeffReturnType; typedef typename XprType::PacketScalar PacketScalar; @@ -760,7 +754,6 @@ struct unary_evaluator<Block<ArgType, BlockRows, BlockCols, InnerPanel>, IndexBa m_startCol(block.startCol()) { } - typedef typename XprType::Index Index; typedef typename XprType::Scalar Scalar; typedef typename XprType::CoeffReturnType CoeffReturnType; typedef typename XprType::PacketScalar PacketScalar; @@ -865,7 +858,6 @@ struct evaluator<Select<ConditionMatrixType, ThenMatrixType, ElseMatrixType> > m_elseImpl(select.elseMatrix()) { } - typedef typename XprType::Index Index; typedef typename XprType::CoeffReturnType CoeffReturnType; inline EIGEN_DEVICE_FUNC CoeffReturnType coeff(Index row, Index col) const @@ -898,7 +890,6 @@ struct unary_evaluator<Replicate<ArgType, RowFactor, ColFactor> > : evaluator_base<Replicate<ArgType, RowFactor, ColFactor> > { typedef Replicate<ArgType, RowFactor, ColFactor> XprType; - typedef typename XprType::Index Index; typedef typename XprType::CoeffReturnType CoeffReturnType; typedef typename XprType::PacketReturnType PacketReturnType; enum { @@ -981,7 +972,6 @@ struct evaluator<PartialReduxExpr<ArgType, MemberOp, Direction> > : m_expr(expr) {} - typedef typename XprType::Index Index; typedef typename XprType::CoeffReturnType CoeffReturnType; EIGEN_DEVICE_FUNC CoeffReturnType coeff(Index row, Index col) const @@ -1016,7 +1006,6 @@ struct evaluator_wrapper_base EIGEN_DEVICE_FUNC explicit evaluator_wrapper_base(const ArgType& arg) : m_argImpl(arg) {} - typedef typename ArgType::Index Index; typedef typename ArgType::Scalar Scalar; typedef typename ArgType::CoeffReturnType CoeffReturnType; typedef typename ArgType::PacketScalar PacketScalar; @@ -1103,7 +1092,6 @@ struct unary_evaluator<Reverse<ArgType, Direction> > : evaluator_base<Reverse<ArgType, Direction> > { typedef Reverse<ArgType, Direction> XprType; - typedef typename XprType::Index Index; typedef typename XprType::Scalar Scalar; typedef typename XprType::CoeffReturnType CoeffReturnType; typedef typename XprType::PacketScalar PacketScalar; @@ -1219,7 +1207,6 @@ struct evaluator<Diagonal<ArgType, DiagIndex> > m_index(diagonal.index()) { } - typedef typename XprType::Index Index; typedef typename XprType::Scalar Scalar; // FIXME having to check whether ArgType is sparse here i not very nice. typedef typename internal::conditional<!internal::is_same<typename ArgType::StorageKind,Sparse>::value, diff --git a/Eigen/src/Core/CoreIterators.h b/Eigen/src/Core/CoreIterators.h index 7feebc4e4..c76bdf68e 100644 --- a/Eigen/src/Core/CoreIterators.h +++ b/Eigen/src/Core/CoreIterators.h @@ -36,7 +36,6 @@ protected: typedef internal::inner_iterator_selector<XprType, typename internal::evaluator_traits<XprType>::Kind> IteratorType; typedef typename internal::evaluator<XprType>::type EvaluatorType; typedef typename internal::traits<XprType>::Scalar Scalar; - typedef typename internal::traits<XprType>::Index Index; public: /** Construct an iterator over the \a outerId -th row or column of \a xpr */ InnerIterator(const XprType &xpr, const Index &outerId) @@ -77,7 +76,6 @@ class inner_iterator_selector<XprType, IndexBased> protected: typedef typename evaluator<XprType>::type EvaluatorType; typedef typename traits<XprType>::Scalar Scalar; - typedef typename traits<XprType>::Index Index; enum { IsRowMajor = (XprType::Flags&RowMajorBit)==RowMajorBit }; public: @@ -115,7 +113,6 @@ class inner_iterator_selector<XprType, IteratorBased> protected: typedef typename evaluator<XprType>::InnerIterator Base; typedef typename evaluator<XprType>::type EvaluatorType; - typedef typename traits<XprType>::Index Index; public: EIGEN_STRONG_INLINE inner_iterator_selector(const EvaluatorType &eval, const Index &outerId, const Index &/*innerSize*/) diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h index a205c3f10..0c9d9fbf2 100644 --- a/Eigen/src/Core/CwiseBinaryOp.h +++ b/Eigen/src/Core/CwiseBinaryOp.h @@ -59,8 +59,8 @@ struct traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> > typedef typename cwise_promote_storage_type<typename traits<Lhs>::StorageKind, typename traits<Rhs>::StorageKind, BinaryOp>::ret StorageKind; - typedef typename promote_index_type<typename traits<Lhs>::Index, - typename traits<Rhs>::Index>::type Index; + typedef typename promote_index_type<typename traits<Lhs>::StorageIndex, + typename traits<Rhs>::StorageIndex>::type StorageIndex; typedef typename Lhs::Nested LhsNested; typedef typename Rhs::Nested RhsNested; typedef typename remove_reference<LhsNested>::type _LhsNested; diff --git a/Eigen/src/Core/CwiseNullaryOp.h b/Eigen/src/Core/CwiseNullaryOp.h index 05c4fedd0..009fd845d 100644 --- a/Eigen/src/Core/CwiseNullaryOp.h +++ b/Eigen/src/Core/CwiseNullaryOp.h @@ -753,7 +753,6 @@ struct setIdentity_impl template<typename Derived> struct setIdentity_impl<Derived, true> { - typedef typename Derived::Index Index; EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Derived& run(Derived& m) { diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index e81b58481..322daad8f 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -58,17 +58,20 @@ template<typename Derived> class DenseBase typedef typename internal::traits<Derived>::StorageKind StorageKind; - /** \brief The type of indices - * \details To change this, \c \#define the preprocessor symbol \c EIGEN_DEFAULT_DENSE_INDEX_TYPE. - * \sa \ref TopicPreprocessorDirectives. - */ - typedef typename internal::traits<Derived>::Index Index; + /** + * \brief The type used to store indices + * \details This typedef is relevant for types that store multiple indices such as + * PermutationMatrix or Transpositions, otherwise it defaults to Eigen::Index + * \sa \ref TopicPreprocessorDirectives, Eigen::Index, SparseMatrixBase. + */ + typedef typename internal::traits<Derived>::StorageIndex StorageIndex; typedef typename internal::traits<Derived>::Scalar Scalar; typedef typename internal::packet_traits<Scalar>::type PacketScalar; typedef typename NumTraits<Scalar>::Real RealScalar; - typedef DenseCoeffsBase<Derived> Base; + typedef internal::special_scalar_op_base<Derived,typename internal::traits<Derived>::Scalar, + typename NumTraits<typename internal::traits<Derived>::Scalar>::Real> Base; using Base::derived; using Base::const_cast_derived; using Base::rows; diff --git a/Eigen/src/Core/DenseCoeffsBase.h b/Eigen/src/Core/DenseCoeffsBase.h index a9e4dbaf9..f08380bed 100644 --- a/Eigen/src/Core/DenseCoeffsBase.h +++ b/Eigen/src/Core/DenseCoeffsBase.h @@ -35,7 +35,6 @@ class DenseCoeffsBase<Derived,ReadOnlyAccessors> : public EigenBase<Derived> { public: typedef typename internal::traits<Derived>::StorageKind StorageKind; - typedef typename internal::traits<Derived>::Index Index; typedef typename internal::traits<Derived>::Scalar Scalar; typedef typename internal::packet_traits<Scalar>::type PacketScalar; @@ -287,7 +286,6 @@ class DenseCoeffsBase<Derived, WriteAccessors> : public DenseCoeffsBase<Derived, typedef DenseCoeffsBase<Derived, ReadOnlyAccessors> Base; typedef typename internal::traits<Derived>::StorageKind StorageKind; - typedef typename internal::traits<Derived>::Index Index; typedef typename internal::traits<Derived>::Scalar Scalar; typedef typename internal::packet_traits<Scalar>::type PacketScalar; typedef typename NumTraits<Scalar>::Real RealScalar; @@ -450,7 +448,6 @@ class DenseCoeffsBase<Derived, DirectAccessors> : public DenseCoeffsBase<Derived public: typedef DenseCoeffsBase<Derived, ReadOnlyAccessors> Base; - typedef typename internal::traits<Derived>::Index Index; typedef typename internal::traits<Derived>::Scalar Scalar; typedef typename NumTraits<Scalar>::Real RealScalar; @@ -525,7 +522,6 @@ class DenseCoeffsBase<Derived, DirectWriteAccessors> public: typedef DenseCoeffsBase<Derived, WriteAccessors> Base; - typedef typename internal::traits<Derived>::Index Index; typedef typename internal::traits<Derived>::Scalar Scalar; typedef typename NumTraits<Scalar>::Real RealScalar; @@ -587,14 +583,14 @@ namespace internal { template<typename Derived, bool JustReturnZero> struct first_aligned_impl { - static inline typename Derived::Index run(const Derived&) + static inline Index run(const Derived&) { return 0; } }; template<typename Derived> struct first_aligned_impl<Derived, false> { - static inline typename Derived::Index run(const Derived& m) + static inline Index run(const Derived& m) { return internal::first_aligned(&m.const_cast_derived().coeffRef(0,0), m.size()); } @@ -606,7 +602,7 @@ struct first_aligned_impl<Derived, false> * documentation. */ template<typename Derived> -static inline typename Derived::Index first_aligned(const Derived& m) +static inline Index first_aligned(const Derived& m) { return first_aligned_impl <Derived, (Derived::Flags & AlignedBit) || !(Derived::Flags & DirectAccessBit)> diff --git a/Eigen/src/Core/DenseStorage.h b/Eigen/src/Core/DenseStorage.h index 852648639..4c37fadbd 100644 --- a/Eigen/src/Core/DenseStorage.h +++ b/Eigen/src/Core/DenseStorage.h @@ -140,12 +140,12 @@ template<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseSt if (this != &other) m_data = other.m_data; return *this; } - EIGEN_DEVICE_FUNC DenseStorage(DenseIndex,DenseIndex,DenseIndex) {} + EIGEN_DEVICE_FUNC DenseStorage(Index,Index,Index) {} EIGEN_DEVICE_FUNC void swap(DenseStorage& other) { std::swap(m_data,other.m_data); } - EIGEN_DEVICE_FUNC static DenseIndex rows(void) {return _Rows;} - EIGEN_DEVICE_FUNC static DenseIndex cols(void) {return _Cols;} - EIGEN_DEVICE_FUNC void conservativeResize(DenseIndex,DenseIndex,DenseIndex) {} - EIGEN_DEVICE_FUNC void resize(DenseIndex,DenseIndex,DenseIndex) {} + EIGEN_DEVICE_FUNC static Index rows(void) {return _Rows;} + EIGEN_DEVICE_FUNC static Index cols(void) {return _Cols;} + EIGEN_DEVICE_FUNC void conservativeResize(Index,Index,Index) {} + EIGEN_DEVICE_FUNC void resize(Index,Index,Index) {} EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; } EIGEN_DEVICE_FUNC T *data() { return m_data.array; } }; @@ -158,12 +158,12 @@ template<typename T, int _Rows, int _Cols, int _Options> class DenseStorage<T, 0 EIGEN_DEVICE_FUNC explicit DenseStorage(internal::constructor_without_unaligned_array_assert) {} EIGEN_DEVICE_FUNC DenseStorage(const DenseStorage&) {} EIGEN_DEVICE_FUNC DenseStorage& operator=(const DenseStorage&) { return *this; } - EIGEN_DEVICE_FUNC DenseStorage(DenseIndex,DenseIndex,DenseIndex) {} + EIGEN_DEVICE_FUNC DenseStorage(Index,Index,Index) {} EIGEN_DEVICE_FUNC void swap(DenseStorage& ) {} - EIGEN_DEVICE_FUNC static DenseIndex rows(void) {return _Rows;} - EIGEN_DEVICE_FUNC static DenseIndex cols(void) {return _Cols;} - EIGEN_DEVICE_FUNC void conservativeResize(DenseIndex,DenseIndex,DenseIndex) {} - EIGEN_DEVICE_FUNC void resize(DenseIndex,DenseIndex,DenseIndex) {} + EIGEN_DEVICE_FUNC static Index rows(void) {return _Rows;} + EIGEN_DEVICE_FUNC static Index cols(void) {return _Cols;} + EIGEN_DEVICE_FUNC void conservativeResize(Index,Index,Index) {} + EIGEN_DEVICE_FUNC void resize(Index,Index,Index) {} EIGEN_DEVICE_FUNC const T *data() const { return 0; } EIGEN_DEVICE_FUNC T *data() { return 0; } }; @@ -182,8 +182,8 @@ template<typename T, int _Cols, int _Options> class DenseStorage<T, 0, Dynamic, template<typename T, int Size, int _Options> class DenseStorage<T, Size, Dynamic, Dynamic, _Options> { internal::plain_array<T,Size,_Options> m_data; - DenseIndex m_rows; - DenseIndex m_cols; + Index m_rows; + Index m_cols; public: EIGEN_DEVICE_FUNC DenseStorage() : m_rows(0), m_cols(0) {} explicit DenseStorage(internal::constructor_without_unaligned_array_assert) @@ -199,13 +199,13 @@ template<typename T, int Size, int _Options> class DenseStorage<T, Size, Dynamic } return *this; } - DenseStorage(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) : m_rows(nbRows), m_cols(nbCols) {} + DenseStorage(Index, Index nbRows, Index nbCols) : m_rows(nbRows), m_cols(nbCols) {} void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); } - EIGEN_DEVICE_FUNC DenseIndex rows() const {return m_rows;} - EIGEN_DEVICE_FUNC DenseIndex cols() const {return m_cols;} - void conservativeResize(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) { m_rows = nbRows; m_cols = nbCols; } - void resize(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) { m_rows = nbRows; m_cols = nbCols; } + EIGEN_DEVICE_FUNC Index rows() const {return m_rows;} + EIGEN_DEVICE_FUNC Index cols() const {return m_cols;} + void conservativeResize(Index, Index nbRows, Index nbCols) { m_rows = nbRows; m_cols = nbCols; } + void resize(Index, Index nbRows, Index nbCols) { m_rows = nbRows; m_cols = nbCols; } EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; } EIGEN_DEVICE_FUNC T *data() { return m_data.array; } }; @@ -214,7 +214,7 @@ template<typename T, int Size, int _Options> class DenseStorage<T, Size, Dynamic template<typename T, int Size, int _Cols, int _Options> class DenseStorage<T, Size, Dynamic, _Cols, _Options> { internal::plain_array<T,Size,_Options> m_data; - DenseIndex m_rows; + Index m_rows; public: EIGEN_DEVICE_FUNC DenseStorage() : m_rows(0) {} explicit DenseStorage(internal::constructor_without_unaligned_array_assert) @@ -229,12 +229,12 @@ template<typename T, int Size, int _Cols, int _Options> class DenseStorage<T, Si } return *this; } - DenseStorage(DenseIndex, DenseIndex nbRows, DenseIndex) : m_rows(nbRows) {} + DenseStorage(Index, Index nbRows, Index) : m_rows(nbRows) {} void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); } - EIGEN_DEVICE_FUNC DenseIndex rows(void) const {return m_rows;} - EIGEN_DEVICE_FUNC DenseIndex cols(void) const {return _Cols;} - void conservativeResize(DenseIndex, DenseIndex nbRows, DenseIndex) { m_rows = nbRows; } - void resize(DenseIndex, DenseIndex nbRows, DenseIndex) { m_rows = nbRows; } + EIGEN_DEVICE_FUNC Index rows(void) const {return m_rows;} + EIGEN_DEVICE_FUNC Index cols(void) const {return _Cols;} + void conservativeResize(Index, Index nbRows, Index) { m_rows = nbRows; } + void resize(Index, Index nbRows, Index) { m_rows = nbRows; } EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; } EIGEN_DEVICE_FUNC T *data() { return m_data.array; } }; @@ -243,7 +243,7 @@ template<typename T, int Size, int _Cols, int _Options> class DenseStorage<T, Si template<typename T, int Size, int _Rows, int _Options> class DenseStorage<T, Size, _Rows, Dynamic, _Options> { internal::plain_array<T,Size,_Options> m_data; - DenseIndex m_cols; + Index m_cols; public: EIGEN_DEVICE_FUNC DenseStorage() : m_cols(0) {} explicit DenseStorage(internal::constructor_without_unaligned_array_assert) @@ -258,12 +258,12 @@ template<typename T, int Size, int _Rows, int _Options> class DenseStorage<T, Si } return *this; } - DenseStorage(DenseIndex, DenseIndex, DenseIndex nbCols) : m_cols(nbCols) {} + DenseStorage(Index, Index, Index nbCols) : m_cols(nbCols) {} void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); } - EIGEN_DEVICE_FUNC DenseIndex rows(void) const {return _Rows;} - EIGEN_DEVICE_FUNC DenseIndex cols(void) const {return m_cols;} - void conservativeResize(DenseIndex, DenseIndex, DenseIndex nbCols) { m_cols = nbCols; } - void resize(DenseIndex, DenseIndex, DenseIndex nbCols) { m_cols = nbCols; } + EIGEN_DEVICE_FUNC Index rows(void) const {return _Rows;} + EIGEN_DEVICE_FUNC Index cols(void) const {return m_cols;} + void conservativeResize(Index, Index, Index nbCols) { m_cols = nbCols; } + void resize(Index, Index, Index nbCols) { m_cols = nbCols; } EIGEN_DEVICE_FUNC const T *data() const { return m_data.array; } EIGEN_DEVICE_FUNC T *data() { return m_data.array; } }; @@ -272,13 +272,13 @@ template<typename T, int Size, int _Rows, int _Options> class DenseStorage<T, Si template<typename T, int _Options> class DenseStorage<T, Dynamic, Dynamic, Dynamic, _Options> { T *m_data; - DenseIndex m_rows; - DenseIndex m_cols; + Index m_rows; + Index m_cols; public: EIGEN_DEVICE_FUNC DenseStorage() : m_data(0), m_rows(0), m_cols(0) {} explicit DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_rows(0), m_cols(0) {} - DenseStorage(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols) + DenseStorage(Index size, Index nbRows, Index nbCols) : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_rows(nbRows), m_cols(nbCols) { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN } DenseStorage(const DenseStorage& other) @@ -317,15 +317,15 @@ template<typename T, int _Options> class DenseStorage<T, Dynamic, Dynamic, Dynam ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols); } void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); } - EIGEN_DEVICE_FUNC DenseIndex rows(void) const {return m_rows;} - EIGEN_DEVICE_FUNC DenseIndex cols(void) const {return m_cols;} - void conservativeResize(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols) + EIGEN_DEVICE_FUNC Index rows(void) const {return m_rows;} + EIGEN_DEVICE_FUNC Index cols(void) const {return m_cols;} + void conservativeResize(Index size, Index nbRows, Index nbCols) { m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, m_rows*m_cols); m_rows = nbRows; m_cols = nbCols; } - void resize(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols) + void resize(Index size, Index nbRows, Index nbCols) { if(size != m_rows*m_cols) { @@ -347,11 +347,11 @@ template<typename T, int _Options> class DenseStorage<T, Dynamic, Dynamic, Dynam template<typename T, int _Rows, int _Options> class DenseStorage<T, Dynamic, _Rows, Dynamic, _Options> { T *m_data; - DenseIndex m_cols; + Index m_cols; public: EIGEN_DEVICE_FUNC DenseStorage() : m_data(0), m_cols(0) {} explicit DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_cols(0) {} - DenseStorage(DenseIndex size, DenseIndex, DenseIndex nbCols) : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_cols(nbCols) + DenseStorage(Index size, Index, Index nbCols) : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_cols(nbCols) { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN } DenseStorage(const DenseStorage& other) : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(_Rows*other.m_cols)) @@ -385,14 +385,14 @@ template<typename T, int _Rows, int _Options> class DenseStorage<T, Dynamic, _Ro #endif ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols); } void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); } - EIGEN_DEVICE_FUNC static DenseIndex rows(void) {return _Rows;} - EIGEN_DEVICE_FUNC DenseIndex cols(void) const {return m_cols;} - void conservativeResize(DenseIndex size, DenseIndex, DenseIndex nbCols) + EIGEN_DEVICE_FUNC static Index rows(void) {return _Rows;} + EIGEN_DEVICE_FUNC Index cols(void) const {return m_cols;} + void conservativeResize(Index size, Index, Index nbCols) { m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, _Rows*m_cols); m_cols = nbCols; } - EIGEN_STRONG_INLINE void resize(DenseIndex size, DenseIndex, DenseIndex nbCols) + EIGEN_STRONG_INLINE void resize(Index size, Index, Index nbCols) { if(size != _Rows*m_cols) { @@ -413,11 +413,11 @@ template<typename T, int _Rows, int _Options> class DenseStorage<T, Dynamic, _Ro template<typename T, int _Cols, int _Options> class DenseStorage<T, Dynamic, Dynamic, _Cols, _Options> { T *m_data; - DenseIndex m_rows; + Index m_rows; public: EIGEN_DEVICE_FUNC DenseStorage() : m_data(0), m_rows(0) {} explicit DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_rows(0) {} - DenseStorage(DenseIndex size, DenseIndex nbRows, DenseIndex) : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_rows(nbRows) + DenseStorage(Index size, Index nbRows, Index) : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_rows(nbRows) { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN } DenseStorage(const DenseStorage& other) : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(other.m_rows*_Cols)) @@ -451,14 +451,14 @@ template<typename T, int _Cols, int _Options> class DenseStorage<T, Dynamic, Dyn #endif ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows); } void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); } - EIGEN_DEVICE_FUNC DenseIndex rows(void) const {return m_rows;} - EIGEN_DEVICE_FUNC static DenseIndex cols(void) {return _Cols;} - void conservativeResize(DenseIndex size, DenseIndex nbRows, DenseIndex) + EIGEN_DEVICE_FUNC Index rows(void) const {return m_rows;} + EIGEN_DEVICE_FUNC static Index cols(void) {return _Cols;} + void conservativeResize(Index size, Index nbRows, Index) { m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, m_rows*_Cols); m_rows = nbRows; } - EIGEN_STRONG_INLINE void resize(DenseIndex size, DenseIndex nbRows, DenseIndex) + EIGEN_STRONG_INLINE void resize(Index size, Index nbRows, Index) { if(size != m_rows*_Cols) { diff --git a/Eigen/src/Core/Diagonal.h b/Eigen/src/Core/Diagonal.h index 33b82f90f..2446a18d4 100644 --- a/Eigen/src/Core/Diagonal.h +++ b/Eigen/src/Core/Diagonal.h @@ -77,8 +77,8 @@ template<typename MatrixType, int _DiagIndex> class Diagonal EIGEN_DEVICE_FUNC inline Index rows() const { - return m_index.value()<0 ? numext::mini(Index(m_matrix.cols()),Index(m_matrix.rows()+m_index.value())) - : numext::mini(Index(m_matrix.rows()),Index(m_matrix.cols()-m_index.value())); + return m_index.value()<0 ? numext::mini<Index>(m_matrix.cols(),m_matrix.rows()+m_index.value()) + : numext::mini<Index>(m_matrix.rows(),m_matrix.cols()-m_index.value()); } EIGEN_DEVICE_FUNC diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h index 49b9b7925..5a9e3abd4 100644 --- a/Eigen/src/Core/DiagonalMatrix.h +++ b/Eigen/src/Core/DiagonalMatrix.h @@ -22,7 +22,7 @@ class DiagonalBase : public EigenBase<Derived> typedef typename DiagonalVectorType::Scalar Scalar; typedef typename DiagonalVectorType::RealScalar RealScalar; typedef typename internal::traits<Derived>::StorageKind StorageKind; - typedef typename internal::traits<Derived>::Index Index; + typedef typename internal::traits<Derived>::StorageIndex StorageIndex; enum { RowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime, @@ -108,7 +108,6 @@ struct traits<DiagonalMatrix<_Scalar,SizeAtCompileTime,MaxSizeAtCompileTime> > { typedef Matrix<_Scalar,SizeAtCompileTime,1,0,MaxSizeAtCompileTime,1> DiagonalVectorType; typedef DiagonalShape StorageKind; - typedef DenseIndex Index; enum { Flags = LvalueBit | NoPreferredStorageOrderBit }; @@ -124,7 +123,7 @@ class DiagonalMatrix typedef const DiagonalMatrix& Nested; typedef _Scalar Scalar; typedef typename internal::traits<DiagonalMatrix>::StorageKind StorageKind; - typedef typename internal::traits<DiagonalMatrix>::Index Index; + typedef typename internal::traits<DiagonalMatrix>::StorageIndex StorageIndex; #endif protected: @@ -230,7 +229,7 @@ struct traits<DiagonalWrapper<_DiagonalVectorType> > { typedef _DiagonalVectorType DiagonalVectorType; typedef typename DiagonalVectorType::Scalar Scalar; - typedef typename DiagonalVectorType::Index Index; + typedef typename DiagonalVectorType::StorageIndex StorageIndex; typedef DiagonalShape StorageKind; typedef typename traits<DiagonalVectorType>::XprKind XprKind; enum { diff --git a/Eigen/src/Core/EigenBase.h b/Eigen/src/Core/EigenBase.h index 52b66e6dc..79dabda37 100644 --- a/Eigen/src/Core/EigenBase.h +++ b/Eigen/src/Core/EigenBase.h @@ -13,7 +13,9 @@ namespace Eigen { -/** Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor MatrixBase(T). +/** \class EigenBase + * + * Common base class for all classes T such that MatrixBase has an operator=(T) and a constructor MatrixBase(T). * * In other words, an EigenBase object is an object that can be copied into a MatrixBase. * @@ -26,9 +28,16 @@ namespace Eigen { template<typename Derived> struct EigenBase { // typedef typename internal::plain_matrix_type<Derived>::type PlainObject; - + + /** \brief The interface type of indices + * \details To change this, \c \#define the preprocessor symbol \c EIGEN_DEFAULT_DENSE_INDEX_TYPE. + * \deprecated Since Eigen 3.3, its usage is deprecated. Use Eigen::Index instead. + * \sa StorageIndex, \ref TopicPreprocessorDirectives. + */ + typedef Eigen::Index Index; + + // FIXME is it needed? typedef typename internal::traits<Derived>::StorageKind StorageKind; - typedef typename internal::traits<Derived>::Index Index; /** \returns a reference to the derived object */ EIGEN_DEVICE_FUNC diff --git a/Eigen/src/Core/GeneralProduct.h b/Eigen/src/Core/GeneralProduct.h index 81750722c..7027130e0 100644 --- a/Eigen/src/Core/GeneralProduct.h +++ b/Eigen/src/Core/GeneralProduct.h @@ -221,7 +221,6 @@ template<> struct gemv_dense_sense_selector<OnTheRight,ColMajor,true> template<typename Lhs, typename Rhs, typename Dest> static inline void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha) { - typedef typename Dest::Index Index; typedef typename Lhs::Scalar LhsScalar; typedef typename Rhs::Scalar RhsScalar; typedef typename Dest::Scalar ResScalar; @@ -298,7 +297,6 @@ template<> struct gemv_dense_sense_selector<OnTheRight,RowMajor,true> template<typename Lhs, typename Rhs, typename Dest> static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha) { - typedef typename Dest::Index Index; typedef typename Lhs::Scalar LhsScalar; typedef typename Rhs::Scalar RhsScalar; typedef typename Dest::Scalar ResScalar; @@ -352,7 +350,6 @@ template<> struct gemv_dense_sense_selector<OnTheRight,ColMajor,false> template<typename Lhs, typename Rhs, typename Dest> static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha) { - typedef typename Dest::Index Index; // TODO makes sure dest is sequentially stored in memory, otherwise use a temp const Index size = rhs.rows(); for(Index k=0; k<size; ++k) @@ -365,7 +362,6 @@ template<> struct gemv_dense_sense_selector<OnTheRight,RowMajor,false> template<typename Lhs, typename Rhs, typename Dest> static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha) { - typedef typename Dest::Index Index; // TODO makes sure rhs is sequentially stored in memory, otherwise use a temp const Index rows = dest.rows(); for(Index i=0; i<rows; ++i) diff --git a/Eigen/src/Core/GenericPacketMath.h b/Eigen/src/Core/GenericPacketMath.h index 8759cd06c..74e1174ae 100644 --- a/Eigen/src/Core/GenericPacketMath.h +++ b/Eigen/src/Core/GenericPacketMath.h @@ -236,10 +236,10 @@ template<typename Scalar, typename Packet> EIGEN_DEVICE_FUNC inline void pstore( template<typename Scalar, typename Packet> EIGEN_DEVICE_FUNC inline void pstoreu(Scalar* to, const Packet& from) { (*to) = from; } - template<typename Scalar, typename Packet> EIGEN_DEVICE_FUNC inline Packet pgather(const Scalar* from, DenseIndex /*stride*/) + template<typename Scalar, typename Packet> EIGEN_DEVICE_FUNC inline Packet pgather(const Scalar* from, Index /*stride*/) { return ploadu<Packet>(from); } - template<typename Scalar, typename Packet> EIGEN_DEVICE_FUNC inline void pscatter(Scalar* to, const Packet& from, DenseIndex /*stride*/) + template<typename Scalar, typename Packet> EIGEN_DEVICE_FUNC inline void pscatter(Scalar* to, const Packet& from, Index /*stride*/) { pstore(to, from); } /** \internal tries to do cache prefetching of \a addr */ diff --git a/Eigen/src/Core/IO.h b/Eigen/src/Core/IO.h index b96802753..9ae37bb5a 100644 --- a/Eigen/src/Core/IO.h +++ b/Eigen/src/Core/IO.h @@ -164,7 +164,6 @@ std::ostream & print_matrix(std::ostream & s, const Derived& _m, const IOFormat& typename Derived::Nested m = _m; typedef typename Derived::Scalar Scalar; - typedef typename Derived::Index Index; Index width = 0; diff --git a/Eigen/src/Core/Inverse.h b/Eigen/src/Core/Inverse.h index f3b0dff87..f3fa82a01 100644 --- a/Eigen/src/Core/Inverse.h +++ b/Eigen/src/Core/Inverse.h @@ -45,7 +45,7 @@ template<typename XprType> class Inverse : public InverseImpl<XprType,typename internal::traits<XprType>::StorageKind> { public: - typedef typename XprType::Index Index; + typedef typename XprType::StorageIndex StorageIndex; typedef typename XprType::PlainObject PlainObject; typedef typename internal::nested<XprType>::type XprTypeNested; typedef typename internal::remove_all<XprTypeNested>::type XprTypeNestedCleaned; diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h index 098f1c096..870e11024 100644 --- a/Eigen/src/Core/Map.h +++ b/Eigen/src/Core/Map.h @@ -70,8 +70,6 @@ struct traits<Map<PlainObjectType, MapOptions, StrideType> > : public traits<PlainObjectType> { typedef traits<PlainObjectType> TraitsBase; - typedef typename PlainObjectType::Index Index; - typedef typename PlainObjectType::Scalar Scalar; enum { InnerStrideAtCompileTime = StrideType::InnerStrideAtCompileTime == 0 ? int(PlainObjectType::InnerStrideAtCompileTime) diff --git a/Eigen/src/Core/MapBase.h b/Eigen/src/Core/MapBase.h index 1589cbaae..acac74aa4 100644 --- a/Eigen/src/Core/MapBase.h +++ b/Eigen/src/Core/MapBase.h @@ -37,7 +37,6 @@ template<typename Derived> class MapBase<Derived, ReadOnlyAccessors> }; typedef typename internal::traits<Derived>::StorageKind StorageKind; - typedef typename internal::traits<Derived>::Index Index; typedef typename internal::traits<Derived>::Scalar Scalar; typedef typename internal::packet_traits<Scalar>::type PacketScalar; typedef typename NumTraits<Scalar>::Real RealScalar; @@ -179,7 +178,7 @@ template<typename Derived> class MapBase<Derived, WriteAccessors> typedef typename Base::Scalar Scalar; typedef typename Base::PacketScalar PacketScalar; - typedef typename Base::Index Index; + typedef typename Base::StorageIndex StorageIndex; typedef typename Base::PointerType PointerType; using Base::derived; diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index 0b3d90786..a10d1856f 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -107,7 +107,7 @@ struct traits<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > { typedef _Scalar Scalar; typedef Dense StorageKind; - typedef DenseIndex Index; + typedef Eigen::Index StorageIndex; typedef MatrixXpr XprKind; enum { RowsAtCompileTime = _Rows, diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 86994cb36..ed28b4d07 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -52,7 +52,7 @@ template<typename Derived> class MatrixBase #ifndef EIGEN_PARSED_BY_DOXYGEN typedef MatrixBase StorageBaseType; typedef typename internal::traits<Derived>::StorageKind StorageKind; - typedef typename internal::traits<Derived>::Index Index; + typedef typename internal::traits<Derived>::StorageIndex StorageIndex; typedef typename internal::traits<Derived>::Scalar Scalar; typedef typename internal::packet_traits<Scalar>::type PacketScalar; typedef typename NumTraits<Scalar>::Real RealScalar; diff --git a/Eigen/src/Core/PermutationMatrix.h b/Eigen/src/Core/PermutationMatrix.h index 4846f2ae1..de824c129 100644 --- a/Eigen/src/Core/PermutationMatrix.h +++ b/Eigen/src/Core/PermutationMatrix.h @@ -66,11 +66,10 @@ class PermutationBase : public EigenBase<Derived> MaxRowsAtCompileTime = Traits::MaxRowsAtCompileTime, MaxColsAtCompileTime = Traits::MaxColsAtCompileTime }; - typedef typename Traits::StorageIndexType StorageIndexType; - typedef typename Traits::Index Index; - typedef Matrix<StorageIndexType,RowsAtCompileTime,ColsAtCompileTime,0,MaxRowsAtCompileTime,MaxColsAtCompileTime> + typedef typename Traits::StorageIndex StorageIndex; + typedef Matrix<StorageIndex,RowsAtCompileTime,ColsAtCompileTime,0,MaxRowsAtCompileTime,MaxColsAtCompileTime> DenseMatrixType; - typedef PermutationMatrix<IndicesType::SizeAtCompileTime,IndicesType::MaxSizeAtCompileTime,StorageIndexType> + typedef PermutationMatrix<IndicesType::SizeAtCompileTime,IndicesType::MaxSizeAtCompileTime,StorageIndex> PlainPermutationType; using Base::derived; typedef Transpose<PermutationBase> TransposeReturnType; @@ -148,7 +147,8 @@ class PermutationBase : public EigenBase<Derived> /** Sets *this to be the identity permutation matrix */ void setIdentity() { - for(StorageIndexType i = 0; i < size(); ++i) + StorageIndex n = StorageIndex(size()); + for(StorageIndex i = 0; i < n; ++i) indices().coeffRef(i) = i; } @@ -174,8 +174,8 @@ class PermutationBase : public EigenBase<Derived> eigen_assert(i>=0 && j>=0 && i<size() && j<size()); for(Index k = 0; k < size(); ++k) { - if(indices().coeff(k) == i) indices().coeffRef(k) = StorageIndexType(j); - else if(indices().coeff(k) == j) indices().coeffRef(k) = StorageIndexType(i); + if(indices().coeff(k) == i) indices().coeffRef(k) = StorageIndex(j); + else if(indices().coeff(k) == j) indices().coeffRef(k) = StorageIndex(i); } return derived(); } @@ -263,7 +263,7 @@ class PermutationBase : public EigenBase<Derived> * * \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 +271,18 @@ class PermutationBase : public EigenBase<Derived> */ namespace internal { -template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndexType> -struct traits<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndexType> > - : traits<Matrix<_StorageIndexType,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> > +template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex> +struct traits<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndex> > + : traits<Matrix<_StorageIndex,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> > { typedef PermutationStorage StorageKind; - typedef Matrix<_StorageIndexType, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType; - typedef typename IndicesType::Index Index; - typedef _StorageIndexType StorageIndexType; + typedef Matrix<_StorageIndex, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType; + typedef _StorageIndex StorageIndex; }; } -template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndexType> -class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndexType> > +template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex> +class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndex> > { typedef PermutationBase<PermutationMatrix> Base; typedef internal::traits<PermutationMatrix> Traits; @@ -293,8 +292,7 @@ class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompile #ifndef EIGEN_PARSED_BY_DOXYGEN typedef typename Traits::IndicesType IndicesType; - typedef typename Traits::StorageIndexType StorageIndexType; - typedef typename Traits::Index Index; + typedef typename Traits::StorageIndex StorageIndex; #endif inline PermutationMatrix() @@ -304,7 +302,7 @@ class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompile */ explicit inline PermutationMatrix(Index size) : m_indices(size) { - eigen_internal_assert(size <= NumTraits<StorageIndexType>::highest()); + eigen_internal_assert(size <= NumTraits<StorageIndex>::highest()); } /** Copy constructor. */ @@ -376,9 +374,9 @@ class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompile PermutationMatrix(const Transpose<PermutationBase<Other> >& other) : m_indices(other.nestedPermutation().size()) { - eigen_internal_assert(m_indices.size() <= NumTraits<StorageIndexType>::highest()); - StorageIndexType end = StorageIndexType(m_indices.size()); - for (StorageIndexType i=0; i<end;++i) + eigen_internal_assert(m_indices.size() <= NumTraits<StorageIndex>::highest()); + StorageIndex end = StorageIndex(m_indices.size()); + for (StorageIndex i=0; i<end;++i) m_indices.coeffRef(other.nestedPermutation().indices().coeff(i)) = i; } template<typename Lhs,typename Rhs> @@ -396,20 +394,19 @@ class PermutationMatrix : public PermutationBase<PermutationMatrix<SizeAtCompile namespace internal { -template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndexType, int _PacketAccess> -struct traits<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndexType>,_PacketAccess> > - : traits<Matrix<_StorageIndexType,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> > +template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex, int _PacketAccess> +struct traits<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndex>,_PacketAccess> > + : traits<Matrix<_StorageIndex,SizeAtCompileTime,SizeAtCompileTime,0,MaxSizeAtCompileTime,MaxSizeAtCompileTime> > { typedef PermutationStorage StorageKind; - typedef Map<const Matrix<_StorageIndexType, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1>, _PacketAccess> IndicesType; - typedef typename IndicesType::Index Index; - typedef _StorageIndexType StorageIndexType; + typedef Map<const Matrix<_StorageIndex, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1>, _PacketAccess> IndicesType; + typedef _StorageIndex StorageIndex; }; } -template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndexType, int _PacketAccess> -class Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndexType>,_PacketAccess> - : public PermutationBase<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndexType>,_PacketAccess> > +template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex, int _PacketAccess> +class Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndex>,_PacketAccess> + : public PermutationBase<Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageIndex>,_PacketAccess> > { typedef PermutationBase<Map> Base; typedef internal::traits<Map> Traits; @@ -417,15 +414,14 @@ class Map<PermutationMatrix<SizeAtCompileTime, MaxSizeAtCompileTime, _StorageInd #ifndef EIGEN_PARSED_BY_DOXYGEN typedef typename Traits::IndicesType IndicesType; - typedef typename IndicesType::Scalar StorageIndexType; - typedef typename IndicesType::Index Index; + typedef typename IndicesType::Scalar StorageIndex; #endif - inline Map(const StorageIndexType* indicesPtr) + inline Map(const StorageIndex* indicesPtr) : m_indices(indicesPtr) {} - inline Map(const StorageIndexType* indicesPtr, Index size) + inline Map(const StorageIndex* indicesPtr, Index size) : m_indices(indicesPtr,size) {} @@ -479,8 +475,7 @@ struct traits<PermutationWrapper<_IndicesType> > { typedef PermutationStorage StorageKind; typedef typename _IndicesType::Scalar Scalar; - typedef typename _IndicesType::Scalar StorageIndexType; - typedef typename _IndicesType::Index Index; + typedef typename _IndicesType::Scalar StorageIndex; typedef _IndicesType IndicesType; enum { RowsAtCompileTime = _IndicesType::SizeAtCompileTime, @@ -558,7 +553,7 @@ struct permut_matrix_product_retval : public ReturnByValue<permut_matrix_product_retval<PermutationType, MatrixType, Side, Transposed> > { typedef typename remove_all<typename MatrixType::Nested>::type MatrixTypeNestedCleaned; - typedef typename MatrixType::Index Index; + typedef typename MatrixType::StorageIndex StorageIndex; permut_matrix_product_retval(const PermutationType& perm, const MatrixType& matrix) : m_permutation(perm), m_matrix(matrix) @@ -650,7 +645,7 @@ class Transpose<PermutationBase<Derived> > MaxColsAtCompileTime = Traits::MaxColsAtCompileTime }; typedef typename Traits::Scalar Scalar; - typedef typename Traits::Index Index; + typedef typename Traits::StorageIndex StorageIndex; #endif Transpose(const PermutationType& p) : m_permutation(p) {} diff --git a/Eigen/src/Core/PlainObjectBase.h b/Eigen/src/Core/PlainObjectBase.h index 06e326a05..65d69f484 100644 --- a/Eigen/src/Core/PlainObjectBase.h +++ b/Eigen/src/Core/PlainObjectBase.h @@ -95,7 +95,6 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type typedef typename internal::dense_xpr_base<Derived>::type Base; typedef typename internal::traits<Derived>::StorageKind StorageKind; - typedef typename internal::traits<Derived>::Index Index; typedef typename internal::traits<Derived>::Scalar Scalar; typedef typename internal::packet_traits<Scalar>::type PacketScalar; typedef typename NumTraits<Scalar>::Real RealScalar; @@ -846,7 +845,6 @@ namespace internal { template <typename Derived, typename OtherDerived, bool IsVector> struct conservative_resize_like_impl { - typedef typename Derived::Index Index; static void run(DenseBase<Derived>& _this, Index rows, Index cols) { if (_this.rows() == rows && _this.cols() == cols) return; @@ -912,7 +910,6 @@ struct conservative_resize_like_impl<Derived,OtherDerived,true> { using conservative_resize_like_impl<Derived,OtherDerived,false>::run; - typedef typename Derived::Index Index; static void run(DenseBase<Derived>& _this, Index size) { const Index new_rows = Derived::RowsAtCompileTime==1 ? 1 : size; diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index cb79543ef..74b895792 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -67,8 +67,8 @@ struct traits<Product<Lhs, Rhs, Option> > typedef typename product_promote_storage_type<typename LhsTraits::StorageKind, typename RhsTraits::StorageKind, internal::product_type<Lhs,Rhs>::ret>::ret StorageKind; - typedef typename promote_index_type<typename LhsTraits::Index, - typename RhsTraits::Index>::type Index; + typedef typename promote_index_type<typename LhsTraits::StorageIndex, + typename RhsTraits::StorageIndex>::type StorageIndex; enum { RowsAtCompileTime = LhsTraits::RowsAtCompileTime, @@ -149,7 +149,6 @@ class dense_product_base<Lhs, Rhs, Option, InnerProduct> public: using Base::derived; typedef typename Base::Scalar Scalar; - typedef typename Base::Index Index; operator const Scalar() const { diff --git a/Eigen/src/Core/ProductEvaluators.h b/Eigen/src/Core/ProductEvaluators.h index 488eee00c..d84e7776b 100644 --- a/Eigen/src/Core/ProductEvaluators.h +++ b/Eigen/src/Core/ProductEvaluators.h @@ -210,7 +210,6 @@ struct generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,InnerProduct> template<typename Dst, typename Lhs, typename Rhs, typename Func> EIGEN_DONT_INLINE void outer_product_selector_run(Dst& dst, const Lhs &lhs, const Rhs &rhs, const Func& func, const false_type&) { - typedef typename Dst::Index Index; typename evaluator<Rhs>::type rhsEval(rhs); // FIXME make sure lhs is sequentially stored // FIXME not very good if rhs is real and lhs complex while alpha is real too @@ -222,8 +221,8 @@ EIGEN_DONT_INLINE void outer_product_selector_run(Dst& dst, const Lhs &lhs, cons // Row major result template<typename Dst, typename Lhs, typename Rhs, typename Func> -EIGEN_DONT_INLINE void outer_product_selector_run(Dst& dst, const Lhs &lhs, const Rhs &rhs, const Func& func, const true_type&) { - typedef typename Dst::Index Index; +EIGEN_DONT_INLINE void outer_product_selector_run(Dst& dst, const Lhs &lhs, const Rhs &rhs, const Func& func, const true_type&) +{ typename evaluator<Lhs>::type lhsEval(lhs); // FIXME make sure rhs is sequentially stored // FIXME not very good if lhs is real and rhs complex while alpha is real too @@ -374,7 +373,6 @@ struct product_evaluator<Product<Lhs, Rhs, LazyProduct>, ProductTag, DenseShape, : evaluator_base<Product<Lhs, Rhs, LazyProduct> > { typedef Product<Lhs, Rhs, LazyProduct> XprType; - typedef typename XprType::Index Index; typedef typename XprType::Scalar Scalar; typedef typename XprType::CoeffReturnType CoeffReturnType; typedef typename XprType::PacketScalar PacketScalar; @@ -526,7 +524,6 @@ struct product_evaluator<Product<Lhs, Rhs, DefaultProduct>, LazyCoeffBasedProduc template<int UnrollingIndex, typename Lhs, typename Rhs, typename Packet, int LoadMode> struct etor_product_packet_impl<RowMajor, UnrollingIndex, Lhs, Rhs, Packet, LoadMode> { - typedef typename Lhs::Index Index; static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, Packet &res) { etor_product_packet_impl<RowMajor, UnrollingIndex-1, Lhs, Rhs, Packet, LoadMode>::run(row, col, lhs, rhs, innerDim, res); @@ -537,7 +534,6 @@ struct etor_product_packet_impl<RowMajor, UnrollingIndex, Lhs, Rhs, Packet, Load template<int UnrollingIndex, typename Lhs, typename Rhs, typename Packet, int LoadMode> struct etor_product_packet_impl<ColMajor, UnrollingIndex, Lhs, Rhs, Packet, LoadMode> { - typedef typename Lhs::Index Index; static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, Packet &res) { etor_product_packet_impl<ColMajor, UnrollingIndex-1, Lhs, Rhs, Packet, LoadMode>::run(row, col, lhs, rhs, innerDim, res); @@ -548,7 +544,6 @@ struct etor_product_packet_impl<ColMajor, UnrollingIndex, Lhs, Rhs, Packet, Load template<typename Lhs, typename Rhs, typename Packet, int LoadMode> struct etor_product_packet_impl<RowMajor, 0, Lhs, Rhs, Packet, LoadMode> { - typedef typename Lhs::Index Index; static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index /*innerDim*/, Packet &res) { res = pmul(pset1<Packet>(lhs.coeff(row, 0)),rhs.template packet<LoadMode>(0, col)); @@ -558,7 +553,6 @@ struct etor_product_packet_impl<RowMajor, 0, Lhs, Rhs, Packet, LoadMode> template<typename Lhs, typename Rhs, typename Packet, int LoadMode> struct etor_product_packet_impl<ColMajor, 0, Lhs, Rhs, Packet, LoadMode> { - typedef typename Lhs::Index Index; static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index /*innerDim*/, Packet &res) { res = pmul(lhs.template packet<LoadMode>(row, 0), pset1<Packet>(rhs.coeff(0, col))); @@ -568,7 +562,6 @@ struct etor_product_packet_impl<ColMajor, 0, Lhs, Rhs, Packet, LoadMode> template<typename Lhs, typename Rhs, typename Packet, int LoadMode> struct etor_product_packet_impl<RowMajor, Dynamic, Lhs, Rhs, Packet, LoadMode> { - typedef typename Lhs::Index Index; static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, Packet& res) { eigen_assert(innerDim>0 && "you are using a non initialized matrix"); @@ -581,7 +574,6 @@ struct etor_product_packet_impl<RowMajor, Dynamic, Lhs, Rhs, Packet, LoadMode> template<typename Lhs, typename Rhs, typename Packet, int LoadMode> struct etor_product_packet_impl<ColMajor, Dynamic, Lhs, Rhs, Packet, LoadMode> { - typedef typename Lhs::Index Index; static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Index innerDim, Packet& res) { eigen_assert(innerDim>0 && "you are using a non initialized matrix"); @@ -670,7 +662,6 @@ template<typename MatrixType, typename DiagonalType, typename Derived, int Produ struct diagonal_product_evaluator_base : evaluator_base<Derived> { - typedef typename MatrixType::Index Index; typedef typename scalar_product_traits<typename MatrixType::Scalar, typename DiagonalType::Scalar>::ReturnType Scalar; typedef typename internal::packet_traits<Scalar>::type PacketScalar; public: @@ -735,7 +726,6 @@ struct product_evaluator<Product<Lhs, Rhs, ProductKind>, ProductTag, DiagonalSha using Base::coeff; using Base::packet_impl; typedef typename Base::Scalar Scalar; - typedef typename Base::Index Index; typedef typename Base::PacketScalar PacketScalar; typedef Product<Lhs, Rhs, ProductKind> XprType; @@ -783,7 +773,6 @@ struct product_evaluator<Product<Lhs, Rhs, ProductKind>, ProductTag, DenseShape, using Base::coeff; using Base::packet_impl; typedef typename Base::Scalar Scalar; - typedef typename Base::Index Index; typedef typename Base::PacketScalar PacketScalar; typedef Product<Lhs, Rhs, ProductKind> XprType; diff --git a/Eigen/src/Core/Redux.h b/Eigen/src/Core/Redux.h index f6546917e..1a0a00481 100644 --- a/Eigen/src/Core/Redux.h +++ b/Eigen/src/Core/Redux.h @@ -191,7 +191,6 @@ template<typename Func, typename Derived> struct redux_impl<Func, Derived, DefaultTraversal, NoUnrolling> { typedef typename Derived::Scalar Scalar; - typedef typename Derived::Index Index; EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Scalar run(const Derived &mat, const Func& func) { @@ -217,7 +216,6 @@ struct redux_impl<Func, Derived, LinearVectorizedTraversal, NoUnrolling> { typedef typename Derived::Scalar Scalar; typedef typename packet_traits<Scalar>::type PacketScalar; - typedef typename Derived::Index Index; static Scalar run(const Derived &mat, const Func& func) { @@ -275,7 +273,6 @@ struct redux_impl<Func, Derived, SliceVectorizedTraversal, NoUnrolling> { typedef typename Derived::Scalar Scalar; typedef typename packet_traits<Scalar>::type PacketScalar; - typedef typename Derived::Index Index; EIGEN_DEVICE_FUNC static Scalar run(const Derived &mat, const Func& func) { @@ -342,7 +339,6 @@ public: typedef _XprType XprType; EIGEN_DEVICE_FUNC explicit redux_evaluator(const XprType &xpr) : m_evaluator(xpr), m_xpr(xpr) {} - typedef typename XprType::Index Index; typedef typename XprType::Scalar Scalar; typedef typename XprType::CoeffReturnType CoeffReturnType; typedef typename XprType::PacketScalar PacketScalar; diff --git a/Eigen/src/Core/SelfAdjointView.h b/Eigen/src/Core/SelfAdjointView.h index b785e8e1e..a05746ad2 100644 --- a/Eigen/src/Core/SelfAdjointView.h +++ b/Eigen/src/Core/SelfAdjointView.h @@ -58,8 +58,7 @@ template<typename _MatrixType, unsigned int UpLo> class SelfAdjointView /** \brief The type of coefficients in this matrix */ typedef typename internal::traits<SelfAdjointView>::Scalar Scalar; - - typedef typename MatrixType::Index Index; + typedef typename MatrixType::StorageIndex StorageIndex; enum { Mode = internal::traits<SelfAdjointView>::Mode, @@ -224,7 +223,6 @@ public: typedef typename Base::DstEvaluatorType DstEvaluatorType; typedef typename Base::SrcEvaluatorType SrcEvaluatorType; typedef typename Base::Scalar Scalar; - typedef typename Base::Index Index; typedef typename Base::AssignmentTraits AssignmentTraits; diff --git a/Eigen/src/Core/Solve.h b/Eigen/src/Core/Solve.h index 3905cd616..47446b49e 100644 --- a/Eigen/src/Core/Solve.h +++ b/Eigen/src/Core/Solve.h @@ -48,6 +48,7 @@ struct traits<Solve<Decomposition, RhsType> > : traits<typename solve_traits<Decomposition,RhsType,typename internal::traits<RhsType>::StorageKind>::PlainObject> { typedef typename solve_traits<Decomposition,RhsType,typename internal::traits<RhsType>::StorageKind>::PlainObject PlainObject; + typedef typename promote_index_type<typename Decomposition::StorageIndex, typename RhsType::StorageIndex>::type StorageIndex; typedef traits<PlainObject> BaseTraits; enum { Flags = BaseTraits::Flags & RowMajorBit, @@ -62,8 +63,8 @@ template<typename Decomposition, typename RhsType> class Solve : public SolveImpl<Decomposition,RhsType,typename internal::traits<RhsType>::StorageKind> { public: - typedef typename RhsType::Index Index; typedef typename internal::traits<Solve>::PlainObject PlainObject; + typedef typename internal::traits<Solve>::StorageIndex StorageIndex; Solve(const Decomposition &dec, const RhsType &rhs) : m_dec(dec), m_rhs(rhs) diff --git a/Eigen/src/Core/SolveTriangular.h b/Eigen/src/Core/SolveTriangular.h index f97048bda..9bac726f7 100644 --- a/Eigen/src/Core/SolveTriangular.h +++ b/Eigen/src/Core/SolveTriangular.h @@ -68,7 +68,7 @@ struct triangular_solver_selector<Lhs,Rhs,Side,Mode,NoUnrolling,1> if(!useRhsDirectly) MappedRhs(actualRhs,rhs.size()) = rhs; - triangular_solve_vector<LhsScalar, RhsScalar, typename Lhs::Index, Side, Mode, LhsProductTraits::NeedToConjugate, + triangular_solve_vector<LhsScalar, RhsScalar, Index, Side, Mode, LhsProductTraits::NeedToConjugate, (int(Lhs::Flags) & RowMajorBit) ? RowMajor : ColMajor> ::run(actualLhs.cols(), actualLhs.data(), actualLhs.outerStride(), actualRhs); @@ -82,7 +82,6 @@ template<typename Lhs, typename Rhs, int Side, int Mode> struct triangular_solver_selector<Lhs,Rhs,Side,Mode,NoUnrolling,Dynamic> { typedef typename Rhs::Scalar Scalar; - typedef typename Rhs::Index Index; typedef blas_traits<Lhs> LhsProductTraits; typedef typename LhsProductTraits::DirectLinearAccessType ActualLhsType; @@ -232,7 +231,6 @@ template<int Side, typename TriangularType, typename Rhs> struct triangular_solv { typedef typename remove_all<typename Rhs::Nested>::type RhsNestedCleaned; typedef ReturnByValue<triangular_solve_retval> Base; - typedef typename Base::Index Index; triangular_solve_retval(const TriangularType& tri, const Rhs& rhs) : m_triangularMatrix(tri), m_rhs(rhs) diff --git a/Eigen/src/Core/StableNorm.h b/Eigen/src/Core/StableNorm.h index 0b7e39827..83a973365 100644 --- a/Eigen/src/Core/StableNorm.h +++ b/Eigen/src/Core/StableNorm.h @@ -55,7 +55,6 @@ inline typename NumTraits<typename traits<Derived>::Scalar>::Real blueNorm_impl(const EigenBase<Derived>& _vec) { typedef typename Derived::RealScalar RealScalar; - typedef typename Derived::Index Index; using std::pow; using std::sqrt; using std::abs; diff --git a/Eigen/src/Core/Stride.h b/Eigen/src/Core/Stride.h index e46faad34..9a2f4f1eb 100644 --- a/Eigen/src/Core/Stride.h +++ b/Eigen/src/Core/Stride.h @@ -44,7 +44,7 @@ template<int _OuterStrideAtCompileTime, int _InnerStrideAtCompileTime> class Stride { public: - typedef DenseIndex Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 enum { InnerStrideAtCompileTime = _InnerStrideAtCompileTime, OuterStrideAtCompileTime = _OuterStrideAtCompileTime @@ -91,7 +91,6 @@ class InnerStride : public Stride<0, Value> { typedef Stride<0, Value> Base; public: - typedef DenseIndex Index; EIGEN_DEVICE_FUNC InnerStride() : Base() {} EIGEN_DEVICE_FUNC InnerStride(Index v) : Base(0, v) {} // FIXME making this explicit could break valid code }; @@ -103,7 +102,6 @@ class OuterStride : public Stride<Value, 0> { typedef Stride<Value, 0> Base; public: - typedef DenseIndex Index; EIGEN_DEVICE_FUNC OuterStride() : Base() {} EIGEN_DEVICE_FUNC OuterStride(Index v) : Base(v,0) {} // FIXME making this explicit could break valid code }; diff --git a/Eigen/src/Core/Swap.h b/Eigen/src/Core/Swap.h index 55319320a..dcb42821f 100644 --- a/Eigen/src/Core/Swap.h +++ b/Eigen/src/Core/Swap.h @@ -28,7 +28,6 @@ protected: public: typedef typename Base::Scalar Scalar; - typedef typename Base::Index Index; typedef typename Base::DstXprType DstXprType; typedef swap_assign_op<Scalar> Functor; diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index 3bab6092c..2c967abca 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -29,14 +29,10 @@ namespace Eigen { namespace internal { template<typename MatrixType> -struct traits<Transpose<MatrixType> > +struct traits<Transpose<MatrixType> > : public traits<MatrixType> { - typedef typename traits<MatrixType>::Scalar Scalar; - typedef typename traits<MatrixType>::Index Index; typedef typename nested<MatrixType>::type MatrixTypeNested; typedef typename remove_reference<MatrixTypeNested>::type MatrixTypeNestedPlain; - typedef typename traits<MatrixType>::StorageKind StorageKind; - typedef typename traits<MatrixType>::XprKind XprKind; enum { RowsAtCompileTime = MatrixType::ColsAtCompileTime, ColsAtCompileTime = MatrixType::RowsAtCompileTime, @@ -236,7 +232,6 @@ struct inplace_transpose_selector<MatrixType,true,true> { // PacketSize x Packet static void run(MatrixType& m) { typedef typename MatrixType::Scalar Scalar; typedef typename internal::packet_traits<typename MatrixType::Scalar>::type Packet; - typedef typename MatrixType::Index Index; const Index PacketSize = internal::packet_traits<Scalar>::size; const Index Alignment = internal::evaluator<MatrixType>::Flags&AlignedBit ? Aligned : Unaligned; PacketBlock<Packet> A; diff --git a/Eigen/src/Core/Transpositions.h b/Eigen/src/Core/Transpositions.h index 77e7d6f45..e9b54c2ba 100644 --- a/Eigen/src/Core/Transpositions.h +++ b/Eigen/src/Core/Transpositions.h @@ -53,8 +53,8 @@ class TranspositionsBase public: typedef typename Traits::IndicesType IndicesType; - typedef typename IndicesType::Scalar StorageIndexType; - typedef typename IndicesType::Index Index; + typedef typename IndicesType::Scalar StorageIndex; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 Derived& derived() { return *static_cast<Derived*>(this); } const Derived& derived() const { return *static_cast<const Derived*>(this); } @@ -82,17 +82,17 @@ class TranspositionsBase inline Index size() const { return indices().size(); } /** Direct access to the underlying index vector */ - inline const StorageIndexType& coeff(Index i) const { return indices().coeff(i); } + inline const StorageIndex& coeff(Index i) const { return indices().coeff(i); } /** Direct access to the underlying index vector */ - inline StorageIndexType& coeffRef(Index i) { return indices().coeffRef(i); } + inline StorageIndex& coeffRef(Index i) { return indices().coeffRef(i); } /** Direct access to the underlying index vector */ - inline const StorageIndexType& operator()(Index i) const { return indices()(i); } + inline const StorageIndex& operator()(Index i) const { return indices()(i); } /** Direct access to the underlying index vector */ - inline StorageIndexType& operator()(Index i) { return indices()(i); } + inline StorageIndex& operator()(Index i) { return indices()(i); } /** Direct access to the underlying index vector */ - inline const StorageIndexType& operator[](Index i) const { return indices()(i); } + inline const StorageIndex& operator[](Index i) const { return indices()(i); } /** Direct access to the underlying index vector */ - inline StorageIndexType& operator[](Index i) { return indices()(i); } + inline StorageIndex& operator[](Index i) { return indices()(i); } /** const version of indices(). */ const IndicesType& indices() const { return derived().indices(); } @@ -108,7 +108,7 @@ class TranspositionsBase /** Sets \c *this to represents an identity transformation */ void setIdentity() { - for(StorageIndexType i = 0; i < indices().size(); ++i) + for(StorageIndex i = 0; i < indices().size(); ++i) coeffRef(i) = i; } @@ -145,26 +145,23 @@ class TranspositionsBase }; namespace internal { -template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndexType> -struct traits<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndexType> > +template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex> +struct traits<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> > { - typedef Matrix<_StorageIndexType, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType; - typedef typename IndicesType::Index Index; - typedef _StorageIndexType StorageIndexType; + typedef Matrix<_StorageIndex, SizeAtCompileTime, 1, 0, MaxSizeAtCompileTime, 1> IndicesType; + typedef _StorageIndex StorageIndex; }; } -template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndexType> -class Transpositions : public TranspositionsBase<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndexType> > +template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex> +class Transpositions : public TranspositionsBase<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex> > { typedef internal::traits<Transpositions> Traits; public: typedef TranspositionsBase<Transpositions> Base; typedef typename Traits::IndicesType IndicesType; - typedef typename IndicesType::Scalar StorageIndexType; - typedef typename IndicesType::Index Index; - + typedef typename IndicesType::Scalar StorageIndex; inline Transpositions() {} @@ -219,32 +216,30 @@ class Transpositions : public TranspositionsBase<Transpositions<SizeAtCompileTim namespace internal { -template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndexType, int _PacketAccess> -struct traits<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndexType>,_PacketAccess> > +template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex, int _PacketAccess> +struct traits<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,_PacketAccess> > { - typedef Map<const Matrix<_StorageIndexType,SizeAtCompileTime,1,0,MaxSizeAtCompileTime,1>, _PacketAccess> IndicesType; - typedef typename IndicesType::Index Index; - typedef _StorageIndexType StorageIndexType; + typedef Map<const Matrix<_StorageIndex,SizeAtCompileTime,1,0,MaxSizeAtCompileTime,1>, _PacketAccess> IndicesType; + typedef _StorageIndex StorageIndex; }; } -template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndexType, int PacketAccess> -class Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndexType>,PacketAccess> - : public TranspositionsBase<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndexType>,PacketAccess> > +template<int SizeAtCompileTime, int MaxSizeAtCompileTime, typename _StorageIndex, int PacketAccess> +class Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,PacketAccess> + : public TranspositionsBase<Map<Transpositions<SizeAtCompileTime,MaxSizeAtCompileTime,_StorageIndex>,PacketAccess> > { typedef internal::traits<Map> Traits; public: typedef TranspositionsBase<Map> Base; typedef typename Traits::IndicesType IndicesType; - typedef typename IndicesType::Scalar StorageIndexType; - typedef typename IndicesType::Index Index; + typedef typename IndicesType::Scalar StorageIndex; - explicit inline Map(const StorageIndexType* indicesPtr) + explicit inline Map(const StorageIndex* indicesPtr) : m_indices(indicesPtr) {} - inline Map(const StorageIndexType* indicesPtr, Index size) + inline Map(const StorageIndex* indicesPtr, Index size) : m_indices(indicesPtr,size) {} @@ -281,8 +276,7 @@ namespace internal { template<typename _IndicesType> struct traits<TranspositionsWrapper<_IndicesType> > { - typedef typename _IndicesType::Scalar StorageIndexType; - typedef typename _IndicesType::Index Index; + typedef typename _IndicesType::Scalar StorageIndex; typedef _IndicesType IndicesType; }; } @@ -296,8 +290,7 @@ class TranspositionsWrapper typedef TranspositionsBase<TranspositionsWrapper> Base; typedef typename Traits::IndicesType IndicesType; - typedef typename IndicesType::Scalar StorageIndexType; - typedef typename IndicesType::Index Index; + typedef typename IndicesType::Scalar StorageIndex; explicit inline TranspositionsWrapper(IndicesType& a_indices) : m_indices(a_indices) @@ -370,8 +363,7 @@ struct transposition_matrix_product_retval : public ReturnByValue<transposition_matrix_product_retval<TranspositionType, MatrixType, Side, Transposed> > { typedef typename remove_all<typename MatrixType::Nested>::type MatrixTypeNestedCleaned; - typedef typename TranspositionType::Index Index; - typedef typename TranspositionType::StorageIndexType StorageIndexType; + typedef typename TranspositionType::StorageIndex StorageIndex; transposition_matrix_product_retval(const TranspositionType& tr, const MatrixType& matrix) : m_transpositions(tr), m_matrix(matrix) @@ -383,7 +375,7 @@ struct transposition_matrix_product_retval template<typename Dest> inline void evalTo(Dest& dst) const { const Index size = m_transpositions.size(); - StorageIndexType j = 0; + StorageIndex j = 0; if(!(is_same<MatrixTypeNestedCleaned,Dest>::value && extract_data(dst) == extract_data(m_matrix))) dst = m_matrix; diff --git a/Eigen/src/Core/TriangularMatrix.h b/Eigen/src/Core/TriangularMatrix.h index cf0255bce..fd53ae4cb 100644 --- a/Eigen/src/Core/TriangularMatrix.h +++ b/Eigen/src/Core/TriangularMatrix.h @@ -45,7 +45,7 @@ template<typename Derived> class TriangularBase : public EigenBase<Derived> }; typedef typename internal::traits<Derived>::Scalar Scalar; typedef typename internal::traits<Derived>::StorageKind StorageKind; - typedef typename internal::traits<Derived>::Index Index; + typedef typename internal::traits<Derived>::StorageIndex StorageIndex; typedef typename internal::traits<Derived>::FullMatrixType DenseMatrixType; typedef DenseMatrixType DenseType; typedef Derived const& Nested; @@ -199,7 +199,6 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView public: typedef typename internal::traits<TriangularView>::StorageKind StorageKind; - typedef typename internal::traits<TriangularView>::Index Index; typedef typename internal::traits<TriangularView>::MatrixTypeNestedCleaned NestedExpression; enum { @@ -325,7 +324,6 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularViewImpl<_Mat using Base::derived; typedef typename internal::traits<TriangularViewType>::StorageKind StorageKind; - typedef typename internal::traits<TriangularViewType>::Index Index; enum { Mode = _Mode, @@ -688,7 +686,6 @@ public: typedef typename Base::DstEvaluatorType DstEvaluatorType; typedef typename Base::SrcEvaluatorType SrcEvaluatorType; typedef typename Base::Scalar Scalar; - typedef typename Base::Index Index; typedef typename Base::AssignmentTraits AssignmentTraits; @@ -831,7 +828,6 @@ struct triangular_assignment_loop<Kernel, Mode, 0, SetOpposite> template<typename Kernel, unsigned int Mode, bool SetOpposite> struct triangular_assignment_loop<Kernel, Mode, Dynamic, SetOpposite> { - typedef typename Kernel::Index Index; typedef typename Kernel::Scalar Scalar; EIGEN_DEVICE_FUNC static inline void run(Kernel &kernel) diff --git a/Eigen/src/Core/VectorwiseOp.h b/Eigen/src/Core/VectorwiseOp.h index a626310ec..b3dc0c224 100644 --- a/Eigen/src/Core/VectorwiseOp.h +++ b/Eigen/src/Core/VectorwiseOp.h @@ -159,7 +159,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp typedef typename ExpressionType::Scalar Scalar; typedef typename ExpressionType::RealScalar RealScalar; - typedef typename ExpressionType::Index Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 typedef typename internal::conditional<internal::must_nest_by_value<ExpressionType>::ret, ExpressionType, ExpressionType&>::type ExpressionTypeNested; typedef typename internal::remove_all<ExpressionTypeNested>::type ExpressionTypeNestedCleaned; diff --git a/Eigen/src/Core/Visitor.h b/Eigen/src/Core/Visitor.h index 02bd4eff3..6b1ecae8b 100644 --- a/Eigen/src/Core/Visitor.h +++ b/Eigen/src/Core/Visitor.h @@ -41,7 +41,6 @@ struct visitor_impl<Visitor, Derived, 1> template<typename Visitor, typename Derived> struct visitor_impl<Visitor, Derived, Dynamic> { - typedef typename Derived::Index Index; static inline void run(const Derived& mat, Visitor& visitor) { visitor.init(mat.coeff(0,0), 0, 0); @@ -60,7 +59,6 @@ class visitor_evaluator public: explicit visitor_evaluator(const XprType &xpr) : m_evaluator(xpr), m_xpr(xpr) {} - typedef typename XprType::Index Index; typedef typename XprType::Scalar Scalar; typedef typename XprType::CoeffReturnType CoeffReturnType; @@ -124,7 +122,6 @@ namespace internal { template <typename Derived> struct coeff_visitor { - typedef typename Derived::Index Index; typedef typename Derived::Scalar Scalar; Index row, col; Scalar res; @@ -144,7 +141,6 @@ struct coeff_visitor template <typename Derived> struct min_coeff_visitor : coeff_visitor<Derived> { - typedef typename Derived::Index Index; typedef typename Derived::Scalar Scalar; void operator() (const Scalar& value, Index i, Index j) { @@ -172,7 +168,6 @@ struct functor_traits<min_coeff_visitor<Scalar> > { template <typename Derived> struct max_coeff_visitor : coeff_visitor<Derived> { - typedef typename Derived::Index Index; typedef typename Derived::Scalar Scalar; void operator() (const Scalar& value, Index i, Index j) { diff --git a/Eigen/src/Core/arch/AVX/Complex.h b/Eigen/src/Core/arch/AVX/Complex.h index aa5aa1e34..003a1fc3c 100644 --- a/Eigen/src/Core/arch/AVX/Complex.h +++ b/Eigen/src/Core/arch/AVX/Complex.h @@ -92,7 +92,7 @@ template<> EIGEN_STRONG_INLINE Packet4cf ploaddup<Packet4cf>(const std::complex< template<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<float>* to, const Packet4cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore(&numext::real_ref(*to), from.v); } template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float>* to, const Packet4cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(&numext::real_ref(*to), from.v); } -template<> EIGEN_DEVICE_FUNC inline Packet4cf pgather<std::complex<float>, Packet4cf>(const std::complex<float>* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet4cf pgather<std::complex<float>, Packet4cf>(const std::complex<float>* from, Index stride) { return Packet4cf(_mm256_set_ps(std::imag(from[3*stride]), std::real(from[3*stride]), std::imag(from[2*stride]), std::real(from[2*stride]), @@ -100,7 +100,7 @@ template<> EIGEN_DEVICE_FUNC inline Packet4cf pgather<std::complex<float>, Packe std::imag(from[0*stride]), std::real(from[0*stride]))); } -template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet4cf>(std::complex<float>* to, const Packet4cf& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet4cf>(std::complex<float>* to, const Packet4cf& from, Index stride) { __m128 low = _mm256_extractf128_ps(from.v, 0); to[stride*0] = std::complex<float>(_mm_cvtss_f32(_mm_shuffle_ps(low, low, 0)), @@ -310,13 +310,13 @@ template<> EIGEN_STRONG_INLINE Packet2cd ploaddup<Packet2cd>(const std::complex< template<> EIGEN_STRONG_INLINE void pstore <std::complex<double> >(std::complex<double> * to, const Packet2cd& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((double*)to, from.v); } template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<double> >(std::complex<double> * to, const Packet2cd& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((double*)to, from.v); } -template<> EIGEN_DEVICE_FUNC inline Packet2cd pgather<std::complex<double>, Packet2cd>(const std::complex<double>* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet2cd pgather<std::complex<double>, Packet2cd>(const std::complex<double>* from, Index stride) { return Packet2cd(_mm256_set_pd(std::imag(from[1*stride]), std::real(from[1*stride]), std::imag(from[0*stride]), std::real(from[0*stride]))); } -template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<double>, Packet2cd>(std::complex<double>* to, const Packet2cd& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<double>, Packet2cd>(std::complex<double>* to, const Packet2cd& from, Index stride) { __m128d low = _mm256_extractf128_pd(from.v, 0); to[stride*0] = std::complex<double>(_mm_cvtsd_f64(low), _mm_cvtsd_f64(_mm_shuffle_pd(low, low, 1))); diff --git a/Eigen/src/Core/arch/AVX/PacketMath.h b/Eigen/src/Core/arch/AVX/PacketMath.h index beade4095..695185a49 100644 --- a/Eigen/src/Core/arch/AVX/PacketMath.h +++ b/Eigen/src/Core/arch/AVX/PacketMath.h @@ -233,17 +233,17 @@ template<> EIGEN_STRONG_INLINE void pstoreu<int>(int* to, const Packet8i& // NOTE: leverage _mm256_i32gather_ps and _mm256_i32gather_pd if AVX2 instructions are available // NOTE: for the record the following seems to be slower: return _mm256_i32gather_ps(from, _mm256_set1_epi32(stride), 4); -template<> EIGEN_DEVICE_FUNC inline Packet8f pgather<float, Packet8f>(const float* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet8f pgather<float, Packet8f>(const float* from, Index stride) { return _mm256_set_ps(from[7*stride], from[6*stride], from[5*stride], from[4*stride], from[3*stride], from[2*stride], from[1*stride], from[0*stride]); } -template<> EIGEN_DEVICE_FUNC inline Packet4d pgather<double, Packet4d>(const double* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet4d pgather<double, Packet4d>(const double* from, Index stride) { return _mm256_set_pd(from[3*stride], from[2*stride], from[1*stride], from[0*stride]); } -template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet8f>(float* to, const Packet8f& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet8f>(float* to, const Packet8f& from, Index stride) { __m128 low = _mm256_extractf128_ps(from, 0); to[stride*0] = _mm_cvtss_f32(low); @@ -257,7 +257,7 @@ template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet8f>(float* to, co to[stride*6] = _mm_cvtss_f32(_mm_shuffle_ps(high, high, 2)); to[stride*7] = _mm_cvtss_f32(_mm_shuffle_ps(high, high, 3)); } -template<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet4d>(double* to, const Packet4d& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet4d>(double* to, const Packet4d& from, Index stride) { __m128d low = _mm256_extractf128_pd(from, 0); to[stride*0] = _mm_cvtsd_f64(low); diff --git a/Eigen/src/Core/arch/AltiVec/Complex.h b/Eigen/src/Core/arch/AltiVec/Complex.h index f9b93a42b..565d2ece0 100644 --- a/Eigen/src/Core/arch/AltiVec/Complex.h +++ b/Eigen/src/Core/arch/AltiVec/Complex.h @@ -67,14 +67,14 @@ template<> EIGEN_STRONG_INLINE Packet2cf pset1<Packet2cf>(const std::complex<flo return res; } -template<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, Index stride) { std::complex<float> EIGEN_ALIGN16 af[2]; af[0] = from[0*stride]; af[1] = from[1*stride]; return Packet2cf(vec_ld(0, (const float*)af)); } -template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, Index stride) { std::complex<float> EIGEN_ALIGN16 af[2]; vec_st(from.v, 0, (float*)af); @@ -285,14 +285,14 @@ template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<double> >(std::complex< template<> EIGEN_STRONG_INLINE Packet1cd pset1<Packet1cd>(const std::complex<double>& from) { /* here we really have to use unaligned loads :( */ return ploadu<Packet1cd>(&from); } -template<> EIGEN_DEVICE_FUNC inline Packet1cd pgather<std::complex<double>, Packet1cd>(const std::complex<double>* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet1cd pgather<std::complex<double>, Packet1cd>(const std::complex<double>* from, Index stride) { std::complex<double> EIGEN_ALIGN16 af[2]; af[0] = from[0*stride]; af[1] = from[1*stride]; return pload<Packet1cd>(af); } -template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<double>, Packet1cd>(std::complex<double>* to, const Packet1cd& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<double>, Packet1cd>(std::complex<double>* to, const Packet1cd& from, Index stride) { std::complex<double> EIGEN_ALIGN16 af[2]; pstore<std::complex<double> >(af, from); diff --git a/Eigen/src/Core/arch/AltiVec/PacketMath.h b/Eigen/src/Core/arch/AltiVec/PacketMath.h index 6b68fc7a5..d647427ce 100755 --- a/Eigen/src/Core/arch/AltiVec/PacketMath.h +++ b/Eigen/src/Core/arch/AltiVec/PacketMath.h @@ -252,7 +252,7 @@ pbroadcast4<Packet4i>(const int *a, a3 = vec_splat(a3, 3); } -template<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const float* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const float* from, Index stride) { float EIGEN_ALIGN16 af[4]; af[0] = from[0*stride]; @@ -261,7 +261,7 @@ template<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const floa af[3] = from[3*stride]; return pload<Packet4f>(af); } -template<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* from, Index stride) { int EIGEN_ALIGN16 ai[4]; ai[0] = from[0*stride]; @@ -270,7 +270,7 @@ template<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* f ai[3] = from[3*stride]; return pload<Packet4i>(ai); } -template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, const Packet4f& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, const Packet4f& from, Index stride) { float EIGEN_ALIGN16 af[4]; pstore<float>(af, from); @@ -279,7 +279,7 @@ template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, co to[2*stride] = af[2]; to[3*stride] = af[3]; } -template<> EIGEN_DEVICE_FUNC inline void pscatter<int, Packet4i>(int* to, const Packet4i& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<int, Packet4i>(int* to, const Packet4i& from, Index stride) { int EIGEN_ALIGN16 ai[4]; pstore<int>((int *)ai, from); @@ -793,14 +793,14 @@ pbroadcast4<Packet2d>(const double *a, a2 = vec_splat_dbl(a3, 0); a3 = vec_splat_dbl(a3, 1); } -template<> EIGEN_DEVICE_FUNC inline Packet2d pgather<double, Packet2d>(const double* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet2d pgather<double, Packet2d>(const double* from, Index stride) { double EIGEN_ALIGN16 af[2]; af[0] = from[0*stride]; af[1] = from[1*stride]; return pload<Packet2d>(af); } -template<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet2d>(double* to, const Packet2d& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet2d>(double* to, const Packet2d& from, Index stride) { double EIGEN_ALIGN16 af[2]; pstore<double>(af, from); diff --git a/Eigen/src/Core/arch/NEON/Complex.h b/Eigen/src/Core/arch/NEON/Complex.h index 0fdcb0741..154daa7a7 100644 --- a/Eigen/src/Core/arch/NEON/Complex.h +++ b/Eigen/src/Core/arch/NEON/Complex.h @@ -112,7 +112,7 @@ template<> EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(const std::complex< template<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((float*)to, from.v); } template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((float*)to, from.v); } -template<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, Index stride) { Packet4f res; res = vsetq_lane_f32(std::real(from[0*stride]), res, 0); @@ -122,7 +122,7 @@ template<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packe return Packet2cf(res); } -template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, Index stride) { to[stride*0] = std::complex<float>(vgetq_lane_f32(from.v, 0), vgetq_lane_f32(from.v, 1)); to[stride*1] = std::complex<float>(vgetq_lane_f32(from.v, 2), vgetq_lane_f32(from.v, 3)); @@ -363,7 +363,7 @@ template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<double> >(std::complex< template<> EIGEN_STRONG_INLINE void prefetch<std::complex<double> >(const std::complex<double> * addr) { EIGEN_ARM_PREFETCH((double *)addr); } -template<> EIGEN_DEVICE_FUNC inline Packet1cd pgather<std::complex<double>, Packet1cd>(const std::complex<double>* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet1cd pgather<std::complex<double>, Packet1cd>(const std::complex<double>* from, Index stride) { Packet2d res; res = vsetq_lane_f64(std::real(from[0*stride]), res, 0); @@ -371,7 +371,7 @@ template<> EIGEN_DEVICE_FUNC inline Packet1cd pgather<std::complex<double>, Pack return Packet1cd(res); } -template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<double>, Packet1cd>(std::complex<double>* to, const Packet1cd& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<double>, Packet1cd>(std::complex<double>* to, const Packet1cd& from, Index stride) { to[stride*0] = std::complex<double>(vgetq_lane_f64(from.v, 0), vgetq_lane_f64(from.v, 1)); } diff --git a/Eigen/src/Core/arch/NEON/PacketMath.h b/Eigen/src/Core/arch/NEON/PacketMath.h index 559682cf7..8149aed7f 100644 --- a/Eigen/src/Core/arch/NEON/PacketMath.h +++ b/Eigen/src/Core/arch/NEON/PacketMath.h @@ -250,7 +250,7 @@ template<> EIGEN_STRONG_INLINE void pstore<int>(int* to, const Packet4i& f template<> EIGEN_STRONG_INLINE void pstoreu<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_UNALIGNED_STORE vst1q_f32(to, from); } template<> EIGEN_STRONG_INLINE void pstoreu<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_UNALIGNED_STORE vst1q_s32(to, from); } -template<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const float* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const float* from, Index stride) { Packet4f res; res = vsetq_lane_f32(from[0*stride], res, 0); @@ -259,7 +259,7 @@ template<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const floa res = vsetq_lane_f32(from[3*stride], res, 3); return res; } -template<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* from, Index stride) { Packet4i res; res = vsetq_lane_s32(from[0*stride], res, 0); @@ -269,14 +269,14 @@ template<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* f return res; } -template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, const Packet4f& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, const Packet4f& from, Index stride) { to[stride*0] = vgetq_lane_f32(from, 0); to[stride*1] = vgetq_lane_f32(from, 1); to[stride*2] = vgetq_lane_f32(from, 2); to[stride*3] = vgetq_lane_f32(from, 3); } -template<> EIGEN_DEVICE_FUNC inline void pscatter<int, Packet4i>(int* to, const Packet4i& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<int, Packet4i>(int* to, const Packet4i& from, Index stride) { to[stride*0] = vgetq_lane_s32(from, 0); to[stride*1] = vgetq_lane_s32(from, 1); @@ -606,14 +606,14 @@ template<> EIGEN_STRONG_INLINE void pstore<double>(double* to, const Packet2d& template<> EIGEN_STRONG_INLINE void pstoreu<double>(double* to, const Packet2d& from) { EIGEN_DEBUG_UNALIGNED_STORE vst1q_f64(to, from); } -template<> EIGEN_DEVICE_FUNC inline Packet2d pgather<double, Packet2d>(const double* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet2d pgather<double, Packet2d>(const double* from, Index stride) { Packet2d res; res = vsetq_lane_f64(from[0*stride], res, 0); res = vsetq_lane_f64(from[1*stride], res, 1); return res; } -template<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet2d>(double* to, const Packet2d& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet2d>(double* to, const Packet2d& from, Index stride) { to[stride*0] = vgetq_lane_f64(from, 0); to[stride*1] = vgetq_lane_f64(from, 1); diff --git a/Eigen/src/Core/arch/SSE/Complex.h b/Eigen/src/Core/arch/SSE/Complex.h index 565e448fe..acb49abf8 100644 --- a/Eigen/src/Core/arch/SSE/Complex.h +++ b/Eigen/src/Core/arch/SSE/Complex.h @@ -115,13 +115,13 @@ template<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<f template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(&numext::real_ref(*to), Packet4f(from.v)); } -template<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet2cf pgather<std::complex<float>, Packet2cf>(const std::complex<float>* from, Index stride) { return Packet2cf(_mm_set_ps(std::imag(from[1*stride]), std::real(from[1*stride]), std::imag(from[0*stride]), std::real(from[0*stride]))); } -template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<std::complex<float>, Packet2cf>(std::complex<float>* to, const Packet2cf& from, Index stride) { to[stride*0] = std::complex<float>(_mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 0)), _mm_cvtss_f32(_mm_shuffle_ps(from.v, from.v, 1))); diff --git a/Eigen/src/Core/arch/SSE/PacketMath.h b/Eigen/src/Core/arch/SSE/PacketMath.h index 898cb9ab0..86d94dffa 100755 --- a/Eigen/src/Core/arch/SSE/PacketMath.h +++ b/Eigen/src/Core/arch/SSE/PacketMath.h @@ -387,32 +387,32 @@ template<> EIGEN_STRONG_INLINE void pstoreu<double>(double* to, const Packet2d& template<> EIGEN_STRONG_INLINE void pstoreu<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(reinterpret_cast<double*>(to), Packet2d(_mm_castps_pd(from))); } template<> EIGEN_STRONG_INLINE void pstoreu<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(reinterpret_cast<double*>(to), Packet2d(_mm_castsi128_pd(from))); } -template<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const float* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet4f pgather<float, Packet4f>(const float* from, Index stride) { return _mm_set_ps(from[3*stride], from[2*stride], from[1*stride], from[0*stride]); } -template<> EIGEN_DEVICE_FUNC inline Packet2d pgather<double, Packet2d>(const double* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet2d pgather<double, Packet2d>(const double* from, Index stride) { return _mm_set_pd(from[1*stride], from[0*stride]); } -template<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline Packet4i pgather<int, Packet4i>(const int* from, Index stride) { return _mm_set_epi32(from[3*stride], from[2*stride], from[1*stride], from[0*stride]); } -template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, const Packet4f& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<float, Packet4f>(float* to, const Packet4f& from, Index stride) { to[stride*0] = _mm_cvtss_f32(from); to[stride*1] = _mm_cvtss_f32(_mm_shuffle_ps(from, from, 1)); to[stride*2] = _mm_cvtss_f32(_mm_shuffle_ps(from, from, 2)); to[stride*3] = _mm_cvtss_f32(_mm_shuffle_ps(from, from, 3)); } -template<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet2d>(double* to, const Packet2d& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<double, Packet2d>(double* to, const Packet2d& from, Index stride) { to[stride*0] = _mm_cvtsd_f64(from); to[stride*1] = _mm_cvtsd_f64(_mm_shuffle_pd(from, from, 1)); } -template<> EIGEN_DEVICE_FUNC inline void pscatter<int, Packet4i>(int* to, const Packet4i& from, DenseIndex stride) +template<> EIGEN_DEVICE_FUNC inline void pscatter<int, Packet4i>(int* to, const Packet4i& from, Index stride) { to[stride*0] = _mm_cvtsi128_si32(from); to[stride*1] = _mm_cvtsi128_si32(_mm_shuffle_epi32(from, 1)); diff --git a/Eigen/src/Core/functors/NullaryFunctors.h b/Eigen/src/Core/functors/NullaryFunctors.h index be03fbf52..2362b3a7f 100644 --- a/Eigen/src/Core/functors/NullaryFunctors.h +++ b/Eigen/src/Core/functors/NullaryFunctors.h @@ -112,7 +112,7 @@ template <typename Scalar, bool RandomAccess> struct functor_traits< linspaced_o template <typename Scalar, bool RandomAccess> struct linspaced_op { typedef typename packet_traits<Scalar>::type Packet; - linspaced_op(const Scalar& low, const Scalar& high, DenseIndex num_steps) : impl((num_steps==1 ? high : low), (num_steps==1 ? Scalar() : (high-low)/Scalar(num_steps-1))) {} + linspaced_op(const Scalar& low, const Scalar& high, Index num_steps) : impl((num_steps==1 ? high : low), (num_steps==1 ? Scalar() : (high-low)/Scalar(num_steps-1))) {} template<typename Index> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar operator() (Index i) const { return impl(i); } diff --git a/Eigen/src/Core/products/GeneralMatrixMatrix.h b/Eigen/src/Core/products/GeneralMatrixMatrix.h index fd9443cd2..44e44b986 100644 --- a/Eigen/src/Core/products/GeneralMatrixMatrix.h +++ b/Eigen/src/Core/products/GeneralMatrixMatrix.h @@ -257,9 +257,9 @@ class level3_blocking LhsScalar* m_blockA; RhsScalar* m_blockB; - DenseIndex m_mc; - DenseIndex m_nc; - DenseIndex m_kc; + Index m_mc; + Index m_nc; + Index m_kc; public: @@ -267,9 +267,9 @@ class level3_blocking : m_blockA(0), m_blockB(0), m_mc(0), m_nc(0), m_kc(0) {} - inline DenseIndex mc() const { return m_mc; } - inline DenseIndex nc() const { return m_nc; } - inline DenseIndex kc() const { return m_kc; } + inline Index mc() const { return m_mc; } + inline Index nc() const { return m_nc; } + inline Index kc() const { return m_kc; } inline LhsScalar* blockA() { return m_blockA; } inline RhsScalar* blockB() { return m_blockB; } @@ -299,7 +299,7 @@ class gemm_blocking_space<StorageOrder,_LhsScalar,_RhsScalar,MaxRows, MaxCols, M public: - gemm_blocking_space(DenseIndex /*rows*/, DenseIndex /*cols*/, DenseIndex /*depth*/, int /*num_threads*/, bool /*full_rows = false*/) + gemm_blocking_space(Index /*rows*/, Index /*cols*/, Index /*depth*/, int /*num_threads*/, bool /*full_rows = false*/) { this->m_mc = ActualRows; this->m_nc = ActualCols; @@ -326,12 +326,12 @@ class gemm_blocking_space<StorageOrder,_LhsScalar,_RhsScalar,MaxRows, MaxCols, M typedef typename conditional<Transpose,_LhsScalar,_RhsScalar>::type RhsScalar; typedef gebp_traits<LhsScalar,RhsScalar> Traits; - DenseIndex m_sizeA; - DenseIndex m_sizeB; + Index m_sizeA; + Index m_sizeB; public: - gemm_blocking_space(DenseIndex rows, DenseIndex cols, DenseIndex depth, int num_threads, bool l3_blocking) + gemm_blocking_space(Index rows, Index cols, Index depth, int num_threads, bool l3_blocking) { this->m_mc = Transpose ? cols : rows; this->m_nc = Transpose ? rows : cols; @@ -343,8 +343,8 @@ class gemm_blocking_space<StorageOrder,_LhsScalar,_RhsScalar,MaxRows, MaxCols, M } else // no l3 blocking { - DenseIndex m = this->m_mc; - DenseIndex n = this->m_nc; + Index m = this->m_mc; + Index n = this->m_nc; computeProductBlockingSizes<LhsScalar,RhsScalar,KcFactor>(this->m_kc, m, n, num_threads); } @@ -386,7 +386,6 @@ struct generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,GemmProduct> : generic_product_impl_base<Lhs,Rhs,generic_product_impl<Lhs,Rhs,DenseShape,DenseShape,GemmProduct> > { typedef typename Product<Lhs,Rhs>::Scalar Scalar; - typedef typename Product<Lhs,Rhs>::Index Index; typedef typename Lhs::Scalar LhsScalar; typedef typename Rhs::Scalar RhsScalar; diff --git a/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h b/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h index e55994900..a36eb2fe0 100644 --- a/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h +++ b/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h @@ -198,7 +198,6 @@ struct general_product_to_triangular_selector<MatrixType,ProductType,UpLo,true> static void run(MatrixType& mat, const ProductType& prod, const typename MatrixType::Scalar& alpha) { typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::Index Index; typedef typename internal::remove_all<typename ProductType::LhsNested>::type Lhs; typedef internal::blas_traits<Lhs> LhsBlasTraits; @@ -243,8 +242,6 @@ struct general_product_to_triangular_selector<MatrixType,ProductType,UpLo,false> { static void run(MatrixType& mat, const ProductType& prod, const typename MatrixType::Scalar& alpha) { - typedef typename MatrixType::Index Index; - typedef typename internal::remove_all<typename ProductType::LhsNested>::type Lhs; typedef internal::blas_traits<Lhs> LhsBlasTraits; typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhs; diff --git a/Eigen/src/Core/products/SelfadjointMatrixMatrix.h b/Eigen/src/Core/products/SelfadjointMatrixMatrix.h index 4b6316d63..f84f54982 100644 --- a/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +++ b/Eigen/src/Core/products/SelfadjointMatrixMatrix.h @@ -474,7 +474,6 @@ template<typename Lhs, int LhsMode, typename Rhs, int RhsMode> struct selfadjoint_product_impl<Lhs,LhsMode,false,Rhs,RhsMode,false> { typedef typename Product<Lhs,Rhs>::Scalar Scalar; - typedef typename Product<Lhs,Rhs>::Index Index; typedef internal::blas_traits<Lhs> LhsBlasTraits; typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType; diff --git a/Eigen/src/Core/products/SelfadjointMatrixVector.h b/Eigen/src/Core/products/SelfadjointMatrixVector.h index 372a44e47..5d6ef9913 100644 --- a/Eigen/src/Core/products/SelfadjointMatrixVector.h +++ b/Eigen/src/Core/products/SelfadjointMatrixVector.h @@ -174,7 +174,6 @@ template<typename Lhs, int LhsMode, typename Rhs> struct selfadjoint_product_impl<Lhs,LhsMode,false,Rhs,0,true> { typedef typename Product<Lhs,Rhs>::Scalar Scalar; - typedef typename Product<Lhs,Rhs>::Index Index; typedef internal::blas_traits<Lhs> LhsBlasTraits; typedef typename LhsBlasTraits::DirectLinearAccessType ActualLhsType; diff --git a/Eigen/src/Core/products/SelfadjointProduct.h b/Eigen/src/Core/products/SelfadjointProduct.h index 6ca4ae6c0..2af00058d 100644 --- a/Eigen/src/Core/products/SelfadjointProduct.h +++ b/Eigen/src/Core/products/SelfadjointProduct.h @@ -53,7 +53,6 @@ struct selfadjoint_product_selector<MatrixType,OtherType,UpLo,true> static void run(MatrixType& mat, const OtherType& other, const typename MatrixType::Scalar& alpha) { typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::Index Index; typedef internal::blas_traits<OtherType> OtherBlasTraits; typedef typename OtherBlasTraits::DirectLinearAccessType ActualOtherType; typedef typename internal::remove_all<ActualOtherType>::type _ActualOtherType; @@ -86,7 +85,6 @@ struct selfadjoint_product_selector<MatrixType,OtherType,UpLo,false> static void run(MatrixType& mat, const OtherType& other, const typename MatrixType::Scalar& alpha) { typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::Index Index; typedef internal::blas_traits<OtherType> OtherBlasTraits; typedef typename OtherBlasTraits::DirectLinearAccessType ActualOtherType; typedef typename internal::remove_all<ActualOtherType>::type _ActualOtherType; diff --git a/Eigen/src/Core/products/TriangularMatrixMatrix.h b/Eigen/src/Core/products/TriangularMatrixMatrix.h index 60c99dcd2..5f01eb5a8 100644 --- a/Eigen/src/Core/products/TriangularMatrixMatrix.h +++ b/Eigen/src/Core/products/TriangularMatrixMatrix.h @@ -388,7 +388,6 @@ struct triangular_product_impl<Mode,LhsIsTriangular,Lhs,false,Rhs,false> { template<typename Dest> static void run(Dest& dst, const Lhs &a_lhs, const Rhs &a_rhs, const typename Dest::Scalar& alpha) { - typedef typename Dest::Index Index; typedef typename Dest::Scalar Scalar; typedef internal::blas_traits<Lhs> LhsBlasTraits; diff --git a/Eigen/src/Core/products/TriangularMatrixVector.h b/Eigen/src/Core/products/TriangularMatrixVector.h index 4d88a710b..7c014b72a 100644 --- a/Eigen/src/Core/products/TriangularMatrixVector.h +++ b/Eigen/src/Core/products/TriangularMatrixVector.h @@ -206,7 +206,6 @@ template<int Mode> struct trmv_selector<Mode,ColMajor> template<typename Lhs, typename Rhs, typename Dest> static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha) { - typedef typename Dest::Index Index; typedef typename Lhs::Scalar LhsScalar; typedef typename Rhs::Scalar RhsScalar; typedef typename Dest::Scalar ResScalar; @@ -283,7 +282,6 @@ template<int Mode> struct trmv_selector<Mode,RowMajor> template<typename Lhs, typename Rhs, typename Dest> static void run(const Lhs &lhs, const Rhs &rhs, Dest& dest, const typename Dest::Scalar& alpha) { - typedef typename Dest::Index Index; typedef typename Lhs::Scalar LhsScalar; typedef typename Rhs::Scalar RhsScalar; typedef typename Dest::Scalar ResScalar; diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index 07c528a2f..e607cdd12 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -648,7 +648,7 @@ namespace Eigen { typedef typename Base::CoeffReturnType CoeffReturnType; /*!< \brief The return type for coefficient access. \details Depending on whether the object allows direct coefficient access (e.g. for a MatrixXd), this type is either 'const Scalar&' or simply 'Scalar' for objects that do not allow direct coefficient access. */ \ typedef typename Eigen::internal::nested<Derived>::type Nested; \ typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \ - typedef typename Eigen::internal::traits<Derived>::Index Index; \ + typedef typename Eigen::internal::traits<Derived>::StorageIndex StorageIndex; \ enum { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \ ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \ Flags = Eigen::internal::traits<Derived>::Flags, \ @@ -658,23 +658,12 @@ namespace Eigen { #define EIGEN_DENSE_PUBLIC_INTERFACE(Derived) \ - typedef typename Eigen::internal::traits<Derived>::Scalar Scalar; /*!< \brief Numeric type, e.g. float, double, int or std::complex<float>. */ \ - typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; /*!< \brief The underlying numeric type for composed scalar types. \details In cases where Scalar is e.g. std::complex<T>, T were corresponding to RealScalar. */ \ + EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \ typedef typename Base::PacketScalar PacketScalar; \ - typedef typename Base::CoeffReturnType CoeffReturnType; /*!< \brief The return type for coefficient access. \details Depending on whether the object allows direct coefficient access (e.g. for a MatrixXd), this type is either 'const Scalar&' or simply 'Scalar' for objects that do not allow direct coefficient access. */ \ - typedef typename Eigen::internal::nested<Derived>::type Nested; \ - typedef typename Eigen::internal::traits<Derived>::StorageKind StorageKind; \ - typedef typename Eigen::internal::traits<Derived>::Index Index; \ - enum { RowsAtCompileTime = Eigen::internal::traits<Derived>::RowsAtCompileTime, \ - ColsAtCompileTime = Eigen::internal::traits<Derived>::ColsAtCompileTime, \ - MaxRowsAtCompileTime = Eigen::internal::traits<Derived>::MaxRowsAtCompileTime, \ - MaxColsAtCompileTime = Eigen::internal::traits<Derived>::MaxColsAtCompileTime, \ - Flags = Eigen::internal::traits<Derived>::Flags, \ - SizeAtCompileTime = Base::SizeAtCompileTime, \ - MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \ - IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \ + enum { MaxRowsAtCompileTime = Eigen::internal::traits<Derived>::MaxRowsAtCompileTime, \ + MaxColsAtCompileTime = Eigen::internal::traits<Derived>::MaxColsAtCompileTime}; \ using Base::derived; \ - using Base::const_cast_derived; + using Base::const_cast_derived; #define EIGEN_PLAIN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b) #define EIGEN_PLAIN_ENUM_MAX(a,b) (((int)a >= (int)b) ? (int)a : (int)b) diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index 3ac37df58..528ebe297 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -26,8 +26,25 @@ namespace Eigen { typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex; +/** + * \brief The Index type as used for the API. + * \details To change this, \c \#define the preprocessor symbol \c EIGEN_DEFAULT_DENSE_INDEX_TYPE. + * \sa \ref TopicPreprocessorDirectives, StorageIndex. + */ + +typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE Index; + namespace internal { +template<typename IndexDest, typename IndexSrc> +EIGEN_DEVICE_FUNC +inline IndexDest convert_index(const IndexSrc& idx) { + // for sizeof(IndexDest)>=sizeof(IndexSrc) compilers should be able to optimize this away: + eigen_internal_assert(idx <= NumTraits<IndexDest>::highest() && "Index value to big for target type"); + return IndexDest(idx); +} + + //classes inheriting no_assignment_operator don't generate a default operator=. class no_assignment_operator { diff --git a/Eigen/src/Eigenvalues/ComplexEigenSolver.h b/Eigen/src/Eigenvalues/ComplexEigenSolver.h index 25082546e..075a62848 100644 --- a/Eigen/src/Eigenvalues/ComplexEigenSolver.h +++ b/Eigen/src/Eigenvalues/ComplexEigenSolver.h @@ -60,7 +60,7 @@ template<typename _MatrixType> class ComplexEigenSolver /** \brief Scalar type for matrices of type #MatrixType. */ typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits<Scalar>::Real RealScalar; - typedef typename MatrixType::Index Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 /** \brief Complex scalar type for #MatrixType. * diff --git a/Eigen/src/Eigenvalues/ComplexSchur.h b/Eigen/src/Eigenvalues/ComplexSchur.h index a3a5a4649..993ee7e1e 100644 --- a/Eigen/src/Eigenvalues/ComplexSchur.h +++ b/Eigen/src/Eigenvalues/ComplexSchur.h @@ -63,7 +63,7 @@ template<typename _MatrixType> class ComplexSchur /** \brief Scalar type for matrices of type \p _MatrixType. */ typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits<Scalar>::Real RealScalar; - typedef typename MatrixType::Index Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 /** \brief Complex scalar type for \p _MatrixType. * diff --git a/Eigen/src/Eigenvalues/EigenSolver.h b/Eigen/src/Eigenvalues/EigenSolver.h index 9372021ff..a63a42341 100644 --- a/Eigen/src/Eigenvalues/EigenSolver.h +++ b/Eigen/src/Eigenvalues/EigenSolver.h @@ -79,7 +79,7 @@ template<typename _MatrixType> class EigenSolver /** \brief Scalar type for matrices of type #MatrixType. */ typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits<Scalar>::Real RealScalar; - typedef typename MatrixType::Index Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 /** \brief Complex scalar type for #MatrixType. * diff --git a/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h b/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h index c20ea03e6..c9da6740a 100644 --- a/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h +++ b/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h @@ -72,7 +72,7 @@ template<typename _MatrixType> class GeneralizedEigenSolver /** \brief Scalar type for matrices of type #MatrixType. */ typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits<Scalar>::Real RealScalar; - typedef typename MatrixType::Index Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 /** \brief Complex scalar type for #MatrixType. * diff --git a/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h b/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h index 1ce1f5f58..5f6bb8289 100644 --- a/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h +++ b/Eigen/src/Eigenvalues/GeneralizedSelfAdjointEigenSolver.h @@ -50,7 +50,6 @@ class GeneralizedSelfAdjointEigenSolver : public SelfAdjointEigenSolver<_MatrixT typedef SelfAdjointEigenSolver<_MatrixType> Base; public: - typedef typename Base::Index Index; typedef _MatrixType MatrixType; /** \brief Default constructor for fixed-size matrices. diff --git a/Eigen/src/Eigenvalues/HessenbergDecomposition.h b/Eigen/src/Eigenvalues/HessenbergDecomposition.h index 2615a9f23..87a5bcb69 100644 --- a/Eigen/src/Eigenvalues/HessenbergDecomposition.h +++ b/Eigen/src/Eigenvalues/HessenbergDecomposition.h @@ -71,7 +71,7 @@ template<typename _MatrixType> class HessenbergDecomposition /** \brief Scalar type for matrices of type #MatrixType. */ typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::Index Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 /** \brief Type for vector of Householder coefficients. * @@ -337,7 +337,6 @@ namespace internal { template<typename MatrixType> struct HessenbergDecompositionMatrixHReturnType : public ReturnByValue<HessenbergDecompositionMatrixHReturnType<MatrixType> > { - typedef typename MatrixType::Index Index; public: /** \brief Constructor. * diff --git a/Eigen/src/Eigenvalues/RealQZ.h b/Eigen/src/Eigenvalues/RealQZ.h index 128ef9028..ca75f2f50 100644 --- a/Eigen/src/Eigenvalues/RealQZ.h +++ b/Eigen/src/Eigenvalues/RealQZ.h @@ -67,7 +67,7 @@ namespace Eigen { }; typedef typename MatrixType::Scalar Scalar; typedef std::complex<typename NumTraits<Scalar>::Real> ComplexScalar; - typedef typename MatrixType::Index Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 typedef Matrix<ComplexScalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> EigenvalueType; typedef Matrix<Scalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> ColumnVectorType; @@ -276,7 +276,7 @@ namespace Eigen { /** \internal Look for single small sub-diagonal element S(res, res-1) and return res (or 0) */ template<typename MatrixType> - inline typename MatrixType::Index RealQZ<MatrixType>::findSmallSubdiagEntry(Index iu) + inline Index RealQZ<MatrixType>::findSmallSubdiagEntry(Index iu) { using std::abs; Index res = iu; @@ -294,7 +294,7 @@ namespace Eigen { /** \internal Look for single small diagonal element T(res, res) for res between f and l, and return res (or f-1) */ template<typename MatrixType> - inline typename MatrixType::Index RealQZ<MatrixType>::findSmallDiagEntry(Index f, Index l) + inline Index RealQZ<MatrixType>::findSmallDiagEntry(Index f, Index l) { using std::abs; Index res = l; diff --git a/Eigen/src/Eigenvalues/RealSchur.h b/Eigen/src/Eigenvalues/RealSchur.h index 51e61ba38..60ade50a0 100644 --- a/Eigen/src/Eigenvalues/RealSchur.h +++ b/Eigen/src/Eigenvalues/RealSchur.h @@ -64,7 +64,7 @@ template<typename _MatrixType> class RealSchur }; typedef typename MatrixType::Scalar Scalar; typedef std::complex<typename NumTraits<Scalar>::Real> ComplexScalar; - typedef typename MatrixType::Index Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 typedef Matrix<ComplexScalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> EigenvalueType; typedef Matrix<Scalar, ColsAtCompileTime, 1, Options & ~RowMajor, MaxColsAtCompileTime, 1> ColumnVectorType; @@ -343,7 +343,7 @@ inline typename MatrixType::Scalar RealSchur<MatrixType>::computeNormOfT() /** \internal Look for single small sub-diagonal element and returns its index */ template<typename MatrixType> -inline typename MatrixType::Index RealSchur<MatrixType>::findSmallSubdiagEntry(Index iu) +inline Index RealSchur<MatrixType>::findSmallSubdiagEntry(Index iu) { using std::abs; Index res = iu; diff --git a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h index 54f60b197..66d1154cf 100644 --- a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +++ b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h @@ -21,7 +21,7 @@ class GeneralizedSelfAdjointEigenSolver; namespace internal { template<typename SolverType,int Size,bool IsComplex> struct direct_selfadjoint_eigenvalues; template<typename MatrixType, typename DiagType, typename SubDiagType> -ComputationInfo computeFromTridiagonal_impl(DiagType& diag, SubDiagType& subdiag, const typename MatrixType::Index maxIterations, bool computeEigenvectors, MatrixType& eivec); +ComputationInfo computeFromTridiagonal_impl(DiagType& diag, SubDiagType& subdiag, const Index maxIterations, bool computeEigenvectors, MatrixType& eivec); } /** \eigenvalues_module \ingroup Eigenvalues_Module @@ -81,7 +81,7 @@ template<typename _MatrixType> class SelfAdjointEigenSolver /** \brief Scalar type for matrices of type \p _MatrixType. */ typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::Index Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 /** \brief Real scalar type for \p _MatrixType. * @@ -456,12 +456,11 @@ namespace internal { * \returns \c Success or \c NoConvergence */ template<typename MatrixType, typename DiagType, typename SubDiagType> -ComputationInfo computeFromTridiagonal_impl(DiagType& diag, SubDiagType& subdiag, const typename MatrixType::Index maxIterations, bool computeEigenvectors, MatrixType& eivec) +ComputationInfo computeFromTridiagonal_impl(DiagType& diag, SubDiagType& subdiag, const Index maxIterations, bool computeEigenvectors, MatrixType& eivec) { using std::abs; ComputationInfo info; - typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; Index n = diag.size(); diff --git a/Eigen/src/Eigenvalues/Tridiagonalization.h b/Eigen/src/Eigenvalues/Tridiagonalization.h index bedd1cb34..a6fb00b21 100644 --- a/Eigen/src/Eigenvalues/Tridiagonalization.h +++ b/Eigen/src/Eigenvalues/Tridiagonalization.h @@ -69,7 +69,7 @@ template<typename _MatrixType> class Tridiagonalization typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits<Scalar>::Real RealScalar; - typedef typename MatrixType::Index Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 enum { Size = MatrixType::RowsAtCompileTime, @@ -345,7 +345,6 @@ template<typename MatrixType, typename CoeffVectorType> void tridiagonalization_inplace(MatrixType& matA, CoeffVectorType& hCoeffs) { using numext::conj; - typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; Index n = matA.rows(); @@ -437,7 +436,6 @@ struct tridiagonalization_inplace_selector { typedef typename Tridiagonalization<MatrixType>::CoeffVectorType CoeffVectorType; typedef typename Tridiagonalization<MatrixType>::HouseholderSequenceType HouseholderSequenceType; - typedef typename MatrixType::Index Index; template<typename DiagonalType, typename SubDiagonalType> static void run(MatrixType& mat, DiagonalType& diag, SubDiagonalType& subdiag, bool extractQ) { @@ -525,7 +523,6 @@ struct tridiagonalization_inplace_selector<MatrixType,1,IsComplex> template<typename MatrixType> struct TridiagonalizationMatrixTReturnType : public ReturnByValue<TridiagonalizationMatrixTReturnType<MatrixType> > { - typedef typename MatrixType::Index Index; public: /** \brief Constructor. * diff --git a/Eigen/src/Geometry/AlignedBox.h b/Eigen/src/Geometry/AlignedBox.h index d6c5c1293..b7c02e8db 100644 --- a/Eigen/src/Geometry/AlignedBox.h +++ b/Eigen/src/Geometry/AlignedBox.h @@ -32,7 +32,7 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim) enum { AmbientDimAtCompileTime = _AmbientDim }; typedef _Scalar Scalar; typedef NumTraits<Scalar> ScalarTraits; - typedef DenseIndex Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 typedef typename ScalarTraits::Real RealScalar; typedef typename ScalarTraits::NonInteger NonInteger; typedef Matrix<Scalar,AmbientDimAtCompileTime,1> VectorType; diff --git a/Eigen/src/Geometry/Homogeneous.h b/Eigen/src/Geometry/Homogeneous.h index 7f1907542..f16451656 100644 --- a/Eigen/src/Geometry/Homogeneous.h +++ b/Eigen/src/Geometry/Homogeneous.h @@ -238,7 +238,6 @@ struct homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs> typedef typename traits<homogeneous_left_product_impl>::LhsMatrixType LhsMatrixType; typedef typename remove_all<LhsMatrixType>::type LhsMatrixTypeCleaned; typedef typename remove_all<typename LhsMatrixTypeCleaned::Nested>::type LhsMatrixTypeNested; - typedef typename MatrixType::Index Index; homogeneous_left_product_impl(const Lhs& lhs, const MatrixType& rhs) : m_lhs(take_matrix_for_product<Lhs>::run(lhs)), m_rhs(rhs) @@ -278,7 +277,6 @@ struct homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs> : public ReturnByValue<homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs> > { typedef typename remove_all<typename Rhs::Nested>::type RhsNested; - typedef typename MatrixType::Index Index; homogeneous_right_product_impl(const MatrixType& lhs, const Rhs& rhs) : m_lhs(lhs), m_rhs(rhs) {} diff --git a/Eigen/src/Geometry/Hyperplane.h b/Eigen/src/Geometry/Hyperplane.h index 00b7c4300..2d076d7f8 100644 --- a/Eigen/src/Geometry/Hyperplane.h +++ b/Eigen/src/Geometry/Hyperplane.h @@ -41,7 +41,7 @@ public: }; typedef _Scalar Scalar; typedef typename NumTraits<Scalar>::Real RealScalar; - typedef DenseIndex Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 typedef Matrix<Scalar,AmbientDimAtCompileTime,1> VectorType; typedef Matrix<Scalar,Index(AmbientDimAtCompileTime)==Dynamic ? Dynamic diff --git a/Eigen/src/Geometry/OrthoMethods.h b/Eigen/src/Geometry/OrthoMethods.h index a245c79d3..6b2e57392 100644 --- a/Eigen/src/Geometry/OrthoMethods.h +++ b/Eigen/src/Geometry/OrthoMethods.h @@ -133,7 +133,6 @@ struct unitOrthogonal_selector typedef typename plain_matrix_type<Derived>::type VectorType; typedef typename traits<Derived>::Scalar Scalar; typedef typename NumTraits<Scalar>::Real RealScalar; - typedef typename Derived::Index Index; typedef Matrix<Scalar,2,1> Vector2; EIGEN_DEVICE_FUNC static inline VectorType run(const Derived& src) diff --git a/Eigen/src/Geometry/ParametrizedLine.h b/Eigen/src/Geometry/ParametrizedLine.h index 77fa228e6..93edd9148 100644 --- a/Eigen/src/Geometry/ParametrizedLine.h +++ b/Eigen/src/Geometry/ParametrizedLine.h @@ -37,7 +37,7 @@ public: }; typedef _Scalar Scalar; typedef typename NumTraits<Scalar>::Real RealScalar; - typedef DenseIndex Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 typedef Matrix<Scalar,AmbientDimAtCompileTime,1,Options> VectorType; /** Default constructor without initialization */ diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h index 508eba767..e1ad803bb 100644 --- a/Eigen/src/Geometry/Quaternion.h +++ b/Eigen/src/Geometry/Quaternion.h @@ -724,7 +724,6 @@ template<typename Other> struct quaternionbase_assign_impl<Other,3,3> { typedef typename Other::Scalar Scalar; - typedef DenseIndex Index; template<class Derived> static inline void run(QuaternionBase<Derived>& q, const Other& mat) { using std::sqrt; @@ -742,13 +741,13 @@ struct quaternionbase_assign_impl<Other,3,3> } else { - DenseIndex i = 0; + Index i = 0; if (mat.coeff(1,1) > mat.coeff(0,0)) i = 1; if (mat.coeff(2,2) > mat.coeff(i,i)) i = 2; - DenseIndex j = (i+1)%3; - DenseIndex k = (j+1)%3; + Index j = (i+1)%3; + Index k = (j+1)%3; t = sqrt(mat.coeff(i,i)-mat.coeff(j,j)-mat.coeff(k,k) + Scalar(1.0)); q.coeffs().coeffRef(i) = Scalar(0.5) * t; diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index d33fc24db..8c9d7049b 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -66,7 +66,7 @@ template<typename _Scalar, int _Dim, int _Mode, int _Options> struct traits<Transform<_Scalar,_Dim,_Mode,_Options> > { typedef _Scalar Scalar; - typedef DenseIndex Index; + typedef Eigen::Index StorageIndex; typedef Dense StorageKind; enum { Dim1 = _Dim==Dynamic ? _Dim : _Dim + 1, @@ -204,7 +204,8 @@ public: }; /** the scalar type of the coefficients */ typedef _Scalar Scalar; - typedef DenseIndex Index; + typedef Eigen::Index StorageIndex; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 /** type of the matrix used to represent the transformation */ typedef typename internal::make_proper_matrix_type<Scalar,Rows,HDim,Options>::type MatrixType; /** constified MatrixType */ diff --git a/Eigen/src/Geometry/Umeyama.h b/Eigen/src/Geometry/Umeyama.h index 5e20662f8..8d9b7a154 100644 --- a/Eigen/src/Geometry/Umeyama.h +++ b/Eigen/src/Geometry/Umeyama.h @@ -97,7 +97,6 @@ umeyama(const MatrixBase<Derived>& src, const MatrixBase<OtherDerived>& dst, boo typedef typename internal::umeyama_transform_matrix_type<Derived, OtherDerived>::type TransformationMatrixType; typedef typename internal::traits<TransformationMatrixType>::Scalar Scalar; typedef typename NumTraits<Scalar>::Real RealScalar; - typedef typename Derived::Index Index; EIGEN_STATIC_ASSERT(!NumTraits<Scalar>::IsComplex, NUMERIC_TYPE_MUST_BE_REAL) EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename internal::traits<OtherDerived>::Scalar>::value), diff --git a/Eigen/src/Householder/BlockHouseholder.h b/Eigen/src/Householder/BlockHouseholder.h index 35dbf80a1..39bf8c83d 100644 --- a/Eigen/src/Householder/BlockHouseholder.h +++ b/Eigen/src/Householder/BlockHouseholder.h @@ -21,7 +21,6 @@ namespace internal { // template<typename TriangularFactorType,typename VectorsType,typename CoeffsType> // void make_block_householder_triangular_factor(TriangularFactorType& triFactor, const VectorsType& vectors, const CoeffsType& hCoeffs) // { -// typedef typename TriangularFactorType::Index Index; // typedef typename VectorsType::Scalar Scalar; // const Index nbVecs = vectors.cols(); // eigen_assert(triFactor.rows() == nbVecs && triFactor.cols() == nbVecs && vectors.rows()>=nbVecs); @@ -51,7 +50,6 @@ namespace internal { template<typename TriangularFactorType,typename VectorsType,typename CoeffsType> void make_block_householder_triangular_factor(TriangularFactorType& triFactor, const VectorsType& vectors, const CoeffsType& hCoeffs) { - typedef typename TriangularFactorType::Index Index; const Index nbVecs = vectors.cols(); eigen_assert(triFactor.rows() == nbVecs && triFactor.cols() == nbVecs && vectors.rows()>=nbVecs); @@ -80,7 +78,6 @@ void make_block_householder_triangular_factor(TriangularFactorType& triFactor, c template<typename MatrixType,typename VectorsType,typename CoeffsType> void apply_block_householder_on_the_left(MatrixType& mat, const VectorsType& vectors, const CoeffsType& hCoeffs, bool forward) { - typedef typename MatrixType::Index Index; enum { TFactorSize = MatrixType::ColsAtCompileTime }; Index nbVecs = vectors.cols(); Matrix<typename MatrixType::Scalar, TFactorSize, TFactorSize, RowMajor> T(nbVecs,nbVecs); diff --git a/Eigen/src/Householder/HouseholderSequence.h b/Eigen/src/Householder/HouseholderSequence.h index 4ded2995f..74cd0a472 100644 --- a/Eigen/src/Householder/HouseholderSequence.h +++ b/Eigen/src/Householder/HouseholderSequence.h @@ -60,7 +60,7 @@ template<typename VectorsType, typename CoeffsType, int Side> struct traits<HouseholderSequence<VectorsType,CoeffsType,Side> > { typedef typename VectorsType::Scalar Scalar; - typedef typename VectorsType::Index Index; + typedef typename VectorsType::StorageIndex StorageIndex; typedef typename VectorsType::StorageKind StorageKind; enum { RowsAtCompileTime = Side==OnTheLeft ? traits<VectorsType>::RowsAtCompileTime @@ -87,7 +87,6 @@ struct hseq_side_dependent_impl { typedef Block<const VectorsType, Dynamic, 1> EssentialVectorType; typedef HouseholderSequence<VectorsType, CoeffsType, OnTheLeft> HouseholderSequenceType; - typedef typename VectorsType::Index Index; static inline const EssentialVectorType essentialVector(const HouseholderSequenceType& h, Index k) { Index start = k+1+h.m_shift; @@ -100,7 +99,6 @@ struct hseq_side_dependent_impl<VectorsType, CoeffsType, OnTheRight> { typedef Transpose<Block<const VectorsType, 1, Dynamic> > EssentialVectorType; typedef HouseholderSequence<VectorsType, CoeffsType, OnTheRight> HouseholderSequenceType; - typedef typename VectorsType::Index Index; static inline const EssentialVectorType essentialVector(const HouseholderSequenceType& h, Index k) { Index start = k+1+h.m_shift; @@ -131,7 +129,6 @@ template<typename VectorsType, typename CoeffsType, int Side> class HouseholderS MaxColsAtCompileTime = internal::traits<HouseholderSequence>::MaxColsAtCompileTime }; typedef typename internal::traits<HouseholderSequence>::Scalar Scalar; - typedef typename VectorsType::Index Index; typedef HouseholderSequence< typename internal::conditional<NumTraits<Scalar>::IsComplex, diff --git a/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h b/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h index 3991afa8f..a09f81225 100644 --- a/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h +++ b/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h @@ -34,9 +34,8 @@ class DiagonalPreconditioner { typedef _Scalar Scalar; typedef Matrix<Scalar,Dynamic,1> Vector; - typedef typename Vector::Index Index; - public: + typedef typename Vector::StorageIndex StorageIndex; // this typedef is only to export the scalar type and compile-time dimensions to solve_retval typedef Matrix<Scalar,Dynamic,Dynamic> MatrixType; diff --git a/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h b/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h index 31a43cb56..e67f09184 100644 --- a/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h +++ b/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h @@ -27,7 +27,7 @@ namespace internal { */ template<typename MatrixType, typename Rhs, typename Dest, typename Preconditioner> bool bicgstab(const MatrixType& mat, const Rhs& rhs, Dest& x, - const Preconditioner& precond, int& iters, + const Preconditioner& precond, Index& iters, typename Dest::RealScalar& tol_error) { using std::sqrt; @@ -36,9 +36,9 @@ bool bicgstab(const MatrixType& mat, const Rhs& rhs, Dest& x, typedef typename Dest::Scalar Scalar; typedef Matrix<Scalar,Dynamic,1> VectorType; RealScalar tol = tol_error; - int maxIters = iters; + Index maxIters = iters; - int n = mat.cols(); + Index n = mat.cols(); VectorType r = rhs - mat * x; VectorType r0 = r; @@ -61,8 +61,8 @@ bool bicgstab(const MatrixType& mat, const Rhs& rhs, Dest& x, RealScalar tol2 = tol*tol; RealScalar eps2 = NumTraits<Scalar>::epsilon()*NumTraits<Scalar>::epsilon(); - int i = 0; - int restarts = 0; + Index i = 0; + Index restarts = 0; while ( r.squaredNorm()/rhs_sqnorm > tol2 && i<maxIters ) { @@ -155,7 +155,6 @@ class BiCGSTAB : public IterativeSolverBase<BiCGSTAB<_MatrixType,_Preconditioner public: typedef _MatrixType MatrixType; typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::Index Index; typedef typename MatrixType::RealScalar RealScalar; typedef _Preconditioner Preconditioner; @@ -183,7 +182,7 @@ public: void _solve_with_guess_impl(const Rhs& b, Dest& x) const { bool failed = false; - for(int j=0; j<b.cols(); ++j) + for(Index j=0; j<b.cols(); ++j) { m_iterations = Base::maxIterations(); m_error = Base::m_tolerance; diff --git a/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h b/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h index 1e819fc9f..a799c3ef5 100644 --- a/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h +++ b/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h @@ -26,7 +26,7 @@ namespace internal { template<typename MatrixType, typename Rhs, typename Dest, typename Preconditioner> EIGEN_DONT_INLINE void conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x, - const Preconditioner& precond, int& iters, + const Preconditioner& precond, Index& iters, typename Dest::RealScalar& tol_error) { using std::sqrt; @@ -36,9 +36,9 @@ void conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x, typedef Matrix<Scalar,Dynamic,1> VectorType; RealScalar tol = tol_error; - int maxIters = iters; + Index maxIters = iters; - int n = mat.cols(); + Index n = mat.cols(); VectorType residual = rhs - mat * x; //initial residual @@ -64,7 +64,7 @@ void conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x, VectorType z(n), tmp(n); RealScalar absNew = numext::real(residual.dot(p)); // the square of the absolute value of r scaled by invM - int i = 0; + Index i = 0; while(i < maxIters) { tmp.noalias() = mat * p; // the bottleneck of the algorithm @@ -153,7 +153,6 @@ class ConjugateGradient : public IterativeSolverBase<ConjugateGradient<_MatrixTy public: typedef _MatrixType MatrixType; typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::Index Index; typedef typename MatrixType::RealScalar RealScalar; typedef _Preconditioner Preconditioner; @@ -191,7 +190,7 @@ public: m_iterations = Base::maxIterations(); m_error = Base::m_tolerance; - for(int j=0; j<b.cols(); ++j) + for(Index j=0; j<b.cols(); ++j) { m_iterations = Base::maxIterations(); m_error = Base::m_tolerance; diff --git a/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h b/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h index 8ed9bdecc..6d63d45e4 100644 --- a/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h +++ b/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h @@ -25,7 +25,7 @@ namespace internal { * \param ind The array of index for the elements in @p row * \param ncut The number of largest elements to keep **/ -template <typename VectorV, typename VectorI, typename Index> +template <typename VectorV, typename VectorI> Index QuickSplit(VectorV &row, VectorI &ind, Index ncut) { typedef typename VectorV::RealScalar RealScalar; @@ -105,7 +105,7 @@ class IncompleteLUT : public SparseSolverBase<IncompleteLUT<_Scalar> > typedef Matrix<Scalar,Dynamic,1> Vector; typedef SparseMatrix<Scalar,RowMajor> FactorType; typedef SparseMatrix<Scalar,ColMajor> PermutType; - typedef typename FactorType::Index Index; + typedef typename FactorType::StorageIndex StorageIndex; public: typedef Matrix<Scalar,Dynamic,Dynamic> MatrixType; @@ -189,8 +189,8 @@ protected: bool m_analysisIsOk; bool m_factorizationIsOk; ComputationInfo m_info; - PermutationMatrix<Dynamic,Dynamic,Index> m_P; // Fill-reducing permutation - PermutationMatrix<Dynamic,Dynamic,Index> m_Pinv; // Inverse permutation + PermutationMatrix<Dynamic,Dynamic,StorageIndex> m_P; // Fill-reducing permutation + PermutationMatrix<Dynamic,Dynamic,StorageIndex> m_Pinv; // Inverse permutation }; /** @@ -218,14 +218,14 @@ template<typename _MatrixType> void IncompleteLUT<Scalar>::analyzePattern(const _MatrixType& amat) { // Compute the Fill-reducing permutation - SparseMatrix<Scalar,ColMajor, Index> mat1 = amat; - SparseMatrix<Scalar,ColMajor, Index> mat2 = amat.transpose(); + SparseMatrix<Scalar,ColMajor, StorageIndex> mat1 = amat; + SparseMatrix<Scalar,ColMajor, StorageIndex> mat2 = amat.transpose(); // Symmetrize the pattern // FIXME for a matrix with nearly symmetric pattern, mat2+mat1 is the appropriate choice. // on the other hand for a really non-symmetric pattern, mat2*mat1 should be prefered... - SparseMatrix<Scalar,ColMajor, Index> AtA = mat2 + mat1; + SparseMatrix<Scalar,ColMajor, StorageIndex> AtA = mat2 + mat1; AtA.prune(keep_diag()); - internal::minimum_degree_ordering<Scalar, Index>(AtA, m_P); // Then compute the AMD ordering... + internal::minimum_degree_ordering<Scalar, StorageIndex>(AtA, m_P); // Then compute the AMD ordering... m_Pinv = m_P.inverse(); // ... and the inverse permutation @@ -239,6 +239,7 @@ void IncompleteLUT<Scalar>::factorize(const _MatrixType& amat) using std::sqrt; using std::swap; using std::abs; + using internal::convert_index; eigen_assert((amat.rows() == amat.cols()) && "The factorization should be done on a square matrix"); Index n = amat.cols(); // Size of the matrix @@ -250,7 +251,7 @@ void IncompleteLUT<Scalar>::factorize(const _MatrixType& amat) // Apply the fill-reducing permutation eigen_assert(m_analysisIsOk && "You must first call analyzePattern()"); - SparseMatrix<Scalar,RowMajor, Index> mat; + SparseMatrix<Scalar,RowMajor, StorageIndex> mat; mat = amat.twistedBy(m_Pinv); // Initialization @@ -259,7 +260,7 @@ void IncompleteLUT<Scalar>::factorize(const _MatrixType& amat) u.fill(0); // number of largest elements to keep in each row: - Index fill_in = static_cast<Index> (amat.nonZeros()*m_fillfactor)/n+1; + Index fill_in = (amat.nonZeros()*m_fillfactor)/n + 1; if (fill_in > n) fill_in = n; // number of largest nonzero elements to keep in the L and the U part of the current row: @@ -274,9 +275,9 @@ void IncompleteLUT<Scalar>::factorize(const _MatrixType& amat) Index sizeu = 1; // number of nonzero elements in the upper part of the current row Index sizel = 0; // number of nonzero elements in the lower part of the current row - ju(ii) = ii; + ju(ii) = convert_index<StorageIndex>(ii); u(ii) = 0; - jr(ii) = ii; + jr(ii) = convert_index<StorageIndex>(ii); RealScalar rownorm = 0; typename FactorType::InnerIterator j_it(mat, ii); // Iterate through the current row ii @@ -286,9 +287,9 @@ void IncompleteLUT<Scalar>::factorize(const _MatrixType& amat) if (k < ii) { // copy the lower part - ju(sizel) = k; + ju(sizel) = convert_index<StorageIndex>(k); u(sizel) = j_it.value(); - jr(k) = sizel; + jr(k) = convert_index<StorageIndex>(sizel); ++sizel; } else if (k == ii) @@ -299,9 +300,9 @@ void IncompleteLUT<Scalar>::factorize(const _MatrixType& amat) { // copy the upper part Index jpos = ii + sizeu; - ju(jpos) = k; + ju(jpos) = convert_index<StorageIndex>(k); u(jpos) = j_it.value(); - jr(k) = jpos; + jr(k) = convert_index<StorageIndex>(jpos); ++sizeu; } rownorm += numext::abs2(j_it.value()); @@ -331,7 +332,8 @@ void IncompleteLUT<Scalar>::factorize(const _MatrixType& amat) // swap the two locations Index j = ju(jj); swap(ju(jj), ju(k)); - jr(minrow) = jj; jr(j) = k; + jr(minrow) = convert_index<StorageIndex>(jj); + jr(j) = convert_index<StorageIndex>(k); swap(u(jj), u(k)); } // Reset this location @@ -355,8 +357,8 @@ void IncompleteLUT<Scalar>::factorize(const _MatrixType& amat) for (; ki_it; ++ki_it) { Scalar prod = fact * ki_it.value(); - Index j = ki_it.index(); - Index jpos = jr(j); + Index j = ki_it.index(); + Index jpos = jr(j); if (jpos == -1) // fill-in element { Index newpos; @@ -372,16 +374,16 @@ void IncompleteLUT<Scalar>::factorize(const _MatrixType& amat) sizel++; eigen_internal_assert(sizel<=ii); } - ju(newpos) = j; + ju(newpos) = convert_index<StorageIndex>(j); u(newpos) = -prod; - jr(j) = newpos; + jr(j) = convert_index<StorageIndex>(newpos); } else u(jpos) -= prod; } // store the pivot element - u(len) = fact; - ju(len) = minrow; + u(len) = fact; + ju(len) = convert_index<StorageIndex>(minrow); ++len; jj++; diff --git a/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h b/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h index 6f48075b4..38334028a 100644 --- a/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h +++ b/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h @@ -28,7 +28,7 @@ public: typedef typename internal::traits<Derived>::MatrixType MatrixType; typedef typename internal::traits<Derived>::Preconditioner Preconditioner; typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::Index Index; + typedef typename MatrixType::StorageIndex StorageIndex; typedef typename MatrixType::RealScalar RealScalar; public: @@ -121,6 +121,7 @@ public: /** \internal */ Index rows() const { return mp_matrix.rows(); } + /** \internal */ Index cols() const { return mp_matrix.cols(); } @@ -144,7 +145,7 @@ public: * It is either the value setted by setMaxIterations or, by default, * twice the number of columns of the matrix. */ - int maxIterations() const + Index maxIterations() const { return (m_maxIterations<0) ? 2*mp_matrix.cols() : m_maxIterations; } @@ -152,14 +153,14 @@ public: /** Sets the max number of iterations. * Default is twice the number of columns of the matrix. */ - Derived& setMaxIterations(int maxIters) + Derived& setMaxIterations(Index maxIters) { m_maxIterations = maxIters; return derived(); } /** \returns the number of iterations performed during the last solve */ - int iterations() const + Index iterations() const { eigen_assert(m_isInitialized && "ConjugateGradient is not initialized."); return m_iterations; @@ -199,11 +200,11 @@ public: { eigen_assert(rows()==b.rows()); - int rhsCols = b.cols(); - int size = b.rows(); + Index rhsCols = b.cols(); + Index size = b.rows(); Eigen::Matrix<DestScalar,Dynamic,1> tb(size); Eigen::Matrix<DestScalar,Dynamic,1> tx(size); - for(int k=0; k<rhsCols; ++k) + for(Index k=0; k<rhsCols; ++k) { tb = b.col(k); tx = derived().solve(tb); @@ -232,11 +233,11 @@ protected: Ref<const MatrixType> mp_matrix; Preconditioner m_preconditioner; - int m_maxIterations; + Index m_maxIterations; RealScalar m_tolerance; mutable RealScalar m_error; - mutable int m_iterations; + mutable Index m_iterations; mutable ComputationInfo m_info; mutable bool m_analysisIsOk, m_factorizationIsOk; }; diff --git a/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h b/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h index 251c6fa1a..ef7efc9cf 100644 --- a/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h +++ b/Eigen/src/IterativeLinearSolvers/SolveWithGuess.h @@ -41,7 +41,6 @@ template<typename Decomposition, typename RhsType, typename GuessType> class SolveWithGuess : public internal::generic_xpr_base<SolveWithGuess<Decomposition,RhsType,GuessType>, MatrixXpr, typename internal::traits<RhsType>::StorageKind>::type { public: - typedef typename RhsType::Index Index; typedef typename internal::traits<SolveWithGuess>::Scalar Scalar; typedef typename internal::traits<SolveWithGuess>::PlainObject PlainObject; typedef typename internal::generic_xpr_base<SolveWithGuess<Decomposition,RhsType,GuessType>, MatrixXpr, typename internal::traits<RhsType>::StorageKind>::type Base; diff --git a/Eigen/src/Jacobi/Jacobi.h b/Eigen/src/Jacobi/Jacobi.h index da9fb53d0..25eabe984 100644 --- a/Eigen/src/Jacobi/Jacobi.h +++ b/Eigen/src/Jacobi/Jacobi.h @@ -62,7 +62,7 @@ template<typename Scalar> class JacobiRotation JacobiRotation adjoint() const { using numext::conj; return JacobiRotation(conj(m_c), -m_s); } template<typename Derived> - bool makeJacobi(const MatrixBase<Derived>&, typename Derived::Index p, typename Derived::Index q); + bool makeJacobi(const MatrixBase<Derived>&, Index p, Index q); bool makeJacobi(const RealScalar& x, const Scalar& y, const RealScalar& z); void makeGivens(const Scalar& p, const Scalar& q, Scalar* z=0); @@ -123,7 +123,7 @@ bool JacobiRotation<Scalar>::makeJacobi(const RealScalar& x, const Scalar& y, co */ template<typename Scalar> template<typename Derived> -inline bool JacobiRotation<Scalar>::makeJacobi(const MatrixBase<Derived>& m, typename Derived::Index p, typename Derived::Index q) +inline bool JacobiRotation<Scalar>::makeJacobi(const MatrixBase<Derived>& m, Index p, Index q) { return makeJacobi(numext::real(m.coeff(p,p)), m.coeff(p,q), numext::real(m.coeff(q,q))); } @@ -300,7 +300,6 @@ namespace internal { template<typename VectorX, typename VectorY, typename OtherScalar> void /*EIGEN_DONT_INLINE*/ apply_rotation_in_the_plane(VectorX& _x, VectorY& _y, const JacobiRotation<OtherScalar>& j) { - typedef typename VectorX::Index Index; typedef typename VectorX::Scalar Scalar; enum { PacketSize = packet_traits<Scalar>::size }; typedef typename packet_traits<Scalar>::type Packet; diff --git a/Eigen/src/LU/FullPivLU.h b/Eigen/src/LU/FullPivLU.h index 96f2cebee..49c8b183d 100644 --- a/Eigen/src/LU/FullPivLU.h +++ b/Eigen/src/LU/FullPivLU.h @@ -66,9 +66,10 @@ template<typename _MatrixType> class FullPivLU typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar; typedef typename internal::traits<MatrixType>::StorageKind StorageKind; - typedef typename MatrixType::Index Index; - typedef typename internal::plain_row_type<MatrixType, Index>::type IntRowVectorType; - typedef typename internal::plain_col_type<MatrixType, Index>::type IntColVectorType; + // FIXME should be int + typedef typename MatrixType::StorageIndex StorageIndex; + typedef typename internal::plain_row_type<MatrixType, StorageIndex>::type IntRowVectorType; + typedef typename internal::plain_col_type<MatrixType, StorageIndex>::type IntColVectorType; typedef PermutationMatrix<ColsAtCompileTime, MaxColsAtCompileTime> PermutationQType; typedef PermutationMatrix<RowsAtCompileTime, MaxRowsAtCompileTime> PermutationPType; typedef typename MatrixType::PlainObject PlainObject; diff --git a/Eigen/src/LU/PartialPivLU.h b/Eigen/src/LU/PartialPivLU.h index d04e4191b..e57b36bc5 100644 --- a/Eigen/src/LU/PartialPivLU.h +++ b/Eigen/src/LU/PartialPivLU.h @@ -72,7 +72,8 @@ template<typename _MatrixType> class PartialPivLU typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar; typedef typename internal::traits<MatrixType>::StorageKind StorageKind; - typedef typename MatrixType::Index Index; + // FIXME should be int + typedef typename MatrixType::StorageIndex StorageIndex; typedef PermutationMatrix<RowsAtCompileTime, MaxRowsAtCompileTime> PermutationType; typedef Transpositions<RowsAtCompileTime, MaxRowsAtCompileTime> TranspositionType; typedef typename MatrixType::PlainObject PlainObject; @@ -261,7 +262,6 @@ struct partial_lu_impl typedef Block<MapLU, Dynamic, Dynamic> MatrixType; typedef Block<MatrixType,Dynamic,Dynamic> BlockType; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; /** \internal performs the LU decomposition in-place of the matrix \a lu * using an unblocked algorithm. @@ -408,13 +408,13 @@ struct partial_lu_impl /** \internal performs the LU decomposition with partial pivoting in-place. */ template<typename MatrixType, typename TranspositionType> -void partial_lu_inplace(MatrixType& lu, TranspositionType& row_transpositions, typename TranspositionType::StorageIndexType& nb_transpositions) +void partial_lu_inplace(MatrixType& lu, TranspositionType& row_transpositions, typename TranspositionType::StorageIndex& nb_transpositions) { eigen_assert(lu.cols() == row_transpositions.size()); eigen_assert((&row_transpositions.coeffRef(1)-&row_transpositions.coeffRef(0)) == 1); partial_lu_impl - <typename MatrixType::Scalar, MatrixType::Flags&RowMajorBit?RowMajor:ColMajor, typename TranspositionType::StorageIndexType> + <typename MatrixType::Scalar, MatrixType::Flags&RowMajorBit?RowMajor:ColMajor, typename TranspositionType::StorageIndex> ::blocked_lu(lu.rows(), lu.cols(), &lu.coeffRef(0,0), lu.outerStride(), &row_transpositions.coeffRef(0), nb_transpositions); } @@ -433,7 +433,7 @@ PartialPivLU<MatrixType>& PartialPivLU<MatrixType>::compute(const MatrixType& ma m_rowsTranspositions.resize(size); - typename TranspositionType::StorageIndexType nb_transpositions; + typename TranspositionType::StorageIndex nb_transpositions; internal::partial_lu_inplace(m_lu, m_rowsTranspositions, nb_transpositions); m_det_p = (nb_transpositions%2) ? -1 : 1; diff --git a/Eigen/src/OrderingMethods/Amd.h b/Eigen/src/OrderingMethods/Amd.h index ce7c0bbf3..3d2981f0c 100644 --- a/Eigen/src/OrderingMethods/Amd.h +++ b/Eigen/src/OrderingMethods/Amd.h @@ -41,10 +41,10 @@ template<typename T0, typename T1> inline bool amd_marked(const T0* w, const T1& template<typename T0, typename T1> inline void amd_mark(const T0* w, const T1& j) { return w[j] = amd_flip(w[j]); } /* clear w */ -template<typename Index> -static int cs_wclear (Index mark, Index lemax, Index *w, Index n) +template<typename StorageIndex> +static StorageIndex cs_wclear (StorageIndex mark, StorageIndex lemax, StorageIndex *w, StorageIndex n) { - Index k; + StorageIndex k; if(mark < 2 || (mark + lemax < 0)) { for(k = 0; k < n; k++) @@ -56,10 +56,10 @@ static int cs_wclear (Index mark, Index lemax, Index *w, Index n) } /* depth-first search and postorder of a tree rooted at node j */ -template<typename Index> -Index cs_tdfs(Index j, Index k, Index *head, const Index *next, Index *post, Index *stack) +template<typename StorageIndex> +StorageIndex cs_tdfs(StorageIndex j, StorageIndex k, StorageIndex *head, const StorageIndex *next, StorageIndex *post, StorageIndex *stack) { - int i, p, top = 0; + StorageIndex i, p, top = 0; if(!head || !next || !post || !stack) return (-1); /* check inputs */ stack[0] = j; /* place j on the stack */ while (top >= 0) /* while (stack is not empty) */ @@ -87,40 +87,39 @@ Index cs_tdfs(Index j, Index k, Index *head, const Index *next, Index *post, Ind * \returns the permutation P reducing the fill-in of the input matrix \a C * The input matrix \a C must be a selfadjoint compressed column major SparseMatrix object. Both the upper and lower parts have to be stored, but the diagonal entries are optional. * On exit the values of C are destroyed */ -template<typename Scalar, typename Index> -void minimum_degree_ordering(SparseMatrix<Scalar,ColMajor,Index>& C, PermutationMatrix<Dynamic,Dynamic,Index>& perm) +template<typename Scalar, typename StorageIndex> +void minimum_degree_ordering(SparseMatrix<Scalar,ColMajor,StorageIndex>& C, PermutationMatrix<Dynamic,Dynamic,StorageIndex>& perm) { using std::sqrt; - int d, dk, dext, lemax = 0, e, elenk, eln, i, j, k, k1, - k2, k3, jlast, ln, dense, nzmax, mindeg = 0, nvi, nvj, nvk, mark, wnvi, - ok, nel = 0, p, p1, p2, p3, p4, pj, pk, pk1, pk2, pn, q, t; - unsigned int h; + StorageIndex d, dk, dext, lemax = 0, e, elenk, eln, i, j, k, k1, + k2, k3, jlast, ln, dense, nzmax, mindeg = 0, nvi, nvj, nvk, mark, wnvi, + ok, nel = 0, p, p1, p2, p3, p4, pj, pk, pk1, pk2, pn, q, t, h; - Index n = C.cols(); - dense = std::max<Index> (16, Index(10 * sqrt(double(n)))); /* find dense threshold */ - dense = std::min<Index> (n-2, dense); + StorageIndex n = StorageIndex(C.cols()); + dense = std::max<StorageIndex> (16, StorageIndex(10 * sqrt(double(n)))); /* find dense threshold */ + dense = (std::min)(n-2, dense); - Index cnz = C.nonZeros(); + StorageIndex cnz = StorageIndex(C.nonZeros()); perm.resize(n+1); t = cnz + cnz/5 + 2*n; /* add elbow room to C */ C.resizeNonZeros(t); // get workspace - ei_declare_aligned_stack_constructed_variable(Index,W,8*(n+1),0); - Index* len = W; - Index* nv = W + (n+1); - Index* next = W + 2*(n+1); - Index* head = W + 3*(n+1); - Index* elen = W + 4*(n+1); - Index* degree = W + 5*(n+1); - Index* w = W + 6*(n+1); - Index* hhead = W + 7*(n+1); - Index* last = perm.indices().data(); /* use P as workspace for last */ + ei_declare_aligned_stack_constructed_variable(StorageIndex,W,8*(n+1),0); + StorageIndex* len = W; + StorageIndex* nv = W + (n+1); + StorageIndex* next = W + 2*(n+1); + StorageIndex* head = W + 3*(n+1); + StorageIndex* elen = W + 4*(n+1); + StorageIndex* degree = W + 5*(n+1); + StorageIndex* w = W + 6*(n+1); + StorageIndex* hhead = W + 7*(n+1); + StorageIndex* last = perm.indices().data(); /* use P as workspace for last */ /* --- Initialize quotient graph ---------------------------------------- */ - Index* Cp = C.outerIndexPtr(); - Index* Ci = C.innerIndexPtr(); + StorageIndex* Cp = C.outerIndexPtr(); + StorageIndex* Ci = C.innerIndexPtr(); for(k = 0; k < n; k++) len[k] = Cp[k+1] - Cp[k]; len[n] = 0; @@ -137,7 +136,7 @@ void minimum_degree_ordering(SparseMatrix<Scalar,ColMajor,Index>& C, Permutation elen[i] = 0; // Ek of node i is empty degree[i] = len[i]; // degree of node i } - mark = internal::cs_wclear<Index>(0, 0, w, n); /* clear w */ + mark = internal::cs_wclear<StorageIndex>(0, 0, w, n); /* clear w */ elen[n] = -2; /* n is a dead element */ Cp[n] = -1; /* n is a root of assembly tree */ w[n] = 0; /* n is a dead element */ @@ -252,7 +251,7 @@ void minimum_degree_ordering(SparseMatrix<Scalar,ColMajor,Index>& C, Permutation elen[k] = -2; /* k is now an element */ /* --- Find set differences ----------------------------------------- */ - mark = internal::cs_wclear<Index>(mark, lemax, w, n); /* clear w if necessary */ + mark = internal::cs_wclear<StorageIndex>(mark, lemax, w, n); /* clear w if necessary */ for(pk = pk1; pk < pk2; pk++) /* scan 1: find |Le\Lk| */ { i = Ci[pk]; @@ -322,7 +321,7 @@ void minimum_degree_ordering(SparseMatrix<Scalar,ColMajor,Index>& C, Permutation } else { - degree[i] = std::min<Index> (degree[i], d); /* update degree(i) */ + degree[i] = std::min<StorageIndex> (degree[i], d); /* update degree(i) */ Ci[pn] = Ci[p3]; /* move first node to end */ Ci[p3] = Ci[p1]; /* move 1st el. to end of Ei */ Ci[p1] = k; /* add k as 1st element in of Ei */ @@ -330,12 +329,12 @@ void minimum_degree_ordering(SparseMatrix<Scalar,ColMajor,Index>& C, Permutation h %= n; /* finalize hash of i */ next[i] = hhead[h]; /* place i in hash bucket */ hhead[h] = i; - last[i] = h; /* save hash of i in last[i] */ + last[i] = h; /* save hash of i in last[i] */ } } /* scan2 is done */ degree[k] = dk; /* finalize |Lk| */ - lemax = std::max<Index>(lemax, dk); - mark = internal::cs_wclear<Index>(mark+lemax, lemax, w, n); /* clear w */ + lemax = std::max<StorageIndex>(lemax, dk); + mark = internal::cs_wclear<StorageIndex>(mark+lemax, lemax, w, n); /* clear w */ /* --- Supernode detection ------------------------------------------ */ for(pk = pk1; pk < pk2; pk++) @@ -383,12 +382,12 @@ void minimum_degree_ordering(SparseMatrix<Scalar,ColMajor,Index>& C, Permutation if((nvi = -nv[i]) <= 0) continue;/* skip if i is dead */ nv[i] = nvi; /* restore nv[i] */ d = degree[i] + dk - nvi; /* compute external degree(i) */ - d = std::min<Index> (d, n - nel - nvi); + d = std::min<StorageIndex> (d, n - nel - nvi); if(head[d] != -1) last[head[d]] = i; next[i] = head[d]; /* put i back in degree list */ last[i] = -1; head[d] = i; - mindeg = std::min<Index> (mindeg, d); /* find new minimum degree */ + mindeg = std::min<StorageIndex> (mindeg, d); /* find new minimum degree */ degree[i] = d; Ci[p++] = i; /* place i in Lk */ } @@ -421,7 +420,7 @@ void minimum_degree_ordering(SparseMatrix<Scalar,ColMajor,Index>& C, Permutation } for(k = 0, i = 0; i <= n; i++) /* postorder the assembly tree */ { - if(Cp[i] == -1) k = internal::cs_tdfs<Index>(i, k, head, next, perm.indices().data(), w); + if(Cp[i] == -1) k = internal::cs_tdfs<StorageIndex>(i, k, head, next, perm.indices().data(), w); } perm.indices().conservativeResize(n); diff --git a/Eigen/src/OrderingMethods/Eigen_Colamd.h b/Eigen/src/OrderingMethods/Eigen_Colamd.h index 44548f660..6238676e5 100644 --- a/Eigen/src/OrderingMethods/Eigen_Colamd.h +++ b/Eigen/src/OrderingMethods/Eigen_Colamd.h @@ -135,54 +135,54 @@ namespace internal { /* ========================================================================== */ // == Row and Column structures == -template <typename Index> +template <typename IndexType> struct colamd_col { - Index start ; /* index for A of first row in this column, or DEAD */ + IndexType start ; /* index for A of first row in this column, or DEAD */ /* if column is dead */ - Index length ; /* number of rows in this column */ + IndexType length ; /* number of rows in this column */ union { - Index thickness ; /* number of original columns represented by this */ + IndexType thickness ; /* number of original columns represented by this */ /* col, if the column is alive */ - Index parent ; /* parent in parent tree super-column structure, if */ + IndexType parent ; /* parent in parent tree super-column structure, if */ /* the column is dead */ } shared1 ; union { - Index score ; /* the score used to maintain heap, if col is alive */ - Index order ; /* pivot ordering of this column, if col is dead */ + IndexType score ; /* the score used to maintain heap, if col is alive */ + IndexType order ; /* pivot ordering of this column, if col is dead */ } shared2 ; union { - Index headhash ; /* head of a hash bucket, if col is at the head of */ + IndexType headhash ; /* head of a hash bucket, if col is at the head of */ /* a degree list */ - Index hash ; /* hash value, if col is not in a degree list */ - Index prev ; /* previous column in degree list, if col is in a */ + IndexType hash ; /* hash value, if col is not in a degree list */ + IndexType prev ; /* previous column in degree list, if col is in a */ /* degree list (but not at the head of a degree list) */ } shared3 ; union { - Index degree_next ; /* next column, if col is in a degree list */ - Index hash_next ; /* next column, if col is in a hash list */ + IndexType degree_next ; /* next column, if col is in a degree list */ + IndexType hash_next ; /* next column, if col is in a hash list */ } shared4 ; }; -template <typename Index> +template <typename IndexType> struct Colamd_Row { - Index start ; /* index for A of first col in this row */ - Index length ; /* number of principal columns in this row */ + IndexType start ; /* index for A of first col in this row */ + IndexType length ; /* number of principal columns in this row */ union { - Index degree ; /* number of principal & non-principal columns in row */ - Index p ; /* used as a row pointer in init_rows_cols () */ + IndexType degree ; /* number of principal & non-principal columns in row */ + IndexType p ; /* used as a row pointer in init_rows_cols () */ } shared1 ; union { - Index mark ; /* for computing set differences and marking dead rows*/ - Index first_column ;/* first column in row (used in garbage collection) */ + IndexType mark ; /* for computing set differences and marking dead rows*/ + IndexType first_column ;/* first column in row (used in garbage collection) */ } shared2 ; }; @@ -202,38 +202,38 @@ struct Colamd_Row This macro is not needed when using symamd. - Explicit typecast to Index added Sept. 23, 2002, COLAMD version 2.2, to avoid + Explicit typecast to IndexType added Sept. 23, 2002, COLAMD version 2.2, to avoid gcc -pedantic warning messages. */ -template <typename Index> -inline Index colamd_c(Index n_col) -{ return Index( ((n_col) + 1) * sizeof (colamd_col<Index>) / sizeof (Index) ) ; } +template <typename IndexType> +inline IndexType colamd_c(IndexType n_col) +{ return IndexType( ((n_col) + 1) * sizeof (colamd_col<IndexType>) / sizeof (IndexType) ) ; } -template <typename Index> -inline Index colamd_r(Index n_row) -{ return Index(((n_row) + 1) * sizeof (Colamd_Row<Index>) / sizeof (Index)); } +template <typename IndexType> +inline IndexType colamd_r(IndexType n_row) +{ return IndexType(((n_row) + 1) * sizeof (Colamd_Row<IndexType>) / sizeof (IndexType)); } // Prototypes of non-user callable routines -template <typename Index> -static Index init_rows_cols (Index n_row, Index n_col, Colamd_Row<Index> Row [], colamd_col<Index> col [], Index A [], Index p [], Index stats[COLAMD_STATS] ); +template <typename IndexType> +static IndexType init_rows_cols (IndexType n_row, IndexType n_col, Colamd_Row<IndexType> Row [], colamd_col<IndexType> col [], IndexType A [], IndexType p [], IndexType stats[COLAMD_STATS] ); -template <typename Index> -static void init_scoring (Index n_row, Index n_col, Colamd_Row<Index> Row [], colamd_col<Index> Col [], Index A [], Index head [], double knobs[COLAMD_KNOBS], Index *p_n_row2, Index *p_n_col2, Index *p_max_deg); +template <typename IndexType> +static void init_scoring (IndexType n_row, IndexType n_col, Colamd_Row<IndexType> Row [], colamd_col<IndexType> Col [], IndexType A [], IndexType head [], double knobs[COLAMD_KNOBS], IndexType *p_n_row2, IndexType *p_n_col2, IndexType *p_max_deg); -template <typename Index> -static Index find_ordering (Index n_row, Index n_col, Index Alen, Colamd_Row<Index> Row [], colamd_col<Index> Col [], Index A [], Index head [], Index n_col2, Index max_deg, Index pfree); +template <typename IndexType> +static IndexType find_ordering (IndexType n_row, IndexType n_col, IndexType Alen, Colamd_Row<IndexType> Row [], colamd_col<IndexType> Col [], IndexType A [], IndexType head [], IndexType n_col2, IndexType max_deg, IndexType pfree); -template <typename Index> -static void order_children (Index n_col, colamd_col<Index> Col [], Index p []); +template <typename IndexType> +static void order_children (IndexType n_col, colamd_col<IndexType> Col [], IndexType p []); -template <typename Index> -static void detect_super_cols (colamd_col<Index> Col [], Index A [], Index head [], Index row_start, Index row_length ) ; +template <typename IndexType> +static void detect_super_cols (colamd_col<IndexType> Col [], IndexType A [], IndexType head [], IndexType row_start, IndexType row_length ) ; -template <typename Index> -static Index garbage_collection (Index n_row, Index n_col, Colamd_Row<Index> Row [], colamd_col<Index> Col [], Index A [], Index *pfree) ; +template <typename IndexType> +static IndexType garbage_collection (IndexType n_row, IndexType n_col, Colamd_Row<IndexType> Row [], colamd_col<IndexType> Col [], IndexType A [], IndexType *pfree) ; -template <typename Index> -static inline Index clear_mark (Index n_row, Colamd_Row<Index> Row [] ) ; +template <typename IndexType> +static inline IndexType clear_mark (IndexType n_row, Colamd_Row<IndexType> Row [] ) ; /* === No debugging ========================================================= */ @@ -260,8 +260,8 @@ static inline Index clear_mark (Index n_row, Colamd_Row<Index> Row [] ) ; * \param n_col number of columns in A * \return recommended value of Alen for use by colamd */ -template <typename Index> -inline Index colamd_recommended ( Index nnz, Index n_row, Index n_col) +template <typename IndexType> +inline IndexType colamd_recommended ( IndexType nnz, IndexType n_row, IndexType n_col) { if ((nnz) < 0 || (n_row) < 0 || (n_col) < 0) return (-1); @@ -325,22 +325,22 @@ static inline void colamd_set_defaults(double knobs[COLAMD_KNOBS]) * \param knobs parameter settings for colamd * \param stats colamd output statistics and error codes */ -template <typename Index> -static bool colamd(Index n_row, Index n_col, Index Alen, Index *A, Index *p, double knobs[COLAMD_KNOBS], Index stats[COLAMD_STATS]) +template <typename IndexType> +static bool colamd(IndexType n_row, IndexType n_col, IndexType Alen, IndexType *A, IndexType *p, double knobs[COLAMD_KNOBS], IndexType stats[COLAMD_STATS]) { /* === Local variables ================================================== */ - Index i ; /* loop index */ - Index nnz ; /* nonzeros in A */ - Index Row_size ; /* size of Row [], in integers */ - Index Col_size ; /* size of Col [], in integers */ - Index need ; /* minimum required length of A */ - Colamd_Row<Index> *Row ; /* pointer into A of Row [0..n_row] array */ - colamd_col<Index> *Col ; /* pointer into A of Col [0..n_col] array */ - Index n_col2 ; /* number of non-dense, non-empty columns */ - Index n_row2 ; /* number of non-dense, non-empty rows */ - Index ngarbage ; /* number of garbage collections performed */ - Index max_deg ; /* maximum row degree */ + IndexType i ; /* loop index */ + IndexType nnz ; /* nonzeros in A */ + IndexType Row_size ; /* size of Row [], in integers */ + IndexType Col_size ; /* size of Col [], in integers */ + IndexType need ; /* minimum required length of A */ + Colamd_Row<IndexType> *Row ; /* pointer into A of Row [0..n_row] array */ + colamd_col<IndexType> *Col ; /* pointer into A of Col [0..n_col] array */ + IndexType n_col2 ; /* number of non-dense, non-empty columns */ + IndexType n_row2 ; /* number of non-dense, non-empty rows */ + IndexType ngarbage ; /* number of garbage collections performed */ + IndexType max_deg ; /* maximum row degree */ double default_knobs [COLAMD_KNOBS] ; /* default knobs array */ @@ -431,8 +431,8 @@ static bool colamd(Index n_row, Index n_col, Index Alen, Index *A, Index *p, dou } Alen -= Col_size + Row_size ; - Col = (colamd_col<Index> *) &A [Alen] ; - Row = (Colamd_Row<Index> *) &A [Alen + Col_size] ; + Col = (colamd_col<IndexType> *) &A [Alen] ; + Row = (Colamd_Row<IndexType> *) &A [Alen + Col_size] ; /* === Construct the row and column data structures ===================== */ @@ -485,29 +485,29 @@ static bool colamd(Index n_row, Index n_col, Index Alen, Index *A, Index *p, dou column form of the matrix. Returns false if the matrix is invalid, true otherwise. Not user-callable. */ -template <typename Index> -static Index init_rows_cols /* returns true if OK, or false otherwise */ +template <typename IndexType> +static IndexType init_rows_cols /* returns true if OK, or false otherwise */ ( /* === Parameters ======================================================= */ - Index n_row, /* number of rows of A */ - Index n_col, /* number of columns of A */ - Colamd_Row<Index> Row [], /* of size n_row+1 */ - colamd_col<Index> Col [], /* of size n_col+1 */ - Index A [], /* row indices of A, of size Alen */ - Index p [], /* pointers to columns in A, of size n_col+1 */ - Index stats [COLAMD_STATS] /* colamd statistics */ + IndexType n_row, /* number of rows of A */ + IndexType n_col, /* number of columns of A */ + Colamd_Row<IndexType> Row [], /* of size n_row+1 */ + colamd_col<IndexType> Col [], /* of size n_col+1 */ + IndexType A [], /* row indices of A, of size Alen */ + IndexType p [], /* pointers to columns in A, of size n_col+1 */ + IndexType stats [COLAMD_STATS] /* colamd statistics */ ) { /* === Local variables ================================================== */ - Index col ; /* a column index */ - Index row ; /* a row index */ - Index *cp ; /* a column pointer */ - Index *cp_end ; /* a pointer to the end of a column */ - Index *rp ; /* a row pointer */ - Index *rp_end ; /* a pointer to the end of a row */ - Index last_row ; /* previous row */ + IndexType col ; /* a column index */ + IndexType row ; /* a row index */ + IndexType *cp ; /* a column pointer */ + IndexType *cp_end ; /* a pointer to the end of a column */ + IndexType *rp ; /* a row pointer */ + IndexType *rp_end ; /* a pointer to the end of a row */ + IndexType last_row ; /* previous row */ /* === Initialize columns, and check column pointers ==================== */ @@ -701,40 +701,40 @@ static Index init_rows_cols /* returns true if OK, or false otherwise */ Kills dense or empty columns and rows, calculates an initial score for each column, and places all columns in the degree lists. Not user-callable. */ -template <typename Index> +template <typename IndexType> static void init_scoring ( /* === Parameters ======================================================= */ - Index n_row, /* number of rows of A */ - Index n_col, /* number of columns of A */ - Colamd_Row<Index> Row [], /* of size n_row+1 */ - colamd_col<Index> Col [], /* of size n_col+1 */ - Index A [], /* column form and row form of A */ - Index head [], /* of size n_col+1 */ + IndexType n_row, /* number of rows of A */ + IndexType n_col, /* number of columns of A */ + Colamd_Row<IndexType> Row [], /* of size n_row+1 */ + colamd_col<IndexType> Col [], /* of size n_col+1 */ + IndexType A [], /* column form and row form of A */ + IndexType head [], /* of size n_col+1 */ double knobs [COLAMD_KNOBS],/* parameters */ - Index *p_n_row2, /* number of non-dense, non-empty rows */ - Index *p_n_col2, /* number of non-dense, non-empty columns */ - Index *p_max_deg /* maximum row degree */ + IndexType *p_n_row2, /* number of non-dense, non-empty rows */ + IndexType *p_n_col2, /* number of non-dense, non-empty columns */ + IndexType *p_max_deg /* maximum row degree */ ) { /* === Local variables ================================================== */ - Index c ; /* a column index */ - Index r, row ; /* a row index */ - Index *cp ; /* a column pointer */ - Index deg ; /* degree of a row or column */ - Index *cp_end ; /* a pointer to the end of a column */ - Index *new_cp ; /* new column pointer */ - Index col_length ; /* length of pruned column */ - Index score ; /* current column score */ - Index n_col2 ; /* number of non-dense, non-empty columns */ - Index n_row2 ; /* number of non-dense, non-empty rows */ - Index dense_row_count ; /* remove rows with more entries than this */ - Index dense_col_count ; /* remove cols with more entries than this */ - Index min_score ; /* smallest column score */ - Index max_deg ; /* maximum row degree */ - Index next_col ; /* Used to add to degree list.*/ + IndexType c ; /* a column index */ + IndexType r, row ; /* a row index */ + IndexType *cp ; /* a column pointer */ + IndexType deg ; /* degree of a row or column */ + IndexType *cp_end ; /* a pointer to the end of a column */ + IndexType *new_cp ; /* new column pointer */ + IndexType col_length ; /* length of pruned column */ + IndexType score ; /* current column score */ + IndexType n_col2 ; /* number of non-dense, non-empty columns */ + IndexType n_row2 ; /* number of non-dense, non-empty rows */ + IndexType dense_row_count ; /* remove rows with more entries than this */ + IndexType dense_col_count ; /* remove cols with more entries than this */ + IndexType min_score ; /* smallest column score */ + IndexType max_deg ; /* maximum row degree */ + IndexType next_col ; /* Used to add to degree list.*/ /* === Extract knobs ==================================================== */ @@ -845,7 +845,7 @@ static void init_scoring score = COLAMD_MIN (score, n_col) ; } /* determine pruned column length */ - col_length = (Index) (new_cp - &A [Col [c].start]) ; + col_length = (IndexType) (new_cp - &A [Col [c].start]) ; if (col_length == 0) { /* a newly-made null column (all rows in this col are "dense" */ @@ -938,56 +938,56 @@ static void init_scoring (no supercolumns on input). Uses a minimum approximate column minimum degree ordering method. Not user-callable. */ -template <typename Index> -static Index find_ordering /* return the number of garbage collections */ +template <typename IndexType> +static IndexType find_ordering /* return the number of garbage collections */ ( /* === Parameters ======================================================= */ - Index n_row, /* number of rows of A */ - Index n_col, /* number of columns of A */ - Index Alen, /* size of A, 2*nnz + n_col or larger */ - Colamd_Row<Index> Row [], /* of size n_row+1 */ - colamd_col<Index> Col [], /* of size n_col+1 */ - Index A [], /* column form and row form of A */ - Index head [], /* of size n_col+1 */ - Index n_col2, /* Remaining columns to order */ - Index max_deg, /* Maximum row degree */ - Index pfree /* index of first free slot (2*nnz on entry) */ + IndexType n_row, /* number of rows of A */ + IndexType n_col, /* number of columns of A */ + IndexType Alen, /* size of A, 2*nnz + n_col or larger */ + Colamd_Row<IndexType> Row [], /* of size n_row+1 */ + colamd_col<IndexType> Col [], /* of size n_col+1 */ + IndexType A [], /* column form and row form of A */ + IndexType head [], /* of size n_col+1 */ + IndexType n_col2, /* Remaining columns to order */ + IndexType max_deg, /* Maximum row degree */ + IndexType pfree /* index of first free slot (2*nnz on entry) */ ) { /* === Local variables ================================================== */ - Index k ; /* current pivot ordering step */ - Index pivot_col ; /* current pivot column */ - Index *cp ; /* a column pointer */ - Index *rp ; /* a row pointer */ - Index pivot_row ; /* current pivot row */ - Index *new_cp ; /* modified column pointer */ - Index *new_rp ; /* modified row pointer */ - Index pivot_row_start ; /* pointer to start of pivot row */ - Index pivot_row_degree ; /* number of columns in pivot row */ - Index pivot_row_length ; /* number of supercolumns in pivot row */ - Index pivot_col_score ; /* score of pivot column */ - Index needed_memory ; /* free space needed for pivot row */ - Index *cp_end ; /* pointer to the end of a column */ - Index *rp_end ; /* pointer to the end of a row */ - Index row ; /* a row index */ - Index col ; /* a column index */ - Index max_score ; /* maximum possible score */ - Index cur_score ; /* score of current column */ + IndexType k ; /* current pivot ordering step */ + IndexType pivot_col ; /* current pivot column */ + IndexType *cp ; /* a column pointer */ + IndexType *rp ; /* a row pointer */ + IndexType pivot_row ; /* current pivot row */ + IndexType *new_cp ; /* modified column pointer */ + IndexType *new_rp ; /* modified row pointer */ + IndexType pivot_row_start ; /* pointer to start of pivot row */ + IndexType pivot_row_degree ; /* number of columns in pivot row */ + IndexType pivot_row_length ; /* number of supercolumns in pivot row */ + IndexType pivot_col_score ; /* score of pivot column */ + IndexType needed_memory ; /* free space needed for pivot row */ + IndexType *cp_end ; /* pointer to the end of a column */ + IndexType *rp_end ; /* pointer to the end of a row */ + IndexType row ; /* a row index */ + IndexType col ; /* a column index */ + IndexType max_score ; /* maximum possible score */ + IndexType cur_score ; /* score of current column */ unsigned int hash ; /* hash value for supernode detection */ - Index head_column ; /* head of hash bucket */ - Index first_col ; /* first column in hash bucket */ - Index tag_mark ; /* marker value for mark array */ - Index row_mark ; /* Row [row].shared2.mark */ - Index set_difference ; /* set difference size of row with pivot row */ - Index min_score ; /* smallest column score */ - Index col_thickness ; /* "thickness" (no. of columns in a supercol) */ - Index max_mark ; /* maximum value of tag_mark */ - Index pivot_col_thickness ; /* number of columns represented by pivot col */ - Index prev_col ; /* Used by Dlist operations. */ - Index next_col ; /* Used by Dlist operations. */ - Index ngarbage ; /* number of garbage collections performed */ + IndexType head_column ; /* head of hash bucket */ + IndexType first_col ; /* first column in hash bucket */ + IndexType tag_mark ; /* marker value for mark array */ + IndexType row_mark ; /* Row [row].shared2.mark */ + IndexType set_difference ; /* set difference size of row with pivot row */ + IndexType min_score ; /* smallest column score */ + IndexType col_thickness ; /* "thickness" (no. of columns in a supercol) */ + IndexType max_mark ; /* maximum value of tag_mark */ + IndexType pivot_col_thickness ; /* number of columns represented by pivot col */ + IndexType prev_col ; /* Used by Dlist operations. */ + IndexType next_col ; /* Used by Dlist operations. */ + IndexType ngarbage ; /* number of garbage collections performed */ /* === Initialization and clear mark ==================================== */ @@ -1277,7 +1277,7 @@ static Index find_ordering /* return the number of garbage collections */ } /* recompute the column's length */ - Col [col].length = (Index) (new_cp - &A [Col [col].start]) ; + Col [col].length = (IndexType) (new_cp - &A [Col [col].start]) ; /* === Further mass elimination ================================= */ @@ -1325,7 +1325,7 @@ static Index find_ordering /* return the number of garbage collections */ Col [col].shared4.hash_next = first_col ; /* save hash function in Col [col].shared3.hash */ - Col [col].shared3.hash = (Index) hash ; + Col [col].shared3.hash = (IndexType) hash ; COLAMD_ASSERT (COL_IS_ALIVE (col)) ; } } @@ -1420,7 +1420,7 @@ static Index find_ordering /* return the number of garbage collections */ /* update pivot row length to reflect any cols that were killed */ /* during super-col detection and mass elimination */ Row [pivot_row].start = pivot_row_start ; - Row [pivot_row].length = (Index) (new_rp - &A[pivot_row_start]) ; + Row [pivot_row].length = (IndexType) (new_rp - &A[pivot_row_start]) ; Row [pivot_row].shared1.degree = pivot_row_degree ; Row [pivot_row].shared2.mark = 0 ; /* pivot row is no longer dead */ @@ -1449,22 +1449,22 @@ static Index find_ordering /* return the number of garbage collections */ taken by this routine is O (n_col), that is, linear in the number of columns. Not user-callable. */ -template <typename Index> +template <typename IndexType> static inline void order_children ( /* === Parameters ======================================================= */ - Index n_col, /* number of columns of A */ - colamd_col<Index> Col [], /* of size n_col+1 */ - Index p [] /* p [0 ... n_col-1] is the column permutation*/ + IndexType n_col, /* number of columns of A */ + colamd_col<IndexType> Col [], /* of size n_col+1 */ + IndexType p [] /* p [0 ... n_col-1] is the column permutation*/ ) { /* === Local variables ================================================== */ - Index i ; /* loop counter for all columns */ - Index c ; /* column index */ - Index parent ; /* index of column's parent */ - Index order ; /* column's order */ + IndexType i ; /* loop counter for all columns */ + IndexType c ; /* column index */ + IndexType parent ; /* index of column's parent */ + IndexType order ; /* column's order */ /* === Order each non-principal column ================================== */ @@ -1550,33 +1550,33 @@ static inline void order_children just been computed in the approximate degree computation. Not user-callable. */ -template <typename Index> +template <typename IndexType> static void detect_super_cols ( /* === Parameters ======================================================= */ - colamd_col<Index> Col [], /* of size n_col+1 */ - Index A [], /* row indices of A */ - Index head [], /* head of degree lists and hash buckets */ - Index row_start, /* pointer to set of columns to check */ - Index row_length /* number of columns to check */ + colamd_col<IndexType> Col [], /* of size n_col+1 */ + IndexType A [], /* row indices of A */ + IndexType head [], /* head of degree lists and hash buckets */ + IndexType row_start, /* pointer to set of columns to check */ + IndexType row_length /* number of columns to check */ ) { /* === Local variables ================================================== */ - Index hash ; /* hash value for a column */ - Index *rp ; /* pointer to a row */ - Index c ; /* a column index */ - Index super_c ; /* column index of the column to absorb into */ - Index *cp1 ; /* column pointer for column super_c */ - Index *cp2 ; /* column pointer for column c */ - Index length ; /* length of column super_c */ - Index prev_c ; /* column preceding c in hash bucket */ - Index i ; /* loop counter */ - Index *rp_end ; /* pointer to the end of the row */ - Index col ; /* a column index in the row to check */ - Index head_column ; /* first column in hash bucket or degree list */ - Index first_col ; /* first column in hash bucket */ + IndexType hash ; /* hash value for a column */ + IndexType *rp ; /* pointer to a row */ + IndexType c ; /* a column index */ + IndexType super_c ; /* column index of the column to absorb into */ + IndexType *cp1 ; /* column pointer for column super_c */ + IndexType *cp2 ; /* column pointer for column c */ + IndexType length ; /* length of column super_c */ + IndexType prev_c ; /* column preceding c in hash bucket */ + IndexType i ; /* loop counter */ + IndexType *rp_end ; /* pointer to the end of the row */ + IndexType col ; /* a column index in the row to check */ + IndexType head_column ; /* first column in hash bucket or degree list */ + IndexType first_col ; /* first column in hash bucket */ /* === Consider each column in the row ================================== */ @@ -1701,27 +1701,27 @@ static void detect_super_cols itself linear in the number of nonzeros in the input matrix. Not user-callable. */ -template <typename Index> -static Index garbage_collection /* returns the new value of pfree */ +template <typename IndexType> +static IndexType garbage_collection /* returns the new value of pfree */ ( /* === Parameters ======================================================= */ - Index n_row, /* number of rows */ - Index n_col, /* number of columns */ - Colamd_Row<Index> Row [], /* row info */ - colamd_col<Index> Col [], /* column info */ - Index A [], /* A [0 ... Alen-1] holds the matrix */ - Index *pfree /* &A [0] ... pfree is in use */ + IndexType n_row, /* number of rows */ + IndexType n_col, /* number of columns */ + Colamd_Row<IndexType> Row [], /* row info */ + colamd_col<IndexType> Col [], /* column info */ + IndexType A [], /* A [0 ... Alen-1] holds the matrix */ + IndexType *pfree /* &A [0] ... pfree is in use */ ) { /* === Local variables ================================================== */ - Index *psrc ; /* source pointer */ - Index *pdest ; /* destination pointer */ - Index j ; /* counter */ - Index r ; /* a row index */ - Index c ; /* a column index */ - Index length ; /* length of a row or column */ + IndexType *psrc ; /* source pointer */ + IndexType *pdest ; /* destination pointer */ + IndexType j ; /* counter */ + IndexType r ; /* a row index */ + IndexType c ; /* a column index */ + IndexType length ; /* length of a row or column */ /* === Defragment the columns =========================================== */ @@ -1734,7 +1734,7 @@ static Index garbage_collection /* returns the new value of pfree */ /* move and compact the column */ COLAMD_ASSERT (pdest <= psrc) ; - Col [c].start = (Index) (pdest - &A [0]) ; + Col [c].start = (IndexType) (pdest - &A [0]) ; length = Col [c].length ; for (j = 0 ; j < length ; j++) { @@ -1744,7 +1744,7 @@ static Index garbage_collection /* returns the new value of pfree */ *pdest++ = r ; } } - Col [c].length = (Index) (pdest - &A [Col [c].start]) ; + Col [c].length = (IndexType) (pdest - &A [Col [c].start]) ; } } @@ -1791,7 +1791,7 @@ static Index garbage_collection /* returns the new value of pfree */ /* move and compact the row */ COLAMD_ASSERT (pdest <= psrc) ; - Row [r].start = (Index) (pdest - &A [0]) ; + Row [r].start = (IndexType) (pdest - &A [0]) ; length = Row [r].length ; for (j = 0 ; j < length ; j++) { @@ -1801,7 +1801,7 @@ static Index garbage_collection /* returns the new value of pfree */ *pdest++ = c ; } } - Row [r].length = (Index) (pdest - &A [Row [r].start]) ; + Row [r].length = (IndexType) (pdest - &A [Row [r].start]) ; } } @@ -1810,7 +1810,7 @@ static Index garbage_collection /* returns the new value of pfree */ /* === Return the new value of pfree ==================================== */ - return ((Index) (pdest - &A [0])) ; + return ((IndexType) (pdest - &A [0])) ; } @@ -1822,18 +1822,18 @@ static Index garbage_collection /* returns the new value of pfree */ Clears the Row [].shared2.mark array, and returns the new tag_mark. Return value is the new tag_mark. Not user-callable. */ -template <typename Index> -static inline Index clear_mark /* return the new value for tag_mark */ +template <typename IndexType> +static inline IndexType clear_mark /* return the new value for tag_mark */ ( /* === Parameters ======================================================= */ - Index n_row, /* number of rows in A */ - Colamd_Row<Index> Row [] /* Row [0 ... n_row-1].shared2.mark is set to zero */ + IndexType n_row, /* number of rows in A */ + Colamd_Row<IndexType> Row [] /* Row [0 ... n_row-1].shared2.mark is set to zero */ ) { /* === Local variables ================================================== */ - Index r ; + IndexType r ; for (r = 0 ; r < n_row ; r++) { diff --git a/Eigen/src/OrderingMethods/Ordering.h b/Eigen/src/OrderingMethods/Ordering.h index f3c31f9cb..e88e637a4 100644 --- a/Eigen/src/OrderingMethods/Ordering.h +++ b/Eigen/src/OrderingMethods/Ordering.h @@ -111,12 +111,12 @@ class NaturalOrdering * Functor computing the \em column \em approximate \em minimum \em degree ordering * The matrix should be in column-major and \b compressed format (see SparseMatrix::makeCompressed()). */ -template<typename Index> +template<typename StorageIndex> class COLAMDOrdering { public: - typedef PermutationMatrix<Dynamic, Dynamic, Index> PermutationType; - typedef Matrix<Index, Dynamic, 1> IndexVector; + typedef PermutationMatrix<Dynamic, Dynamic, StorageIndex> PermutationType; + typedef Matrix<StorageIndex, Dynamic, 1> IndexVector; /** Compute the permutation vector \a perm form the sparse matrix \a mat * \warning The input sparse matrix \a mat must be in compressed mode (see SparseMatrix::makeCompressed()). @@ -126,26 +126,26 @@ class COLAMDOrdering { eigen_assert(mat.isCompressed() && "COLAMDOrdering requires a sparse matrix in compressed mode. Call .makeCompressed() before passing it to COLAMDOrdering"); - Index m = mat.rows(); - Index n = mat.cols(); - Index nnz = mat.nonZeros(); + StorageIndex m = StorageIndex(mat.rows()); + StorageIndex n = StorageIndex(mat.cols()); + StorageIndex nnz = StorageIndex(mat.nonZeros()); // Get the recommended value of Alen to be used by colamd - Index Alen = internal::colamd_recommended(nnz, m, n); + StorageIndex Alen = internal::colamd_recommended(nnz, m, n); // Set the default parameters double knobs [COLAMD_KNOBS]; - Index stats [COLAMD_STATS]; + StorageIndex stats [COLAMD_STATS]; internal::colamd_set_defaults(knobs); IndexVector p(n+1), A(Alen); - for(Index i=0; i <= n; i++) p(i) = mat.outerIndexPtr()[i]; - for(Index i=0; i < nnz; i++) A(i) = mat.innerIndexPtr()[i]; + for(StorageIndex i=0; i <= n; i++) p(i) = mat.outerIndexPtr()[i]; + for(StorageIndex i=0; i < nnz; i++) A(i) = mat.innerIndexPtr()[i]; // Call Colamd routine to compute the ordering - Index info = internal::colamd(m, n, Alen, A.data(), p.data(), knobs, stats); + StorageIndex info = internal::colamd(m, n, Alen, A.data(), p.data(), knobs, stats); EIGEN_UNUSED_VARIABLE(info); eigen_assert( info && "COLAMD failed " ); perm.resize(n); - for (Index i = 0; i < n; i++) perm.indices()(p(i)) = i; + for (StorageIndex i = 0; i < n; i++) perm.indices()(p(i)) = i; } }; diff --git a/Eigen/src/PaStiXSupport/PaStiXSupport.h b/Eigen/src/PaStiXSupport/PaStiXSupport.h index a96c27695..4e73edf5b 100644 --- a/Eigen/src/PaStiXSupport/PaStiXSupport.h +++ b/Eigen/src/PaStiXSupport/PaStiXSupport.h @@ -43,7 +43,7 @@ namespace internal typedef _MatrixType MatrixType; typedef typename _MatrixType::Scalar Scalar; typedef typename _MatrixType::RealScalar RealScalar; - typedef typename _MatrixType::Index Index; + typedef typename _MatrixType::StorageIndex StorageIndex; }; template<typename _MatrixType, int Options> @@ -52,7 +52,7 @@ namespace internal typedef _MatrixType MatrixType; typedef typename _MatrixType::Scalar Scalar; typedef typename _MatrixType::RealScalar RealScalar; - typedef typename _MatrixType::Index Index; + typedef typename _MatrixType::StorageIndex StorageIndex; }; template<typename _MatrixType, int Options> @@ -61,7 +61,7 @@ namespace internal typedef _MatrixType MatrixType; typedef typename _MatrixType::Scalar Scalar; typedef typename _MatrixType::RealScalar RealScalar; - typedef typename _MatrixType::Index Index; + typedef typename _MatrixType::StorageIndex StorageIndex; }; void eigen_pastix(pastix_data_t **pastix_data, int pastix_comm, int n, int *ptr, int *idx, float *vals, int *perm, int * invp, float *x, int nbrhs, int *iparm, double *dparm) @@ -138,7 +138,7 @@ class PastixBase : public SparseSolverBase<Derived> typedef _MatrixType MatrixType; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; + typedef typename MatrixType::StorageIndex StorageIndex; typedef Matrix<Scalar,Dynamic,1> Vector; typedef SparseMatrix<Scalar, ColMajor> ColSpMatrix; @@ -162,7 +162,7 @@ class PastixBase : public SparseSolverBase<Derived> * The statistics related to the different phases of factorization and solve are saved here as well * \sa analyzePattern() factorize() */ - Array<Index,IPARM_SIZE,1>& iparm() + Array<StorageIndex,IPARM_SIZE,1>& iparm() { return m_iparm; } @@ -242,8 +242,8 @@ class PastixBase : public SparseSolverBase<Derived> mutable int m_comm; // The MPI communicator identifier mutable Matrix<int,IPARM_SIZE,1> m_iparm; // integer vector for the input parameters mutable Matrix<double,DPARM_SIZE,1> m_dparm; // Scalar vector for the input parameters - mutable Matrix<Index,Dynamic,1> m_perm; // Permutation vector - mutable Matrix<Index,Dynamic,1> m_invp; // Inverse permutation vector + mutable Matrix<StorageIndex,Dynamic,1> m_perm; // Permutation vector + mutable Matrix<StorageIndex,Dynamic,1> m_invp; // Inverse permutation vector mutable int m_size; // Size of the matrix }; @@ -308,7 +308,7 @@ void PastixBase<Derived>::analyzePattern(ColSpMatrix& mat) if(m_size>0) clean(); - m_size = mat.rows(); + m_size = internal::convert_index<int>(mat.rows()); m_perm.resize(m_size); m_invp.resize(m_size); @@ -337,7 +337,7 @@ void PastixBase<Derived>::factorize(ColSpMatrix& mat) eigen_assert(m_analysisIsOk && "The analysis phase should be called before the factorization phase"); m_iparm(IPARM_START_TASK) = API_TASK_NUMFACT; m_iparm(IPARM_END_TASK) = API_TASK_NUMFACT; - m_size = mat.rows(); + m_size = internal::convert_index<int>(mat.rows()); internal::eigen_pastix(&m_pastixdata, MPI_COMM_WORLD, m_size, mat.outerIndexPtr(), mat.innerIndexPtr(), mat.valuePtr(), m_perm.data(), m_invp.data(), 0, 0, m_iparm.data(), m_dparm.data()); @@ -373,7 +373,7 @@ bool PastixBase<Base>::_solve_impl(const MatrixBase<Rhs> &b, MatrixBase<Dest> &x m_iparm[IPARM_START_TASK] = API_TASK_SOLVE; m_iparm[IPARM_END_TASK] = API_TASK_REFINE; - internal::eigen_pastix(&m_pastixdata, MPI_COMM_WORLD, x.rows(), 0, 0, 0, + internal::eigen_pastix(&m_pastixdata, MPI_COMM_WORLD, internal::convert_index<int>(x.rows()), 0, 0, 0, m_perm.data(), m_invp.data(), &x(0, i), rhs, m_iparm.data(), m_dparm.data()); } @@ -409,7 +409,7 @@ class PastixLU : public PastixBase< PastixLU<_MatrixType> > typedef _MatrixType MatrixType; typedef PastixBase<PastixLU<MatrixType> > Base; typedef typename Base::ColSpMatrix ColSpMatrix; - typedef typename MatrixType::Index Index; + typedef typename MatrixType::StorageIndex StorageIndex; public: PastixLU() : Base() diff --git a/Eigen/src/PardisoSupport/PardisoSupport.h b/Eigen/src/PardisoSupport/PardisoSupport.h index 054af6635..7ab2e3e6b 100644 --- a/Eigen/src/PardisoSupport/PardisoSupport.h +++ b/Eigen/src/PardisoSupport/PardisoSupport.h @@ -40,13 +40,13 @@ template<typename _MatrixType, int Options=Upper> class PardisoLDLT; namespace internal { - template<typename Index> + template<typename IndexType> struct pardiso_run_selector { - static Index run( _MKL_DSS_HANDLE_t pt, Index maxfct, Index mnum, Index type, Index phase, Index n, void *a, - Index *ia, Index *ja, Index *perm, Index nrhs, Index *iparm, Index msglvl, void *b, void *x) + static IndexType run( _MKL_DSS_HANDLE_t pt, IndexType maxfct, IndexType mnum, IndexType type, IndexType phase, IndexType n, void *a, + IndexType *ia, IndexType *ja, IndexType *perm, IndexType nrhs, IndexType *iparm, IndexType msglvl, void *b, void *x) { - Index error = 0; + IndexType error = 0; ::pardiso(pt, &maxfct, &mnum, &type, &phase, &n, a, ia, ja, perm, &nrhs, iparm, &msglvl, b, x, &error); return error; } @@ -54,11 +54,11 @@ namespace internal template<> struct pardiso_run_selector<long long int> { - typedef long long int Index; - static Index run( _MKL_DSS_HANDLE_t pt, Index maxfct, Index mnum, Index type, Index phase, Index n, void *a, - Index *ia, Index *ja, Index *perm, Index nrhs, Index *iparm, Index msglvl, void *b, void *x) + typedef long long int IndexTypeType; + static IndexType run( _MKL_DSS_HANDLE_t pt, IndexType maxfct, IndexType mnum, IndexType type, IndexType phase, IndexType n, void *a, + IndexType *ia, IndexType *ja, IndexType *perm, IndexType nrhs, IndexType *iparm, IndexType msglvl, void *b, void *x) { - Index error = 0; + IndexType error = 0; ::pardiso_64(pt, &maxfct, &mnum, &type, &phase, &n, a, ia, ja, perm, &nrhs, iparm, &msglvl, b, x, &error); return error; } @@ -72,7 +72,7 @@ namespace internal typedef _MatrixType MatrixType; typedef typename _MatrixType::Scalar Scalar; typedef typename _MatrixType::RealScalar RealScalar; - typedef typename _MatrixType::Index Index; + typedef typename _MatrixType::StorageIndex StorageIndex; }; template<typename _MatrixType, int Options> @@ -81,7 +81,7 @@ namespace internal typedef _MatrixType MatrixType; typedef typename _MatrixType::Scalar Scalar; typedef typename _MatrixType::RealScalar RealScalar; - typedef typename _MatrixType::Index Index; + typedef typename _MatrixType::StorageIndex StorageIndex; }; template<typename _MatrixType, int Options> @@ -90,7 +90,7 @@ namespace internal typedef _MatrixType MatrixType; typedef typename _MatrixType::Scalar Scalar; typedef typename _MatrixType::RealScalar RealScalar; - typedef typename _MatrixType::Index Index; + typedef typename _MatrixType::StorageIndex StorageIndex; }; } @@ -110,19 +110,19 @@ class PardisoImpl : public SparseSolveBase<PardisoImpl<Derived> typedef typename Traits::MatrixType MatrixType; typedef typename Traits::Scalar Scalar; typedef typename Traits::RealScalar RealScalar; - typedef typename Traits::Index Index; - typedef SparseMatrix<Scalar,RowMajor,Index> SparseMatrixType; + typedef typename Traits::StorageIndex StorageIndex; + typedef SparseMatrix<Scalar,RowMajor,StorageIndex> SparseMatrixType; typedef Matrix<Scalar,Dynamic,1> VectorType; - typedef Matrix<Index, 1, MatrixType::ColsAtCompileTime> IntRowVectorType; - typedef Matrix<Index, MatrixType::RowsAtCompileTime, 1> IntColVectorType; - typedef Array<Index,64,1,DontAlign> ParameterType; + typedef Matrix<StorageIndex, 1, MatrixType::ColsAtCompileTime> IntRowVectorType; + typedef Matrix<StorageIndex, MatrixType::RowsAtCompileTime, 1> IntColVectorType; + typedef Array<StorageIndex,64,1,DontAlign> ParameterType; enum { ScalarIsComplex = NumTraits<Scalar>::IsComplex }; PardisoImpl() { - eigen_assert((sizeof(Index) >= sizeof(_INTEGER_t) && sizeof(Index) <= 8) && "Non-supported index type"); + eigen_assert((sizeof(StorageIndex) >= sizeof(_INTEGER_t) && sizeof(StorageIndex) <= 8) && "Non-supported index type"); m_iparm.setZero(); m_msglvl = 0; // No output m_isInitialized = false; @@ -181,7 +181,7 @@ class PardisoImpl : public SparseSolveBase<PardisoImpl<Derived> { if(m_isInitialized) // Factorization ran at least once { - internal::pardiso_run_selector<Index>::run(m_pt, 1, 1, m_type, -1, m_size, 0, 0, 0, m_perm.data(), 0, + internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, -1, m_size, 0, 0, 0, m_perm.data(), 0, m_iparm.data(), m_msglvl, 0, 0); } } @@ -261,9 +261,9 @@ Derived& PardisoImpl<Derived>::compute(const MatrixType& a) derived().getMatrix(a); Index error; - error = internal::pardiso_run_selector<Index>::run(m_pt, 1, 1, m_type, 12, m_size, - m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(), - m_perm.data(), 0, m_iparm.data(), m_msglvl, NULL, NULL); + error = internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, 12, m_size, + m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(), + m_perm.data(), 0, m_iparm.data(), m_msglvl, NULL, NULL); manageErrorCode(error); m_analysisIsOk = true; @@ -284,9 +284,9 @@ Derived& PardisoImpl<Derived>::analyzePattern(const MatrixType& a) derived().getMatrix(a); Index error; - error = internal::pardiso_run_selector<Index>::run(m_pt, 1, 1, m_type, 11, m_size, - m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(), - m_perm.data(), 0, m_iparm.data(), m_msglvl, NULL, NULL); + error = internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, 11, m_size, + m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(), + m_perm.data(), 0, m_iparm.data(), m_msglvl, NULL, NULL); manageErrorCode(error); m_analysisIsOk = true; @@ -304,9 +304,9 @@ Derived& PardisoImpl<Derived>::factorize(const MatrixType& a) derived().getMatrix(a); Index error; - error = internal::pardiso_run_selector<Index>::run(m_pt, 1, 1, m_type, 22, m_size, - m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(), - m_perm.data(), 0, m_iparm.data(), m_msglvl, NULL, NULL); + error = internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, 22, m_size, + m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(), + m_perm.data(), 0, m_iparm.data(), m_msglvl, NULL, NULL); manageErrorCode(error); m_factorizationIsOk = true; @@ -348,10 +348,10 @@ bool PardisoImpl<Base>::_solve_impl(const MatrixBase<BDerived> &b, MatrixBase<XD } Index error; - error = internal::pardiso_run_selector<Index>::run(m_pt, 1, 1, m_type, 33, m_size, - m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(), - m_perm.data(), nrhs, m_iparm.data(), m_msglvl, - rhs_ptr, x.derived().data()); + error = internal::pardiso_run_selector<StorageIndex>::run(m_pt, 1, 1, m_type, 33, m_size, + m_matrix.valuePtr(), m_matrix.outerIndexPtr(), m_matrix.innerIndexPtr(), + m_perm.data(), nrhs, m_iparm.data(), m_msglvl, + rhs_ptr, x.derived().data()); return error==0; } @@ -424,7 +424,7 @@ class PardisoLLT : public PardisoImpl< PardisoLLT<MatrixType,_UpLo> > protected: typedef PardisoImpl< PardisoLLT<MatrixType,_UpLo> > Base; typedef typename Base::Scalar Scalar; - typedef typename Base::Index Index; + typedef typename Base::StorageIndex StorageIndex; typedef typename Base::RealScalar RealScalar; using Base::pardisoInit; using Base::m_matrix; @@ -454,7 +454,7 @@ class PardisoLLT : public PardisoImpl< PardisoLLT<MatrixType,_UpLo> > void getMatrix(const MatrixType& matrix) { // PARDISO supports only upper, row-major matrices - PermutationMatrix<Dynamic,Dynamic,Index> p_null; + PermutationMatrix<Dynamic,Dynamic,StorageIndex> p_null; m_matrix.resize(matrix.rows(), matrix.cols()); m_matrix.template selfadjointView<Upper>() = matrix.template selfadjointView<UpLo>().twistedBy(p_null); } @@ -482,7 +482,7 @@ class PardisoLDLT : public PardisoImpl< PardisoLDLT<MatrixType,Options> > protected: typedef PardisoImpl< PardisoLDLT<MatrixType,Options> > Base; typedef typename Base::Scalar Scalar; - typedef typename Base::Index Index; + typedef typename Base::StorageIndex StorageIndex; typedef typename Base::RealScalar RealScalar; using Base::pardisoInit; using Base::m_matrix; @@ -510,7 +510,7 @@ class PardisoLDLT : public PardisoImpl< PardisoLDLT<MatrixType,Options> > void getMatrix(const MatrixType& matrix) { // PARDISO supports only upper, row-major matrices - PermutationMatrix<Dynamic,Dynamic,Index> p_null; + PermutationMatrix<Dynamic,Dynamic,StorageIndex> p_null; m_matrix.resize(matrix.rows(), matrix.cols()); m_matrix.template selfadjointView<Upper>() = matrix.template selfadjointView<UpLo>().twistedBy(p_null); } diff --git a/Eigen/src/QR/ColPivHouseholderQR.h b/Eigen/src/QR/ColPivHouseholderQR.h index 2696c4b2f..03ff0a8f2 100644 --- a/Eigen/src/QR/ColPivHouseholderQR.h +++ b/Eigen/src/QR/ColPivHouseholderQR.h @@ -57,7 +57,8 @@ template<typename _MatrixType> class ColPivHouseholderQR }; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; + // FIXME should be int + typedef typename MatrixType::StorageIndex StorageIndex; typedef Matrix<Scalar, RowsAtCompileTime, RowsAtCompileTime, Options, MaxRowsAtCompileTime, MaxRowsAtCompileTime> MatrixQType; typedef typename internal::plain_diag_type<MatrixType>::type HCoeffsType; typedef PermutationMatrix<ColsAtCompileTime, MaxColsAtCompileTime> PermutationType; @@ -69,7 +70,7 @@ template<typename _MatrixType> class ColPivHouseholderQR private: - typedef typename PermutationType::Index PermIndexType; + typedef typename PermutationType::StorageIndex PermIndexType; public: diff --git a/Eigen/src/QR/FullPivHouseholderQR.h b/Eigen/src/QR/FullPivHouseholderQR.h index 5712d175c..7d5e58d2f 100644 --- a/Eigen/src/QR/FullPivHouseholderQR.h +++ b/Eigen/src/QR/FullPivHouseholderQR.h @@ -66,10 +66,11 @@ template<typename _MatrixType> class FullPivHouseholderQR }; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; + // FIXME should be int + typedef typename MatrixType::StorageIndex StorageIndex; typedef internal::FullPivHouseholderQRMatrixQReturnType<MatrixType> MatrixQReturnType; typedef typename internal::plain_diag_type<MatrixType>::type HCoeffsType; - typedef Matrix<Index, 1, + typedef Matrix<StorageIndex, 1, EIGEN_SIZE_MIN_PREFER_DYNAMIC(ColsAtCompileTime,RowsAtCompileTime), RowMajor, 1, EIGEN_SIZE_MIN_PREFER_FIXED(MaxColsAtCompileTime,MaxRowsAtCompileTime)> IntDiagSizeVectorType; typedef PermutationMatrix<ColsAtCompileTime, MaxColsAtCompileTime> PermutationType; @@ -556,7 +557,6 @@ template<typename MatrixType> struct FullPivHouseholderQRMatrixQReturnType : public ReturnByValue<FullPivHouseholderQRMatrixQReturnType<MatrixType> > { public: - typedef typename MatrixType::Index Index; typedef typename FullPivHouseholderQR<MatrixType>::IntDiagSizeVectorType IntDiagSizeVectorType; typedef typename internal::plain_diag_type<MatrixType>::type HCoeffsType; typedef Matrix<typename MatrixType::Scalar, 1, MatrixType::RowsAtCompileTime, RowMajor, 1, diff --git a/Eigen/src/QR/HouseholderQR.h b/Eigen/src/QR/HouseholderQR.h index f22008494..195bacb85 100644 --- a/Eigen/src/QR/HouseholderQR.h +++ b/Eigen/src/QR/HouseholderQR.h @@ -53,7 +53,8 @@ template<typename _MatrixType> class HouseholderQR }; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; + // FIXME should be int + typedef typename MatrixType::StorageIndex StorageIndex; typedef Matrix<Scalar, RowsAtCompileTime, RowsAtCompileTime, (MatrixType::Flags&RowMajorBit) ? RowMajor : ColMajor, MaxRowsAtCompileTime, MaxRowsAtCompileTime> MatrixQType; typedef typename internal::plain_diag_type<MatrixType>::type HCoeffsType; typedef typename internal::plain_row_type<MatrixType>::type RowVectorType; @@ -224,7 +225,6 @@ namespace internal { template<typename MatrixQR, typename HCoeffs> void householder_qr_inplace_unblocked(MatrixQR& mat, HCoeffs& hCoeffs, typename MatrixQR::Scalar* tempData = 0) { - typedef typename MatrixQR::Index Index; typedef typename MatrixQR::Scalar Scalar; typedef typename MatrixQR::RealScalar RealScalar; Index rows = mat.rows(); @@ -263,11 +263,9 @@ template<typename MatrixQR, typename HCoeffs, struct householder_qr_inplace_blocked { // This is specialized for MKL-supported Scalar types in HouseholderQR_MKL.h - static void run(MatrixQR& mat, HCoeffs& hCoeffs, - typename MatrixQR::Index maxBlockSize=32, + static void run(MatrixQR& mat, HCoeffs& hCoeffs, Index maxBlockSize=32, typename MatrixQR::Scalar* tempData = 0) { - typedef typename MatrixQR::Index Index; typedef typename MatrixQR::Scalar Scalar; typedef Block<MatrixQR,Dynamic,Dynamic> BlockType; diff --git a/Eigen/src/QR/HouseholderQR_MKL.h b/Eigen/src/QR/HouseholderQR_MKL.h index 8a3a7e406..84ab640a1 100644 --- a/Eigen/src/QR/HouseholderQR_MKL.h +++ b/Eigen/src/QR/HouseholderQR_MKL.h @@ -46,8 +46,7 @@ namespace internal { template<typename MatrixQR, typename HCoeffs> \ struct householder_qr_inplace_blocked<MatrixQR, HCoeffs, EIGTYPE, true> \ { \ - static void run(MatrixQR& mat, HCoeffs& hCoeffs, \ - typename MatrixQR::Index = 32, \ + static void run(MatrixQR& mat, HCoeffs& hCoeffs, Index = 32, \ typename MatrixQR::Scalar* = 0) \ { \ lapack_int m = (lapack_int) mat.rows(); \ diff --git a/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h b/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h index 54a1b21b8..4ad22f8b4 100644 --- a/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h +++ b/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h @@ -63,9 +63,9 @@ class SPQR : public SparseSolverBase<SPQR<_MatrixType> > public: typedef typename _MatrixType::Scalar Scalar; typedef typename _MatrixType::RealScalar RealScalar; - typedef UF_long Index ; - typedef SparseMatrix<Scalar, ColMajor, Index> MatrixType; - typedef Map<PermutationMatrix<Dynamic, Dynamic, Index> > PermutationType; + typedef UF_long StorageIndex ; + typedef SparseMatrix<Scalar, ColMajor, StorageIndex> MatrixType; + typedef Map<PermutationMatrix<Dynamic, Dynamic, StorageIndex> > PermutationType; public: SPQR() : m_ordering(SPQR_ORDERING_DEFAULT), m_allow_tol(SPQR_DEFAULT_TOL), m_tolerance (NumTraits<Scalar>::epsilon()), m_useDefaultThreshold(true) @@ -174,7 +174,7 @@ class SPQR : public SparseSolverBase<SPQR<_MatrixType> > { eigen_assert(m_isInitialized && " The QR factorization should be computed first, call compute()"); if(!m_isRUpToDate) { - m_R = viewAsEigen<Scalar,ColMajor, typename MatrixType::Index>(*m_cR); + m_R = viewAsEigen<Scalar,ColMajor, typename MatrixType::StorageIndex>(*m_cR); m_isRUpToDate = true; } return m_R; @@ -232,9 +232,9 @@ class SPQR : public SparseSolverBase<SPQR<_MatrixType> > RealScalar m_tolerance; // treat columns with 2-norm below this tolerance as zero mutable cholmod_sparse *m_cR; // The sparse R factor in cholmod format mutable MatrixType m_R; // The sparse matrix R in Eigen format - mutable Index *m_E; // The permutation applied to columns + mutable StorageIndex *m_E; // The permutation applied to columns mutable cholmod_sparse *m_H; //The householder vectors - mutable Index *m_HPinv; // The row permutation of H + mutable StorageIndex *m_HPinv; // The row permutation of H mutable cholmod_dense *m_HTau; // The Householder coefficients mutable Index m_rank; // The rank of the matrix mutable cholmod_common m_cc; // Workspace and parameters @@ -246,7 +246,7 @@ template <typename SPQRType, typename Derived> struct SPQR_QProduct : ReturnByValue<SPQR_QProduct<SPQRType,Derived> > { typedef typename SPQRType::Scalar Scalar; - typedef typename SPQRType::Index Index; + typedef typename SPQRType::StorageIndex StorageIndex; //Define the constructor to get reference to argument types SPQR_QProduct(const SPQRType& spqr, const Derived& other, bool transpose) : m_spqr(spqr),m_other(other),m_transpose(transpose) {} diff --git a/Eigen/src/SVD/BDCSVD.h b/Eigen/src/SVD/BDCSVD.h index dad59bcca..fd7c8a4b2 100644 --- a/Eigen/src/SVD/BDCSVD.h +++ b/Eigen/src/SVD/BDCSVD.h @@ -65,7 +65,6 @@ public: typedef _MatrixType MatrixType; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar; - typedef typename MatrixType::Index Index; enum { RowsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime, @@ -307,7 +306,7 @@ void BDCSVD<MatrixType>::structured_update(Block<MatrixXr,Dynamic,Dynamic> A, co { // If the matrices are large enough, let's exploit the sparse structure of A by // splitting it in half (wrt n1), and packing the non-zero columns. - DenseIndex n2 = n - n1; + Index n2 = n - n1; MatrixXr A1(n1,n), A2(n2,n), B1(n,n), B2(n,n); Index k1=0, k2=0; for(Index j=0; j<n; ++j) diff --git a/Eigen/src/SVD/JacobiSVD.h b/Eigen/src/SVD/JacobiSVD.h index 444187ae7..fcf01f518 100644 --- a/Eigen/src/SVD/JacobiSVD.h +++ b/Eigen/src/SVD/JacobiSVD.h @@ -52,7 +52,6 @@ template<typename MatrixType, int QRPreconditioner, int Case> class qr_preconditioner_impl<MatrixType, QRPreconditioner, Case, false> { public: - typedef typename MatrixType::Index Index; void allocate(const JacobiSVD<MatrixType, QRPreconditioner>&) {} bool run(JacobiSVD<MatrixType, QRPreconditioner>&, const MatrixType&) { @@ -66,7 +65,6 @@ template<typename MatrixType> class qr_preconditioner_impl<MatrixType, FullPivHouseholderQRPreconditioner, PreconditionIfMoreRowsThanCols, true> { public: - typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; enum { @@ -107,7 +105,6 @@ template<typename MatrixType> class qr_preconditioner_impl<MatrixType, FullPivHouseholderQRPreconditioner, PreconditionIfMoreColsThanRows, true> { public: - typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; enum { @@ -157,8 +154,6 @@ template<typename MatrixType> class qr_preconditioner_impl<MatrixType, ColPivHouseholderQRPreconditioner, PreconditionIfMoreRowsThanCols, true> { public: - typedef typename MatrixType::Index Index; - void allocate(const JacobiSVD<MatrixType, ColPivHouseholderQRPreconditioner>& svd) { if (svd.rows() != m_qr.rows() || svd.cols() != m_qr.cols()) @@ -198,7 +193,6 @@ template<typename MatrixType> class qr_preconditioner_impl<MatrixType, ColPivHouseholderQRPreconditioner, PreconditionIfMoreColsThanRows, true> { public: - typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; enum { @@ -257,8 +251,6 @@ template<typename MatrixType> class qr_preconditioner_impl<MatrixType, HouseholderQRPreconditioner, PreconditionIfMoreRowsThanCols, true> { public: - typedef typename MatrixType::Index Index; - void allocate(const JacobiSVD<MatrixType, HouseholderQRPreconditioner>& svd) { if (svd.rows() != m_qr.rows() || svd.cols() != m_qr.cols()) @@ -297,7 +289,6 @@ template<typename MatrixType> class qr_preconditioner_impl<MatrixType, HouseholderQRPreconditioner, PreconditionIfMoreColsThanRows, true> { public: - typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; enum { @@ -359,7 +350,6 @@ template<typename MatrixType, int QRPreconditioner> struct svd_precondition_2x2_block_to_be_real<MatrixType, QRPreconditioner, false> { typedef JacobiSVD<MatrixType, QRPreconditioner> SVD; - typedef typename SVD::Index Index; static void run(typename SVD::WorkMatrixType&, SVD&, Index, Index) {} }; @@ -369,7 +359,6 @@ struct svd_precondition_2x2_block_to_be_real<MatrixType, QRPreconditioner, true> typedef JacobiSVD<MatrixType, QRPreconditioner> SVD; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename SVD::Index Index; static void run(typename SVD::WorkMatrixType& work_matrix, SVD& svd, Index p, Index q) { using std::sqrt; @@ -514,7 +503,6 @@ template<typename _MatrixType, int QRPreconditioner> class JacobiSVD typedef _MatrixType MatrixType; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar; - typedef typename MatrixType::Index Index; enum { RowsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime, diff --git a/Eigen/src/SVD/SVDBase.h b/Eigen/src/SVD/SVDBase.h index 27b732b80..8903755e7 100644 --- a/Eigen/src/SVD/SVDBase.h +++ b/Eigen/src/SVD/SVDBase.h @@ -52,7 +52,8 @@ public: typedef typename internal::traits<Derived>::MatrixType MatrixType; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar; - typedef typename MatrixType::Index Index; + typedef typename MatrixType::StorageIndex StorageIndex; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 enum { RowsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime, diff --git a/Eigen/src/SVD/UpperBidiagonalization.h b/Eigen/src/SVD/UpperBidiagonalization.h index eaa6bb86e..9dc470fd9 100644 --- a/Eigen/src/SVD/UpperBidiagonalization.h +++ b/Eigen/src/SVD/UpperBidiagonalization.h @@ -29,7 +29,7 @@ template<typename _MatrixType> class UpperBidiagonalization }; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; + typedef Eigen::Index Index; ///< \deprecated since Eigen 3.3 typedef Matrix<Scalar, 1, ColsAtCompileTime> RowVectorType; typedef Matrix<Scalar, RowsAtCompileTime, 1> ColVectorType; typedef BandMatrix<RealScalar, ColsAtCompileTime, ColsAtCompileTime, 1, 0, RowMajor> BidiagonalType; @@ -95,7 +95,6 @@ void upperbidiagonalization_inplace_unblocked(MatrixType& mat, typename MatrixType::RealScalar *upper_diagonal, typename MatrixType::Scalar* tempData = 0) { - typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; Index rows = mat.rows(); @@ -153,13 +152,12 @@ template<typename MatrixType> void upperbidiagonalization_blocked_helper(MatrixType& A, typename MatrixType::RealScalar *diagonal, typename MatrixType::RealScalar *upper_diagonal, - typename MatrixType::Index bs, + Index bs, Ref<Matrix<typename MatrixType::Scalar, Dynamic, Dynamic, traits<MatrixType>::Flags & RowMajorBit> > X, Ref<Matrix<typename MatrixType::Scalar, Dynamic, Dynamic, traits<MatrixType>::Flags & RowMajorBit> > Y) { - typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; enum { StorageOrder = traits<MatrixType>::Flags & RowMajorBit }; typedef InnerStride<int(StorageOrder) == int(ColMajor) ? 1 : Dynamic> ColInnerStride; @@ -282,10 +280,9 @@ void upperbidiagonalization_blocked_helper(MatrixType& A, */ template<typename MatrixType, typename BidiagType> void upperbidiagonalization_inplace_blocked(MatrixType& A, BidiagType& bidiagonal, - typename MatrixType::Index maxBlockSize=32, + Index maxBlockSize=32, typename MatrixType::Scalar* /*tempData*/ = 0) { - typedef typename MatrixType::Index Index; typedef typename MatrixType::Scalar Scalar; typedef Block<MatrixType,Dynamic,Dynamic> BlockType; diff --git a/Eigen/src/SparseCholesky/SimplicialCholesky.h b/Eigen/src/SparseCholesky/SimplicialCholesky.h index 22325d7f4..e2d7f95f2 100644 --- a/Eigen/src/SparseCholesky/SimplicialCholesky.h +++ b/Eigen/src/SparseCholesky/SimplicialCholesky.h @@ -65,8 +65,8 @@ class SimplicialCholeskyBase : public SparseSolverBase<Derived> enum { UpLo = internal::traits<Derived>::UpLo }; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; - typedef SparseMatrix<Scalar,ColMajor,Index> CholMatrixType; + typedef typename MatrixType::StorageIndex StorageIndex; + typedef SparseMatrix<Scalar,ColMajor,StorageIndex> CholMatrixType; typedef CholMatrixType const * ConstCholMatrixPtr; typedef Matrix<Scalar,Dynamic,1> VectorType; @@ -108,12 +108,12 @@ class SimplicialCholeskyBase : public SparseSolverBase<Derived> /** \returns the permutation P * \sa permutationPinv() */ - const PermutationMatrix<Dynamic,Dynamic,Index>& permutationP() const + const PermutationMatrix<Dynamic,Dynamic,StorageIndex>& permutationP() const { return m_P; } /** \returns the inverse P^-1 of the permutation P * \sa permutationP() */ - const PermutationMatrix<Dynamic,Dynamic,Index>& permutationPinv() const + const PermutationMatrix<Dynamic,Dynamic,StorageIndex>& permutationPinv() const { return m_Pinv; } /** Sets the shift parameters that will be used to adjust the diagonal coefficients during the numerical factorization. @@ -202,7 +202,7 @@ class SimplicialCholeskyBase : public SparseSolverBase<Derived> void factorize(const MatrixType& a) { eigen_assert(a.rows()==a.cols()); - int size = a.cols(); + Index size = a.cols(); CholMatrixType tmp(size,size); ConstCholMatrixPtr pmat; @@ -226,7 +226,7 @@ class SimplicialCholeskyBase : public SparseSolverBase<Derived> void analyzePattern(const MatrixType& a, bool doLDLT) { eigen_assert(a.rows()==a.cols()); - int size = a.cols(); + Index size = a.cols(); CholMatrixType tmp(size,size); ConstCholMatrixPtr pmat; ordering(a, pmat, tmp); @@ -252,16 +252,16 @@ class SimplicialCholeskyBase : public SparseSolverBase<Derived> VectorType m_diag; // the diagonal coefficients (LDLT mode) VectorXi m_parent; // elimination tree VectorXi m_nonZerosPerCol; - PermutationMatrix<Dynamic,Dynamic,Index> m_P; // the permutation - PermutationMatrix<Dynamic,Dynamic,Index> m_Pinv; // the inverse permutation + PermutationMatrix<Dynamic,Dynamic,StorageIndex> m_P; // the permutation + PermutationMatrix<Dynamic,Dynamic,StorageIndex> m_Pinv; // the inverse permutation RealScalar m_shiftOffset; RealScalar m_shiftScale; }; -template<typename _MatrixType, int _UpLo = Lower, typename _Ordering = AMDOrdering<typename _MatrixType::Index> > class SimplicialLLT; -template<typename _MatrixType, int _UpLo = Lower, typename _Ordering = AMDOrdering<typename _MatrixType::Index> > class SimplicialLDLT; -template<typename _MatrixType, int _UpLo = Lower, typename _Ordering = AMDOrdering<typename _MatrixType::Index> > class SimplicialCholesky; +template<typename _MatrixType, int _UpLo = Lower, typename _Ordering = AMDOrdering<typename _MatrixType::StorageIndex> > class SimplicialLLT; +template<typename _MatrixType, int _UpLo = Lower, typename _Ordering = AMDOrdering<typename _MatrixType::StorageIndex> > class SimplicialLDLT; +template<typename _MatrixType, int _UpLo = Lower, typename _Ordering = AMDOrdering<typename _MatrixType::StorageIndex> > class SimplicialCholesky; namespace internal { @@ -271,8 +271,8 @@ template<typename _MatrixType, int _UpLo, typename _Ordering> struct traits<Simp typedef _Ordering OrderingType; enum { UpLo = _UpLo }; typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::Index Index; - typedef SparseMatrix<Scalar, ColMajor, Index> CholMatrixType; + typedef typename MatrixType::StorageIndex StorageIndex; + typedef SparseMatrix<Scalar, ColMajor, StorageIndex> CholMatrixType; typedef TriangularView<const CholMatrixType, Eigen::Lower> MatrixL; typedef TriangularView<const typename CholMatrixType::AdjointReturnType, Eigen::Upper> MatrixU; static inline MatrixL getL(const MatrixType& m) { return MatrixL(m); } @@ -285,8 +285,8 @@ template<typename _MatrixType,int _UpLo, typename _Ordering> struct traits<Simpl typedef _Ordering OrderingType; enum { UpLo = _UpLo }; typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::Index Index; - typedef SparseMatrix<Scalar, ColMajor, Index> CholMatrixType; + typedef typename MatrixType::StorageIndex StorageIndex; + typedef SparseMatrix<Scalar, ColMajor, StorageIndex> CholMatrixType; typedef TriangularView<const CholMatrixType, Eigen::UnitLower> MatrixL; typedef TriangularView<const typename CholMatrixType::AdjointReturnType, Eigen::UnitUpper> MatrixU; static inline MatrixL getL(const MatrixType& m) { return MatrixL(m); } @@ -329,7 +329,7 @@ public: typedef SimplicialCholeskyBase<SimplicialLLT> Base; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; + typedef typename MatrixType::StorageIndex StorageIndex; typedef SparseMatrix<Scalar,ColMajor,Index> CholMatrixType; typedef Matrix<Scalar,Dynamic,1> VectorType; typedef internal::traits<SimplicialLLT> Traits; @@ -418,8 +418,8 @@ public: typedef SimplicialCholeskyBase<SimplicialLDLT> Base; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; - typedef SparseMatrix<Scalar,ColMajor,Index> CholMatrixType; + typedef typename MatrixType::StorageIndex StorageIndex; + typedef SparseMatrix<Scalar,ColMajor,StorageIndex> CholMatrixType; typedef Matrix<Scalar,Dynamic,1> VectorType; typedef internal::traits<SimplicialLDLT> Traits; typedef typename Traits::MatrixL MatrixL; @@ -500,8 +500,8 @@ public: typedef SimplicialCholeskyBase<SimplicialCholesky> Base; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; - typedef SparseMatrix<Scalar,ColMajor,Index> CholMatrixType; + typedef typename MatrixType::StorageIndex StorageIndex; + typedef SparseMatrix<Scalar,ColMajor,StorageIndex> CholMatrixType; typedef Matrix<Scalar,Dynamic,1> VectorType; typedef internal::traits<SimplicialCholesky> Traits; typedef internal::traits<SimplicialLDLT<MatrixType,UpLo> > LDLTTraits; diff --git a/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h b/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h index b7fd62faa..31e06995b 100644 --- a/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h +++ b/Eigen/src/SparseCholesky/SimplicialCholesky_impl.h @@ -50,14 +50,14 @@ namespace Eigen { template<typename Derived> void SimplicialCholeskyBase<Derived>::analyzePattern_preordered(const CholMatrixType& ap, bool doLDLT) { - const Index size = ap.rows(); + const StorageIndex size = StorageIndex(ap.rows()); m_matrix.resize(size, size); m_parent.resize(size); m_nonZerosPerCol.resize(size); - ei_declare_aligned_stack_constructed_variable(Index, tags, size, 0); + ei_declare_aligned_stack_constructed_variable(StorageIndex, tags, size, 0); - for(Index k = 0; k < size; ++k) + for(StorageIndex k = 0; k < size; ++k) { /* L(k,:) pattern: all nodes reachable in etree from nz in A(0:k-1,k) */ m_parent[k] = -1; /* parent of k is not yet known */ @@ -65,7 +65,7 @@ void SimplicialCholeskyBase<Derived>::analyzePattern_preordered(const CholMatrix m_nonZerosPerCol[k] = 0; /* count of nonzeros in column k of L */ for(typename CholMatrixType::InnerIterator it(ap,k); it; ++it) { - Index i = it.index(); + StorageIndex i = it.index(); if(i < k) { /* follow path from i to root of etree, stop at flagged node */ @@ -82,9 +82,9 @@ void SimplicialCholeskyBase<Derived>::analyzePattern_preordered(const CholMatrix } /* construct Lp index array from m_nonZerosPerCol column counts */ - Index* Lp = m_matrix.outerIndexPtr(); + StorageIndex* Lp = m_matrix.outerIndexPtr(); Lp[0] = 0; - for(Index k = 0; k < size; ++k) + for(StorageIndex k = 0; k < size; ++k) Lp[k+1] = Lp[k] + m_nonZerosPerCol[k] + (doLDLT ? 0 : 1); m_matrix.resizeNonZeros(Lp[size]); @@ -104,31 +104,31 @@ void SimplicialCholeskyBase<Derived>::factorize_preordered(const CholMatrixType& eigen_assert(m_analysisIsOk && "You must first call analyzePattern()"); eigen_assert(ap.rows()==ap.cols()); - const Index size = ap.rows(); - eigen_assert(m_parent.size()==size); - eigen_assert(m_nonZerosPerCol.size()==size); + eigen_assert(m_parent.size()==ap.rows()); + eigen_assert(m_nonZerosPerCol.size()==ap.rows()); - const Index* Lp = m_matrix.outerIndexPtr(); - Index* Li = m_matrix.innerIndexPtr(); + const StorageIndex size = StorageIndex(ap.rows()); + const StorageIndex* Lp = m_matrix.outerIndexPtr(); + StorageIndex* Li = m_matrix.innerIndexPtr(); Scalar* Lx = m_matrix.valuePtr(); ei_declare_aligned_stack_constructed_variable(Scalar, y, size, 0); - ei_declare_aligned_stack_constructed_variable(Index, pattern, size, 0); - ei_declare_aligned_stack_constructed_variable(Index, tags, size, 0); + ei_declare_aligned_stack_constructed_variable(StorageIndex, pattern, size, 0); + ei_declare_aligned_stack_constructed_variable(StorageIndex, tags, size, 0); bool ok = true; m_diag.resize(DoLDLT ? size : 0); - for(Index k = 0; k < size; ++k) + for(StorageIndex k = 0; k < size; ++k) { // compute nonzero pattern of kth row of L, in topological order y[k] = 0.0; // Y(0:k) is now all zero - Index top = size; // stack for pattern is empty + StorageIndex top = size; // stack for pattern is empty tags[k] = k; // mark node k as visited m_nonZerosPerCol[k] = 0; // count of nonzeros in column k of L for(typename CholMatrixType::InnerIterator it(ap,k); it; ++it) { - Index i = it.index(); + StorageIndex i = it.index(); if(i <= k) { y[i] += numext::conj(it.value()); /* scatter A(i,k) into Y (sum duplicates) */ diff --git a/Eigen/src/SparseCore/AmbiVector.h b/Eigen/src/SparseCore/AmbiVector.h index 76ef25f7d..1233e164e 100644 --- a/Eigen/src/SparseCore/AmbiVector.h +++ b/Eigen/src/SparseCore/AmbiVector.h @@ -19,12 +19,12 @@ namespace internal { * * See BasicSparseLLT and SparseProduct for usage examples. */ -template<typename _Scalar, typename _Index> +template<typename _Scalar, typename _StorageIndex> class AmbiVector { public: typedef _Scalar Scalar; - typedef _Index Index; + typedef _StorageIndex StorageIndex; typedef typename NumTraits<Scalar>::Real RealScalar; explicit AmbiVector(Index size) @@ -39,7 +39,7 @@ class AmbiVector Index nonZeros() const; /** Specifies a sub-vector to work on */ - void setBounds(Index start, Index end) { m_start = start; m_end = end; } + void setBounds(Index start, Index end) { m_start = convert_index(start); m_end = convert_index(end); } void setZero(); @@ -55,12 +55,16 @@ class AmbiVector { if (m_allocatedSize < size) reallocate(size); - m_size = size; + m_size = convert_index(size); } - Index size() const { return m_size; } + StorageIndex size() const { return m_size; } protected: + StorageIndex convert_index(Index idx) + { + return internal::convert_index<StorageIndex>(idx); + } void reallocate(Index size) { @@ -70,15 +74,15 @@ class AmbiVector if (size<1000) { Index allocSize = (size * sizeof(ListEl) + sizeof(Scalar) - 1)/sizeof(Scalar); - m_allocatedElements = (allocSize*sizeof(Scalar))/sizeof(ListEl); + m_allocatedElements = convert_index((allocSize*sizeof(Scalar))/sizeof(ListEl)); m_buffer = new Scalar[allocSize]; } else { - m_allocatedElements = (size*sizeof(Scalar))/sizeof(ListEl); + m_allocatedElements = convert_index((size*sizeof(Scalar))/sizeof(ListEl)); m_buffer = new Scalar[size]; } - m_size = size; + m_size = convert_index(size); m_start = 0; m_end = m_size; } @@ -86,7 +90,7 @@ class AmbiVector void reallocateSparse() { Index copyElements = m_allocatedElements; - m_allocatedElements = (std::min)(Index(m_allocatedElements*1.5),m_size); + m_allocatedElements = (std::min)(StorageIndex(m_allocatedElements*1.5),m_size); Index allocSize = m_allocatedElements * sizeof(ListEl); allocSize = (allocSize + sizeof(Scalar) - 1)/sizeof(Scalar); Scalar* newBuffer = new Scalar[allocSize]; @@ -99,30 +103,30 @@ class AmbiVector // element type of the linked list struct ListEl { - Index next; - Index index; + StorageIndex next; + StorageIndex index; Scalar value; }; // used to store data in both mode Scalar* m_buffer; Scalar m_zero; - Index m_size; - Index m_start; - Index m_end; - Index m_allocatedSize; - Index m_allocatedElements; - Index m_mode; + StorageIndex m_size; + StorageIndex m_start; + StorageIndex m_end; + StorageIndex m_allocatedSize; + StorageIndex m_allocatedElements; + StorageIndex m_mode; // linked list mode - Index m_llStart; - Index m_llCurrent; - Index m_llSize; + StorageIndex m_llStart; + StorageIndex m_llCurrent; + StorageIndex m_llSize; }; /** \returns the number of non zeros in the current sub vector */ -template<typename _Scalar,typename _Index> -_Index AmbiVector<_Scalar,_Index>::nonZeros() const +template<typename _Scalar,typename _StorageIndex> +Index AmbiVector<_Scalar,_StorageIndex>::nonZeros() const { if (m_mode==IsSparse) return m_llSize; @@ -130,8 +134,8 @@ _Index AmbiVector<_Scalar,_Index>::nonZeros() const return m_end - m_start; } -template<typename _Scalar,typename _Index> -void AmbiVector<_Scalar,_Index>::init(double estimatedDensity) +template<typename _Scalar,typename _StorageIndex> +void AmbiVector<_Scalar,_StorageIndex>::init(double estimatedDensity) { if (estimatedDensity>0.1) init(IsDense); @@ -139,8 +143,8 @@ void AmbiVector<_Scalar,_Index>::init(double estimatedDensity) init(IsSparse); } -template<typename _Scalar,typename _Index> -void AmbiVector<_Scalar,_Index>::init(int mode) +template<typename _Scalar,typename _StorageIndex> +void AmbiVector<_Scalar,_StorageIndex>::init(int mode) { m_mode = mode; if (m_mode==IsSparse) @@ -155,15 +159,15 @@ void AmbiVector<_Scalar,_Index>::init(int mode) * * Don't worry, this function is extremely cheap. */ -template<typename _Scalar,typename _Index> -void AmbiVector<_Scalar,_Index>::restart() +template<typename _Scalar,typename _StorageIndex> +void AmbiVector<_Scalar,_StorageIndex>::restart() { m_llCurrent = m_llStart; } /** Set all coefficients of current subvector to zero */ -template<typename _Scalar,typename _Index> -void AmbiVector<_Scalar,_Index>::setZero() +template<typename _Scalar,typename _StorageIndex> +void AmbiVector<_Scalar,_StorageIndex>::setZero() { if (m_mode==IsDense) { @@ -178,8 +182,8 @@ void AmbiVector<_Scalar,_Index>::setZero() } } -template<typename _Scalar,typename _Index> -_Scalar& AmbiVector<_Scalar,_Index>::coeffRef(_Index i) +template<typename _Scalar,typename _StorageIndex> +_Scalar& AmbiVector<_Scalar,_StorageIndex>::coeffRef(Index i) { if (m_mode==IsDense) return m_buffer[i]; @@ -195,7 +199,7 @@ _Scalar& AmbiVector<_Scalar,_Index>::coeffRef(_Index i) m_llCurrent = 0; ++m_llSize; llElements[0].value = Scalar(0); - llElements[0].index = i; + llElements[0].index = convert_index(i); llElements[0].next = -1; return llElements[0].value; } @@ -204,7 +208,7 @@ _Scalar& AmbiVector<_Scalar,_Index>::coeffRef(_Index i) // this is going to be the new first element of the list ListEl& el = llElements[m_llSize]; el.value = Scalar(0); - el.index = i; + el.index = convert_index(i); el.next = m_llStart; m_llStart = m_llSize; ++m_llSize; @@ -213,7 +217,7 @@ _Scalar& AmbiVector<_Scalar,_Index>::coeffRef(_Index i) } else { - Index nextel = llElements[m_llCurrent].next; + StorageIndex nextel = llElements[m_llCurrent].next; eigen_assert(i>=llElements[m_llCurrent].index && "you must call restart() before inserting an element with lower or equal index"); while (nextel >= 0 && llElements[nextel].index<=i) { @@ -237,7 +241,7 @@ _Scalar& AmbiVector<_Scalar,_Index>::coeffRef(_Index i) // let's insert a new coefficient ListEl& el = llElements[m_llSize]; el.value = Scalar(0); - el.index = i; + el.index = convert_index(i); el.next = llElements[m_llCurrent].next; llElements[m_llCurrent].next = m_llSize; ++m_llSize; @@ -247,8 +251,8 @@ _Scalar& AmbiVector<_Scalar,_Index>::coeffRef(_Index i) } } -template<typename _Scalar,typename _Index> -_Scalar& AmbiVector<_Scalar,_Index>::coeff(_Index i) +template<typename _Scalar,typename _StorageIndex> +_Scalar& AmbiVector<_Scalar,_StorageIndex>::coeff(Index i) { if (m_mode==IsDense) return m_buffer[i]; @@ -275,8 +279,8 @@ _Scalar& AmbiVector<_Scalar,_Index>::coeff(_Index i) } /** Iterator over the nonzero coefficients */ -template<typename _Scalar,typename _Index> -class AmbiVector<_Scalar,_Index>::Iterator +template<typename _Scalar,typename _StorageIndex> +class AmbiVector<_Scalar,_StorageIndex>::Iterator { public: typedef _Scalar Scalar; @@ -320,7 +324,7 @@ class AmbiVector<_Scalar,_Index>::Iterator } } - Index index() const { return m_cachedIndex; } + StorageIndex index() const { return m_cachedIndex; } Scalar value() const { return m_cachedValue; } operator bool() const { return m_cachedIndex>=0; } @@ -359,9 +363,9 @@ class AmbiVector<_Scalar,_Index>::Iterator protected: const AmbiVector& m_vector; // the target vector - Index m_currentEl; // the current element in sparse/linked-list mode + StorageIndex m_currentEl; // the current element in sparse/linked-list mode RealScalar m_epsilon; // epsilon used to prune zero coefficients - Index m_cachedIndex; // current coordinate + StorageIndex m_cachedIndex; // current coordinate Scalar m_cachedValue; // current value bool m_isDense; // mode of the vector }; diff --git a/Eigen/src/SparseCore/CompressedStorage.h b/Eigen/src/SparseCore/CompressedStorage.h index 99f741138..454462ad5 100644 --- a/Eigen/src/SparseCore/CompressedStorage.h +++ b/Eigen/src/SparseCore/CompressedStorage.h @@ -18,13 +18,13 @@ namespace internal { * Stores a sparse set of values as a list of values and a list of indices. * */ -template<typename _Scalar,typename _Index> +template<typename _Scalar,typename _StorageIndex> class CompressedStorage { public: typedef _Scalar Scalar; - typedef _Index Index; + typedef _StorageIndex StorageIndex; protected: @@ -36,7 +36,7 @@ class CompressedStorage : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0) {} - explicit CompressedStorage(size_t size) + explicit CompressedStorage(Index size) : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0) { resize(size); @@ -70,9 +70,9 @@ class CompressedStorage delete[] m_indices; } - void reserve(size_t size) + void reserve(Index size) { - size_t newAllocatedSize = m_size + size; + Index newAllocatedSize = m_size + size; if (newAllocatedSize > m_allocatedSize) reallocate(newAllocatedSize); } @@ -83,54 +83,55 @@ class CompressedStorage reallocate(m_size); } - void resize(size_t size, double reserveSizeFactor = 0) + void resize(Index size, double reserveSizeFactor = 0) { if (m_allocatedSize<size) - reallocate(size + size_t(reserveSizeFactor*double(size))); + reallocate(size + Index(reserveSizeFactor*double(size))); m_size = size; } + // FIXME i should be a StorageIndex void append(const Scalar& v, Index i) { - Index id = static_cast<Index>(m_size); + Index id = m_size; resize(m_size+1, 1); m_values[id] = v; - m_indices[id] = i; + m_indices[id] = internal::convert_index<StorageIndex>(i); } - inline size_t size() const { return m_size; } - inline size_t allocatedSize() const { return m_allocatedSize; } + inline Index size() const { return m_size; } + inline Index allocatedSize() const { return m_allocatedSize; } inline void clear() { m_size = 0; } - inline Scalar& value(size_t i) { return m_values[i]; } - inline const Scalar& value(size_t i) const { return m_values[i]; } + inline Scalar& value(Index i) { return m_values[i]; } + inline const Scalar& value(Index i) const { return m_values[i]; } - inline Index& index(size_t i) { return m_indices[i]; } - inline const Index& index(size_t i) const { return m_indices[i]; } + inline StorageIndex& index(Index i) { return m_indices[i]; } + inline const StorageIndex& index(Index i) const { return m_indices[i]; } /** \returns the largest \c k such that for all \c j in [0,k) index[\c j]\<\a key */ - inline Index searchLowerIndex(Index key) const + inline StorageIndex searchLowerIndex(StorageIndex key) const { return searchLowerIndex(0, m_size, key); } /** \returns the largest \c k in [start,end) such that for all \c j in [start,k) index[\c j]\<\a key */ - inline Index searchLowerIndex(size_t start, size_t end, Index key) const + inline Index searchLowerIndex(Index start, Index end, StorageIndex key) const { while(end>start) { - size_t mid = (end+start)>>1; + Index mid = (end+start)>>1; if (m_indices[mid]<key) start = mid+1; else end = mid; } - return static_cast<Index>(start); + return start; } /** \returns the stored value at index \a key * If the value does not exist, then the value \a defaultValue is returned without any insertion. */ - inline Scalar at(Index key, const Scalar& defaultValue = Scalar(0)) const + inline Scalar at(StorageIndex key, const Scalar& defaultValue = Scalar(0)) const { if (m_size==0) return defaultValue; @@ -138,12 +139,12 @@ class CompressedStorage return m_values[m_size-1]; // ^^ optimization: let's first check if it is the last coefficient // (very common in high level algorithms) - const size_t id = searchLowerIndex(0,m_size-1,key); + const Index id = searchLowerIndex(0,m_size-1,key); return ((id<m_size) && (m_indices[id]==key)) ? m_values[id] : defaultValue; } /** Like at(), but the search is performed in the range [start,end) */ - inline Scalar atInRange(size_t start, size_t end, Index key, const Scalar &defaultValue = Scalar(0)) const + inline Scalar atInRange(Index start, Index end, StorageIndex key, const Scalar &defaultValue = Scalar(0)) const { if (start>=end) return defaultValue; @@ -151,23 +152,23 @@ class CompressedStorage return m_values[end-1]; // ^^ optimization: let's first check if it is the last coefficient // (very common in high level algorithms) - const size_t id = searchLowerIndex(start,end-1,key); + const Index id = searchLowerIndex(start,end-1,key); return ((id<end) && (m_indices[id]==key)) ? m_values[id] : defaultValue; } /** \returns a reference to the value at index \a key * If the value does not exist, then the value \a defaultValue is inserted * such that the keys are sorted. */ - inline Scalar& atWithInsertion(Index key, const Scalar& defaultValue = Scalar(0)) + inline Scalar& atWithInsertion(StorageIndex key, const Scalar& defaultValue = Scalar(0)) { - size_t id = searchLowerIndex(0,m_size,key); + Index id = searchLowerIndex(0,m_size,key); if (id>=m_size || m_indices[id]!=key) { if (m_allocatedSize<m_size+1) { m_allocatedSize = 2*(m_size+1); internal::scoped_array<Scalar> newValues(m_allocatedSize); - internal::scoped_array<Index> newIndices(m_allocatedSize); + internal::scoped_array<StorageIndex> newIndices(m_allocatedSize); // copy first chunk internal::smart_copy(m_values, m_values +id, newValues.ptr()); @@ -196,9 +197,9 @@ class CompressedStorage void prune(const Scalar& reference, const RealScalar& epsilon = NumTraits<RealScalar>::dummy_precision()) { - size_t k = 0; - size_t n = size(); - for (size_t i=0; i<n; ++i) + Index k = 0; + Index n = size(); + for (Index i=0; i<n; ++i) { if (!internal::isMuchSmallerThan(value(i), reference, epsilon)) { @@ -212,12 +213,12 @@ class CompressedStorage protected: - inline void reallocate(size_t size) + inline void reallocate(Index size) { eigen_internal_assert(size!=m_allocatedSize); internal::scoped_array<Scalar> newValues(size); - internal::scoped_array<Index> newIndices(size); - size_t copySize = (std::min)(size, m_size); + internal::scoped_array<StorageIndex> newIndices(size); + Index copySize = (std::min)(size, m_size); internal::smart_copy(m_values, m_values+copySize, newValues.ptr()); internal::smart_copy(m_indices, m_indices+copySize, newIndices.ptr()); std::swap(m_values,newValues.ptr()); @@ -227,9 +228,9 @@ class CompressedStorage protected: Scalar* m_values; - Index* m_indices; - size_t m_size; - size_t m_allocatedSize; + StorageIndex* m_indices; + Index m_size; + Index m_allocatedSize; }; diff --git a/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h b/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h index a30522ff7..244f1b50e 100644 --- a/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h +++ b/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h @@ -18,7 +18,6 @@ template<typename Lhs, typename Rhs, typename ResultType> static void conservative_sparse_sparse_product_impl(const Lhs& lhs, const Rhs& rhs, ResultType& res, bool sortedInsertion = false) { typedef typename remove_all<Lhs>::type::Scalar Scalar; - typedef typename remove_all<Lhs>::type::Index Index; // make sure to call innerSize/outerSize since we fake the storage order. Index rows = lhs.innerSize(); @@ -137,8 +136,8 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,ColMajor,C static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res) { - typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::Index> RowMajorMatrix; - typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::Index> ColMajorMatrixAux; + typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::StorageIndex> RowMajorMatrix; + typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::StorageIndex> ColMajorMatrixAux; typedef typename sparse_eval<ColMajorMatrixAux,ResultType::RowsAtCompileTime,ResultType::ColsAtCompileTime>::type ColMajorMatrix; // If the result is tall and thin (in the extreme case a column vector) @@ -167,7 +166,7 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,RowMajor,C { static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res) { - typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::Index> RowMajorMatrix; + typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::StorageIndex> RowMajorMatrix; RowMajorMatrix rhsRow = rhs; RowMajorMatrix resRow(lhs.rows(), rhs.cols()); internal::conservative_sparse_sparse_product_impl<RowMajorMatrix,Lhs,RowMajorMatrix>(rhsRow, lhs, resRow); @@ -180,7 +179,7 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,ColMajor,R { static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res) { - typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::Index> RowMajorMatrix; + typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::StorageIndex> RowMajorMatrix; RowMajorMatrix lhsRow = lhs; RowMajorMatrix resRow(lhs.rows(), rhs.cols()); internal::conservative_sparse_sparse_product_impl<Rhs,RowMajorMatrix,RowMajorMatrix>(rhs, lhsRow, resRow); @@ -193,7 +192,7 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,RowMajor,R { static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res) { - typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::Index> RowMajorMatrix; + typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::StorageIndex> RowMajorMatrix; RowMajorMatrix resRow(lhs.rows(), rhs.cols()); internal::conservative_sparse_sparse_product_impl<Rhs,Lhs,RowMajorMatrix>(rhs, lhs, resRow); res = resRow; @@ -208,7 +207,7 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,ColMajor,C static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res) { - typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::Index> ColMajorMatrix; + typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::StorageIndex> ColMajorMatrix; ColMajorMatrix resCol(lhs.rows(), rhs.cols()); internal::conservative_sparse_sparse_product_impl<Lhs,Rhs,ColMajorMatrix>(lhs, rhs, resCol); res = resCol; @@ -220,7 +219,7 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,RowMajor,C { static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res) { - typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::Index> ColMajorMatrix; + typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::StorageIndex> ColMajorMatrix; ColMajorMatrix lhsCol = lhs; ColMajorMatrix resCol(lhs.rows(), rhs.cols()); internal::conservative_sparse_sparse_product_impl<ColMajorMatrix,Rhs,ColMajorMatrix>(lhsCol, rhs, resCol); @@ -233,7 +232,7 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,ColMajor,R { static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res) { - typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::Index> ColMajorMatrix; + typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::StorageIndex> ColMajorMatrix; ColMajorMatrix rhsCol = rhs; ColMajorMatrix resCol(lhs.rows(), rhs.cols()); internal::conservative_sparse_sparse_product_impl<Lhs,ColMajorMatrix,ColMajorMatrix>(lhs, rhsCol, resCol); @@ -246,8 +245,8 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,RowMajor,R { static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res) { - typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::Index> RowMajorMatrix; - typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::Index> ColMajorMatrix; + typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::StorageIndex> RowMajorMatrix; + typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::StorageIndex> ColMajorMatrix; RowMajorMatrix resRow(lhs.rows(),rhs.cols()); internal::conservative_sparse_sparse_product_impl<Rhs,Lhs,RowMajorMatrix>(rhs, lhs, resRow); // sort the non zeros: diff --git a/Eigen/src/SparseCore/MappedSparseMatrix.h b/Eigen/src/SparseCore/MappedSparseMatrix.h index 533479fd0..67718c85b 100644 --- a/Eigen/src/SparseCore/MappedSparseMatrix.h +++ b/Eigen/src/SparseCore/MappedSparseMatrix.h @@ -23,23 +23,23 @@ namespace Eigen { * */ namespace internal { -template<typename _Scalar, int _Flags, typename _Index> -struct traits<MappedSparseMatrix<_Scalar, _Flags, _Index> > : traits<SparseMatrix<_Scalar, _Flags, _Index> > +template<typename _Scalar, int _Flags, typename _StorageIndex> +struct traits<MappedSparseMatrix<_Scalar, _Flags, _StorageIndex> > : traits<SparseMatrix<_Scalar, _Flags, _StorageIndex> > {}; } // end namespace internal -template<typename _Scalar, int _Flags, typename _Index> +template<typename _Scalar, int _Flags, typename _StorageIndex> class MappedSparseMatrix - : public Map<SparseMatrix<_Scalar, _Flags, _Index> > + : public Map<SparseMatrix<_Scalar, _Flags, _StorageIndex> > { - typedef Map<SparseMatrix<_Scalar, _Flags, _Index> > Base; + typedef Map<SparseMatrix<_Scalar, _Flags, _StorageIndex> > Base; public: - typedef typename Base::Index Index; + typedef typename Base::StorageIndex StorageIndex; typedef typename Base::Scalar Scalar; - inline MappedSparseMatrix(Index rows, Index cols, Index nnz, Index* outerIndexPtr, Index* innerIndexPtr, Scalar* valuePtr, Index* innerNonZeroPtr = 0) + inline MappedSparseMatrix(Index rows, Index cols, Index nnz, StorageIndex* outerIndexPtr, StorageIndex* innerIndexPtr, Scalar* valuePtr, StorageIndex* innerNonZeroPtr = 0) : Base(rows, cols, nnz, outerIndexPtr, innerIndexPtr, valuePtr, innerNonZeroPtr) {} @@ -49,11 +49,11 @@ class MappedSparseMatrix namespace internal { -template<typename _Scalar, int _Options, typename _Index> -struct evaluator<MappedSparseMatrix<_Scalar,_Options,_Index> > - : evaluator<SparseCompressedBase<MappedSparseMatrix<_Scalar,_Options,_Index> > > +template<typename _Scalar, int _Options, typename _StorageIndex> +struct evaluator<MappedSparseMatrix<_Scalar,_Options,_StorageIndex> > + : evaluator<SparseCompressedBase<MappedSparseMatrix<_Scalar,_Options,_StorageIndex> > > { - typedef MappedSparseMatrix<_Scalar,_Options,_Index> XprType; + typedef MappedSparseMatrix<_Scalar,_Options,_StorageIndex> XprType; typedef evaluator<SparseCompressedBase<XprType> > Base; evaluator() : Base() {} diff --git a/Eigen/src/SparseCore/SparseAssign.h b/Eigen/src/SparseCore/SparseAssign.h index 97c079d3f..469c2b188 100644 --- a/Eigen/src/SparseCore/SparseAssign.h +++ b/Eigen/src/SparseCore/SparseAssign.h @@ -71,7 +71,6 @@ void assign_sparse_to_sparse(DstXprType &dst, const SrcXprType &src) { eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); - typedef typename DstXprType::Index Index; typedef typename DstXprType::Scalar Scalar; typedef typename internal::evaluator<DstXprType>::type DstEvaluatorType; typedef typename internal::evaluator<SrcXprType>::type SrcEvaluatorType; @@ -144,7 +143,6 @@ struct Assignment<DstXprType, SrcXprType, Functor, Sparse2Dense, Scalar> static void run(DstXprType &dst, const SrcXprType &src, const Functor &func) { eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); - typedef typename SrcXprType::Index Index; typename internal::evaluator<SrcXprType>::type srcEval(src); typename internal::evaluator<DstXprType>::type dstEval(dst); @@ -161,7 +159,6 @@ struct Assignment<DstXprType, SrcXprType, internal::assign_op<typename DstXprTyp static void run(DstXprType &dst, const SrcXprType &src, const internal::assign_op<typename DstXprType::Scalar> &) { eigen_assert(dst.rows() == src.rows() && dst.cols() == src.cols()); - typedef typename SrcXprType::Index Index; dst.setZero(); typename internal::evaluator<SrcXprType>::type srcEval(src); diff --git a/Eigen/src/SparseCore/SparseBlock.h b/Eigen/src/SparseCore/SparseBlock.h index 6b8ade5aa..40dc1a2bd 100644 --- a/Eigen/src/SparseCore/SparseBlock.h +++ b/Eigen/src/SparseCore/SparseBlock.h @@ -27,11 +27,11 @@ public: EIGEN_SPARSE_PUBLIC_INTERFACE(BlockType)
inline BlockImpl(const XprType& xpr, Index i)
- : m_matrix(xpr), m_outerStart(i), m_outerSize(OuterSize)
+ : m_matrix(xpr), m_outerStart(convert_index(i)), m_outerSize(OuterSize)
{}
inline BlockImpl(const XprType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)
- : m_matrix(xpr), m_outerStart(IsRowMajor ? startRow : startCol), m_outerSize(IsRowMajor ? blockRows : blockCols)
+ : m_matrix(xpr), m_outerStart(convert_index(IsRowMajor ? startRow : startCol)), m_outerSize(convert_index(IsRowMajor ? blockRows : blockCols))
{}
EIGEN_STRONG_INLINE Index rows() const { return IsRowMajor ? m_outerSize.value() : m_matrix.rows(); }
@@ -43,7 +43,7 @@ public: EvaluatorType matEval(m_matrix);
Index nnz = 0;
Index end = m_outerStart + m_outerSize.value();
- for(int j=m_outerStart; j<end; ++j)
+ for(Index j=m_outerStart; j<end; ++j)
for(typename EvaluatorType::InnerIterator it(matEval, j); it; ++it)
++nnz;
return nnz;
@@ -82,15 +82,16 @@ public: enum { IsRowMajor = internal::traits<BlockType>::IsRowMajor };
EIGEN_SPARSE_PUBLIC_INTERFACE(BlockType)
protected:
+ typedef typename Base::IndexVector IndexVector;
enum { OuterSize = IsRowMajor ? BlockRows : BlockCols };
public:
inline sparse_matrix_block_impl(const SparseMatrixType& xpr, Index i)
- : m_matrix(xpr), m_outerStart(i), m_outerSize(OuterSize)
+ : m_matrix(xpr), m_outerStart(convert_index(i)), m_outerSize(OuterSize)
{}
inline sparse_matrix_block_impl(const SparseMatrixType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)
- : m_matrix(xpr), m_outerStart(IsRowMajor ? startRow : startCol), m_outerSize(IsRowMajor ? blockRows : blockCols)
+ : m_matrix(xpr), m_outerStart(convert_index(IsRowMajor ? startRow : startCol)), m_outerSize(convert_index(IsRowMajor ? blockRows : blockCols))
{}
template<typename OtherDerived>
@@ -102,7 +103,7 @@ public: // and/or it is not at the end of the nonzeros of the underlying matrix.
// 1 - eval to a temporary to avoid transposition and/or aliasing issues
- SparseMatrix<Scalar, IsRowMajor ? RowMajor : ColMajor, Index> tmp(other);
+ SparseMatrix<Scalar, IsRowMajor ? RowMajor : ColMajor, StorageIndex> tmp(other);
// 2 - let's check whether there is enough allocated memory
Index nnz = tmp.nonZeros();
@@ -148,16 +149,16 @@ public: // update innerNonZeros
if(!m_matrix.isCompressed())
for(Index j=0; j<m_outerSize.value(); ++j)
- matrix.innerNonZeroPtr()[m_outerStart+j] = tmp.innerVector(j).nonZeros();
+ matrix.innerNonZeroPtr()[m_outerStart+j] = StorageIndex(tmp.innerVector(j).nonZeros());
// update outer index pointers
- Index p = start;
+ StorageIndex p = StorageIndex(start);
for(Index k=0; k<m_outerSize.value(); ++k)
{
matrix.outerIndexPtr()[m_outerStart+k] = p;
p += tmp.innerVector(k).nonZeros();
}
- std::ptrdiff_t offset = nnz - block_size;
+ StorageIndex offset = internal::convert_index<StorageIndex>(nnz - block_size);
for(Index k = m_outerStart + m_outerSize.value(); k<=matrix.outerSize(); ++k)
{
matrix.outerIndexPtr()[k] += offset;
@@ -176,30 +177,30 @@ public: inline Scalar* valuePtr()
{ return m_matrix.const_cast_derived().valuePtr(); }
- inline const Index* innerIndexPtr() const
+ inline const StorageIndex* innerIndexPtr() const
{ return m_matrix.innerIndexPtr(); }
- inline Index* innerIndexPtr()
+ inline StorageIndex* innerIndexPtr()
{ return m_matrix.const_cast_derived().innerIndexPtr(); }
- inline const Index* outerIndexPtr() const
+ inline const StorageIndex* outerIndexPtr() const
{ return m_matrix.outerIndexPtr() + m_outerStart; }
- inline Index* outerIndexPtr()
+ inline StorageIndex* outerIndexPtr()
{ return m_matrix.const_cast_derived().outerIndexPtr() + m_outerStart; }
- inline const Index* innerNonZeroPtr() const
+ inline const StorageIndex* innerNonZeroPtr() const
{ return isCompressed() ? 0 : m_matrix.innerNonZeroPtr(); }
- inline Index* innerNonZeroPtr()
+ inline StorageIndex* innerNonZeroPtr()
{ return isCompressed() ? 0 : m_matrix.const_cast_derived().innerNonZeroPtr(); }
Index nonZeros() const
{
if(m_matrix.isCompressed())
- return Index( std::size_t(m_matrix.outerIndexPtr()[m_outerStart+m_outerSize.value()])
- - std::size_t(m_matrix.outerIndexPtr()[m_outerStart]));
+ return ( (m_matrix.outerIndexPtr()[m_outerStart+m_outerSize.value()])
+ - (m_matrix.outerIndexPtr()[m_outerStart]));
else if(m_outerSize.value()==0)
return 0;
else
- return Map<const Matrix<Index,OuterSize,1> >(m_matrix.innerNonZeroPtr()+m_outerStart, m_outerSize.value()).sum();
+ return Map<const IndexVector>(m_matrix.innerNonZeroPtr()+m_outerStart, m_outerSize.value()).sum();
}
bool isCompressed() const { return m_matrix.innerNonZeroPtr()==0; }
@@ -233,13 +234,13 @@ public: } // namespace internal
-template<typename _Scalar, int _Options, typename _Index, int BlockRows, int BlockCols>
-class BlockImpl<SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols,true,Sparse>
- : public internal::sparse_matrix_block_impl<SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols>
+template<typename _Scalar, int _Options, typename _StorageIndex, int BlockRows, int BlockCols>
+class BlockImpl<SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols,true,Sparse>
+ : public internal::sparse_matrix_block_impl<SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols>
{
public:
- typedef _Index Index;
- typedef SparseMatrix<_Scalar, _Options, _Index> SparseMatrixType;
+ typedef _StorageIndex StorageIndex;
+ typedef SparseMatrix<_Scalar, _Options, _StorageIndex> SparseMatrixType;
typedef internal::sparse_matrix_block_impl<SparseMatrixType,BlockRows,BlockCols> Base;
inline BlockImpl(SparseMatrixType& xpr, Index i)
: Base(xpr, i)
@@ -252,13 +253,13 @@ public: using Base::operator=;
};
-template<typename _Scalar, int _Options, typename _Index, int BlockRows, int BlockCols>
-class BlockImpl<const SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols,true,Sparse>
- : public internal::sparse_matrix_block_impl<const SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols>
+template<typename _Scalar, int _Options, typename _StorageIndex, int BlockRows, int BlockCols>
+class BlockImpl<const SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols,true,Sparse>
+ : public internal::sparse_matrix_block_impl<const SparseMatrix<_Scalar, _Options, _StorageIndex>,BlockRows,BlockCols>
{
public:
- typedef _Index Index;
- typedef const SparseMatrix<_Scalar, _Options, _Index> SparseMatrixType;
+ typedef _StorageIndex StorageIndex;
+ typedef const SparseMatrix<_Scalar, _Options, _StorageIndex> SparseMatrixType;
typedef internal::sparse_matrix_block_impl<SparseMatrixType,BlockRows,BlockCols> Base;
inline BlockImpl(SparseMatrixType& xpr, Index i)
: Base(xpr, i)
@@ -340,8 +341,8 @@ public: */
inline BlockImpl(const XprType& xpr, Index i)
: m_matrix(xpr),
- m_startRow( (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0),
- m_startCol( (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? i : 0),
+ m_startRow( (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? convert_index(i) : 0),
+ m_startCol( (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? convert_index(i) : 0),
m_blockRows(BlockRows==1 ? 1 : xpr.rows()),
m_blockCols(BlockCols==1 ? 1 : xpr.cols())
{}
@@ -349,7 +350,7 @@ public: /** Dynamic-size constructor
*/
inline BlockImpl(const XprType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols)
- : m_matrix(xpr), m_startRow(startRow), m_startCol(startCol), m_blockRows(blockRows), m_blockCols(blockCols)
+ : m_matrix(xpr), m_startRow(convert_index(startRow)), m_startCol(convert_index(startCol)), m_blockRows(convert_index(blockRows)), m_blockCols(convert_index(blockCols))
{}
inline Index rows() const { return m_blockRows.value(); }
@@ -409,7 +410,7 @@ namespace internal { IsRowMajor = BlockType::IsRowMajor
};
typedef typename BlockType::_MatrixTypeNested _MatrixTypeNested;
- typedef typename BlockType::Index Index;
+ typedef typename BlockType::StorageIndex StorageIndex;
typedef typename _MatrixTypeNested::InnerIterator Base;
const BlockType& m_block;
Index m_end;
@@ -441,7 +442,7 @@ namespace internal { IsRowMajor = BlockType::IsRowMajor
};
typedef typename BlockType::_MatrixTypeNested _MatrixTypeNested;
- typedef typename BlockType::Index Index;
+ typedef typename BlockType::StorageIndex StorageIndex;
typedef typename BlockType::Scalar Scalar;
const BlockType& m_block;
Index m_outerPos;
@@ -498,7 +499,7 @@ struct unary_evaluator<Block<ArgType,BlockRows,BlockCols,InnerPanel>, IteratorBa class OuterVectorInnerIterator;
public:
typedef Block<ArgType,BlockRows,BlockCols,InnerPanel> XprType;
- typedef typename XprType::Index Index;
+ typedef typename XprType::StorageIndex StorageIndex;
typedef typename XprType::Scalar Scalar;
class ReverseInnerIterator;
diff --git a/Eigen/src/SparseCore/SparseColEtree.h b/Eigen/src/SparseCore/SparseColEtree.h index f8745f461..ebe02d1ab 100644 --- a/Eigen/src/SparseCore/SparseColEtree.h +++ b/Eigen/src/SparseCore/SparseColEtree.h @@ -58,30 +58,29 @@ Index etree_find (Index i, IndexVector& pp) * \param perm The permutation to apply to the column of \b mat */ template <typename MatrixType, typename IndexVector> -int coletree(const MatrixType& mat, IndexVector& parent, IndexVector& firstRowElt, typename MatrixType::Index *perm=0) +int coletree(const MatrixType& mat, IndexVector& parent, IndexVector& firstRowElt, typename MatrixType::StorageIndex *perm=0) { - typedef typename MatrixType::Index Index; - Index nc = mat.cols(); // Number of columns - Index m = mat.rows(); - Index diagSize = (std::min)(nc,m); + typedef typename MatrixType::StorageIndex StorageIndex; + StorageIndex nc = convert_index<StorageIndex>(mat.cols()); // Number of columns + StorageIndex m = convert_index<StorageIndex>(mat.rows()); + StorageIndex diagSize = (std::min)(nc,m); IndexVector root(nc); // root of subtree of etree root.setZero(); IndexVector pp(nc); // disjoint sets pp.setZero(); // Initialize disjoint sets parent.resize(mat.cols()); //Compute first nonzero column in each row - Index row,col; firstRowElt.resize(m); firstRowElt.setConstant(nc); firstRowElt.segment(0, diagSize).setLinSpaced(diagSize, 0, diagSize-1); bool found_diag; - for (col = 0; col < nc; col++) + for (StorageIndex col = 0; col < nc; col++) { - Index pcol = col; + StorageIndex pcol = col; if(perm) pcol = perm[col]; for (typename MatrixType::InnerIterator it(mat, pcol); it; ++it) { - row = it.row(); + Index row = it.row(); firstRowElt(row) = (std::min)(firstRowElt(row), col); } } @@ -89,8 +88,8 @@ int coletree(const MatrixType& mat, IndexVector& parent, IndexVector& firstRowEl except use (firstRowElt[r],c) in place of an edge (r,c) of A. Thus each row clique in A'*A is replaced by a star centered at its first vertex, which has the same fill. */ - Index rset, cset, rroot; - for (col = 0; col < nc; col++) + StorageIndex rset, cset, rroot; + for (StorageIndex col = 0; col < nc; col++) { found_diag = col>=m; pp(col) = col; @@ -99,7 +98,7 @@ int coletree(const MatrixType& mat, IndexVector& parent, IndexVector& firstRowEl parent(col) = nc; /* The diagonal element is treated here even if it does not exist in the matrix * hence the loop is executed once more */ - Index pcol = col; + StorageIndex pcol = col; if(perm) pcol = perm[col]; for (typename MatrixType::InnerIterator it(mat, pcol); it||!found_diag; ++it) { // A sequence of interleaved find and union is performed @@ -107,7 +106,7 @@ int coletree(const MatrixType& mat, IndexVector& parent, IndexVector& firstRowEl if(it) i = it.index(); if (i == col) found_diag = true; - row = firstRowElt(i); + StorageIndex row = firstRowElt(i); if (row >= col) continue; rset = internal::etree_find(row, pp); // Find the name of the set containing row rroot = root(rset); @@ -127,10 +126,11 @@ int coletree(const MatrixType& mat, IndexVector& parent, IndexVector& firstRowEl * Depth-first search from vertex n. No recursion. * This routine was contributed by Cédric Doucet, CEDRAT Group, Meylan, France. */ -template <typename Index, typename IndexVector> -void nr_etdfs (Index n, IndexVector& parent, IndexVector& first_kid, IndexVector& next_kid, IndexVector& post, Index postnum) +template <typename IndexVector> +void nr_etdfs (typename IndexVector::Scalar n, IndexVector& parent, IndexVector& first_kid, IndexVector& next_kid, IndexVector& post, typename IndexVector::Scalar postnum) { - Index current = n, first, next; + typedef typename IndexVector::Scalar StorageIndex; + StorageIndex current = n, first, next; while (postnum != n) { // No kid for the current node @@ -174,22 +174,22 @@ void nr_etdfs (Index n, IndexVector& parent, IndexVector& first_kid, IndexVector * \param parent Input tree * \param post postordered tree */ -template <typename Index, typename IndexVector> -void treePostorder(Index n, IndexVector& parent, IndexVector& post) +template <typename IndexVector> +void treePostorder(typename IndexVector::Scalar n, IndexVector& parent, IndexVector& post) { + typedef typename IndexVector::Scalar StorageIndex; IndexVector first_kid, next_kid; // Linked list of children - Index postnum; + StorageIndex postnum; // Allocate storage for working arrays and results first_kid.resize(n+1); next_kid.setZero(n+1); post.setZero(n+1); // Set up structure describing children - Index v, dad; first_kid.setConstant(-1); - for (v = n-1; v >= 0; v--) + for (StorageIndex v = n-1; v >= 0; v--) { - dad = parent(v); + StorageIndex dad = parent(v); next_kid(v) = first_kid(dad); first_kid(dad) = v; } diff --git a/Eigen/src/SparseCore/SparseCompressedBase.h b/Eigen/src/SparseCore/SparseCompressedBase.h index 00658181e..a5ba45e04 100644 --- a/Eigen/src/SparseCore/SparseCompressedBase.h +++ b/Eigen/src/SparseCore/SparseCompressedBase.h @@ -47,29 +47,29 @@ class SparseCompressedBase /** \returns a const pointer to the array of inner indices. * This function is aimed at interoperability with other libraries. * \sa valuePtr(), outerIndexPtr() */ - inline const Index* innerIndexPtr() const { return derived().innerIndexPtr(); } + inline const StorageIndex* innerIndexPtr() const { return derived().innerIndexPtr(); } /** \returns a non-const pointer to the array of inner indices. * This function is aimed at interoperability with other libraries. * \sa valuePtr(), outerIndexPtr() */ - inline Index* innerIndexPtr() { return derived().innerIndexPtr(); } + inline StorageIndex* innerIndexPtr() { return derived().innerIndexPtr(); } /** \returns a const pointer to the array of the starting positions of the inner vectors. * This function is aimed at interoperability with other libraries. * \sa valuePtr(), innerIndexPtr() */ - inline const Index* outerIndexPtr() const { return derived().outerIndexPtr(); } + inline const StorageIndex* outerIndexPtr() const { return derived().outerIndexPtr(); } /** \returns a non-const pointer to the array of the starting positions of the inner vectors. * This function is aimed at interoperability with other libraries. * \sa valuePtr(), innerIndexPtr() */ - inline Index* outerIndexPtr() { return derived().outerIndexPtr(); } + inline StorageIndex* outerIndexPtr() { return derived().outerIndexPtr(); } /** \returns a const pointer to the array of the number of non zeros of the inner vectors. * This function is aimed at interoperability with other libraries. * \warning it returns the null pointer 0 in compressed mode */ - inline const Index* innerNonZeroPtr() const { return derived().innerNonZeroPtr(); } + inline const StorageIndex* innerNonZeroPtr() const { return derived().innerNonZeroPtr(); } /** \returns a non-const pointer to the array of the number of non zeros of the inner vectors. * This function is aimed at interoperability with other libraries. * \warning it returns the null pointer 0 in compressed mode */ - inline Index* innerNonZeroPtr() { return derived().innerNonZeroPtr(); } + inline StorageIndex* innerNonZeroPtr() { return derived().innerNonZeroPtr(); } /** \returns whether \c *this is in compressed form. */ inline bool isCompressed() const { return innerNonZeroPtr()==0; } @@ -94,7 +94,7 @@ class SparseCompressedBase<Derived>::InnerIterator inline const Scalar& value() const { return m_values[m_id]; } inline Scalar& valueRef() { return const_cast<Scalar&>(m_values[m_id]); } - inline Index index() const { return m_indices[m_id]; } + inline StorageIndex index() const { return m_indices[m_id]; } inline Index outer() const { return m_outer; } inline Index row() const { return IsRowMajor ? m_outer : index(); } inline Index col() const { return IsRowMajor ? index() : m_outer; } @@ -103,7 +103,7 @@ class SparseCompressedBase<Derived>::InnerIterator protected: const Scalar* m_values; - const Index* m_indices; + const StorageIndex* m_indices; const Index m_outer; Index m_id; Index m_end; @@ -111,7 +111,7 @@ class SparseCompressedBase<Derived>::InnerIterator // If you get here, then you're not using the right InnerIterator type, e.g.: // SparseMatrix<double,RowMajor> A; // SparseMatrix<double>::InnerIterator it(A,0); - template<typename T> InnerIterator(const SparseMatrixBase<T>&,Index outer); + template<typename T> InnerIterator(const SparseMatrixBase<T>&, Index outer); }; template<typename Derived> @@ -132,7 +132,7 @@ class SparseCompressedBase<Derived>::ReverseInnerIterator inline const Scalar& value() const { return m_values[m_id-1]; } inline Scalar& valueRef() { return const_cast<Scalar&>(m_values[m_id-1]); } - inline Index index() const { return m_indices[m_id-1]; } + inline StorageIndex index() const { return m_indices[m_id-1]; } inline Index outer() const { return m_outer; } inline Index row() const { return IsRowMajor ? m_outer : index(); } inline Index col() const { return IsRowMajor ? index() : m_outer; } @@ -141,7 +141,7 @@ class SparseCompressedBase<Derived>::ReverseInnerIterator protected: const Scalar* m_values; - const Index* m_indices; + const StorageIndex* m_indices; const Index m_outer; Index m_id; const Index m_start; @@ -154,7 +154,6 @@ struct evaluator<SparseCompressedBase<Derived> > : evaluator_base<Derived> { typedef typename Derived::Scalar Scalar; - typedef typename Derived::Index Index; typedef typename Derived::InnerIterator InnerIterator; typedef typename Derived::ReverseInnerIterator ReverseInnerIterator; diff --git a/Eigen/src/SparseCore/SparseCwiseBinaryOp.h b/Eigen/src/SparseCore/SparseCwiseBinaryOp.h index 94ca9b1a4..3b4e9df59 100644 --- a/Eigen/src/SparseCore/SparseCwiseBinaryOp.h +++ b/Eigen/src/SparseCore/SparseCwiseBinaryOp.h @@ -56,7 +56,6 @@ public: class InnerIterator { typedef typename traits<XprType>::Scalar Scalar; - typedef typename XprType::Index Index; public: @@ -145,7 +144,6 @@ public: class InnerIterator { typedef typename traits<XprType>::Scalar Scalar; - typedef typename XprType::Index Index; public: @@ -223,7 +221,6 @@ public: class InnerIterator { typedef typename traits<XprType>::Scalar Scalar; - typedef typename XprType::Index Index; enum { IsRowMajor = (int(Rhs::Flags)&RowMajorBit)==RowMajorBit }; public: @@ -288,7 +285,6 @@ public: class InnerIterator { typedef typename traits<XprType>::Scalar Scalar; - typedef typename XprType::Index Index; enum { IsRowMajor = (int(Lhs::Flags)&RowMajorBit)==RowMajorBit }; public: diff --git a/Eigen/src/SparseCore/SparseCwiseUnaryOp.h b/Eigen/src/SparseCore/SparseCwiseUnaryOp.h index 32b7bc949..63d8f329c 100644 --- a/Eigen/src/SparseCore/SparseCwiseUnaryOp.h +++ b/Eigen/src/SparseCore/SparseCwiseUnaryOp.h @@ -47,7 +47,7 @@ class unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>::InnerIterat typedef typename unary_evaluator<CwiseUnaryOp<UnaryOp,ArgType>, IteratorBased>::EvalIterator Base; public: - EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, typename XprType::Index outer) + EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, Index outer) : Base(unaryOp.m_argImpl,outer), m_functor(unaryOp.m_functor) {} @@ -122,7 +122,7 @@ class unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>::InnerItera typedef typename unary_evaluator<CwiseUnaryView<ViewOp,ArgType>, IteratorBased>::EvalIterator Base; public: - EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, typename XprType::Index outer) + EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, Index outer) : Base(unaryOp.m_argImpl,outer), m_functor(unaryOp.m_functor) {} diff --git a/Eigen/src/SparseCore/SparseDenseProduct.h b/Eigen/src/SparseCore/SparseDenseProduct.h index 5aea11425..edb9d5998 100644 --- a/Eigen/src/SparseCore/SparseDenseProduct.h +++ b/Eigen/src/SparseCore/SparseDenseProduct.h @@ -29,7 +29,6 @@ struct sparse_time_dense_product_impl<SparseLhsType,DenseRhsType,DenseResType, t typedef typename internal::remove_all<SparseLhsType>::type Lhs; typedef typename internal::remove_all<DenseRhsType>::type Rhs; typedef typename internal::remove_all<DenseResType>::type Res; - typedef typename Lhs::Index Index; typedef typename evaluator<Lhs>::InnerIterator LhsInnerIterator; static void run(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res, const typename Res::Scalar& alpha) { @@ -62,7 +61,6 @@ struct sparse_time_dense_product_impl<SparseLhsType,DenseRhsType,DenseResType, A typedef typename internal::remove_all<SparseLhsType>::type Lhs; typedef typename internal::remove_all<DenseRhsType>::type Rhs; typedef typename internal::remove_all<DenseResType>::type Res; - typedef typename Lhs::Index Index; typedef typename evaluator<Lhs>::InnerIterator LhsInnerIterator; static void run(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res, const AlphaType& alpha) { @@ -86,7 +84,6 @@ struct sparse_time_dense_product_impl<SparseLhsType,DenseRhsType,DenseResType, t typedef typename internal::remove_all<SparseLhsType>::type Lhs; typedef typename internal::remove_all<DenseRhsType>::type Rhs; typedef typename internal::remove_all<DenseResType>::type Res; - typedef typename Lhs::Index Index; typedef typename evaluator<Lhs>::InnerIterator LhsInnerIterator; static void run(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res, const typename Res::Scalar& alpha) { @@ -106,7 +103,6 @@ struct sparse_time_dense_product_impl<SparseLhsType,DenseRhsType,DenseResType, t typedef typename internal::remove_all<SparseLhsType>::type Lhs; typedef typename internal::remove_all<DenseRhsType>::type Rhs; typedef typename internal::remove_all<DenseResType>::type Res; - typedef typename Lhs::Index Index; typedef typename evaluator<Lhs>::InnerIterator LhsInnerIterator; static void run(const SparseLhsType& lhs, const DenseRhsType& rhs, DenseResType& res, const typename Res::Scalar& alpha) { @@ -193,7 +189,6 @@ protected: typedef typename evaluator<ActualRhs>::type RhsEval; typedef typename evaluator<ActualLhs>::InnerIterator LhsIterator; typedef typename ProdXprType::Scalar Scalar; - typedef typename ProdXprType::Index Index; public: enum { diff --git a/Eigen/src/SparseCore/SparseDiagonalProduct.h b/Eigen/src/SparseCore/SparseDiagonalProduct.h index be935e9f3..b7598c885 100644 --- a/Eigen/src/SparseCore/SparseDiagonalProduct.h +++ b/Eigen/src/SparseCore/SparseDiagonalProduct.h @@ -66,7 +66,6 @@ struct sparse_diagonal_product_evaluator<SparseXprType, DiagonalCoeffType, SDP_A protected: typedef typename evaluator<SparseXprType>::InnerIterator SparseXprInnerIterator; typedef typename SparseXprType::Scalar Scalar; - typedef typename SparseXprType::Index Index; public: class InnerIterator : public SparseXprInnerIterator @@ -96,7 +95,6 @@ template<typename SparseXprType, typename DiagCoeffType> struct sparse_diagonal_product_evaluator<SparseXprType, DiagCoeffType, SDP_AsCwiseProduct> { typedef typename SparseXprType::Scalar Scalar; - typedef typename SparseXprType::Index Index; typedef CwiseBinaryOp<scalar_product_op<Scalar>, const typename SparseXprType::ConstInnerVectorReturnType, @@ -114,7 +112,7 @@ struct sparse_diagonal_product_evaluator<SparseXprType, DiagCoeffType, SDP_AsCwi m_outer(outer) {} - inline Scalar value() const { return m_cwiseIter.value(); } + inline Scalar value() const { return m_cwiseIter.value(); } inline Index index() const { return m_cwiseIter.index(); } inline Index outer() const { return m_outer; } inline Index col() const { return SparseXprType::IsRowMajor ? m_cwiseIter.index() : m_outer; } diff --git a/Eigen/src/SparseCore/SparseMap.h b/Eigen/src/SparseCore/SparseMap.h index 72dedb1ec..a6ff7d559 100644 --- a/Eigen/src/SparseCore/SparseMap.h +++ b/Eigen/src/SparseCore/SparseMap.h @@ -49,7 +49,7 @@ class SparseMapBase<Derived,ReadOnlyAccessors> public: typedef SparseCompressedBase<Derived> Base; typedef typename Base::Scalar Scalar; - typedef typename Base::Index Index; + typedef typename Base::StorageIndex StorageIndex; enum { IsRowMajor = Base::IsRowMajor }; using Base::operator=; protected: @@ -59,7 +59,7 @@ class SparseMapBase<Derived,ReadOnlyAccessors> Scalar *, const Scalar *>::type ScalarPointer; typedef typename internal::conditional< bool(internal::is_lvalue<Derived>::value), - Index *, const Index *>::type IndexPointer; + StorageIndex *, const StorageIndex *>::type IndexPointer; Index m_outerSize; Index m_innerSize; @@ -81,9 +81,9 @@ class SparseMapBase<Derived,ReadOnlyAccessors> //---------------------------------------- // direct access interface inline const Scalar* valuePtr() const { return m_values; } - inline const Index* innerIndexPtr() const { return m_innerIndices; } - inline const Index* outerIndexPtr() const { return m_outerIndex; } - inline const Index* innerNonZeroPtr() const { return m_innerNonZeros; } + inline const StorageIndex* innerIndexPtr() const { return m_innerIndices; } + inline const StorageIndex* outerIndexPtr() const { return m_outerIndex; } + inline const StorageIndex* innerNonZeroPtr() const { return m_innerNonZeros; } //---------------------------------------- inline Scalar coeff(Index row, Index col) const @@ -100,7 +100,7 @@ class SparseMapBase<Derived,ReadOnlyAccessors> // ^^ optimization: let's first check if it is the last coefficient // (very common in high level algorithms) - const Index* r = std::lower_bound(&m_innerIndices[start],&m_innerIndices[end-1],inner); + const StorageIndex* r = std::lower_bound(&m_innerIndices[start],&m_innerIndices[end-1],inner); const Index id = r-&m_innerIndices[0]; return ((*r==inner) && (id<end)) ? m_values[id] : Scalar(0); } @@ -127,7 +127,7 @@ class SparseMapBase<Derived,WriteAccessors> public: typedef SparseMapBase<Derived, ReadOnlyAccessors> Base; typedef typename Base::Scalar Scalar; - typedef typename Base::Index Index; + typedef typename Base::StorageIndex StorageIndex; enum { IsRowMajor = Base::IsRowMajor }; using Base::operator=; @@ -141,9 +141,9 @@ class SparseMapBase<Derived,WriteAccessors> using Base::outerIndexPtr; using Base::innerNonZeroPtr; inline Scalar* valuePtr() { return Base::m_values; } - inline Index* innerIndexPtr() { return Base::m_innerIndices; } - inline Index* outerIndexPtr() { return Base::m_outerIndex; } - inline Index* innerNonZeroPtr() { return Base::m_innerNonZeros; } + inline StorageIndex* innerIndexPtr() { return Base::m_innerIndices; } + inline StorageIndex* outerIndexPtr() { return Base::m_outerIndex; } + inline StorageIndex* innerNonZeroPtr() { return Base::m_innerNonZeros; } //---------------------------------------- inline Scalar& coeffRef(Index row, Index col) @@ -161,8 +161,8 @@ class SparseMapBase<Derived,WriteAccessors> return const_cast<Scalar*>(Base::m_values)[id]; } - inline SparseMapBase(Index rows, Index cols, Index nnz, Index* outerIndexPtr, Index* innerIndexPtr, - Scalar* valuePtr, Index* innerNonZerosPtr = 0) + inline SparseMapBase(Index rows, Index cols, Index nnz, StorageIndex* outerIndexPtr, StorageIndex* innerIndexPtr, + Scalar* valuePtr, StorageIndex* innerNonZerosPtr = 0) : Base(rows, cols, nnz, outerIndexPtr, innerIndexPtr, valuePtr, innerNonZerosPtr) {} @@ -181,8 +181,8 @@ class Map<SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType> public: - inline Map(Index rows, Index cols, Index nnz, Index* outerIndexPtr, - Index* innerIndexPtr, Scalar* valuePtr, Index* innerNonZerosPtr = 0) + inline Map(Index rows, Index cols, Index nnz, StorageIndex* outerIndexPtr, + StorageIndex* innerIndexPtr, Scalar* valuePtr, StorageIndex* innerNonZerosPtr = 0) : Base(rows, cols, nnz, outerIndexPtr, innerIndexPtr, valuePtr, innerNonZerosPtr) {} @@ -201,8 +201,8 @@ class Map<const SparseMatrix<MatScalar,MatOptions,MatIndex>, Options, StrideType public: - inline Map(Index rows, Index cols, Index nnz, const Index* outerIndexPtr, - const Index* innerIndexPtr, const Scalar* valuePtr, const Index* innerNonZerosPtr = 0) + inline Map(Index rows, Index cols, Index nnz, const StorageIndex* outerIndexPtr, + const StorageIndex* innerIndexPtr, const Scalar* valuePtr, const StorageIndex* innerNonZerosPtr = 0) : Base(rows, cols, nnz, outerIndexPtr, innerIndexPtr, valuePtr, innerNonZerosPtr) {} diff --git a/Eigen/src/SparseCore/SparseMatrix.h b/Eigen/src/SparseCore/SparseMatrix.h index 74b4c6a9d..4cf4f1826 100644 --- a/Eigen/src/SparseCore/SparseMatrix.h +++ b/Eigen/src/SparseCore/SparseMatrix.h @@ -43,7 +43,7 @@ template<typename _Scalar, int _Options, typename _Index> struct traits<SparseMatrix<_Scalar, _Options, _Index> > { typedef _Scalar Scalar; - typedef _Index Index; + typedef _Index StorageIndex; typedef Sparse StorageKind; typedef MatrixXpr XprKind; enum { @@ -65,7 +65,7 @@ struct traits<Diagonal<SparseMatrix<_Scalar, _Options, _Index>, DiagIndex> > typedef _Scalar Scalar; typedef Dense StorageKind; - typedef _Index Index; + typedef _Index StorageIndex; typedef MatrixXpr XprKind; enum { @@ -107,23 +107,24 @@ class SparseMatrix using Base::IsRowMajor; - typedef internal::CompressedStorage<Scalar,Index> Storage; + typedef internal::CompressedStorage<Scalar,StorageIndex> Storage; enum { Options = _Options }; + typedef typename Base::IndexVector IndexVector; + typedef typename Base::ScalarVector ScalarVector; protected: - typedef SparseMatrix<Scalar,(Flags&~RowMajorBit)|(IsRowMajor?RowMajorBit:0)> TransposedSparseMatrix; Index m_outerSize; Index m_innerSize; - Index* m_outerIndex; - Index* m_innerNonZeros; // optional, if null then the data is compressed + StorageIndex* m_outerIndex; + StorageIndex* m_innerNonZeros; // optional, if null then the data is compressed Storage m_data; - Eigen::Map<Matrix<Index,Dynamic,1> > innerNonZeros() { return Eigen::Map<Matrix<Index,Dynamic,1> >(m_innerNonZeros, m_innerNonZeros?m_outerSize:0); } - const Eigen::Map<const Matrix<Index,Dynamic,1> > innerNonZeros() const { return Eigen::Map<const Matrix<Index,Dynamic,1> >(m_innerNonZeros, m_innerNonZeros?m_outerSize:0); } + Eigen::Map<IndexVector> innerNonZeros() { return Eigen::Map<IndexVector>(m_innerNonZeros, m_innerNonZeros?m_outerSize:0); } + const Eigen::Map<const IndexVector> innerNonZeros() const { return Eigen::Map<const IndexVector>(m_innerNonZeros, m_innerNonZeros?m_outerSize:0); } public: @@ -149,29 +150,29 @@ class SparseMatrix /** \returns a const pointer to the array of inner indices. * This function is aimed at interoperability with other libraries. * \sa valuePtr(), outerIndexPtr() */ - inline const Index* innerIndexPtr() const { return &m_data.index(0); } + inline const StorageIndex* innerIndexPtr() const { return &m_data.index(0); } /** \returns a non-const pointer to the array of inner indices. * This function is aimed at interoperability with other libraries. * \sa valuePtr(), outerIndexPtr() */ - inline Index* innerIndexPtr() { return &m_data.index(0); } + inline StorageIndex* innerIndexPtr() { return &m_data.index(0); } /** \returns a const pointer to the array of the starting positions of the inner vectors. * This function is aimed at interoperability with other libraries. * \sa valuePtr(), innerIndexPtr() */ - inline const Index* outerIndexPtr() const { return m_outerIndex; } + inline const StorageIndex* outerIndexPtr() const { return m_outerIndex; } /** \returns a non-const pointer to the array of the starting positions of the inner vectors. * This function is aimed at interoperability with other libraries. * \sa valuePtr(), innerIndexPtr() */ - inline Index* outerIndexPtr() { return m_outerIndex; } + inline StorageIndex* outerIndexPtr() { return m_outerIndex; } /** \returns a const pointer to the array of the number of non zeros of the inner vectors. * This function is aimed at interoperability with other libraries. * \warning it returns the null pointer 0 in compressed mode */ - inline const Index* innerNonZeroPtr() const { return m_innerNonZeros; } + inline const StorageIndex* innerNonZeroPtr() const { return m_innerNonZeros; } /** \returns a non-const pointer to the array of the number of non zeros of the inner vectors. * This function is aimed at interoperability with other libraries. * \warning it returns the null pointer 0 in compressed mode */ - inline Index* innerNonZeroPtr() { return m_innerNonZeros; } + inline StorageIndex* innerNonZeroPtr() { return m_innerNonZeros; } /** \internal */ inline Storage& data() { return m_data; } @@ -187,7 +188,7 @@ class SparseMatrix const Index outer = IsRowMajor ? row : col; const Index inner = IsRowMajor ? col : row; Index end = m_innerNonZeros ? m_outerIndex[outer] + m_innerNonZeros[outer] : m_outerIndex[outer+1]; - return m_data.atInRange(m_outerIndex[outer], end, inner); + return m_data.atInRange(m_outerIndex[outer], end, StorageIndex(inner)); } /** \returns a non-const reference to the value of the matrix at position \a i, \a j @@ -210,7 +211,7 @@ class SparseMatrix eigen_assert(end>=start && "you probably called coeffRef on a non finalized matrix"); if(end<=start) return insert(row,col); - const Index p = m_data.searchLowerIndex(start,end-1,inner); + const Index p = m_data.searchLowerIndex(start,end-1,StorageIndex(inner)); if((p<end) && (m_data.index(p)==inner)) return m_data.value(p); else @@ -235,7 +236,7 @@ class SparseMatrix if(isCompressed()) { - reserve(Matrix<Index,Dynamic,1>::Constant(outerSize(), 2)); + reserve(IndexVector::Constant(outerSize(), 2)); } return insertUncompressed(row,col); } @@ -246,9 +247,9 @@ class SparseMatrix inline void setZero() { m_data.clear(); - memset(m_outerIndex, 0, (m_outerSize+1)*sizeof(Index)); + memset(m_outerIndex, 0, (m_outerSize+1)*sizeof(StorageIndex)); if(m_innerNonZeros) - memset(m_innerNonZeros, 0, (m_outerSize)*sizeof(Index)); + memset(m_innerNonZeros, 0, (m_outerSize)*sizeof(StorageIndex)); } /** \returns the number of non zero coefficients */ @@ -256,7 +257,7 @@ class SparseMatrix { if(m_innerNonZeros) return innerNonZeros().sum(); - return static_cast<Index>(m_data.size()); + return convert_index(Index(m_data.size())); } /** Preallocates \a reserveSize non zeros. @@ -298,15 +299,15 @@ class SparseMatrix { if(isCompressed()) { - std::size_t totalReserveSize = 0; + Index totalReserveSize = 0; // turn the matrix into non-compressed mode - m_innerNonZeros = static_cast<Index*>(std::malloc(m_outerSize * sizeof(Index))); + m_innerNonZeros = static_cast<StorageIndex*>(std::malloc(m_outerSize * sizeof(StorageIndex))); if (!m_innerNonZeros) internal::throw_std_bad_alloc(); // temporarily use m_innerSizes to hold the new starting points. - Index* newOuterIndex = m_innerNonZeros; + StorageIndex* newOuterIndex = m_innerNonZeros; - Index count = 0; + StorageIndex count = 0; for(Index j=0; j<m_outerSize; ++j) { newOuterIndex[j] = count; @@ -314,10 +315,10 @@ class SparseMatrix totalReserveSize += reserveSizes[j]; } m_data.reserve(totalReserveSize); - Index previousOuterIndex = m_outerIndex[m_outerSize]; + StorageIndex previousOuterIndex = m_outerIndex[m_outerSize]; for(Index j=m_outerSize-1; j>=0; --j) { - Index innerNNZ = previousOuterIndex - m_outerIndex[j]; + StorageIndex innerNNZ = previousOuterIndex - m_outerIndex[j]; for(Index i=innerNNZ-1; i>=0; --i) { m_data.index(newOuterIndex[j]+i) = m_data.index(m_outerIndex[j]+i); @@ -333,15 +334,15 @@ class SparseMatrix } else { - Index* newOuterIndex = static_cast<Index*>(std::malloc((m_outerSize+1)*sizeof(Index))); + StorageIndex* newOuterIndex = static_cast<StorageIndex*>(std::malloc((m_outerSize+1)*sizeof(StorageIndex))); if (!newOuterIndex) internal::throw_std_bad_alloc(); - Index count = 0; + StorageIndex count = 0; for(Index j=0; j<m_outerSize; ++j) { newOuterIndex[j] = count; - Index alreadyReserved = (m_outerIndex[j+1]-m_outerIndex[j]) - m_innerNonZeros[j]; - Index toReserve = std::max<Index>(reserveSizes[j], alreadyReserved); + StorageIndex alreadyReserved = (m_outerIndex[j+1]-m_outerIndex[j]) - m_innerNonZeros[j]; + StorageIndex toReserve = std::max<StorageIndex>(reserveSizes[j], alreadyReserved); count += toReserve + m_innerNonZeros[j]; } newOuterIndex[m_outerSize] = count; @@ -352,7 +353,7 @@ class SparseMatrix Index offset = newOuterIndex[j] - m_outerIndex[j]; if(offset>0) { - Index innerNNZ = m_innerNonZeros[j]; + StorageIndex innerNNZ = m_innerNonZeros[j]; for(Index i=innerNNZ-1; i>=0; --i) { m_data.index(newOuterIndex[j]+i) = m_data.index(m_outerIndex[j]+i); @@ -389,7 +390,7 @@ class SparseMatrix * \sa insertBack, startVec */ inline Scalar& insertBackByOuterInner(Index outer, Index inner) { - eigen_assert(size_t(m_outerIndex[outer+1]) == m_data.size() && "Invalid ordered insertion (invalid outer index)"); + eigen_assert(Index(m_outerIndex[outer+1]) == m_data.size() && "Invalid ordered insertion (invalid outer index)"); eigen_assert( (m_outerIndex[outer+1]-m_outerIndex[outer]==0 || m_data.index(m_data.size()-1)<inner) && "Invalid ordered insertion (invalid inner index)"); Index p = m_outerIndex[outer+1]; ++m_outerIndex[outer+1]; @@ -423,7 +424,7 @@ class SparseMatrix { if(isCompressed()) { - Index size = static_cast<Index>(m_data.size()); + StorageIndex size = internal::convert_index<StorageIndex>(m_data.size()); Index i = m_outerSize; // find the last filled column while (i>=0 && m_outerIndex[i]==0) @@ -488,7 +489,7 @@ class SparseMatrix { if(m_innerNonZeros != 0) return; - m_innerNonZeros = static_cast<Index*>(std::malloc(m_outerSize * sizeof(Index))); + m_innerNonZeros = static_cast<StorageIndex*>(std::malloc(m_outerSize * sizeof(StorageIndex))); for (Index i = 0; i < m_outerSize; i++) { m_innerNonZeros[i] = m_outerIndex[i+1] - m_outerIndex[i]; @@ -515,7 +516,7 @@ class SparseMatrix // TODO also implement a unit test makeCompressed(); - Index k = 0; + StorageIndex k = 0; for(Index j=0; j<m_outerSize; ++j) { Index previousStart = m_outerIndex[j]; @@ -548,13 +549,13 @@ class SparseMatrix Index innerChange = IsRowMajor ? cols - this->cols() : rows - this->rows(); Index outerChange = IsRowMajor ? rows - this->rows() : cols - this->cols(); - Index newInnerSize = IsRowMajor ? cols : rows; + StorageIndex newInnerSize = convert_index(IsRowMajor ? cols : rows); // Deals with inner non zeros if (m_innerNonZeros) { // Resize m_innerNonZeros - Index *newInnerNonZeros = static_cast<Index*>(std::realloc(m_innerNonZeros, (m_outerSize + outerChange) * sizeof(Index))); + StorageIndex *newInnerNonZeros = static_cast<StorageIndex*>(std::realloc(m_innerNonZeros, (m_outerSize + outerChange) * sizeof(StorageIndex))); if (!newInnerNonZeros) internal::throw_std_bad_alloc(); m_innerNonZeros = newInnerNonZeros; @@ -564,7 +565,7 @@ class SparseMatrix else if (innerChange < 0) { // Inner size decreased: allocate a new m_innerNonZeros - m_innerNonZeros = static_cast<Index*>(std::malloc((m_outerSize+outerChange+1) * sizeof(Index))); + m_innerNonZeros = static_cast<StorageIndex*>(std::malloc((m_outerSize+outerChange+1) * sizeof(StorageIndex))); if (!m_innerNonZeros) internal::throw_std_bad_alloc(); for(Index i = 0; i < m_outerSize; i++) m_innerNonZeros[i] = m_outerIndex[i+1] - m_outerIndex[i]; @@ -575,8 +576,8 @@ class SparseMatrix { for(Index i = 0; i < m_outerSize + (std::min)(outerChange, Index(0)); i++) { - Index &n = m_innerNonZeros[i]; - Index start = m_outerIndex[i]; + StorageIndex &n = m_innerNonZeros[i]; + StorageIndex start = m_outerIndex[i]; while (n > 0 && m_data.index(start+n-1) >= newInnerSize) --n; } } @@ -587,12 +588,12 @@ class SparseMatrix if (outerChange == 0) return; - Index *newOuterIndex = static_cast<Index*>(std::realloc(m_outerIndex, (m_outerSize + outerChange + 1) * sizeof(Index))); + StorageIndex *newOuterIndex = static_cast<StorageIndex*>(std::realloc(m_outerIndex, (m_outerSize + outerChange + 1) * sizeof(StorageIndex))); if (!newOuterIndex) internal::throw_std_bad_alloc(); m_outerIndex = newOuterIndex; if (outerChange > 0) { - Index last = m_outerSize == 0 ? 0 : m_outerIndex[m_outerSize]; + StorageIndex last = m_outerSize == 0 ? 0 : m_outerIndex[m_outerSize]; for(Index i=m_outerSize; i<m_outerSize+outerChange+1; i++) m_outerIndex[i] = last; } @@ -610,7 +611,7 @@ class SparseMatrix if (m_outerSize != outerSize || m_outerSize==0) { std::free(m_outerIndex); - m_outerIndex = static_cast<Index*>(std::malloc((outerSize + 1) * sizeof(Index))); + m_outerIndex = static_cast<StorageIndex*>(std::malloc((outerSize + 1) * sizeof(StorageIndex))); if (!m_outerIndex) internal::throw_std_bad_alloc(); m_outerSize = outerSize; @@ -620,7 +621,7 @@ class SparseMatrix std::free(m_innerNonZeros); m_innerNonZeros = 0; } - memset(m_outerIndex, 0, (m_outerSize+1)*sizeof(Index)); + memset(m_outerIndex, 0, (m_outerSize+1)*sizeof(StorageIndex)); } /** \internal @@ -713,9 +714,9 @@ class SparseMatrix { eigen_assert(rows() == cols() && "ONLY FOR SQUARED MATRICES"); this->m_data.resize(rows()); - Eigen::Map<Matrix<Index, Dynamic, 1> >(&this->m_data.index(0), rows()).setLinSpaced(0, rows()-1); - Eigen::Map<Matrix<Scalar, Dynamic, 1> >(&this->m_data.value(0), rows()).setOnes(); - Eigen::Map<Matrix<Index, Dynamic, 1> >(this->m_outerIndex, rows()+1).setLinSpaced(0, rows()); + Eigen::Map<IndexVector>(&this->m_data.index(0), rows()).setLinSpaced(0, StorageIndex(rows()-1)); + Eigen::Map<ScalarVector>(&this->m_data.value(0), rows()).setOnes(); + Eigen::Map<IndexVector>(this->m_outerIndex, rows()+1).setLinSpaced(0, StorageIndex(rows())); } inline SparseMatrix& operator=(const SparseMatrix& other) { @@ -806,9 +807,7 @@ protected: template<typename Other> void initAssignment(const Other& other) { - eigen_assert( other.rows() == typename Other::Index(Index(other.rows())) - && other.cols() == typename Other::Index(Index(other.cols())) ); - resize(Index(other.rows()), Index(other.cols())); + resize(other.rows(), other.cols()); if(m_innerNonZeros) { std::free(m_innerNonZeros); @@ -824,15 +823,15 @@ protected: * A vector object that is equal to 0 everywhere but v at the position i */ class SingletonVector { - Index m_index; - Index m_value; + StorageIndex m_index; + StorageIndex m_value; public: - typedef Index value_type; + typedef StorageIndex value_type; SingletonVector(Index i, Index v) - : m_index(i), m_value(v) + : m_index(convert_index(i)), m_value(convert_index(v)) {} - Index operator[](Index i) const { return i==m_index ? m_value : 0; } + StorageIndex operator[](Index i) const { return i==m_index ? m_value : 0; } }; /** \internal @@ -851,14 +850,14 @@ public: eigen_assert(m_innerNonZeros[outer]<=(m_outerIndex[outer+1] - m_outerIndex[outer])); Index p = m_outerIndex[outer] + m_innerNonZeros[outer]++; - m_data.index(p) = inner; + m_data.index(p) = convert_index(inner); return (m_data.value(p) = 0); } private: static void check_template_parameters() { - EIGEN_STATIC_ASSERT(NumTraits<Index>::IsSigned,THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE); + EIGEN_STATIC_ASSERT(NumTraits<StorageIndex>::IsSigned,THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE); EIGEN_STATIC_ASSERT((Options&(ColMajor|RowMajor))==Options,INVALID_MATRIX_TEMPLATE_PARAMETERS); } @@ -873,7 +872,6 @@ private: }; }; - namespace internal { template<typename InputIterator, typename SparseMatrixType> @@ -882,13 +880,13 @@ void set_from_triplets(const InputIterator& begin, const InputIterator& end, Spa EIGEN_UNUSED_VARIABLE(Options); enum { IsRowMajor = SparseMatrixType::IsRowMajor }; typedef typename SparseMatrixType::Scalar Scalar; - typedef typename SparseMatrixType::Index Index; - SparseMatrix<Scalar,IsRowMajor?ColMajor:RowMajor,Index> trMat(mat.rows(),mat.cols()); + typedef typename SparseMatrixType::StorageIndex StorageIndex; + SparseMatrix<Scalar,IsRowMajor?ColMajor:RowMajor,StorageIndex> trMat(mat.rows(),mat.cols()); if(begin!=end) { // pass 1: count the nnz per inner-vector - Matrix<Index,Dynamic,1> wi(trMat.outerSize()); + typename SparseMatrixType::IndexVector wi(trMat.outerSize()); wi.setZero(); for(InputIterator it(begin); it!=end; ++it) { @@ -962,13 +960,13 @@ void SparseMatrix<Scalar,_Options,_Index>::sumupDuplicates() { eigen_assert(!isCompressed()); // TODO, in practice we should be able to use m_innerNonZeros for that task - Matrix<Index,Dynamic,1> wi(innerSize()); + IndexVector wi(innerSize()); wi.fill(-1); - Index count = 0; + StorageIndex count = 0; // for each inner-vector, wi[inner_index] will hold the position of first element into the index/value buffers for(Index j=0; j<outerSize(); ++j) { - Index start = count; + StorageIndex start = count; Index oldEnd = m_outerIndex[j]+m_innerNonZeros[j]; for(Index k=m_outerIndex[j]; k<oldEnd; ++k) { @@ -1021,7 +1019,7 @@ EIGEN_DONT_INLINE SparseMatrix<Scalar,_Options,_Index>& SparseMatrix<Scalar,_Opt OtherCopyEval otherCopyEval(otherCopy); SparseMatrix dest(other.rows(),other.cols()); - Eigen::Map<Matrix<Index, Dynamic, 1> > (dest.m_outerIndex,dest.outerSize()).setZero(); + Eigen::Map<IndexVector> (dest.m_outerIndex,dest.outerSize()).setZero(); // pass 1 // FIXME the above copy could be merged with that pass @@ -1030,8 +1028,8 @@ EIGEN_DONT_INLINE SparseMatrix<Scalar,_Options,_Index>& SparseMatrix<Scalar,_Opt ++dest.m_outerIndex[it.index()]; // prefix sum - Index count = 0; - Matrix<Index,Dynamic,1> positions(dest.outerSize()); + StorageIndex count = 0; + IndexVector positions(dest.outerSize()); for (Index j=0; j<dest.outerSize(); ++j) { Index tmp = dest.m_outerIndex[j]; @@ -1043,7 +1041,7 @@ EIGEN_DONT_INLINE SparseMatrix<Scalar,_Options,_Index>& SparseMatrix<Scalar,_Opt // alloc dest.m_data.resize(count); // pass 2 - for (Index j=0; j<otherCopy.outerSize(); ++j) + for (StorageIndex j=0; j<otherCopy.outerSize(); ++j) { for (typename OtherCopyEval::InnerIterator it(otherCopyEval, j); it; ++it) { @@ -1072,14 +1070,14 @@ EIGEN_DONT_INLINE typename SparseMatrix<_Scalar,_Options,_Index>::Scalar& Sparse eigen_assert(!isCompressed()); const Index outer = IsRowMajor ? row : col; - const Index inner = IsRowMajor ? col : row; + const StorageIndex inner = convert_index(IsRowMajor ? col : row); Index room = m_outerIndex[outer+1] - m_outerIndex[outer]; - Index innerNNZ = m_innerNonZeros[outer]; + StorageIndex innerNNZ = m_innerNonZeros[outer]; if(innerNNZ>=room) { // this inner vector is full, we need to reallocate the whole buffer :( - reserve(SingletonVector(outer,std::max<Index>(2,innerNNZ))); + reserve(SingletonVector(outer,std::max<StorageIndex>(2,innerNNZ))); } Index startId = m_outerIndex[outer]; @@ -1112,7 +1110,7 @@ EIGEN_DONT_INLINE typename SparseMatrix<_Scalar,_Options,_Index>::Scalar& Sparse // we start a new inner vector while (previousOuter>=0 && m_outerIndex[previousOuter]==0) { - m_outerIndex[previousOuter] = static_cast<Index>(m_data.size()); + m_outerIndex[previousOuter] = convert_index(m_data.size()); --previousOuter; } m_outerIndex[outer+1] = m_outerIndex[outer]; 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 diff --git a/Eigen/src/SparseCore/SparsePermutation.h b/Eigen/src/SparseCore/SparsePermutation.h index 21411f232..4be93c18c 100644 --- a/Eigen/src/SparseCore/SparsePermutation.h +++ b/Eigen/src/SparseCore/SparsePermutation.h @@ -21,15 +21,15 @@ struct traits<permut_sparsematrix_product_retval<PermutationType, MatrixType, Si { typedef typename remove_all<typename MatrixType::Nested>::type MatrixTypeNestedCleaned; typedef typename MatrixTypeNestedCleaned::Scalar Scalar; - typedef typename MatrixTypeNestedCleaned::Index Index; + typedef typename MatrixTypeNestedCleaned::StorageIndex StorageIndex; enum { SrcStorageOrder = MatrixTypeNestedCleaned::Flags&RowMajorBit ? RowMajor : ColMajor, MoveOuter = SrcStorageOrder==RowMajor ? Side==OnTheLeft : Side==OnTheRight }; typedef typename internal::conditional<MoveOuter, - SparseMatrix<Scalar,SrcStorageOrder,Index>, - SparseMatrix<Scalar,int(SrcStorageOrder)==RowMajor?ColMajor:RowMajor,Index> >::type ReturnType; + SparseMatrix<Scalar,SrcStorageOrder,StorageIndex>, + SparseMatrix<Scalar,int(SrcStorageOrder)==RowMajor?ColMajor:RowMajor,StorageIndex> >::type ReturnType; }; template<typename PermutationType, typename MatrixType, int Side, bool Transposed> @@ -38,7 +38,7 @@ struct permut_sparsematrix_product_retval { typedef typename remove_all<typename MatrixType::Nested>::type MatrixTypeNestedCleaned; typedef typename MatrixTypeNestedCleaned::Scalar Scalar; - typedef typename MatrixTypeNestedCleaned::Index Index; + typedef typename MatrixTypeNestedCleaned::StorageIndex StorageIndex; enum { SrcStorageOrder = MatrixTypeNestedCleaned::Flags&RowMajorBit ? RowMajor : ColMajor, @@ -56,12 +56,12 @@ struct permut_sparsematrix_product_retval { if(MoveOuter) { - SparseMatrix<Scalar,SrcStorageOrder,Index> tmp(m_matrix.rows(), m_matrix.cols()); - Matrix<Index,Dynamic,1> sizes(m_matrix.outerSize()); + SparseMatrix<Scalar,SrcStorageOrder,StorageIndex> tmp(m_matrix.rows(), m_matrix.cols()); + Matrix<StorageIndex,Dynamic,1> sizes(m_matrix.outerSize()); for(Index j=0; j<m_matrix.outerSize(); ++j) { Index jp = m_permutation.indices().coeff(j); - sizes[((Side==OnTheLeft) ^ Transposed) ? jp : j] = m_matrix.innerVector(((Side==OnTheRight) ^ Transposed) ? jp : j).nonZeros(); + sizes[((Side==OnTheLeft) ^ Transposed) ? jp : j] = StorageIndex(m_matrix.innerVector(((Side==OnTheRight) ^ Transposed) ? jp : j).nonZeros()); } tmp.reserve(sizes); for(Index j=0; j<m_matrix.outerSize(); ++j) @@ -76,10 +76,10 @@ struct permut_sparsematrix_product_retval } else { - SparseMatrix<Scalar,int(SrcStorageOrder)==RowMajor?ColMajor:RowMajor,Index> tmp(m_matrix.rows(), m_matrix.cols()); - Matrix<Index,Dynamic,1> sizes(tmp.outerSize()); + SparseMatrix<Scalar,int(SrcStorageOrder)==RowMajor?ColMajor:RowMajor,StorageIndex> tmp(m_matrix.rows(), m_matrix.cols()); + Matrix<StorageIndex,Dynamic,1> sizes(tmp.outerSize()); sizes.setZero(); - PermutationMatrix<Dynamic,Dynamic,Index> perm; + PermutationMatrix<Dynamic,Dynamic,StorageIndex> perm; if((Side==OnTheLeft) ^ Transposed) perm = m_permutation; else diff --git a/Eigen/src/SparseCore/SparseSelfAdjointView.h b/Eigen/src/SparseCore/SparseSelfAdjointView.h index 5da7d2bef..6467d4894 100644 --- a/Eigen/src/SparseCore/SparseSelfAdjointView.h +++ b/Eigen/src/SparseCore/SparseSelfAdjointView.h @@ -33,10 +33,10 @@ struct traits<SparseSelfAdjointView<MatrixType,Mode> > : traits<MatrixType> { }; template<int SrcMode,int DstMode,typename MatrixType,int DestOrder> -void permute_symm_to_symm(const MatrixType& mat, SparseMatrix<typename MatrixType::Scalar,DestOrder,typename MatrixType::Index>& _dest, const typename MatrixType::Index* perm = 0); +void permute_symm_to_symm(const MatrixType& mat, SparseMatrix<typename MatrixType::Scalar,DestOrder,typename MatrixType::StorageIndex>& _dest, const typename MatrixType::StorageIndex* perm = 0); template<int Mode,typename MatrixType,int DestOrder> -void permute_symm_to_fullsymm(const MatrixType& mat, SparseMatrix<typename MatrixType::Scalar,DestOrder,typename MatrixType::Index>& _dest, const typename MatrixType::Index* perm = 0); +void permute_symm_to_fullsymm(const MatrixType& mat, SparseMatrix<typename MatrixType::Scalar,DestOrder,typename MatrixType::StorageIndex>& _dest, const typename MatrixType::StorageIndex* perm = 0); } @@ -48,8 +48,8 @@ template<typename MatrixType, unsigned int _Mode> class SparseSelfAdjointView enum { Mode = _Mode }; typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::Index Index; - typedef Matrix<Index,Dynamic,1> VectorI; + typedef typename MatrixType::StorageIndex StorageIndex; + typedef Matrix<StorageIndex,Dynamic,1> VectorI; typedef typename MatrixType::Nested MatrixTypeNested; typedef typename internal::remove_all<MatrixTypeNested>::type _MatrixTypeNested; @@ -117,22 +117,22 @@ template<typename MatrixType, unsigned int _Mode> class SparseSelfAdjointView SparseSelfAdjointView& rankUpdate(const SparseMatrixBase<DerivedU>& u, const Scalar& alpha = Scalar(1)); /** \internal triggered by sparse_matrix = SparseSelfadjointView; */ - template<typename DestScalar,int StorageOrder> void evalTo(SparseMatrix<DestScalar,StorageOrder,Index>& _dest) const + template<typename DestScalar,int StorageOrder> void evalTo(SparseMatrix<DestScalar,StorageOrder,StorageIndex>& _dest) const { internal::permute_symm_to_fullsymm<Mode>(m_matrix, _dest); } - template<typename DestScalar> void evalTo(DynamicSparseMatrix<DestScalar,ColMajor,Index>& _dest) const + template<typename DestScalar> void evalTo(DynamicSparseMatrix<DestScalar,ColMajor,StorageIndex>& _dest) const { // TODO directly evaluate into _dest; - SparseMatrix<DestScalar,ColMajor,Index> tmp(_dest.rows(),_dest.cols()); + SparseMatrix<DestScalar,ColMajor,StorageIndex> tmp(_dest.rows(),_dest.cols()); internal::permute_symm_to_fullsymm<Mode>(m_matrix, tmp); _dest = tmp; } /** \returns an expression of P H P^-1 */ // TODO implement twists in a more evaluator friendly fashion - SparseSymmetricPermutationProduct<_MatrixTypeNested,Mode> twistedBy(const PermutationMatrix<Dynamic,Dynamic,Index>& perm) const + SparseSymmetricPermutationProduct<_MatrixTypeNested,Mode> twistedBy(const PermutationMatrix<Dynamic,Dynamic,StorageIndex>& perm) const { return SparseSymmetricPermutationProduct<_MatrixTypeNested,Mode>(m_matrix, perm); } @@ -215,7 +215,6 @@ inline void sparse_selfadjoint_time_dense_product(const SparseLhsType& lhs, cons typedef typename evaluator<SparseLhsType>::type LhsEval; typedef typename evaluator<SparseLhsType>::InnerIterator LhsIterator; - typedef typename SparseLhsType::Index Index; typedef typename SparseLhsType::Scalar LhsScalar; enum { @@ -302,7 +301,7 @@ struct generic_product_impl<Lhs, RhsView, DenseShape, SparseSelfAdjointShape, Pr } }; -// NOTE: these two overloads are needed to evaluate the sparse sefladjoint view into a full sparse matrix +// NOTE: these two overloads are needed to evaluate the sparse selfadjoint view into a full sparse matrix // TODO: maybe the copy could be handled by generic_product_impl so that these overloads would not be needed anymore template<typename LhsView, typename Rhs, int ProductTag> @@ -353,12 +352,12 @@ protected: namespace internal { template<int Mode,typename MatrixType,int DestOrder> -void permute_symm_to_fullsymm(const MatrixType& mat, SparseMatrix<typename MatrixType::Scalar,DestOrder,typename MatrixType::Index>& _dest, const typename MatrixType::Index* perm) +void permute_symm_to_fullsymm(const MatrixType& mat, SparseMatrix<typename MatrixType::Scalar,DestOrder,typename MatrixType::StorageIndex>& _dest, const typename MatrixType::StorageIndex* perm) { - typedef typename MatrixType::Index Index; + typedef typename MatrixType::StorageIndex StorageIndex; typedef typename MatrixType::Scalar Scalar; - typedef SparseMatrix<Scalar,DestOrder,Index> Dest; - typedef Matrix<Index,Dynamic,1> VectorI; + typedef SparseMatrix<Scalar,DestOrder,StorageIndex> Dest; + typedef Matrix<StorageIndex,Dynamic,1> VectorI; Dest& dest(_dest.derived()); enum { @@ -401,16 +400,16 @@ void permute_symm_to_fullsymm(const MatrixType& mat, SparseMatrix<typename Matri count[j] = dest.outerIndexPtr()[j]; // copy data - for(Index j = 0; j<size; ++j) + for(StorageIndex j = 0; j<size; ++j) { for(typename MatrixType::InnerIterator it(mat,j); it; ++it) { - Index i = it.index(); + StorageIndex i = internal::convert_index<StorageIndex>(it.index()); Index r = it.row(); Index c = it.col(); - Index jp = perm ? perm[j] : j; - Index ip = perm ? perm[i] : i; + StorageIndex jp = perm ? perm[j] : j; + StorageIndex ip = perm ? perm[i] : i; if(Mode==(Upper|Lower)) { @@ -440,12 +439,12 @@ void permute_symm_to_fullsymm(const MatrixType& mat, SparseMatrix<typename Matri } template<int _SrcMode,int _DstMode,typename MatrixType,int DstOrder> -void permute_symm_to_symm(const MatrixType& mat, SparseMatrix<typename MatrixType::Scalar,DstOrder,typename MatrixType::Index>& _dest, const typename MatrixType::Index* perm) +void permute_symm_to_symm(const MatrixType& mat, SparseMatrix<typename MatrixType::Scalar,DstOrder,typename MatrixType::StorageIndex>& _dest, const typename MatrixType::StorageIndex* perm) { - typedef typename MatrixType::Index Index; + typedef typename MatrixType::StorageIndex StorageIndex; typedef typename MatrixType::Scalar Scalar; - SparseMatrix<Scalar,DstOrder,Index>& dest(_dest.derived()); - typedef Matrix<Index,Dynamic,1> VectorI; + SparseMatrix<Scalar,DstOrder,StorageIndex>& dest(_dest.derived()); + typedef Matrix<StorageIndex,Dynamic,1> VectorI; enum { SrcOrder = MatrixType::IsRowMajor ? RowMajor : ColMajor, StorageOrderMatch = int(SrcOrder) == int(DstOrder), @@ -457,16 +456,16 @@ void permute_symm_to_symm(const MatrixType& mat, SparseMatrix<typename MatrixTyp VectorI count(size); count.setZero(); dest.resize(size,size); - for(Index j = 0; j<size; ++j) + for(StorageIndex j = 0; j<size; ++j) { - Index jp = perm ? perm[j] : j; + StorageIndex jp = perm ? perm[j] : j; for(typename MatrixType::InnerIterator it(mat,j); it; ++it) { - Index i = it.index(); + StorageIndex i = it.index(); if((int(SrcMode)==int(Lower) && i<j) || (int(SrcMode)==int(Upper) && i>j)) continue; - Index ip = perm ? perm[i] : i; + StorageIndex ip = perm ? perm[i] : i; count[int(DstMode)==int(Lower) ? (std::min)(ip,jp) : (std::max)(ip,jp)]++; } } @@ -477,17 +476,17 @@ void permute_symm_to_symm(const MatrixType& mat, SparseMatrix<typename MatrixTyp for(Index j=0; j<size; ++j) count[j] = dest.outerIndexPtr()[j]; - for(Index j = 0; j<size; ++j) + for(StorageIndex j = 0; j<size; ++j) { for(typename MatrixType::InnerIterator it(mat,j); it; ++it) { - Index i = it.index(); + StorageIndex i = it.index(); if((int(SrcMode)==int(Lower) && i<j) || (int(SrcMode)==int(Upper) && i>j)) continue; - Index jp = perm ? perm[j] : j; - Index ip = perm? perm[i] : i; + StorageIndex jp = perm ? perm[j] : j; + StorageIndex ip = perm? perm[i] : i; Index k = count[int(DstMode)==int(Lower) ? (std::min)(ip,jp) : (std::max)(ip,jp)]++; dest.innerIndexPtr()[k] = int(DstMode)==int(Lower) ? (std::max)(ip,jp) : (std::min)(ip,jp); @@ -519,11 +518,11 @@ class SparseSymmetricPermutationProduct { public: typedef typename MatrixType::Scalar Scalar; - typedef typename MatrixType::Index Index; + typedef typename MatrixType::StorageIndex StorageIndex; protected: - typedef PermutationMatrix<Dynamic,Dynamic,Index> Perm; + typedef PermutationMatrix<Dynamic,Dynamic,StorageIndex> Perm; public: - typedef Matrix<Index,Dynamic,1> VectorI; + typedef Matrix<StorageIndex,Dynamic,1> VectorI; typedef typename MatrixType::Nested MatrixTypeNested; typedef typename internal::remove_all<MatrixTypeNested>::type _MatrixTypeNested; diff --git a/Eigen/src/SparseCore/SparseSolverBase.h b/Eigen/src/SparseCore/SparseSolverBase.h index df4e2f017..1cb7080cf 100644 --- a/Eigen/src/SparseCore/SparseSolverBase.h +++ b/Eigen/src/SparseCore/SparseSolverBase.h @@ -24,16 +24,16 @@ void solve_sparse_through_dense_panels(const Decomposition &dec, const Rhs& rhs, EIGEN_STATIC_ASSERT((Dest::Flags&RowMajorBit)==0,THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES); typedef typename Dest::Scalar DestScalar; // we process the sparse rhs per block of NbColsAtOnce columns temporarily stored into a dense matrix. - static const int NbColsAtOnce = 4; - int rhsCols = rhs.cols(); - int size = rhs.rows(); + static const Index NbColsAtOnce = 4; + Index rhsCols = rhs.cols(); + Index size = rhs.rows(); // the temporary matrices do not need more columns than NbColsAtOnce: - int tmpCols = (std::min)(rhsCols, NbColsAtOnce); + Index tmpCols = (std::min)(rhsCols, NbColsAtOnce); Eigen::Matrix<DestScalar,Dynamic,Dynamic> tmp(size,tmpCols); Eigen::Matrix<DestScalar,Dynamic,Dynamic> tmpX(size,tmpCols); - for(int k=0; k<rhsCols; k+=NbColsAtOnce) + for(Index k=0; k<rhsCols; k+=NbColsAtOnce) { - int actualCols = std::min<int>(rhsCols-k, NbColsAtOnce); + Index actualCols = std::min<Index>(rhsCols-k, NbColsAtOnce); tmp.leftCols(actualCols) = rhs.middleCols(k,actualCols); tmpX.leftCols(actualCols) = dec.solve(tmp.leftCols(actualCols)); dest.middleCols(k,actualCols) = tmpX.leftCols(actualCols).sparseView(); diff --git a/Eigen/src/SparseCore/SparseSparseProductWithPruning.h b/Eigen/src/SparseCore/SparseSparseProductWithPruning.h index f291f8cef..3db01bf2d 100644 --- a/Eigen/src/SparseCore/SparseSparseProductWithPruning.h +++ b/Eigen/src/SparseCore/SparseSparseProductWithPruning.h @@ -22,7 +22,7 @@ static void sparse_sparse_product_with_pruning_impl(const Lhs& lhs, const Rhs& r // return sparse_sparse_product_with_pruning_impl2(lhs,rhs,res); typedef typename remove_all<Lhs>::type::Scalar Scalar; - typedef typename remove_all<Lhs>::type::Index Index; + typedef typename remove_all<Lhs>::type::StorageIndex StorageIndex; // make sure to call innerSize/outerSize since we fake the storage order. Index rows = lhs.innerSize(); @@ -31,7 +31,7 @@ static void sparse_sparse_product_with_pruning_impl(const Lhs& lhs, const Rhs& r eigen_assert(lhs.outerSize() == rhs.innerSize()); // allocate a temporary buffer - AmbiVector<Scalar,Index> tempVector(rows); + AmbiVector<Scalar,StorageIndex> tempVector(rows); // estimate the number of non zero entries // given a rhs column containing Y non zeros, we assume that the respective Y columns @@ -70,7 +70,7 @@ static void sparse_sparse_product_with_pruning_impl(const Lhs& lhs, const Rhs& r } } res.startVec(j); - for (typename AmbiVector<Scalar,Index>::Iterator it(tempVector,tolerance); it; ++it) + for (typename AmbiVector<Scalar,StorageIndex>::Iterator it(tempVector,tolerance); it; ++it) res.insertBackByOuterInner(j,it.index()) = it.value(); } res.finalize(); @@ -103,7 +103,7 @@ struct sparse_sparse_product_with_pruning_selector<Lhs,Rhs,ResultType,ColMajor,C static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res, const RealScalar& tolerance) { // we need a col-major matrix to hold the result - typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::Index> SparseTemporaryType; + typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::StorageIndex> SparseTemporaryType; SparseTemporaryType _res(res.rows(), res.cols()); internal::sparse_sparse_product_with_pruning_impl<Lhs,Rhs,SparseTemporaryType>(lhs, rhs, _res, tolerance); res = _res; @@ -129,8 +129,8 @@ struct sparse_sparse_product_with_pruning_selector<Lhs,Rhs,ResultType,RowMajor,R typedef typename ResultType::RealScalar RealScalar; static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res, const RealScalar& tolerance) { - typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename Lhs::Index> ColMajorMatrixLhs; - typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename Lhs::Index> ColMajorMatrixRhs; + typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename Lhs::StorageIndex> ColMajorMatrixLhs; + typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename Lhs::StorageIndex> ColMajorMatrixRhs; ColMajorMatrixLhs colLhs(lhs); ColMajorMatrixRhs colRhs(rhs); internal::sparse_sparse_product_with_pruning_impl<ColMajorMatrixLhs,ColMajorMatrixRhs,ResultType>(colLhs, colRhs, res, tolerance); @@ -149,7 +149,7 @@ struct sparse_sparse_product_with_pruning_selector<Lhs,Rhs,ResultType,ColMajor,R typedef typename ResultType::RealScalar RealScalar; static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res, const RealScalar& tolerance) { - typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename Lhs::Index> RowMajorMatrixLhs; + typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename Lhs::StorageIndex> RowMajorMatrixLhs; RowMajorMatrixLhs rowLhs(lhs); sparse_sparse_product_with_pruning_selector<RowMajorMatrixLhs,Rhs,ResultType,RowMajor,RowMajor>(rowLhs,rhs,res,tolerance); } @@ -161,7 +161,7 @@ struct sparse_sparse_product_with_pruning_selector<Lhs,Rhs,ResultType,RowMajor,C typedef typename ResultType::RealScalar RealScalar; static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res, const RealScalar& tolerance) { - typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename Lhs::Index> RowMajorMatrixRhs; + typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename Lhs::StorageIndex> RowMajorMatrixRhs; RowMajorMatrixRhs rowRhs(rhs); sparse_sparse_product_with_pruning_selector<Lhs,RowMajorMatrixRhs,ResultType,RowMajor,RowMajor,RowMajor>(lhs,rowRhs,res,tolerance); } @@ -173,7 +173,7 @@ struct sparse_sparse_product_with_pruning_selector<Lhs,Rhs,ResultType,ColMajor,R typedef typename ResultType::RealScalar RealScalar; static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res, const RealScalar& tolerance) { - typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename Lhs::Index> ColMajorMatrixRhs; + typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename Lhs::StorageIndex> ColMajorMatrixRhs; ColMajorMatrixRhs colRhs(rhs); internal::sparse_sparse_product_with_pruning_impl<Lhs,ColMajorMatrixRhs,ResultType>(lhs, colRhs, res, tolerance); } @@ -185,7 +185,7 @@ struct sparse_sparse_product_with_pruning_selector<Lhs,Rhs,ResultType,RowMajor,C typedef typename ResultType::RealScalar RealScalar; static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res, const RealScalar& tolerance) { - typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename Lhs::Index> ColMajorMatrixLhs; + typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename Lhs::StorageIndex> ColMajorMatrixLhs; ColMajorMatrixLhs colLhs(lhs); internal::sparse_sparse_product_with_pruning_impl<ColMajorMatrixLhs,Rhs,ResultType>(colLhs, rhs, res, tolerance); } diff --git a/Eigen/src/SparseCore/SparseTranspose.h b/Eigen/src/SparseCore/SparseTranspose.h index 37ce7b0d5..45d9c6700 100644 --- a/Eigen/src/SparseCore/SparseTranspose.h +++ b/Eigen/src/SparseCore/SparseTranspose.h @@ -26,17 +26,17 @@ namespace internal { public: using Base::derived; typedef typename Base::Scalar Scalar; - typedef typename Base::Index Index; + typedef typename Base::StorageIndex StorageIndex; inline const Scalar* valuePtr() const { return derived().nestedExpression().valuePtr(); } - inline const Index* innerIndexPtr() const { return derived().nestedExpression().innerIndexPtr(); } - inline const Index* outerIndexPtr() const { return derived().nestedExpression().outerIndexPtr(); } - inline const Index* innerNonZeroPtr() const { return derived().nestedExpression().innerNonZeroPtr(); } + inline const StorageIndex* innerIndexPtr() const { return derived().nestedExpression().innerIndexPtr(); } + inline const StorageIndex* outerIndexPtr() const { return derived().nestedExpression().outerIndexPtr(); } + inline const StorageIndex* innerNonZeroPtr() const { return derived().nestedExpression().innerNonZeroPtr(); } inline Scalar* valuePtr() { return derived().nestedExpression().valuePtr(); } - inline Index* innerIndexPtr() { return derived().nestedExpression().innerIndexPtr(); } - inline Index* outerIndexPtr() { return derived().nestedExpression().outerIndexPtr(); } - inline Index* innerNonZeroPtr() { return derived().nestedExpression().innerNonZeroPtr(); } + inline StorageIndex* innerIndexPtr() { return derived().nestedExpression().innerIndexPtr(); } + inline StorageIndex* outerIndexPtr() { return derived().nestedExpression().outerIndexPtr(); } + inline StorageIndex* innerNonZeroPtr() { return derived().nestedExpression().innerNonZeroPtr(); } }; } @@ -48,7 +48,7 @@ template<typename MatrixType> class TransposeImpl<MatrixType,Sparse> protected: typedef internal::SparseTransposeImpl<MatrixType> Base; public: - inline typename MatrixType::Index nonZeros() const { return Base::derived().nestedExpression().nonZeros(); } + inline Index nonZeros() const { return Base::derived().nestedExpression().nonZeros(); } }; namespace internal { @@ -61,12 +61,11 @@ struct unary_evaluator<Transpose<ArgType>, IteratorBased> typedef typename evaluator<ArgType>::ReverseInnerIterator EvalReverseIterator; public: typedef Transpose<ArgType> XprType; - typedef typename XprType::Index Index; class InnerIterator : public EvalIterator { public: - EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, typename XprType::Index outer) + EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& unaryOp, Index outer) : EvalIterator(unaryOp.m_argImpl,outer) {} @@ -77,7 +76,7 @@ struct unary_evaluator<Transpose<ArgType>, IteratorBased> class ReverseInnerIterator : public EvalReverseIterator { public: - EIGEN_STRONG_INLINE ReverseInnerIterator(const unary_evaluator& unaryOp, typename XprType::Index outer) + EIGEN_STRONG_INLINE ReverseInnerIterator(const unary_evaluator& unaryOp, Index outer) : EvalReverseIterator(unaryOp.m_argImpl,outer) {} diff --git a/Eigen/src/SparseCore/SparseTriangularView.h b/Eigen/src/SparseCore/SparseTriangularView.h index b044d6778..b5fbcbdde 100644 --- a/Eigen/src/SparseCore/SparseTriangularView.h +++ b/Eigen/src/SparseCore/SparseTriangularView.h @@ -64,7 +64,6 @@ template<typename MatrixType, unsigned int Mode> class TriangularViewImpl<MatrixType,Mode,Sparse>::InnerIterator : public MatrixTypeNestedCleaned::InnerIterator { typedef typename MatrixTypeNestedCleaned::InnerIterator Base; - typedef typename TriangularViewType::Index Index; public: EIGEN_STRONG_INLINE InnerIterator(const TriangularViewImpl& view, Index outer) @@ -134,7 +133,6 @@ template<typename MatrixType, unsigned int Mode> class TriangularViewImpl<MatrixType,Mode,Sparse>::ReverseInnerIterator : public MatrixTypeNestedCleaned::ReverseInnerIterator { typedef typename MatrixTypeNestedCleaned::ReverseInnerIterator Base; - typedef typename TriangularViewImpl::Index Index; public: EIGEN_STRONG_INLINE ReverseInnerIterator(const TriangularViewType& view, Index outer) @@ -175,7 +173,6 @@ struct unary_evaluator<TriangularView<ArgType,Mode>, IteratorBased> protected: typedef typename XprType::Scalar Scalar; - typedef typename XprType::Index Index; typedef typename evaluator<ArgType>::InnerIterator EvalIterator; enum { SkipFirst = ((Mode&Lower) && !(ArgType::Flags&RowMajorBit)) diff --git a/Eigen/src/SparseCore/SparseUtil.h b/Eigen/src/SparseCore/SparseUtil.h index ba4803646..ac2b4f10b 100644 --- a/Eigen/src/SparseCore/SparseUtil.h +++ b/Eigen/src/SparseCore/SparseUtil.h @@ -43,19 +43,21 @@ EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \ EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \ EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=) +// TODO this is mostly the same as EIGEN_GENERIC_PUBLIC_INTERFACE #define _EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) \ typedef typename Eigen::internal::traits<Derived >::Scalar Scalar; \ typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \ typedef typename Eigen::internal::nested<Derived >::type Nested; \ typedef typename Eigen::internal::traits<Derived >::StorageKind StorageKind; \ - typedef typename Eigen::internal::traits<Derived >::Index Index; \ + typedef typename Eigen::internal::traits<Derived >::StorageIndex StorageIndex; \ enum { RowsAtCompileTime = Eigen::internal::traits<Derived >::RowsAtCompileTime, \ ColsAtCompileTime = Eigen::internal::traits<Derived >::ColsAtCompileTime, \ Flags = Eigen::internal::traits<Derived>::Flags, \ SizeAtCompileTime = Base::SizeAtCompileTime, \ IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \ using Base::derived; \ - using Base::const_cast_derived; + using Base::const_cast_derived; \ + using Base::convert_index; #define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) \ typedef Eigen::SparseMatrixBase<Derived > Base; \ @@ -67,10 +69,10 @@ const int OuterRandomAccessPattern = 0x4 | CoherentAccessPattern; const int RandomAccessPattern = 0x8 | OuterRandomAccessPattern | InnerRandomAccessPattern; template<typename Derived> class SparseMatrixBase; -template<typename _Scalar, int _Flags = 0, typename _Index = int> class SparseMatrix; -template<typename _Scalar, int _Flags = 0, typename _Index = int> class DynamicSparseMatrix; -template<typename _Scalar, int _Flags = 0, typename _Index = int> class SparseVector; -template<typename _Scalar, int _Flags = 0, typename _Index = int> class MappedSparseMatrix; +template<typename _Scalar, int _Flags = 0, typename _StorageIndex = int> class SparseMatrix; +template<typename _Scalar, int _Flags = 0, typename _StorageIndex = int> class DynamicSparseMatrix; +template<typename _Scalar, int _Flags = 0, typename _StorageIndex = int> class SparseVector; +template<typename _Scalar, int _Flags = 0, typename _StorageIndex = int> class MappedSparseMatrix; template<typename MatrixType, unsigned int UpLo> class SparseSelfAdjointView; template<typename Lhs, typename Rhs> class SparseDiagonalProduct; @@ -99,24 +101,25 @@ template<typename T> struct eval<T,Sparse> template<typename T,int Cols> struct sparse_eval<T,1,Cols> { typedef typename traits<T>::Scalar _Scalar; - typedef typename traits<T>::Index _Index; + typedef typename traits<T>::StorageIndex _StorageIndex; public: - typedef SparseVector<_Scalar, RowMajor, _Index> type; + typedef SparseVector<_Scalar, RowMajor, _StorageIndex> type; }; template<typename T,int Rows> struct sparse_eval<T,Rows,1> { typedef typename traits<T>::Scalar _Scalar; - typedef typename traits<T>::Index _Index; + typedef typename traits<T>::StorageIndex _StorageIndex; public: - typedef SparseVector<_Scalar, ColMajor, _Index> type; + typedef SparseVector<_Scalar, ColMajor, _StorageIndex> type; }; +// TODO this seems almost identical to plain_matrix_type<T, Sparse> template<typename T,int Rows,int Cols> struct sparse_eval { typedef typename traits<T>::Scalar _Scalar; - typedef typename traits<T>::Index _Index; + typedef typename traits<T>::StorageIndex _StorageIndex; enum { _Options = ((traits<T>::Flags&RowMajorBit)==RowMajorBit) ? RowMajor : ColMajor }; public: - typedef SparseMatrix<_Scalar, _Options, _Index> type; + typedef SparseMatrix<_Scalar, _Options, _StorageIndex> type; }; template<typename T> struct sparse_eval<T,1,1> { @@ -128,10 +131,10 @@ template<typename T> struct sparse_eval<T,1,1> { template<typename T> struct plain_matrix_type<T,Sparse> { typedef typename traits<T>::Scalar _Scalar; - typedef typename traits<T>::Index _Index; + typedef typename traits<T>::StorageIndex _StorageIndex; enum { _Options = ((evaluator<T>::Flags&RowMajorBit)==RowMajorBit) ? RowMajor : ColMajor }; public: - typedef SparseMatrix<_Scalar, _Options, _Index> type; + typedef SparseMatrix<_Scalar, _Options, _StorageIndex> type; }; template<typename Decomposition, typename RhsType> @@ -162,26 +165,26 @@ template<> struct glue_shapes<SparseShape,TriangularShape > { typedef SparseTria * * \sa SparseMatrix::setFromTriplets() */ -template<typename Scalar, typename Index=typename SparseMatrix<Scalar>::Index > +template<typename Scalar, typename StorageIndex=typename SparseMatrix<Scalar>::StorageIndex > class Triplet { public: Triplet() : m_row(0), m_col(0), m_value(0) {} - Triplet(const Index& i, const Index& j, const Scalar& v = Scalar(0)) + Triplet(const StorageIndex& i, const StorageIndex& j, const Scalar& v = Scalar(0)) : m_row(i), m_col(j), m_value(v) {} /** \returns the row index of the element */ - const Index& row() const { return m_row; } + const StorageIndex& row() const { return m_row; } /** \returns the column index of the element */ - const Index& col() const { return m_col; } + const StorageIndex& col() const { return m_col; } /** \returns the value of the element */ const Scalar& value() const { return m_value; } protected: - Index m_row, m_col; + StorageIndex m_row, m_col; Scalar m_value; }; diff --git a/Eigen/src/SparseCore/SparseVector.h b/Eigen/src/SparseCore/SparseVector.h index 8b696a476..35bcec819 100644 --- a/Eigen/src/SparseCore/SparseVector.h +++ b/Eigen/src/SparseCore/SparseVector.h @@ -26,11 +26,11 @@ namespace Eigen { */ namespace internal { -template<typename _Scalar, int _Options, typename _Index> -struct traits<SparseVector<_Scalar, _Options, _Index> > +template<typename _Scalar, int _Options, typename _StorageIndex> +struct traits<SparseVector<_Scalar, _Options, _StorageIndex> > { typedef _Scalar Scalar; - typedef _Index Index; + typedef _StorageIndex StorageIndex; typedef Sparse StorageKind; typedef MatrixXpr XprKind; enum { @@ -61,9 +61,9 @@ struct sparse_vector_assign_selector; } -template<typename _Scalar, int _Options, typename _Index> +template<typename _Scalar, int _Options, typename _StorageIndex> class SparseVector - : public SparseMatrixBase<SparseVector<_Scalar, _Options, _Index> > + : public SparseMatrixBase<SparseVector<_Scalar, _Options, _StorageIndex> > { typedef SparseMatrixBase<SparseVector> SparseBase; @@ -72,7 +72,7 @@ class SparseVector EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(SparseVector, +=) EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(SparseVector, -=) - typedef internal::CompressedStorage<Scalar,Index> Storage; + typedef internal::CompressedStorage<Scalar,StorageIndex> Storage; enum { IsColVector = internal::traits<SparseVector>::IsColVector }; enum { @@ -87,8 +87,8 @@ class SparseVector EIGEN_STRONG_INLINE const Scalar* valuePtr() const { return &m_data.value(0); } EIGEN_STRONG_INLINE Scalar* valuePtr() { return &m_data.value(0); } - EIGEN_STRONG_INLINE const Index* innerIndexPtr() const { return &m_data.index(0); } - EIGEN_STRONG_INLINE Index* innerIndexPtr() { return &m_data.index(0); } + EIGEN_STRONG_INLINE const StorageIndex* innerIndexPtr() const { return &m_data.index(0); } + EIGEN_STRONG_INLINE StorageIndex* innerIndexPtr() { return &m_data.index(0); } /** \internal */ inline Storage& data() { return m_data; } @@ -103,7 +103,7 @@ class SparseVector inline Scalar coeff(Index i) const { eigen_assert(i>=0 && i<m_size); - return m_data.at(i); + return m_data.at(StorageIndex(i)); } inline Scalar& coeffRef(Index row, Index col) @@ -121,7 +121,7 @@ class SparseVector inline Scalar& coeffRef(Index i) { eigen_assert(i>=0 && i<m_size); - return m_data.atWithInsertion(i); + return m_data.atWithInsertion(StorageIndex(i)); } public: @@ -132,7 +132,7 @@ class SparseVector inline void setZero() { m_data.clear(); } /** \returns the number of non zero coefficients */ - inline Index nonZeros() const { return static_cast<Index>(m_data.size()); } + inline Index nonZeros() const { return m_data.size(); } inline void startVec(Index outer) { @@ -188,7 +188,7 @@ class SparseVector m_data.value(p+1) = m_data.value(p); --p; } - m_data.index(p+1) = i; + m_data.index(p+1) = convert_index(i); m_data.value(p+1) = 0; return m_data.value(p+1); } @@ -207,7 +207,7 @@ class SparseVector void resize(Index rows, Index cols) { - eigen_assert(rows==1 || cols==1); + eigen_assert((IsColVector ? cols : rows)==1 && "Outer dimension must equal 1"); resize(IsColVector ? rows : cols); } @@ -348,7 +348,7 @@ protected: static void check_template_parameters() { - EIGEN_STATIC_ASSERT(NumTraits<Index>::IsSigned,THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE); + EIGEN_STATIC_ASSERT(NumTraits<StorageIndex>::IsSigned,THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE); EIGEN_STATIC_ASSERT((_Options&(ColMajor|RowMajor))==Options,INVALID_MATRIX_TEMPLATE_PARAMETERS); } @@ -356,19 +356,19 @@ protected: Index m_size; }; -template<typename Scalar, int _Options, typename _Index> -class SparseVector<Scalar,_Options,_Index>::InnerIterator +template<typename Scalar, int _Options, typename _StorageIndex> +class SparseVector<Scalar,_Options,_StorageIndex>::InnerIterator { public: explicit InnerIterator(const SparseVector& vec, Index outer=0) - : m_data(vec.m_data), m_id(0), m_end(static_cast<Index>(m_data.size())) + : m_data(vec.m_data), m_id(0), m_end(m_data.size()) { EIGEN_UNUSED_VARIABLE(outer); eigen_assert(outer==0); } - explicit InnerIterator(const internal::CompressedStorage<Scalar,Index>& data) - : m_data(data), m_id(0), m_end(static_cast<Index>(m_data.size())) + explicit InnerIterator(const internal::CompressedStorage<Scalar,StorageIndex>& data) + : m_data(data), m_id(0), m_end(m_data.size()) {} inline InnerIterator& operator++() { m_id++; return *this; } @@ -383,7 +383,7 @@ class SparseVector<Scalar,_Options,_Index>::InnerIterator inline operator bool() const { return (m_id < m_end); } protected: - const internal::CompressedStorage<Scalar,Index>& m_data; + const internal::CompressedStorage<Scalar,StorageIndex>& m_data; Index m_id; const Index m_end; private: @@ -393,19 +393,19 @@ class SparseVector<Scalar,_Options,_Index>::InnerIterator template<typename T> InnerIterator(const SparseMatrixBase<T>&,Index outer=0); }; -template<typename Scalar, int _Options, typename _Index> -class SparseVector<Scalar,_Options,_Index>::ReverseInnerIterator +template<typename Scalar, int _Options, typename _StorageIndex> +class SparseVector<Scalar,_Options,_StorageIndex>::ReverseInnerIterator { public: explicit ReverseInnerIterator(const SparseVector& vec, Index outer=0) - : m_data(vec.m_data), m_id(static_cast<Index>(m_data.size())), m_start(0) + : m_data(vec.m_data), m_id(m_data.size()), m_start(0) { EIGEN_UNUSED_VARIABLE(outer); eigen_assert(outer==0); } - explicit ReverseInnerIterator(const internal::CompressedStorage<Scalar,Index>& data) - : m_data(data), m_id(static_cast<Index>(m_data.size())), m_start(0) + explicit ReverseInnerIterator(const internal::CompressedStorage<Scalar,StorageIndex>& data) + : m_data(data), m_id(m_data.size()), m_start(0) {} inline ReverseInnerIterator& operator--() { m_id--; return *this; } @@ -420,7 +420,7 @@ class SparseVector<Scalar,_Options,_Index>::ReverseInnerIterator inline operator bool() const { return (m_id > m_start); } protected: - const internal::CompressedStorage<Scalar,Index>& m_data; + const internal::CompressedStorage<Scalar,StorageIndex>& m_data; Index m_id; const Index m_start; }; @@ -465,7 +465,7 @@ struct sparse_vector_assign_selector<Dest,Src,SVA_Outer> { eigen_internal_assert(src.outerSize()==src.size()); typedef typename internal::evaluator<Src>::type SrcEvaluatorType; SrcEvaluatorType srcEval(src); - for(typename Dest::Index i=0; i<src.size(); ++i) + for(Index i=0; i<src.size(); ++i) { typename SrcEvaluatorType::InnerIterator it(srcEval, i); if(it) diff --git a/Eigen/src/SparseCore/SparseView.h b/Eigen/src/SparseCore/SparseView.h index 40a3019fa..1c69aa458 100644 --- a/Eigen/src/SparseCore/SparseView.h +++ b/Eigen/src/SparseCore/SparseView.h @@ -18,7 +18,7 @@ namespace internal { template<typename MatrixType> struct traits<SparseView<MatrixType> > : traits<MatrixType> { - typedef typename MatrixType::Index Index; + typedef typename MatrixType::StorageIndex StorageIndex; typedef Sparse StorageKind; enum { Flags = int(traits<MatrixType>::Flags) & (RowMajorBit) @@ -78,7 +78,7 @@ struct unary_evaluator<SparseView<ArgType>, IteratorBased> typedef typename XprType::Scalar Scalar; public: - EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& sve, typename XprType::Index outer) + EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& sve, Index outer) : EvalIterator(sve.m_argImpl,outer), m_view(sve.m_view) { incrementToNonZero(); @@ -126,7 +126,6 @@ struct unary_evaluator<SparseView<ArgType>, IndexBased> typedef SparseView<ArgType> XprType; protected: enum { IsRowMajor = (XprType::Flags&RowMajorBit)==RowMajorBit }; - typedef typename XprType::Index Index; typedef typename XprType::Scalar Scalar; public: @@ -134,7 +133,7 @@ struct unary_evaluator<SparseView<ArgType>, IndexBased> { public: - EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& sve, typename XprType::Index outer) + EIGEN_STRONG_INLINE InnerIterator(const unary_evaluator& sve, Index outer) : m_sve(sve), m_inner(0), m_outer(outer), m_end(sve.m_view.innerSize()) { incrementToNonZero(); diff --git a/Eigen/src/SparseCore/TriangularSolver.h b/Eigen/src/SparseCore/TriangularSolver.h index 98062e9c6..ccfbdc762 100644 --- a/Eigen/src/SparseCore/TriangularSolver.h +++ b/Eigen/src/SparseCore/TriangularSolver.h @@ -28,7 +28,7 @@ template<typename Lhs, typename Rhs, int Mode> struct sparse_solve_triangular_selector<Lhs,Rhs,Mode,Lower,RowMajor> { typedef typename Rhs::Scalar Scalar; - typedef typename Lhs::Index Index; + typedef typename Lhs::StorageIndex StorageIndex; typedef typename evaluator<Lhs>::type LhsEval; typedef typename evaluator<Lhs>::InnerIterator LhsIterator; static void run(const Lhs& lhs, Rhs& other) @@ -66,7 +66,7 @@ template<typename Lhs, typename Rhs, int Mode> struct sparse_solve_triangular_selector<Lhs,Rhs,Mode,Upper,RowMajor> { typedef typename Rhs::Scalar Scalar; - typedef typename Lhs::Index Index; + typedef typename Lhs::StorageIndex StorageIndex; typedef typename evaluator<Lhs>::type LhsEval; typedef typename evaluator<Lhs>::InnerIterator LhsIterator; static void run(const Lhs& lhs, Rhs& other) @@ -106,7 +106,7 @@ template<typename Lhs, typename Rhs, int Mode> struct sparse_solve_triangular_selector<Lhs,Rhs,Mode,Lower,ColMajor> { typedef typename Rhs::Scalar Scalar; - typedef typename Lhs::Index Index; + typedef typename Lhs::StorageIndex StorageIndex; typedef typename evaluator<Lhs>::type LhsEval; typedef typename evaluator<Lhs>::InnerIterator LhsIterator; static void run(const Lhs& lhs, Rhs& other) @@ -142,7 +142,7 @@ template<typename Lhs, typename Rhs, int Mode> struct sparse_solve_triangular_selector<Lhs,Rhs,Mode,Upper,ColMajor> { typedef typename Rhs::Scalar Scalar; - typedef typename Lhs::Index Index; + typedef typename Lhs::StorageIndex StorageIndex; typedef typename evaluator<Lhs>::type LhsEval; typedef typename evaluator<Lhs>::InnerIterator LhsIterator; static void run(const Lhs& lhs, Rhs& other) @@ -212,12 +212,12 @@ template<typename Lhs, typename Rhs, int Mode, int UpLo> struct sparse_solve_triangular_sparse_selector<Lhs,Rhs,Mode,UpLo,ColMajor> { typedef typename Rhs::Scalar Scalar; - typedef typename promote_index_type<typename traits<Lhs>::Index, - typename traits<Rhs>::Index>::type Index; + typedef typename promote_index_type<typename traits<Lhs>::StorageIndex, + typename traits<Rhs>::StorageIndex>::type StorageIndex; static void run(const Lhs& lhs, Rhs& other) { const bool IsLower = (UpLo==Lower); - AmbiVector<Scalar,Index> tempVector(other.rows()*2); + AmbiVector<Scalar,StorageIndex> tempVector(other.rows()*2); tempVector.setBounds(0,other.rows()); Rhs res(other.rows(), other.cols()); @@ -273,7 +273,7 @@ struct sparse_solve_triangular_sparse_selector<Lhs,Rhs,Mode,UpLo,ColMajor> Index count = 0; // FIXME compute a reference value to filter zeros - for (typename AmbiVector<Scalar,Index>::Iterator it(tempVector/*,1e-12*/); it; ++it) + for (typename AmbiVector<Scalar,StorageIndex>::Iterator it(tempVector/*,1e-12*/); it; ++it) { ++ count; // std::cerr << "fill " << it.index() << ", " << col << "\n"; diff --git a/Eigen/src/SparseLU/SparseLU.h b/Eigen/src/SparseLU/SparseLU.h index 79b78da99..1e448f2ab 100644 --- a/Eigen/src/SparseLU/SparseLU.h +++ b/Eigen/src/SparseLU/SparseLU.h @@ -14,7 +14,7 @@ namespace Eigen { -template <typename _MatrixType, typename _OrderingType = COLAMDOrdering<typename _MatrixType::Index> > class SparseLU; +template <typename _MatrixType, typename _OrderingType = COLAMDOrdering<typename _MatrixType::StorageIndex> > class SparseLU; template <typename MappedSparseMatrixType> struct SparseLUMatrixLReturnType; template <typename MatrixLType, typename MatrixUType> struct SparseLUMatrixUReturnType; @@ -70,7 +70,7 @@ template <typename MatrixLType, typename MatrixUType> struct SparseLUMatrixURetu * \sa \ref OrderingMethods_Module */ template <typename _MatrixType, typename _OrderingType> -class SparseLU : public SparseSolverBase<SparseLU<_MatrixType,_OrderingType> >, public internal::SparseLUImpl<typename _MatrixType::Scalar, typename _MatrixType::Index> +class SparseLU : public SparseSolverBase<SparseLU<_MatrixType,_OrderingType> >, public internal::SparseLUImpl<typename _MatrixType::Scalar, typename _MatrixType::StorageIndex> { protected: typedef SparseSolverBase<SparseLU<_MatrixType,_OrderingType> > APIBase; @@ -82,13 +82,13 @@ class SparseLU : public SparseSolverBase<SparseLU<_MatrixType,_OrderingType> >, typedef _OrderingType OrderingType; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; - typedef SparseMatrix<Scalar,ColMajor,Index> NCMatrix; - typedef internal::MappedSuperNodalMatrix<Scalar, Index> SCMatrix; + typedef typename MatrixType::StorageIndex StorageIndex; + typedef SparseMatrix<Scalar,ColMajor,StorageIndex> NCMatrix; + typedef internal::MappedSuperNodalMatrix<Scalar, StorageIndex> SCMatrix; typedef Matrix<Scalar,Dynamic,1> ScalarVector; - typedef Matrix<Index,Dynamic,1> IndexVector; - typedef PermutationMatrix<Dynamic, Dynamic, Index> PermutationType; - typedef internal::SparseLUImpl<Scalar, Index> Base; + typedef Matrix<StorageIndex,Dynamic,1> IndexVector; + typedef PermutationMatrix<Dynamic, Dynamic, StorageIndex> PermutationType; + typedef internal::SparseLUImpl<Scalar, StorageIndex> Base; public: SparseLU():m_lastError(""),m_Ustore(0,0,0,0,0,0),m_symmetricmode(false),m_diagpivotthresh(1.0),m_detPermR(1) @@ -146,9 +146,9 @@ class SparseLU : public SparseSolverBase<SparseLU<_MatrixType,_OrderingType> >, * y = b; matrixU().solveInPlace(y); * \endcode */ - SparseLUMatrixUReturnType<SCMatrix,MappedSparseMatrix<Scalar,ColMajor,Index> > matrixU() const + SparseLUMatrixUReturnType<SCMatrix,MappedSparseMatrix<Scalar,ColMajor,StorageIndex> > matrixU() const { - return SparseLUMatrixUReturnType<SCMatrix, MappedSparseMatrix<Scalar,ColMajor,Index> >(m_Lstore, m_Ustore); + return SparseLUMatrixUReturnType<SCMatrix, MappedSparseMatrix<Scalar,ColMajor,StorageIndex> >(m_Lstore, m_Ustore); } /** @@ -324,7 +324,7 @@ class SparseLU : public SparseSolverBase<SparseLU<_MatrixType,_OrderingType> >, std::string m_lastError; NCMatrix m_mat; // The input (permuted ) matrix SCMatrix m_Lstore; // The lower triangular matrix (supernodal) - MappedSparseMatrix<Scalar,ColMajor,Index> m_Ustore; // The upper triangular matrix + MappedSparseMatrix<Scalar,ColMajor,StorageIndex> m_Ustore; // The upper triangular matrix PermutationType m_perm_c; // Column permutation PermutationType m_perm_r ; // Row permutation IndexVector m_etree; // Column elimination tree @@ -334,9 +334,9 @@ class SparseLU : public SparseSolverBase<SparseLU<_MatrixType,_OrderingType> >, // SparseLU options bool m_symmetricmode; // values for performance - internal::perfvalues<Index> m_perfv; + internal::perfvalues m_perfv; RealScalar m_diagpivotthresh; // Specifies the threshold used for a diagonal entry to be an acceptable pivot - Index m_nnzL, m_nnzU; // Nonzeros in L and U factors + Index m_nnzL, m_nnzU; // Nonzeros in L and U factors Index m_detPermR; // Determinant of the coefficient matrix private: // Disable copy constructor @@ -375,7 +375,7 @@ void SparseLU<MatrixType, OrderingType>::analyzePattern(const MatrixType& mat) { m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers. FIXME : This vector is filled but not subsequently used. // Then, permute only the column pointers - ei_declare_aligned_stack_constructed_variable(Index,outerIndexPtr,mat.cols()+1,mat.isCompressed()?const_cast<Index*>(mat.outerIndexPtr()):0); + ei_declare_aligned_stack_constructed_variable(StorageIndex,outerIndexPtr,mat.cols()+1,mat.isCompressed()?const_cast<StorageIndex*>(mat.outerIndexPtr()):0); // If the input matrix 'mat' is uncompressed, then the outer-indices do not match the ones of m_mat, and a copy is thus needed. if(!mat.isCompressed()) @@ -397,7 +397,7 @@ void SparseLU<MatrixType, OrderingType>::analyzePattern(const MatrixType& mat) if (!m_symmetricmode) { IndexVector post, iwork; // Post order etree - internal::treePostorder(m_mat.cols(), m_etree, post); + internal::treePostorder(StorageIndex(m_mat.cols()), m_etree, post); // Renumber etree in postorder @@ -449,7 +449,7 @@ void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix) eigen_assert(m_analysisIsOk && "analyzePattern() should be called first"); eigen_assert((matrix.rows() == matrix.cols()) && "Only for squared matrices"); - typedef typename IndexVector::Scalar Index; + typedef typename IndexVector::Scalar StorageIndex; m_isInitialized = true; @@ -461,11 +461,11 @@ void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix) { m_mat.uncompress(); //NOTE: The effect of this command is only to create the InnerNonzeros pointers. //Then, permute only the column pointers - const Index * outerIndexPtr; + const StorageIndex * outerIndexPtr; if (matrix.isCompressed()) outerIndexPtr = matrix.outerIndexPtr(); else { - Index* outerIndexPtr_t = new Index[matrix.cols()+1]; + StorageIndex* outerIndexPtr_t = new StorageIndex[matrix.cols()+1]; for(Index i = 0; i <= matrix.cols(); i++) outerIndexPtr_t[i] = m_mat.outerIndexPtr()[i]; outerIndexPtr = outerIndexPtr_t; } @@ -479,7 +479,7 @@ void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix) else { //FIXME This should not be needed if the empty permutation is handled transparently m_perm_c.resize(matrix.cols()); - for(Index i = 0; i < matrix.cols(); ++i) m_perm_c.indices()(i) = i; + for(StorageIndex i = 0; i < matrix.cols(); ++i) m_perm_c.indices()(i) = i; } Index m = m_mat.rows(); @@ -640,7 +640,7 @@ void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix) // Create supernode matrix L m_Lstore.setInfos(m, n, m_glu.lusup, m_glu.xlusup, m_glu.lsub, m_glu.xlsub, m_glu.supno, m_glu.xsup); // Create the column major upper sparse matrix U; - new (&m_Ustore) MappedSparseMatrix<Scalar, ColMajor, Index> ( m, n, m_nnzU, m_glu.xusub.data(), m_glu.usub.data(), m_glu.ucol.data() ); + new (&m_Ustore) MappedSparseMatrix<Scalar, ColMajor, StorageIndex> ( m, n, m_nnzU, m_glu.xusub.data(), m_glu.usub.data(), m_glu.ucol.data() ); m_info = Success; m_factorizationIsOk = true; @@ -649,7 +649,6 @@ void SparseLU<MatrixType, OrderingType>::factorize(const MatrixType& matrix) template<typename MappedSupernodalType> struct SparseLUMatrixLReturnType : internal::no_assignment_operator { - typedef typename MappedSupernodalType::Index Index; typedef typename MappedSupernodalType::Scalar Scalar; explicit SparseLUMatrixLReturnType(const MappedSupernodalType& mapL) : m_mapL(mapL) { } @@ -666,7 +665,6 @@ struct SparseLUMatrixLReturnType : internal::no_assignment_operator template<typename MatrixLType, typename MatrixUType> struct SparseLUMatrixUReturnType : internal::no_assignment_operator { - typedef typename MatrixLType::Index Index; typedef typename MatrixLType::Scalar Scalar; explicit SparseLUMatrixUReturnType(const MatrixLType& mapL, const MatrixUType& mapU) : m_mapL(mapL),m_mapU(mapU) @@ -676,11 +674,8 @@ struct SparseLUMatrixUReturnType : internal::no_assignment_operator template<typename Dest> void solveInPlace(MatrixBase<Dest> &X) const { - /* Explicit type conversion as the Index type of MatrixBase<Dest> may be wider than Index */ - eigen_assert(X.rows() <= NumTraits<Index>::highest()); - eigen_assert(X.cols() <= NumTraits<Index>::highest()); - Index nrhs = Index(X.cols()); - Index n = Index(X.rows()); + Index nrhs = X.cols(); + Index n = X.rows(); // Backward solve with U for (Index k = m_mapL.nsuper(); k >= 0; k--) { diff --git a/Eigen/src/SparseLU/SparseLUImpl.h b/Eigen/src/SparseLU/SparseLUImpl.h index 14d70897d..731d1652c 100644 --- a/Eigen/src/SparseLU/SparseLUImpl.h +++ b/Eigen/src/SparseLU/SparseLUImpl.h @@ -16,17 +16,17 @@ namespace internal { * \class SparseLUImpl * Base class for sparseLU */ -template <typename Scalar, typename Index> +template <typename Scalar, typename StorageIndex> class SparseLUImpl { public: typedef Matrix<Scalar,Dynamic,1> ScalarVector; - typedef Matrix<Index,Dynamic,1> IndexVector; + typedef Matrix<StorageIndex,Dynamic,1> IndexVector; typedef typename ScalarVector::RealScalar RealScalar; typedef Ref<Matrix<Scalar,Dynamic,1> > BlockScalarVector; - typedef Ref<Matrix<Index,Dynamic,1> > BlockIndexVector; + typedef Ref<Matrix<StorageIndex,Dynamic,1> > BlockIndexVector; typedef LU_GlobalLU_t<IndexVector, ScalarVector> GlobalLU_t; - typedef SparseMatrix<Scalar,ColMajor,Index> MatrixType; + typedef SparseMatrix<Scalar,ColMajor,StorageIndex> MatrixType; protected: template <typename VectorType> @@ -40,7 +40,7 @@ class SparseLUImpl Index snode_bmod (const Index jcol, const Index fsupc, ScalarVector& dense, GlobalLU_t& glu); Index pivotL(const Index jcol, const RealScalar& diagpivotthresh, IndexVector& perm_r, IndexVector& iperm_c, Index& pivrow, GlobalLU_t& glu); template <typename Traits> - void dfs_kernel(const Index jj, IndexVector& perm_r, + void dfs_kernel(const StorageIndex jj, IndexVector& perm_r, Index& nseg, IndexVector& panel_lsub, IndexVector& segrep, Ref<IndexVector> repfnz_col, IndexVector& xprune, Ref<IndexVector> marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu, Index& nextl_col, Index krow, Traits& traits); diff --git a/Eigen/src/SparseLU/SparseLU_Memory.h b/Eigen/src/SparseLU/SparseLU_Memory.h index 1ffa7d54e..1cf8bebc7 100644 --- a/Eigen/src/SparseLU/SparseLU_Memory.h +++ b/Eigen/src/SparseLU/SparseLU_Memory.h @@ -36,13 +36,12 @@ namespace internal { enum { LUNoMarker = 3 }; enum {emptyIdxLU = -1}; -template<typename Index> inline Index LUnumTempV(Index& m, Index& w, Index& t, Index& b) { return (std::max)(m, (t+b)*w); } -template< typename Scalar, typename Index> +template< typename Scalar> inline Index LUTempSpace(Index&m, Index& w) { return (2*w + 4 + LUNoMarker) * m * sizeof(Index) + (w + 1) * m * sizeof(Scalar); @@ -59,9 +58,9 @@ inline Index LUTempSpace(Index&m, Index& w) * \param keep_prev 1: use length and do not expand the vector; 0: compute new_len and expand * \param[in,out] num_expansions Number of times the memory has been expanded */ -template <typename Scalar, typename Index> +template <typename Scalar, typename StorageIndex> template <typename VectorType> -Index SparseLUImpl<Scalar,Index>::expand(VectorType& vec, Index& length, Index nbElts, Index keep_prev, Index& num_expansions) +Index SparseLUImpl<Scalar,StorageIndex>::expand(VectorType& vec, Index& length, Index nbElts, Index keep_prev, Index& num_expansions) { float alpha = 1.5; // Ratio of the memory increase @@ -148,8 +147,8 @@ Index SparseLUImpl<Scalar,Index>::expand(VectorType& vec, Index& length, Index * \return an estimated size of the required memory if lwork = -1; otherwise, return the size of actually allocated memory when allocation failed, and 0 on success * \note Unlike SuperLU, this routine does not support successive factorization with the same pattern and the same row permutation */ -template <typename Scalar, typename Index> -Index SparseLUImpl<Scalar,Index>::memInit(Index m, Index n, Index annz, Index lwork, Index fillratio, Index panel_size, GlobalLU_t& glu) +template <typename Scalar, typename StorageIndex> +Index SparseLUImpl<Scalar,StorageIndex>::memInit(Index m, Index n, Index annz, Index lwork, Index fillratio, Index panel_size, GlobalLU_t& glu) { Index& num_expansions = glu.num_expansions; //No memory expansions so far num_expansions = 0; @@ -205,9 +204,9 @@ Index SparseLUImpl<Scalar,Index>::memInit(Index m, Index n, Index annz, Index lw * \param num_expansions Number of expansions * \return 0 on success, > 0 size of the memory allocated so far */ -template <typename Scalar, typename Index> +template <typename Scalar, typename StorageIndex> template <typename VectorType> -Index SparseLUImpl<Scalar,Index>::memXpand(VectorType& vec, Index& maxlen, Index nbElts, MemType memtype, Index& num_expansions) +Index SparseLUImpl<Scalar,StorageIndex>::memXpand(VectorType& vec, Index& maxlen, Index nbElts, MemType memtype, Index& num_expansions) { Index failed_size; if (memtype == USUB) diff --git a/Eigen/src/SparseLU/SparseLU_Structs.h b/Eigen/src/SparseLU/SparseLU_Structs.h index 24d6bf179..cf5ec449b 100644 --- a/Eigen/src/SparseLU/SparseLU_Structs.h +++ b/Eigen/src/SparseLU/SparseLU_Structs.h @@ -75,7 +75,7 @@ typedef enum {LUSUP, UCOL, LSUB, USUB, LLVL, ULVL} MemType; template <typename IndexVector, typename ScalarVector> struct LU_GlobalLU_t { - typedef typename IndexVector::Scalar Index; + typedef typename IndexVector::Scalar StorageIndex; IndexVector xsup; //First supernode column ... xsup(s) points to the beginning of the s-th supernode IndexVector supno; // Supernode number corresponding to this column (column to supernode mapping) ScalarVector lusup; // nonzero values of L ordered by columns @@ -93,7 +93,6 @@ struct LU_GlobalLU_t { }; // Values to set for performance -template <typename Index> struct perfvalues { Index panel_size; // a panel consists of at most <panel_size> consecutive columns Index relax; // To control degree of relaxing supernodes. If the number of nodes (columns) diff --git a/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h b/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h index e8ee35a94..b37b93cf1 100644 --- a/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h +++ b/Eigen/src/SparseLU/SparseLU_SupernodalMatrix.h @@ -29,20 +29,20 @@ namespace internal { * SuperInnerIterator to iterate through all supernodes * Function for triangular solve */ -template <typename _Scalar, typename _Index> +template <typename _Scalar, typename _StorageIndex> class MappedSuperNodalMatrix { public: typedef _Scalar Scalar; - typedef _Index Index; - typedef Matrix<Index,Dynamic,1> IndexVector; + typedef _StorageIndex StorageIndex; + typedef Matrix<StorageIndex,Dynamic,1> IndexVector; typedef Matrix<Scalar,Dynamic,1> ScalarVector; public: MappedSuperNodalMatrix() { } - MappedSuperNodalMatrix(Index m, Index n, ScalarVector& nzval, IndexVector& nzval_colptr, IndexVector& rowind, + MappedSuperNodalMatrix(Index m, Index n, ScalarVector& nzval, IndexVector& nzval_colptr, IndexVector& rowind, IndexVector& rowind_colptr, IndexVector& col_to_sup, IndexVector& sup_to_col ) { setInfos(m, n, nzval, nzval_colptr, rowind, rowind_colptr, col_to_sup, sup_to_col); @@ -58,7 +58,7 @@ class MappedSuperNodalMatrix * FIXME This class will be modified such that it can be use in the course * of the factorization. */ - void setInfos(Index m, Index n, ScalarVector& nzval, IndexVector& nzval_colptr, IndexVector& rowind, + void setInfos(Index m, Index n, ScalarVector& nzval, IndexVector& nzval_colptr, IndexVector& rowind, IndexVector& rowind_colptr, IndexVector& col_to_sup, IndexVector& sup_to_col ) { m_row = m; @@ -96,12 +96,12 @@ class MappedSuperNodalMatrix /** * Return the pointers to the beginning of each column in \ref valuePtr() */ - Index* colIndexPtr() + StorageIndex* colIndexPtr() { return m_nzval_colptr; } - const Index* colIndexPtr() const + const StorageIndex* colIndexPtr() const { return m_nzval_colptr; } @@ -109,9 +109,9 @@ class MappedSuperNodalMatrix /** * Return the array of compressed row indices of all supernodes */ - Index* rowIndex() { return m_rowind; } + StorageIndex* rowIndex() { return m_rowind; } - const Index* rowIndex() const + const StorageIndex* rowIndex() const { return m_rowind; } @@ -119,9 +119,9 @@ class MappedSuperNodalMatrix /** * Return the location in \em rowvaluePtr() which starts each column */ - Index* rowIndexPtr() { return m_rowind_colptr; } + StorageIndex* rowIndexPtr() { return m_rowind_colptr; } - const Index* rowIndexPtr() const + const StorageIndex* rowIndexPtr() const { return m_rowind_colptr; } @@ -129,18 +129,18 @@ class MappedSuperNodalMatrix /** * Return the array of column-to-supernode mapping */ - Index* colToSup() { return m_col_to_sup; } + StorageIndex* colToSup() { return m_col_to_sup; } - const Index* colToSup() const + const StorageIndex* colToSup() const { return m_col_to_sup; } /** * Return the array of supernode-to-column mapping */ - Index* supToCol() { return m_sup_to_col; } + StorageIndex* supToCol() { return m_sup_to_col; } - const Index* supToCol() const + const StorageIndex* supToCol() const { return m_sup_to_col; } @@ -148,7 +148,7 @@ class MappedSuperNodalMatrix /** * Return the number of supernodes */ - Index nsuper() const + Index nsuper() const { return m_nsuper; } @@ -162,14 +162,14 @@ class MappedSuperNodalMatrix protected: Index m_row; // Number of rows - Index m_col; // Number of columns - Index m_nsuper; // Number of supernodes + Index m_col; // Number of columns + Index m_nsuper; // Number of supernodes Scalar* m_nzval; //array of nonzero values packed by column - Index* m_nzval_colptr; //nzval_colptr[j] Stores the location in nzval[] which starts column j - Index* m_rowind; // Array of compressed row indices of rectangular supernodes - Index* m_rowind_colptr; //rowind_colptr[j] stores the location in rowind[] which starts column j - Index* m_col_to_sup; // col_to_sup[j] is the supernode number to which column j belongs - Index* m_sup_to_col; //sup_to_col[s] points to the starting column of the s-th supernode + StorageIndex* m_nzval_colptr; //nzval_colptr[j] Stores the location in nzval[] which starts column j + StorageIndex* m_rowind; // Array of compressed row indices of rectangular supernodes + StorageIndex* m_rowind_colptr; //rowind_colptr[j] stores the location in rowind[] which starts column j + StorageIndex* m_col_to_sup; // col_to_sup[j] is the supernode number to which column j belongs + StorageIndex* m_sup_to_col; //sup_to_col[s] points to the starting column of the s-th supernode private : }; @@ -178,13 +178,13 @@ class MappedSuperNodalMatrix * \brief InnerIterator class to iterate over nonzero values of the current column in the supernodal matrix L * */ -template<typename Scalar, typename Index> -class MappedSuperNodalMatrix<Scalar,Index>::InnerIterator +template<typename Scalar, typename StorageIndex> +class MappedSuperNodalMatrix<Scalar,StorageIndex>::InnerIterator { public: InnerIterator(const MappedSuperNodalMatrix& mat, Index outer) : m_matrix(mat), - m_outer(outer), + m_outer(outer), m_supno(mat.colToSup()[outer]), m_idval(mat.colIndexPtr()[outer]), m_startidval(m_idval), @@ -229,14 +229,14 @@ class MappedSuperNodalMatrix<Scalar,Index>::InnerIterator * \brief Solve with the supernode triangular matrix * */ -template<typename Scalar, typename Index> +template<typename Scalar, typename Index_> template<typename Dest> -void MappedSuperNodalMatrix<Scalar,Index>::solveInPlace( MatrixBase<Dest>&X) const +void MappedSuperNodalMatrix<Scalar,Index_>::solveInPlace( MatrixBase<Dest>&X) const { /* Explicit type conversion as the Index type of MatrixBase<Dest> may be wider than Index */ - eigen_assert(X.rows() <= NumTraits<Index>::highest()); - eigen_assert(X.cols() <= NumTraits<Index>::highest()); - Index n = Index(X.rows()); +// eigen_assert(X.rows() <= NumTraits<Index>::highest()); +// eigen_assert(X.cols() <= NumTraits<Index>::highest()); + Index n = int(X.rows()); Index nrhs = Index(X.cols()); const Scalar * Lval = valuePtr(); // Nonzero values Matrix<Scalar,Dynamic,Dynamic> work(n, nrhs); // working vector diff --git a/Eigen/src/SparseLU/SparseLU_Utils.h b/Eigen/src/SparseLU/SparseLU_Utils.h index 15352ac33..9e3dab44d 100644 --- a/Eigen/src/SparseLU/SparseLU_Utils.h +++ b/Eigen/src/SparseLU/SparseLU_Utils.h @@ -17,8 +17,8 @@ namespace internal { /** * \brief Count Nonzero elements in the factors */ -template <typename Scalar, typename Index> -void SparseLUImpl<Scalar,Index>::countnz(const Index n, Index& nnzL, Index& nnzU, GlobalLU_t& glu) +template <typename Scalar, typename StorageIndex> +void SparseLUImpl<Scalar,StorageIndex>::countnz(const Index n, Index& nnzL, Index& nnzU, GlobalLU_t& glu) { nnzL = 0; nnzU = (glu.xusub)(n); @@ -48,12 +48,12 @@ void SparseLUImpl<Scalar,Index>::countnz(const Index n, Index& nnzL, Index& nnzU * and applies permutation to the remaining subscripts * */ -template <typename Scalar, typename Index> -void SparseLUImpl<Scalar,Index>::fixupL(const Index n, const IndexVector& perm_r, GlobalLU_t& glu) +template <typename Scalar, typename StorageIndex> +void SparseLUImpl<Scalar,StorageIndex>::fixupL(const Index n, const IndexVector& perm_r, GlobalLU_t& glu) { Index fsupc, i, j, k, jstart; - Index nextl = 0; + StorageIndex nextl = 0; Index nsuper = (glu.supno)(n); // For each supernode diff --git a/Eigen/src/SparseLU/SparseLU_column_bmod.h b/Eigen/src/SparseLU/SparseLU_column_bmod.h index f24bd87d3..be190997d 100644 --- a/Eigen/src/SparseLU/SparseLU_column_bmod.h +++ b/Eigen/src/SparseLU/SparseLU_column_bmod.h @@ -49,8 +49,9 @@ namespace internal { * > 0 - number of bytes allocated when run out of space * */ -template <typename Scalar, typename Index> -Index SparseLUImpl<Scalar,Index>::column_bmod(const Index jcol, const Index nseg, BlockScalarVector dense, ScalarVector& tempv, BlockIndexVector segrep, BlockIndexVector repfnz, Index fpanelc, GlobalLU_t& glu) +template <typename Scalar, typename StorageIndex> +Index SparseLUImpl<Scalar,StorageIndex>::column_bmod(const Index jcol, const Index nseg, BlockScalarVector dense, ScalarVector& tempv, + BlockIndexVector segrep, BlockIndexVector repfnz, Index fpanelc, GlobalLU_t& glu) { Index jsupno, k, ksub, krep, ksupno; Index lptr, nrow, isub, irow, nextlu, new_next, ufirst; @@ -137,7 +138,7 @@ Index SparseLUImpl<Scalar,Index>::column_bmod(const Index jcol, const Index nseg glu.lusup.segment(nextlu,offset).setZero(); nextlu += offset; } - glu.xlusup(jcol + 1) = nextlu; // close L\U(*,jcol); + glu.xlusup(jcol + 1) = StorageIndex(nextlu); // close L\U(*,jcol); /* For more updates within the panel (also within the current supernode), * should start from the first column of the panel, or the first column diff --git a/Eigen/src/SparseLU/SparseLU_column_dfs.h b/Eigen/src/SparseLU/SparseLU_column_dfs.h index 4c04b0e44..c98b30e32 100644 --- a/Eigen/src/SparseLU/SparseLU_column_dfs.h +++ b/Eigen/src/SparseLU/SparseLU_column_dfs.h @@ -30,7 +30,7 @@ #ifndef SPARSELU_COLUMN_DFS_H #define SPARSELU_COLUMN_DFS_H -template <typename Scalar, typename Index> class SparseLUImpl; +template <typename Scalar, typename StorageIndex> class SparseLUImpl; namespace Eigen { namespace internal { @@ -39,8 +39,8 @@ template<typename IndexVector, typename ScalarVector> struct column_dfs_traits : no_assignment_operator { typedef typename ScalarVector::Scalar Scalar; - typedef typename IndexVector::Scalar Index; - column_dfs_traits(Index jcol, Index& jsuper, typename SparseLUImpl<Scalar, Index>::GlobalLU_t& glu, SparseLUImpl<Scalar, Index>& luImpl) + typedef typename IndexVector::Scalar StorageIndex; + column_dfs_traits(Index jcol, Index& jsuper, typename SparseLUImpl<Scalar, StorageIndex>::GlobalLU_t& glu, SparseLUImpl<Scalar, StorageIndex>& luImpl) : m_jcol(jcol), m_jsuper_ref(jsuper), m_glu(glu), m_luImpl(luImpl) {} bool update_segrep(Index /*krep*/, Index /*jj*/) @@ -57,8 +57,8 @@ struct column_dfs_traits : no_assignment_operator Index m_jcol; Index& m_jsuper_ref; - typename SparseLUImpl<Scalar, Index>::GlobalLU_t& m_glu; - SparseLUImpl<Scalar, Index>& m_luImpl; + typename SparseLUImpl<Scalar, StorageIndex>::GlobalLU_t& m_glu; + SparseLUImpl<Scalar, StorageIndex>& m_luImpl; }; @@ -89,8 +89,10 @@ struct column_dfs_traits : no_assignment_operator * > 0 number of bytes allocated when run out of space * */ -template <typename Scalar, typename Index> -Index SparseLUImpl<Scalar,Index>::column_dfs(const Index m, const Index jcol, IndexVector& perm_r, Index maxsuper, Index& nseg, BlockIndexVector lsub_col, IndexVector& segrep, BlockIndexVector repfnz, IndexVector& xprune, IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu) +template <typename Scalar, typename StorageIndex> +Index SparseLUImpl<Scalar,StorageIndex>::column_dfs(const Index m, const Index jcol, IndexVector& perm_r, Index maxsuper, Index& nseg, + BlockIndexVector lsub_col, IndexVector& segrep, BlockIndexVector repfnz, IndexVector& xprune, + IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu) { Index jsuper = glu.supno(jcol); @@ -110,13 +112,13 @@ Index SparseLUImpl<Scalar,Index>::column_dfs(const Index m, const Index jcol, In // krow was visited before, go to the next nonz; if (kmark == jcol) continue; - dfs_kernel(jcol, perm_r, nseg, glu.lsub, segrep, repfnz, xprune, marker2, parent, + dfs_kernel(StorageIndex(jcol), perm_r, nseg, glu.lsub, segrep, repfnz, xprune, marker2, parent, xplore, glu, nextl, krow, traits); } // for each nonzero ... - Index fsupc, jptr, jm1ptr, ito, ifrom, istop; - Index nsuper = glu.supno(jcol); - Index jcolp1 = jcol + 1; + Index fsupc; + StorageIndex nsuper = glu.supno(jcol); + StorageIndex jcolp1 = StorageIndex(jcol) + 1; Index jcolm1 = jcol - 1; // check to see if j belongs in the same supernode as j-1 @@ -127,8 +129,8 @@ Index SparseLUImpl<Scalar,Index>::column_dfs(const Index m, const Index jcol, In else { fsupc = glu.xsup(nsuper); - jptr = glu.xlsub(jcol); // Not yet compressed - jm1ptr = glu.xlsub(jcolm1); + StorageIndex jptr = glu.xlsub(jcol); // Not yet compressed + StorageIndex jm1ptr = glu.xlsub(jcolm1); // Use supernodes of type T2 : see SuperLU paper if ( (nextl-jptr != jptr-jm1ptr-1) ) jsuper = emptyIdxLU; @@ -146,13 +148,13 @@ Index SparseLUImpl<Scalar,Index>::column_dfs(const Index m, const Index jcol, In { // starts a new supernode if ( (fsupc < jcolm1-1) ) { // >= 3 columns in nsuper - ito = glu.xlsub(fsupc+1); + StorageIndex ito = glu.xlsub(fsupc+1); glu.xlsub(jcolm1) = ito; - istop = ito + jptr - jm1ptr; + StorageIndex istop = ito + jptr - jm1ptr; xprune(jcolm1) = istop; // intialize xprune(jcol-1) glu.xlsub(jcol) = istop; - for (ifrom = jm1ptr; ifrom < nextl; ++ifrom, ++ito) + for (StorageIndex ifrom = jm1ptr; ifrom < nextl; ++ifrom, ++ito) glu.lsub(ito) = glu.lsub(ifrom); nextl = ito; // = istop + length(jcol) } @@ -164,8 +166,8 @@ Index SparseLUImpl<Scalar,Index>::column_dfs(const Index m, const Index jcol, In // Tidy up the pointers before exit glu.xsup(nsuper+1) = jcolp1; glu.supno(jcolp1) = nsuper; - xprune(jcol) = nextl; // Intialize upper bound for pruning - glu.xlsub(jcolp1) = nextl; + xprune(jcol) = StorageIndex(nextl); // Intialize upper bound for pruning + glu.xlsub(jcolp1) = StorageIndex(nextl); return 0; } diff --git a/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h b/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h index 170610d9f..c32d8d8b1 100644 --- a/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h +++ b/Eigen/src/SparseLU/SparseLU_copy_to_ucol.h @@ -46,8 +46,9 @@ namespace internal { * > 0 - number of bytes allocated when run out of space * */ -template <typename Scalar, typename Index> -Index SparseLUImpl<Scalar,Index>::copy_to_ucol(const Index jcol, const Index nseg, IndexVector& segrep, BlockIndexVector repfnz ,IndexVector& perm_r, BlockScalarVector dense, GlobalLU_t& glu) +template <typename Scalar, typename StorageIndex> +Index SparseLUImpl<Scalar,StorageIndex>::copy_to_ucol(const Index jcol, const Index nseg, IndexVector& segrep, + BlockIndexVector repfnz ,IndexVector& perm_r, BlockScalarVector dense, GlobalLU_t& glu) { Index ksub, krep, ksupno; @@ -55,7 +56,7 @@ Index SparseLUImpl<Scalar,Index>::copy_to_ucol(const Index jcol, const Index nse // For each nonzero supernode segment of U[*,j] in topological order Index k = nseg - 1, i; - Index nextu = glu.xusub(jcol); + StorageIndex nextu = glu.xusub(jcol); Index kfnz, isub, segsize; Index new_next,irow; Index fsupc, mem; diff --git a/Eigen/src/SparseLU/SparseLU_gemm_kernel.h b/Eigen/src/SparseLU/SparseLU_gemm_kernel.h index 9e4e3e72b..7420b4d17 100644 --- a/Eigen/src/SparseLU/SparseLU_gemm_kernel.h +++ b/Eigen/src/SparseLU/SparseLU_gemm_kernel.h @@ -21,7 +21,7 @@ namespace internal { * - lda and ldc must be multiples of the respective packet size * - C must have the same alignment as A */ -template<typename Scalar,typename Index> +template<typename Scalar> EIGEN_DONT_INLINE void sparselu_gemm(Index m, Index n, Index d, const Scalar* A, Index lda, const Scalar* B, Index ldb, Scalar* C, Index ldc) { diff --git a/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h b/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h index 7a4e4305a..6f75d500e 100644 --- a/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h +++ b/Eigen/src/SparseLU/SparseLU_heap_relax_snode.h @@ -42,21 +42,20 @@ namespace internal { * \param descendants Number of descendants of each node in the etree * \param relax_end last column in a supernode */ -template <typename Scalar, typename Index> -void SparseLUImpl<Scalar,Index>::heap_relax_snode (const Index n, IndexVector& et, const Index relax_columns, IndexVector& descendants, IndexVector& relax_end) +template <typename Scalar, typename StorageIndex> +void SparseLUImpl<Scalar,StorageIndex>::heap_relax_snode (const Index n, IndexVector& et, const Index relax_columns, IndexVector& descendants, IndexVector& relax_end) { // The etree may not be postordered, but its heap ordered IndexVector post; - internal::treePostorder(n, et, post); // Post order etree + internal::treePostorder(StorageIndex(n), et, post); // Post order etree IndexVector inv_post(n+1); - Index i; - for (i = 0; i < n+1; ++i) inv_post(post(i)) = i; // inv_post = post.inverse()??? + for (StorageIndex i = 0; i < n+1; ++i) inv_post(post(i)) = i; // inv_post = post.inverse()??? // Renumber etree in postorder IndexVector iwork(n); IndexVector et_save(n+1); - for (i = 0; i < n; ++i) + for (Index i = 0; i < n; ++i) { iwork(post(i)) = post(et(i)); } @@ -75,10 +74,10 @@ void SparseLUImpl<Scalar,Index>::heap_relax_snode (const Index n, IndexVector& e } // Identify the relaxed supernodes by postorder traversal of the etree Index snode_start; // beginning of a snode - Index k; + StorageIndex k; Index nsuper_et_post = 0; // Number of relaxed snodes in postordered etree Index nsuper_et = 0; // Number of relaxed snodes in the original etree - Index l; + StorageIndex l; for (j = 0; j < n; ) { parent = et(j); @@ -90,8 +89,8 @@ void SparseLUImpl<Scalar,Index>::heap_relax_snode (const Index n, IndexVector& e } // Found a supernode in postordered etree, j is the last column ++nsuper_et_post; - k = n; - for (i = snode_start; i <= j; ++i) + k = StorageIndex(n); + for (Index i = snode_start; i <= j; ++i) k = (std::min)(k, inv_post(i)); l = inv_post(j); if ( (l - k) == (j - snode_start) ) // Same number of columns in the snode @@ -102,7 +101,7 @@ void SparseLUImpl<Scalar,Index>::heap_relax_snode (const Index n, IndexVector& e } else { - for (i = snode_start; i <= j; ++i) + for (Index i = snode_start; i <= j; ++i) { l = inv_post(i); if (descendants(i) == 0) diff --git a/Eigen/src/SparseLU/SparseLU_kernel_bmod.h b/Eigen/src/SparseLU/SparseLU_kernel_bmod.h index cad149ded..9513f8369 100644 --- a/Eigen/src/SparseLU/SparseLU_kernel_bmod.h +++ b/Eigen/src/SparseLU/SparseLU_kernel_bmod.h @@ -30,13 +30,13 @@ namespace internal { */ template <int SegSizeAtCompileTime> struct LU_kernel_bmod { - template <typename BlockScalarVector, typename ScalarVector, typename IndexVector, typename Index> + template <typename BlockScalarVector, typename ScalarVector, typename IndexVector> static EIGEN_DONT_INLINE void run(const Index segsize, BlockScalarVector& dense, ScalarVector& tempv, ScalarVector& lusup, Index& luptr, const Index lda, const Index nrow, IndexVector& lsub, const Index lptr, const Index no_zeros); }; template <int SegSizeAtCompileTime> -template <typename BlockScalarVector, typename ScalarVector, typename IndexVector, typename Index> +template <typename BlockScalarVector, typename ScalarVector, typename IndexVector> EIGEN_DONT_INLINE void LU_kernel_bmod<SegSizeAtCompileTime>::run(const Index segsize, BlockScalarVector& dense, ScalarVector& tempv, ScalarVector& lusup, Index& luptr, const Index lda, const Index nrow, IndexVector& lsub, const Index lptr, const Index no_zeros) { @@ -91,21 +91,22 @@ EIGEN_DONT_INLINE void LU_kernel_bmod<SegSizeAtCompileTime>::run(const Index seg template <> struct LU_kernel_bmod<1> { - template <typename BlockScalarVector, typename ScalarVector, typename IndexVector, typename Index> + template <typename BlockScalarVector, typename ScalarVector, typename IndexVector> static EIGEN_DONT_INLINE void run(const Index /*segsize*/, BlockScalarVector& dense, ScalarVector& /*tempv*/, ScalarVector& lusup, Index& luptr, const Index lda, const Index nrow, IndexVector& lsub, const Index lptr, const Index no_zeros); }; -template <typename BlockScalarVector, typename ScalarVector, typename IndexVector, typename Index> +template <typename BlockScalarVector, typename ScalarVector, typename IndexVector> EIGEN_DONT_INLINE void LU_kernel_bmod<1>::run(const Index /*segsize*/, BlockScalarVector& dense, ScalarVector& /*tempv*/, ScalarVector& lusup, Index& luptr, const Index lda, const Index nrow, IndexVector& lsub, const Index lptr, const Index no_zeros) { typedef typename ScalarVector::Scalar Scalar; + typedef typename IndexVector::Scalar StorageIndex; Scalar f = dense(lsub(lptr + no_zeros)); luptr += lda * no_zeros + no_zeros + 1; const Scalar* a(lusup.data() + luptr); - const /*typename IndexVector::Scalar*/Index* irow(lsub.data()+lptr + no_zeros + 1); + const StorageIndex* irow(lsub.data()+lptr + no_zeros + 1); Index i = 0; for (; i+1 < nrow; i+=2) { diff --git a/Eigen/src/SparseLU/SparseLU_panel_bmod.h b/Eigen/src/SparseLU/SparseLU_panel_bmod.h index da0e0fc3c..bd3cf87b9 100644 --- a/Eigen/src/SparseLU/SparseLU_panel_bmod.h +++ b/Eigen/src/SparseLU/SparseLU_panel_bmod.h @@ -52,8 +52,8 @@ namespace internal { * * */ -template <typename Scalar, typename Index> -void SparseLUImpl<Scalar,Index>::panel_bmod(const Index m, const Index w, const Index jcol, +template <typename Scalar, typename StorageIndex> +void SparseLUImpl<Scalar,StorageIndex>::panel_bmod(const Index m, const Index w, const Index jcol, const Index nseg, ScalarVector& dense, ScalarVector& tempv, IndexVector& segrep, IndexVector& repfnz, GlobalLU_t& glu) { diff --git a/Eigen/src/SparseLU/SparseLU_panel_dfs.h b/Eigen/src/SparseLU/SparseLU_panel_dfs.h index dc0054efd..155df7336 100644 --- a/Eigen/src/SparseLU/SparseLU_panel_dfs.h +++ b/Eigen/src/SparseLU/SparseLU_panel_dfs.h @@ -37,11 +37,11 @@ namespace internal { template<typename IndexVector> struct panel_dfs_traits { - typedef typename IndexVector::Scalar Index; - panel_dfs_traits(Index jcol, Index* marker) + typedef typename IndexVector::Scalar StorageIndex; + panel_dfs_traits(Index jcol, StorageIndex* marker) : m_jcol(jcol), m_marker(marker) {} - bool update_segrep(Index krep, Index jj) + bool update_segrep(Index krep, StorageIndex jj) { if(m_marker[krep]<m_jcol) { @@ -53,13 +53,13 @@ struct panel_dfs_traits void mem_expand(IndexVector& /*glu.lsub*/, Index /*nextl*/, Index /*chmark*/) {} enum { ExpandMem = false }; Index m_jcol; - Index* m_marker; + StorageIndex* m_marker; }; -template <typename Scalar, typename Index> +template <typename Scalar, typename StorageIndex> template <typename Traits> -void SparseLUImpl<Scalar,Index>::dfs_kernel(const Index jj, IndexVector& perm_r, +void SparseLUImpl<Scalar,StorageIndex>::dfs_kernel(const StorageIndex jj, IndexVector& perm_r, Index& nseg, IndexVector& panel_lsub, IndexVector& segrep, Ref<IndexVector> repfnz_col, IndexVector& xprune, Ref<IndexVector> marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu, @@ -67,14 +67,14 @@ void SparseLUImpl<Scalar,Index>::dfs_kernel(const Index jj, IndexVector& perm_r, ) { - Index kmark = marker(krow); + StorageIndex kmark = marker(krow); // For each unmarked krow of jj marker(krow) = jj; - Index kperm = perm_r(krow); + StorageIndex kperm = perm_r(krow); if (kperm == emptyIdxLU ) { // krow is in L : place it in structure of L(*, jj) - panel_lsub(nextl_col++) = krow; // krow is indexed into A + panel_lsub(nextl_col++) = StorageIndex(krow); // krow is indexed into A traits.mem_expand(panel_lsub, nextl_col, kmark); } @@ -83,9 +83,9 @@ void SparseLUImpl<Scalar,Index>::dfs_kernel(const Index jj, IndexVector& perm_r, // krow is in U : if its supernode-representative krep // has been explored, update repfnz(*) // krep = supernode representative of the current row - Index krep = glu.xsup(glu.supno(kperm)+1) - 1; + StorageIndex krep = glu.xsup(glu.supno(kperm)+1) - 1; // First nonzero element in the current column: - Index myfnz = repfnz_col(krep); + StorageIndex myfnz = repfnz_col(krep); if (myfnz != emptyIdxLU ) { @@ -96,26 +96,26 @@ void SparseLUImpl<Scalar,Index>::dfs_kernel(const Index jj, IndexVector& perm_r, else { // Otherwise, perform dfs starting at krep - Index oldrep = emptyIdxLU; + StorageIndex oldrep = emptyIdxLU; parent(krep) = oldrep; repfnz_col(krep) = kperm; - Index xdfs = glu.xlsub(krep); + StorageIndex xdfs = glu.xlsub(krep); Index maxdfs = xprune(krep); - Index kpar; + StorageIndex kpar; do { // For each unmarked kchild of krep while (xdfs < maxdfs) { - Index kchild = glu.lsub(xdfs); + StorageIndex kchild = glu.lsub(xdfs); xdfs++; - Index chmark = marker(kchild); + StorageIndex chmark = marker(kchild); if (chmark != jj ) { marker(kchild) = jj; - Index chperm = perm_r(kchild); + StorageIndex chperm = perm_r(kchild); if (chperm == emptyIdxLU) { @@ -128,7 +128,7 @@ void SparseLUImpl<Scalar,Index>::dfs_kernel(const Index jj, IndexVector& perm_r, // case kchild is in U : // chrep = its supernode-rep. If its rep has been explored, // update its repfnz(*) - Index chrep = glu.xsup(glu.supno(chperm)+1) - 1; + StorageIndex chrep = glu.xsup(glu.supno(chperm)+1) - 1; myfnz = repfnz_col(chrep); if (myfnz != emptyIdxLU) @@ -215,8 +215,8 @@ void SparseLUImpl<Scalar,Index>::dfs_kernel(const Index jj, IndexVector& perm_r, * */ -template <typename Scalar, typename Index> -void SparseLUImpl<Scalar,Index>::panel_dfs(const Index m, const Index w, const Index jcol, MatrixType& A, IndexVector& perm_r, Index& nseg, ScalarVector& dense, IndexVector& panel_lsub, IndexVector& segrep, IndexVector& repfnz, IndexVector& xprune, IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu) +template <typename Scalar, typename StorageIndex> +void SparseLUImpl<Scalar,StorageIndex>::panel_dfs(const Index m, const Index w, const Index jcol, MatrixType& A, IndexVector& perm_r, Index& nseg, ScalarVector& dense, IndexVector& panel_lsub, IndexVector& segrep, IndexVector& repfnz, IndexVector& xprune, IndexVector& marker, IndexVector& parent, IndexVector& xplore, GlobalLU_t& glu) { Index nextl_col; // Next available position in panel_lsub[*,jj] @@ -227,7 +227,7 @@ void SparseLUImpl<Scalar,Index>::panel_dfs(const Index m, const Index w, const I panel_dfs_traits<IndexVector> traits(jcol, marker1.data()); // For each column in the panel - for (Index jj = jcol; jj < jcol + w; jj++) + for (StorageIndex jj = StorageIndex(jcol); jj < jcol + w; jj++) { nextl_col = (jj - jcol) * m; @@ -241,7 +241,7 @@ void SparseLUImpl<Scalar,Index>::panel_dfs(const Index m, const Index w, const I Index krow = it.row(); dense_col(krow) = it.value(); - Index kmark = marker(krow); + StorageIndex kmark = marker(krow); if (kmark == jj) continue; // krow visited before, go to the next nonzero diff --git a/Eigen/src/SparseLU/SparseLU_pivotL.h b/Eigen/src/SparseLU/SparseLU_pivotL.h index 457789c78..562128b69 100644 --- a/Eigen/src/SparseLU/SparseLU_pivotL.h +++ b/Eigen/src/SparseLU/SparseLU_pivotL.h @@ -56,8 +56,8 @@ namespace internal { * \return 0 if success, i > 0 if U(i,i) is exactly zero * */ -template <typename Scalar, typename Index> -Index SparseLUImpl<Scalar,Index>::pivotL(const Index jcol, const RealScalar& diagpivotthresh, IndexVector& perm_r, IndexVector& iperm_c, Index& pivrow, GlobalLU_t& glu) +template <typename Scalar, typename StorageIndex> +Index SparseLUImpl<Scalar,StorageIndex>::pivotL(const Index jcol, const RealScalar& diagpivotthresh, IndexVector& perm_r, IndexVector& iperm_c, Index& pivrow, GlobalLU_t& glu) { Index fsupc = (glu.xsup)((glu.supno)(jcol)); // First column in the supernode containing the column jcol @@ -67,7 +67,7 @@ Index SparseLUImpl<Scalar,Index>::pivotL(const Index jcol, const RealScalar& dia Index lda = glu.xlusup(fsupc+1) - glu.xlusup(fsupc); // leading dimension Scalar* lu_sup_ptr = &(glu.lusup.data()[glu.xlusup(fsupc)]); // Start of the current supernode Scalar* lu_col_ptr = &(glu.lusup.data()[glu.xlusup(jcol)]); // Start of jcol in the supernode - Index* lsub_ptr = &(glu.lsub.data()[lptr]); // Start of row indices of the supernode + StorageIndex* lsub_ptr = &(glu.lsub.data()[lptr]); // Start of row indices of the supernode // Determine the largest abs numerical value for partial pivoting Index diagind = iperm_c(jcol); // diagonal index @@ -89,7 +89,7 @@ Index SparseLUImpl<Scalar,Index>::pivotL(const Index jcol, const RealScalar& dia // Test for singularity if ( pivmax == 0.0 ) { pivrow = lsub_ptr[pivptr]; - perm_r(pivrow) = jcol; + perm_r(pivrow) = StorageIndex(jcol); return (jcol+1); } @@ -110,7 +110,7 @@ Index SparseLUImpl<Scalar,Index>::pivotL(const Index jcol, const RealScalar& dia } // Record pivot row - perm_r(pivrow) = jcol; + perm_r(pivrow) = StorageIndex(jcol); // Interchange row subscripts if (pivptr != nsupc ) { diff --git a/Eigen/src/SparseLU/SparseLU_pruneL.h b/Eigen/src/SparseLU/SparseLU_pruneL.h index 66460d168..ad32fed5e 100644 --- a/Eigen/src/SparseLU/SparseLU_pruneL.h +++ b/Eigen/src/SparseLU/SparseLU_pruneL.h @@ -49,8 +49,9 @@ namespace internal { * \param glu Global LU data * */ -template <typename Scalar, typename Index> -void SparseLUImpl<Scalar,Index>::pruneL(const Index jcol, const IndexVector& perm_r, const Index pivrow, const Index nseg, const IndexVector& segrep, BlockIndexVector repfnz, IndexVector& xprune, GlobalLU_t& glu) +template <typename Scalar, typename StorageIndex> +void SparseLUImpl<Scalar,StorageIndex>::pruneL(const Index jcol, const IndexVector& perm_r, const Index pivrow, const Index nseg, + const IndexVector& segrep, BlockIndexVector repfnz, IndexVector& xprune, GlobalLU_t& glu) { // For each supernode-rep irep in U(*,j] Index jsupno = glu.supno(jcol); @@ -123,7 +124,7 @@ void SparseLUImpl<Scalar,Index>::pruneL(const Index jcol, const IndexVector& per } } // end while - xprune(irep) = kmin; //Pruning + xprune(irep) = StorageIndex(kmin); //Pruning } // end if do_prune } // end pruning } // End for each U-segment diff --git a/Eigen/src/SparseLU/SparseLU_relax_snode.h b/Eigen/src/SparseLU/SparseLU_relax_snode.h index 58ec32e27..c408d01b4 100644 --- a/Eigen/src/SparseLU/SparseLU_relax_snode.h +++ b/Eigen/src/SparseLU/SparseLU_relax_snode.h @@ -43,15 +43,15 @@ namespace internal { * \param descendants Number of descendants of each node in the etree * \param relax_end last column in a supernode */ -template <typename Scalar, typename Index> -void SparseLUImpl<Scalar,Index>::relax_snode (const Index n, IndexVector& et, const Index relax_columns, IndexVector& descendants, IndexVector& relax_end) +template <typename Scalar, typename StorageIndex> +void SparseLUImpl<Scalar,StorageIndex>::relax_snode (const Index n, IndexVector& et, const Index relax_columns, IndexVector& descendants, IndexVector& relax_end) { // compute the number of descendants of each node in the etree - Index j, parent; + Index parent; relax_end.setConstant(emptyIdxLU); descendants.setZero(); - for (j = 0; j < n; j++) + for (Index j = 0; j < n; j++) { parent = et(j); if (parent != n) // not the dummy root @@ -59,7 +59,7 @@ void SparseLUImpl<Scalar,Index>::relax_snode (const Index n, IndexVector& et, co } // Identify the relaxed supernodes by postorder traversal of the etree Index snode_start; // beginning of a snode - for (j = 0; j < n; ) + for (Index j = 0; j < n; ) { parent = et(j); snode_start = j; @@ -69,7 +69,7 @@ void SparseLUImpl<Scalar,Index>::relax_snode (const Index n, IndexVector& et, co parent = et(j); } // Found a supernode in postordered etree, j is the last column - relax_end(snode_start) = j; // Record last column + relax_end(snode_start) = StorageIndex(j); // Record last column j++; // Search for a new leaf while (descendants(j) != 0 && j < n) j++; diff --git a/Eigen/src/SparseQR/SparseQR.h b/Eigen/src/SparseQR/SparseQR.h index 133211488..ce4a70454 100644 --- a/Eigen/src/SparseQR/SparseQR.h +++ b/Eigen/src/SparseQR/SparseQR.h @@ -21,7 +21,7 @@ namespace internal { template <typename SparseQRType> struct traits<SparseQRMatrixQReturnType<SparseQRType> > { typedef typename SparseQRType::MatrixType ReturnType; - typedef typename ReturnType::Index Index; + typedef typename ReturnType::StorageIndex StorageIndex; typedef typename ReturnType::StorageKind StorageKind; }; template <typename SparseQRType> struct traits<SparseQRMatrixQTransposeReturnType<SparseQRType> > @@ -73,11 +73,11 @@ class SparseQR : public SparseSolverBase<SparseQR<_MatrixType,_OrderingType> > typedef _OrderingType OrderingType; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; - typedef SparseMatrix<Scalar,ColMajor,Index> QRMatrixType; - typedef Matrix<Index, Dynamic, 1> IndexVector; + typedef typename MatrixType::StorageIndex StorageIndex; + typedef SparseMatrix<Scalar,ColMajor,StorageIndex> QRMatrixType; + typedef Matrix<StorageIndex, Dynamic, 1> IndexVector; typedef Matrix<Scalar, Dynamic, 1> ScalarVector; - typedef PermutationMatrix<Dynamic, Dynamic, Index> PermutationType; + typedef PermutationMatrix<Dynamic, Dynamic, StorageIndex> PermutationType; public: SparseQR () : m_analysisIsok(false), m_lastError(""), m_useDefaultThreshold(true),m_isQSorted(false),m_isEtreeOk(false) { } @@ -123,7 +123,7 @@ class SparseQR : public SparseSolverBase<SparseQR<_MatrixType,_OrderingType> > * * \sa setPivotThreshold() */ - Index rank() const + Index rank() const { eigen_assert(m_isInitialized && "The factorization should be called first, use compute()"); return m_nonzeropivots; @@ -179,7 +179,7 @@ class SparseQR : public SparseSolverBase<SparseQR<_MatrixType,_OrderingType> > b = y; // Solve with the triangular matrix R - y.resize((std::max)(cols(),Index(y.rows())),y.cols()); + y.resize((std::max<Index>)(cols(),y.rows()),y.cols()); y.topRows(rank) = this->matrixR().topLeftCorner(rank, rank).template triangularView<Upper>().solve(b.topRows(rank)); y.bottomRows(y.rows()-rank).setZero(); @@ -260,7 +260,7 @@ class SparseQR : public SparseSolverBase<SparseQR<_MatrixType,_OrderingType> > PermutationType m_outputPerm_c; // The final column permutation RealScalar m_threshold; // Threshold to determine null Householder reflections bool m_useDefaultThreshold; // Use default threshold - Index m_nonzeropivots; // Number of non zero pivots found + Index m_nonzeropivots; // Number of non zero pivots found IndexVector m_etree; // Column elimination tree IndexVector m_firstRowElt; // First element in each row bool m_isQSorted; // whether Q is sorted or not @@ -296,7 +296,7 @@ void SparseQR<MatrixType,OrderingType>::analyzePattern(const MatrixType& mat) if (!m_perm_c.size()) { m_perm_c.resize(n); - m_perm_c.indices().setLinSpaced(n, 0,n-1); + m_perm_c.indices().setLinSpaced(n, 0,StorageIndex(n-1)); } // Compute the column elimination tree of the permuted matrix @@ -327,9 +327,9 @@ void SparseQR<MatrixType,OrderingType>::factorize(const MatrixType& mat) using std::abs; eigen_assert(m_analysisIsok && "analyzePattern() should be called before this step"); - Index m = mat.rows(); - Index n = mat.cols(); - Index diagSize = (std::min)(m,n); + StorageIndex m = StorageIndex(mat.rows()); + StorageIndex n = StorageIndex(mat.cols()); + StorageIndex diagSize = (std::min)(m,n); IndexVector mark((std::max)(m,n)); mark.setConstant(-1); // Record the visited nodes IndexVector Ridx(n), Qidx(m); // Store temporarily the row indexes for the current column of R and Q Index nzcolR, nzcolQ; // Number of nonzero for the current column of R and Q @@ -354,7 +354,7 @@ void SparseQR<MatrixType,OrderingType>::factorize(const MatrixType& mat) // otherwise directly use the input matrix // IndexVector originalOuterIndicesCpy; - const Index *originalOuterIndices = mat.outerIndexPtr(); + const StorageIndex *originalOuterIndices = mat.outerIndexPtr(); if(MatrixType::IsRowMajor) { originalOuterIndicesCpy = IndexVector::Map(m_pmat.outerIndexPtr(),n+1); @@ -385,11 +385,11 @@ void SparseQR<MatrixType,OrderingType>::factorize(const MatrixType& mat) // Initialize the numerical permutation m_pivotperm.setIdentity(n); - Index nonzeroCol = 0; // Record the number of valid pivots + StorageIndex nonzeroCol = 0; // Record the number of valid pivots m_Q.startVec(0); // Left looking rank-revealing QR factorization: compute a column of R and Q at a time - for (Index col = 0; col < n; ++col) + for (StorageIndex col = 0; col < n; ++col) { mark.setConstant(-1); m_R.startVec(col); @@ -405,12 +405,12 @@ void SparseQR<MatrixType,OrderingType>::factorize(const MatrixType& mat) // thus the trick with found_diag that permits to do one more iteration on the diagonal element if this one has not been found. for (typename QRMatrixType::InnerIterator itp(m_pmat, col); itp || !found_diag; ++itp) { - Index curIdx = nonzeroCol; - if(itp) curIdx = itp.row(); + StorageIndex curIdx = nonzeroCol; + if(itp) curIdx = StorageIndex(itp.row()); if(curIdx == nonzeroCol) found_diag = true; // Get the nonzeros indexes of the current column of R - Index st = m_firstRowElt(curIdx); // The traversal of the etree starts here + StorageIndex st = m_firstRowElt(curIdx); // The traversal of the etree starts here if (st < 0 ) { m_lastError = "Empty row found during numerical factorization"; @@ -467,7 +467,7 @@ void SparseQR<MatrixType,OrderingType>::factorize(const MatrixType& mat) { for (typename QRMatrixType::InnerIterator itq(m_Q, curIdx); itq; ++itq) { - Index iQ = itq.row(); + StorageIndex iQ = StorageIndex(itq.row()); if (mark(iQ) != col) { Qidx(nzcolQ++) = iQ; // Add this row to the pattern of Q, @@ -578,7 +578,6 @@ struct SparseQR_QProduct : ReturnByValue<SparseQR_QProduct<SparseQRType, Derived { typedef typename SparseQRType::QRMatrixType MatrixType; typedef typename SparseQRType::Scalar Scalar; - typedef typename SparseQRType::Index Index; // Get the references SparseQR_QProduct(const SparseQRType& qr, const Derived& other, bool transpose) : m_qr(qr),m_other(other),m_transpose(transpose) {} @@ -634,7 +633,6 @@ struct SparseQR_QProduct : ReturnByValue<SparseQR_QProduct<SparseQRType, Derived template<typename SparseQRType> struct SparseQRMatrixQReturnType : public EigenBase<SparseQRMatrixQReturnType<SparseQRType> > { - typedef typename SparseQRType::Index Index; typedef typename SparseQRType::Scalar Scalar; typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix; explicit SparseQRMatrixQReturnType(const SparseQRType& qr) : m_qr(qr) {} diff --git a/Eigen/src/SuperLUSupport/SuperLUSupport.h b/Eigen/src/SuperLUSupport/SuperLUSupport.h index 6de5b3dc5..d182b59b3 100644 --- a/Eigen/src/SuperLUSupport/SuperLUSupport.h +++ b/Eigen/src/SuperLUSupport/SuperLUSupport.h @@ -156,10 +156,10 @@ struct SluMatrix : SuperMatrix res.setScalarType<typename MatrixType::Scalar>(); res.Mtype = SLU_GE; - res.nrow = mat.rows(); - res.ncol = mat.cols(); + res.nrow = internal::convert_index<int>(mat.rows()); + res.ncol = internal::convert_index<int>(mat.cols()); - res.storage.lda = MatrixType::IsVectorAtCompileTime ? mat.size() : mat.outerStride(); + res.storage.lda = internal::convert_index<int>(MatrixType::IsVectorAtCompileTime ? mat.size() : mat.outerStride()); res.storage.values = (void*)(mat.data()); return res; } @@ -298,7 +298,7 @@ class SuperLUBase : public SparseSolverBase<Derived> typedef _MatrixType MatrixType; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; + typedef typename MatrixType::StorageIndex StorageIndex; typedef Matrix<Scalar,Dynamic,1> Vector; typedef Matrix<int, 1, MatrixType::ColsAtCompileTime> IntRowVectorType; typedef Matrix<int, MatrixType::RowsAtCompileTime, 1> IntColVectorType; @@ -457,7 +457,7 @@ class SuperLU : public SuperLUBase<_MatrixType,SuperLU<_MatrixType> > typedef _MatrixType MatrixType; typedef typename Base::Scalar Scalar; typedef typename Base::RealScalar RealScalar; - typedef typename Base::Index Index; + typedef typename Base::StorageIndex StorageIndex; typedef typename Base::IntRowVectorType IntRowVectorType; typedef typename Base::IntColVectorType IntColVectorType; typedef typename Base::LUMatrixType LUMatrixType; @@ -616,8 +616,8 @@ void SuperLU<MatrixType>::_solve_impl(const MatrixBase<Rhs> &b, MatrixBase<Dest> { eigen_assert(m_factorizationIsOk && "The decomposition is not in a valid state for solving, you must first call either compute() or analyzePattern()/factorize()"); - const int size = m_matrix.rows(); - const int rhsCols = b.cols(); + const Index size = m_matrix.rows(); + const Index rhsCols = b.cols(); eigen_assert(size==b.rows()); m_sluOptions.Trans = NOTRANS; @@ -808,7 +808,6 @@ class SuperILU : public SuperLUBase<_MatrixType,SuperILU<_MatrixType> > typedef _MatrixType MatrixType; typedef typename Base::Scalar Scalar; typedef typename Base::RealScalar RealScalar; - typedef typename Base::Index Index; public: using Base::_solve_impl; diff --git a/Eigen/src/UmfPackSupport/UmfPackSupport.h b/Eigen/src/UmfPackSupport/UmfPackSupport.h index a2bb75b09..3d30403c7 100644 --- a/Eigen/src/UmfPackSupport/UmfPackSupport.h +++ b/Eigen/src/UmfPackSupport/UmfPackSupport.h @@ -141,7 +141,7 @@ class UmfPackLU : public SparseSolverBase<UmfPackLU<_MatrixType> > typedef _MatrixType MatrixType; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; - typedef typename MatrixType::Index Index; + typedef typename MatrixType::StorageIndex StorageIndex; typedef Matrix<Scalar,Dynamic,1> Vector; typedef Matrix<int, 1, MatrixType::ColsAtCompileTime> IntRowVectorType; typedef Matrix<int, MatrixType::RowsAtCompileTime, 1> IntColVectorType; @@ -279,7 +279,7 @@ class UmfPackLU : public SparseSolverBase<UmfPackLU<_MatrixType> > void grapInput_impl(const InputMatrixType& mat, internal::true_type) { m_copyMatrix.resize(mat.rows(), mat.cols()); - if( ((MatrixType::Flags&RowMajorBit)==RowMajorBit) || sizeof(typename MatrixType::Index)!=sizeof(int) || !mat.isCompressed() ) + if( ((MatrixType::Flags&RowMajorBit)==RowMajorBit) || sizeof(typename MatrixType::StorageIndex)!=sizeof(int) || !mat.isCompressed() ) { // non supported input -> copy m_copyMatrix = mat; @@ -313,8 +313,9 @@ class UmfPackLU : public SparseSolverBase<UmfPackLU<_MatrixType> > void analyzePattern_impl() { int errorCode = 0; - errorCode = umfpack_symbolic(m_copyMatrix.rows(), m_copyMatrix.cols(), m_outerIndexPtr, m_innerIndexPtr, m_valuePtr, - &m_symbolic, 0, 0); + errorCode = umfpack_symbolic(internal::convert_index<int>(m_copyMatrix.rows()), + internal::convert_index<int>(m_copyMatrix.cols()), + m_outerIndexPtr, m_innerIndexPtr, m_valuePtr, &m_symbolic, 0, 0); m_isInitialized = true; m_info = errorCode ? InvalidInput : Success; @@ -397,7 +398,7 @@ template<typename MatrixType> template<typename BDerived,typename XDerived> bool UmfPackLU<MatrixType>::_solve_impl(const MatrixBase<BDerived> &b, MatrixBase<XDerived> &x) const { - const int rhsCols = b.cols(); + Index rhsCols = b.cols(); eigen_assert((BDerived::Flags&RowMajorBit)==0 && "UmfPackLU backend does not support non col-major rhs yet"); eigen_assert((XDerived::Flags&RowMajorBit)==0 && "UmfPackLU backend does not support non col-major result yet"); eigen_assert(b.derived().data() != x.derived().data() && " Umfpack does not support inplace solve"); diff --git a/Eigen/src/misc/Image.h b/Eigen/src/misc/Image.h index 75c5f433a..b8b8a0455 100644 --- a/Eigen/src/misc/Image.h +++ b/Eigen/src/misc/Image.h @@ -38,7 +38,6 @@ template<typename _DecompositionType> struct image_retval_base typedef _DecompositionType DecompositionType; typedef typename DecompositionType::MatrixType MatrixType; typedef ReturnByValue<image_retval_base> Base; - typedef typename Base::Index Index; image_retval_base(const DecompositionType& dec, const MatrixType& originalMatrix) : m_dec(dec), m_rank(dec.rank()), @@ -69,7 +68,6 @@ template<typename _DecompositionType> struct image_retval_base typedef typename DecompositionType::MatrixType MatrixType; \ typedef typename MatrixType::Scalar Scalar; \ typedef typename MatrixType::RealScalar RealScalar; \ - typedef typename MatrixType::Index Index; \ typedef Eigen::internal::image_retval_base<DecompositionType> Base; \ using Base::dec; \ using Base::originalMatrix; \ diff --git a/Eigen/src/misc/Kernel.h b/Eigen/src/misc/Kernel.h index 4b03e44c1..bef5d6ff5 100644 --- a/Eigen/src/misc/Kernel.h +++ b/Eigen/src/misc/Kernel.h @@ -39,7 +39,6 @@ template<typename _DecompositionType> struct kernel_retval_base { typedef _DecompositionType DecompositionType; typedef ReturnByValue<kernel_retval_base> Base; - typedef typename Base::Index Index; explicit kernel_retval_base(const DecompositionType& dec) : m_dec(dec), @@ -68,7 +67,6 @@ template<typename _DecompositionType> struct kernel_retval_base typedef typename DecompositionType::MatrixType MatrixType; \ typedef typename MatrixType::Scalar Scalar; \ typedef typename MatrixType::RealScalar RealScalar; \ - typedef typename MatrixType::Index Index; \ typedef Eigen::internal::kernel_retval_base<DecompositionType> Base; \ using Base::dec; \ using Base::rank; \ |