diff --git a/Eigen/src/Array/ArrayBase.h b/Eigen/src/Array/ArrayBase.h index ccbc77202..527bcd329 100644 --- a/Eigen/src/Array/ArrayBase.h +++ b/Eigen/src/Array/ArrayBase.h @@ -61,7 +61,7 @@ template class ArrayBase typename NumTraits::Scalar>::Real>::operator*; typedef typename ei_traits::StorageKind StorageKind; - typedef typename ei_index::type Index; + typedef typename ei_traits::Index Index; typedef typename ei_traits::Scalar Scalar; typedef typename ei_packet_traits::type PacketScalar; typedef typename NumTraits::Real RealScalar; diff --git a/Eigen/src/Core/BandMatrix.h b/Eigen/src/Core/BandMatrix.h index fbe7e394b..af2a81df3 100644 --- a/Eigen/src/Core/BandMatrix.h +++ b/Eigen/src/Core/BandMatrix.h @@ -47,6 +47,7 @@ struct ei_traits > { typedef _Scalar Scalar; typedef Dense StorageKind; + typedef DenseIndex Index; enum { CoeffReadCost = NumTraits::ReadCost, RowsAtCompileTime = Rows, diff --git a/Eigen/src/Core/CwiseBinaryOp.h b/Eigen/src/Core/CwiseBinaryOp.h index 530777577..6e158fdf1 100644 --- a/Eigen/src/Core/CwiseBinaryOp.h +++ b/Eigen/src/Core/CwiseBinaryOp.h @@ -57,6 +57,8 @@ struct ei_traits > : ei_traits >::type Scalar; typedef typename ei_promote_storage_type::StorageKind, typename ei_traits::StorageKind>::ret StorageKind; + typedef typename ei_promote_index_type::Index, + typename ei_traits::Index>::type Index; typedef typename Lhs::Nested LhsNested; typedef typename Rhs::Nested RhsNested; typedef typename ei_unref::type _LhsNested; @@ -97,7 +99,7 @@ class CwiseBinaryOp : ei_no_assignment_operator, BinaryOp, Lhs, Rhs, typename ei_promote_storage_type::StorageKind, typename ei_traits::StorageKind>::ret>::Base Base; - EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(CwiseBinaryOp) + EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseBinaryOp) typedef typename ei_nested::type LhsNested; typedef typename ei_nested::type RhsNested; @@ -125,14 +127,14 @@ class CwiseBinaryOp : ei_no_assignment_operator, EIGEN_STRONG_INLINE Index rows() const { // return the fixed size type if available to enable compile time optimizations - if (ei_traits::type>::RowsAtCompileTime==Dynamic) + if (ei_traits::type>::RowsAtCompileTime==Dynamic) return m_rhs.rows(); else return m_lhs.rows(); } EIGEN_STRONG_INLINE Index cols() const { // return the fixed size type if available to enable compile time optimizations - if (ei_traits::type>::ColsAtCompileTime==Dynamic) + if (ei_traits::type>::ColsAtCompileTime==Dynamic) return m_rhs.cols(); else return m_lhs.cols(); diff --git a/Eigen/src/Core/CwiseUnaryOp.h b/Eigen/src/Core/CwiseUnaryOp.h index da398d131..a05ef1d9f 100644 --- a/Eigen/src/Core/CwiseUnaryOp.h +++ b/Eigen/src/Core/CwiseUnaryOp.h @@ -71,7 +71,7 @@ class CwiseUnaryOp : ei_no_assignment_operator, public: typedef typename CwiseUnaryOpImpl::StorageKind>::Base Base; - EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(CwiseUnaryOp) + EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryOp) inline CwiseUnaryOp(const XprType& xpr, const UnaryOp& func = UnaryOp()) : m_xpr(xpr), m_functor(func) {} diff --git a/Eigen/src/Core/CwiseUnaryView.h b/Eigen/src/Core/CwiseUnaryView.h index 11a23c66a..1fbe440af 100644 --- a/Eigen/src/Core/CwiseUnaryView.h +++ b/Eigen/src/Core/CwiseUnaryView.h @@ -67,7 +67,7 @@ class CwiseUnaryView : ei_no_assignment_operator, public: typedef typename CwiseUnaryViewImpl::StorageKind>::Base Base; - EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(CwiseUnaryView) + EIGEN_GENERIC_PUBLIC_INTERFACE(CwiseUnaryView) inline CwiseUnaryView(const MatrixType& mat, const ViewOp& func = ViewOp()) : m_matrix(mat), m_functor(func) {} diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index 80db0f421..95e37801d 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -51,7 +51,7 @@ template class DenseBase class InnerIterator; typedef typename ei_traits::StorageKind StorageKind; - typedef typename ei_index::type Index; + typedef typename ei_traits::Index Index; typedef typename ei_traits::Scalar Scalar; typedef typename ei_packet_traits::type PacketScalar; typedef typename NumTraits::Real RealScalar; diff --git a/Eigen/src/Core/DenseCoeffsBase.h b/Eigen/src/Core/DenseCoeffsBase.h index 7026bbe34..c55576c02 100644 --- a/Eigen/src/Core/DenseCoeffsBase.h +++ b/Eigen/src/Core/DenseCoeffsBase.h @@ -30,7 +30,7 @@ class DenseCoeffsBase : public EigenBase { public: typedef typename ei_traits::StorageKind StorageKind; - typedef typename ei_index::type Index; + typedef typename ei_traits::Index Index; typedef typename ei_traits::Scalar Scalar; typedef typename ei_packet_traits::type PacketScalar; typedef typename ei_meta_if::ret, const Scalar&, Scalar>::ret CoeffReturnType; @@ -40,7 +40,7 @@ class DenseCoeffsBase : public EigenBase using Base::cols; using Base::size; using Base::derived; - + EIGEN_STRONG_INLINE Index rowIndexByOuterInner(Index outer, Index inner) const { return int(Derived::RowsAtCompileTime) == 1 ? 0 @@ -245,7 +245,7 @@ class DenseCoeffsBase : public DenseCoeffsBase typedef DenseCoeffsBase Base; typedef typename ei_traits::StorageKind StorageKind; - typedef typename ei_index::type Index; + typedef typename ei_traits::Index Index; typedef typename ei_traits::Scalar Scalar; typedef typename ei_packet_traits::type PacketScalar; typedef typename NumTraits::Real RealScalar; diff --git a/Eigen/src/Core/DenseStorageBase.h b/Eigen/src/Core/DenseStorageBase.h index 15f3988ea..a9c4607b7 100644 --- a/Eigen/src/Core/DenseStorageBase.h +++ b/Eigen/src/Core/DenseStorageBase.h @@ -46,7 +46,7 @@ class DenseStorageBase : public ei_dense_xpr_base::type typedef typename ei_dense_xpr_base::type Base; typedef typename ei_traits::StorageKind StorageKind; - typedef typename ei_index::type Index; + typedef typename ei_traits::Index Index; typedef typename ei_traits::Scalar Scalar; typedef typename ei_packet_traits::type PacketScalar; typedef typename NumTraits::Real RealScalar; diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h index 8d3b458a9..34eeda089 100644 --- a/Eigen/src/Core/DiagonalMatrix.h +++ b/Eigen/src/Core/DiagonalMatrix.h @@ -34,7 +34,7 @@ class DiagonalBase : public EigenBase typedef typename ei_traits::DiagonalVectorType DiagonalVectorType; typedef typename DiagonalVectorType::Scalar Scalar; typedef typename ei_traits::StorageKind StorageKind; - typedef typename ei_index::type Index; + typedef typename ei_traits::Index Index; enum { RowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime, @@ -103,6 +103,7 @@ struct ei_traits { typedef Matrix<_Scalar,SizeAtCompileTime,1,0,MaxSizeAtCompileTime,1> DiagonalVectorType; typedef Dense StorageKind; + typedef DenseIndex Index; }; template @@ -115,7 +116,7 @@ class DiagonalMatrix typedef const DiagonalMatrix& Nested; typedef _Scalar Scalar; typedef typename ei_traits::StorageKind StorageKind; - typedef typename ei_index::type Index; + typedef typename ei_traits::Index Index; #endif protected: @@ -203,6 +204,7 @@ struct ei_traits > { typedef _DiagonalVectorType DiagonalVectorType; typedef typename DiagonalVectorType::Scalar Scalar; + typedef typename DiagonalVectorType::Index Index; typedef typename DiagonalVectorType::StorageKind StorageKind; enum { RowsAtCompileTime = DiagonalVectorType::SizeAtCompileTime, diff --git a/Eigen/src/Core/EigenBase.h b/Eigen/src/Core/EigenBase.h index c9d3bd875..3485b36d2 100644 --- a/Eigen/src/Core/EigenBase.h +++ b/Eigen/src/Core/EigenBase.h @@ -40,7 +40,7 @@ template struct EigenBase // typedef typename ei_plain_matrix_type::type PlainObject; typedef typename ei_traits::StorageKind StorageKind; - typedef typename ei_index::type Index; + typedef typename ei_traits::Index Index; /** \returns a reference to the derived object */ Derived& derived() { return *static_cast(this); } diff --git a/Eigen/src/Core/MapBase.h b/Eigen/src/Core/MapBase.h index 8cdd452ac..e0b3a7857 100644 --- a/Eigen/src/Core/MapBase.h +++ b/Eigen/src/Core/MapBase.h @@ -46,7 +46,7 @@ template class MapBase typedef typename ei_traits::StorageKind StorageKind; - typedef typename ei_index::type Index; + typedef typename ei_traits::Index Index; typedef typename ei_traits::Scalar Scalar; typedef typename ei_packet_traits::type PacketScalar; typedef typename NumTraits::Real RealScalar; diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index 4407b0db1..54fca7046 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -113,6 +113,7 @@ struct ei_traits > { typedef _Scalar Scalar; typedef Dense StorageKind; + typedef DenseIndex Index; typedef MatrixXpr XprKind; enum { RowsAtCompileTime = _Rows, diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 633b0106e..ebda37d07 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -58,11 +58,11 @@ template class MatrixBase #ifndef EIGEN_PARSED_BY_DOXYGEN typedef MatrixBase StorageBaseType; typedef typename ei_traits::StorageKind StorageKind; - typedef typename ei_index::type Index; + typedef typename ei_traits::Index Index; typedef typename ei_traits::Scalar Scalar; typedef typename ei_packet_traits::type PacketScalar; typedef typename NumTraits::Real RealScalar; - + typedef DenseBase Base; using Base::RowsAtCompileTime; using Base::ColsAtCompileTime; diff --git a/Eigen/src/Core/ProductBase.h b/Eigen/src/Core/ProductBase.h index 36626f838..35a3a280f 100644 --- a/Eigen/src/Core/ProductBase.h +++ b/Eigen/src/Core/ProductBase.h @@ -37,6 +37,8 @@ struct ei_traits > typedef typename ei_scalar_product_traits::ReturnType Scalar; typedef typename ei_promote_storage_type::StorageKind, typename ei_traits::StorageKind>::ret StorageKind; + typedef typename ei_promote_index_type::Index, + typename ei_traits::Index>::type Index; enum { RowsAtCompileTime = ei_traits::RowsAtCompileTime, ColsAtCompileTime = ei_traits::ColsAtCompileTime, diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index 38d942e04..6928ae31a 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -66,7 +66,7 @@ template class Transpose public: typedef typename TransposeImpl::StorageKind>::Base Base; - EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(Transpose) + EIGEN_GENERIC_PUBLIC_INTERFACE(Transpose) inline Transpose(const MatrixType& matrix) : m_matrix(matrix) {} diff --git a/Eigen/src/Core/TriangularMatrix.h b/Eigen/src/Core/TriangularMatrix.h index d4799fbc1..20af49c90 100644 --- a/Eigen/src/Core/TriangularMatrix.h +++ b/Eigen/src/Core/TriangularMatrix.h @@ -46,7 +46,7 @@ template class TriangularBase : public EigenBase }; typedef typename ei_traits::Scalar Scalar; typedef typename ei_traits::StorageKind StorageKind; - typedef typename ei_index::type Index; + typedef typename ei_traits::Index Index; inline TriangularBase() { ei_assert(!((Mode&UnitDiag) && (Mode&ZeroDiag))); } @@ -159,7 +159,7 @@ template class TriangularView using Base::evalToLazy; typedef typename ei_traits::StorageKind StorageKind; - typedef typename ei_index::type Index; + typedef typename ei_traits::Index Index; enum { Mode = _Mode, diff --git a/Eigen/src/Core/products/CoeffBasedProduct.h b/Eigen/src/Core/products/CoeffBasedProduct.h index 0c39cbd84..317fdfd4c 100644 --- a/Eigen/src/Core/products/CoeffBasedProduct.h +++ b/Eigen/src/Core/products/CoeffBasedProduct.h @@ -54,6 +54,8 @@ struct ei_traits > typedef typename ei_scalar_product_traits::ReturnType Scalar; typedef typename ei_promote_storage_type::StorageKind, typename ei_traits<_RhsNested>::StorageKind>::ret StorageKind; + typedef typename ei_promote_index_type::Index, + typename ei_traits<_RhsNested>::Index>::type Index; enum { LhsCoeffReadCost = _LhsNested::CoeffReadCost, diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index 312a14414..82045b37c 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -98,10 +98,6 @@ #define EIGEN_DEFAULT_DENSE_INDEX_TYPE std::ptrdiff_t #endif -#ifndef EIGEN_DEFAULT_SPARSE_INDEX_TYPE -#define EIGEN_DEFAULT_SPARSE_INDEX_TYPE int -#endif - /** Allows to disable some optimizations which might affect the accuracy of the result. * Such optimization are enabled by default, and set EIGEN_FAST_MATH to 0 to disable them. * They currently include: @@ -269,13 +265,13 @@ * documentation in a single line. **/ -#define EIGEN_GENERIC_PUBLIC_INTERFACE_NEW(Derived) \ +#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \ typedef typename Eigen::ei_traits::Scalar Scalar; /*!< \brief Numeric type, e.g. float, double, int or std::complex. */ \ typedef typename Eigen::NumTraits::Real RealScalar; /*!< \brief The underlying numeric type for composed scalar types. \details In cases where Scalar is e.g. std::complex, T were corresponding to RealScalar. */ \ 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::ei_nested::type Nested; \ typedef typename Eigen::ei_traits::StorageKind StorageKind; \ - typedef typename Eigen::ei_index::type Index; \ + typedef typename Eigen::ei_traits::Index Index; \ enum { RowsAtCompileTime = Eigen::ei_traits::RowsAtCompileTime, \ ColsAtCompileTime = Eigen::ei_traits::ColsAtCompileTime, \ Flags = Eigen::ei_traits::Flags, \ @@ -292,7 +288,7 @@ 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::ei_nested::type Nested; \ typedef typename Eigen::ei_traits::StorageKind StorageKind; \ - typedef typename Eigen::ei_index::type Index; \ + typedef typename Eigen::ei_traits::Index Index; \ enum { RowsAtCompileTime = Eigen::ei_traits::RowsAtCompileTime, \ ColsAtCompileTime = Eigen::ei_traits::ColsAtCompileTime, \ MaxRowsAtCompileTime = Eigen::ei_traits::MaxRowsAtCompileTime, \ diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index 63e99730a..9b82a609a 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -42,13 +42,14 @@ class ei_no_assignment_operator ei_no_assignment_operator& operator=(const ei_no_assignment_operator&); }; -template struct ei_index {}; +typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE DenseIndex; -template<> -struct ei_index -{ typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE type; }; - -typedef ei_index::type DenseIndex; +/** \internal return the index type with the largest number of bits */ +template +struct ei_promote_index_type +{ + typedef typename ei_meta_if<(sizeof(I1)::ret type; +}; /** \internal If the template parameter Value is Dynamic, this class is just a wrapper around a T variable that * can be accessed using value() and setValue(). diff --git a/Eigen/src/Householder/HouseholderSequence.h b/Eigen/src/Householder/HouseholderSequence.h index 90c5bf8a2..835fe6a1c 100644 --- a/Eigen/src/Householder/HouseholderSequence.h +++ b/Eigen/src/Householder/HouseholderSequence.h @@ -53,6 +53,7 @@ template struct ei_traits > { typedef typename VectorsType::Scalar Scalar; + typedef typename VectorsType::Index Index; typedef typename VectorsType::StorageKind StorageKind; enum { RowsAtCompileTime = Side==OnTheLeft ? ei_traits::RowsAtCompileTime diff --git a/Eigen/src/LU/FullPivLU.h b/Eigen/src/LU/FullPivLU.h index da4dce6bc..61a6fd730 100644 --- a/Eigen/src/LU/FullPivLU.h +++ b/Eigen/src/LU/FullPivLU.h @@ -69,7 +69,7 @@ template class FullPivLU typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef typename ei_traits::StorageKind StorageKind; - typedef typename ei_index::type Index; + typedef typename MatrixType::Index Index; typedef typename ei_plain_row_type::type IntRowVectorType; typedef typename ei_plain_col_type::type IntColVectorType; typedef PermutationMatrix PermutationQType; diff --git a/Eigen/src/LU/PartialPivLU.h b/Eigen/src/LU/PartialPivLU.h index 39c348e5e..0bf1ac3ce 100644 --- a/Eigen/src/LU/PartialPivLU.h +++ b/Eigen/src/LU/PartialPivLU.h @@ -72,7 +72,7 @@ template class PartialPivLU typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef typename ei_traits::StorageKind StorageKind; - typedef typename ei_index::type Index; + typedef typename MatrixType::Index Index; typedef typename ei_plain_col_type::type PermutationVectorType; typedef PermutationMatrix PermutationType; diff --git a/Eigen/src/Sparse/AmbiVector.h b/Eigen/src/Sparse/AmbiVector.h index 7b18f8cc2..673cb32a5 100644 --- a/Eigen/src/Sparse/AmbiVector.h +++ b/Eigen/src/Sparse/AmbiVector.h @@ -30,12 +30,14 @@ * * See BasicSparseLLT and SparseProduct for usage examples. */ -template class AmbiVector +template +class AmbiVector { public: typedef _Scalar Scalar; + typedef _Index Index; typedef typename NumTraits::Real RealScalar; - typedef SparseIndex Index; + AmbiVector(Index size) : m_buffer(0), m_zero(0), m_size(0), m_allocatedSize(0), m_allocatedElements(0), m_mode(-1) { @@ -130,8 +132,8 @@ template class AmbiVector }; /** \returns the number of non zeros in the current sub vector */ -template -SparseIndex AmbiVector::nonZeros() const +template +_Index AmbiVector<_Scalar,_Index>::nonZeros() const { if (m_mode==IsSparse) return m_llSize; @@ -139,8 +141,8 @@ SparseIndex AmbiVector::nonZeros() const return m_end - m_start; } -template -void AmbiVector::init(double estimatedDensity) +template +void AmbiVector<_Scalar,_Index>::init(double estimatedDensity) { if (estimatedDensity>0.1) init(IsDense); @@ -148,8 +150,8 @@ void AmbiVector::init(double estimatedDensity) init(IsSparse); } -template -void AmbiVector::init(int mode) +template +void AmbiVector<_Scalar,_Index>::init(int mode) { m_mode = mode; if (m_mode==IsSparse) @@ -164,15 +166,15 @@ void AmbiVector::init(int mode) * * Don't worry, this function is extremely cheap. */ -template -void AmbiVector::restart() +template +void AmbiVector<_Scalar,_Index>::restart() { m_llCurrent = m_llStart; } /** Set all coefficients of current subvector to zero */ -template -void AmbiVector::setZero() +template +void AmbiVector<_Scalar,_Index>::setZero() { if (m_mode==IsDense) { @@ -187,8 +189,8 @@ void AmbiVector::setZero() } } -template -Scalar& AmbiVector::coeffRef(Index i) +template +_Scalar& AmbiVector<_Scalar,_Index>::coeffRef(_Index i) { if (m_mode==IsDense) return m_buffer[i]; @@ -256,8 +258,8 @@ Scalar& AmbiVector::coeffRef(Index i) } } -template -Scalar& AmbiVector::coeff(Index i) +template +_Scalar& AmbiVector<_Scalar,_Index>::coeff(_Index i) { if (m_mode==IsDense) return m_buffer[i]; @@ -284,8 +286,8 @@ Scalar& AmbiVector::coeff(Index i) } /** Iterator over the nonzero coefficients */ -template -class AmbiVector<_Scalar>::Iterator +template +class AmbiVector<_Scalar,_Index>::Iterator { public: typedef _Scalar Scalar; diff --git a/Eigen/src/Sparse/CholmodSupport.h b/Eigen/src/Sparse/CholmodSupport.h index 1b34492aa..a8d7a8fec 100644 --- a/Eigen/src/Sparse/CholmodSupport.h +++ b/Eigen/src/Sparse/CholmodSupport.h @@ -109,8 +109,8 @@ cholmod_dense ei_cholmod_map_eigen_to_dense(MatrixBase& mat) return res; } -template -MappedSparseMatrix::MappedSparseMatrix(cholmod_sparse& cm) +template +MappedSparseMatrix::MappedSparseMatrix(cholmod_sparse& cm) { m_innerSize = cm.nrow; m_outerSize = cm.ncol; diff --git a/Eigen/src/Sparse/CompressedStorage.h b/Eigen/src/Sparse/CompressedStorage.h index 37d337639..73488f225 100644 --- a/Eigen/src/Sparse/CompressedStorage.h +++ b/Eigen/src/Sparse/CompressedStorage.h @@ -28,12 +28,20 @@ /** Stores a sparse set of values as a list of values and a list of indices. * */ -template +template class CompressedStorage { - typedef typename NumTraits::Real RealScalar; - typedef SparseIndex Index; public: + + typedef _Scalar Scalar; + typedef _Index Index; + + protected: + + typedef typename NumTraits::Real RealScalar; + + public: + CompressedStorage() : m_values(0), m_indices(0), m_size(0), m_allocatedSize(0) {} @@ -118,13 +126,13 @@ class CompressedStorage res.m_allocatedSize = res.m_size = size; return res; } - + /** \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 { 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 { @@ -138,7 +146,7 @@ class CompressedStorage } return static_cast(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, Scalar defaultValue = Scalar(0)) const @@ -152,7 +160,7 @@ class CompressedStorage const size_t id = searchLowerIndex(0,m_size-1,key); return ((id::dummy_precision()) { size_t k = 0; diff --git a/Eigen/src/Sparse/DynamicSparseMatrix.h b/Eigen/src/Sparse/DynamicSparseMatrix.h index defe312b3..d0ce2b248 100644 --- a/Eigen/src/Sparse/DynamicSparseMatrix.h +++ b/Eigen/src/Sparse/DynamicSparseMatrix.h @@ -42,10 +42,11 @@ * * \see SparseMatrix */ -template -struct ei_traits > +template +struct ei_traits > { typedef _Scalar Scalar; + typedef _Index Index; typedef Sparse StorageKind; typedef MatrixXpr XprKind; enum { @@ -59,12 +60,12 @@ struct ei_traits > }; }; -template +template class DynamicSparseMatrix - : public SparseMatrixBase > + : public SparseMatrixBase > { public: - EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(DynamicSparseMatrix) + EIGEN_SPARSE_PUBLIC_INTERFACE(DynamicSparseMatrix) // FIXME: why are these operator already alvailable ??? // EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(DynamicSparseMatrix, +=) // EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(DynamicSparseMatrix, -=) @@ -76,7 +77,7 @@ class DynamicSparseMatrix typedef DynamicSparseMatrix TransposedSparseMatrix; Index m_innerSize; - std::vector > m_data; + std::vector > m_data; public: @@ -86,8 +87,8 @@ class DynamicSparseMatrix inline Index outerSize() const { return static_cast(m_data.size()); } inline Index innerNonZeros(Index j) const { return m_data[j].size(); } - std::vector >& _data() { return m_data; } - const std::vector >& _data() const { return m_data; } + std::vector >& _data() { return m_data; } + const std::vector >& _data() const { return m_data; } /** \returns the coefficient value at given position \a row, \a col * This operation involes a log(rho*outer_size) binary search. @@ -321,8 +322,8 @@ class DynamicSparseMatrix EIGEN_DEPRECATED void endFill() {} }; -template -class DynamicSparseMatrix::InnerIterator : public SparseVector::InnerIterator +template +class DynamicSparseMatrix::InnerIterator : public SparseVector::InnerIterator { typedef typename SparseVector::InnerIterator Base; public: diff --git a/Eigen/src/Sparse/MappedSparseMatrix.h b/Eigen/src/Sparse/MappedSparseMatrix.h index 07233ac67..99aeeb106 100644 --- a/Eigen/src/Sparse/MappedSparseMatrix.h +++ b/Eigen/src/Sparse/MappedSparseMatrix.h @@ -34,25 +34,25 @@ * See http://www.netlib.org/linalg/html_templates/node91.html for details on the storage scheme. * */ -template -struct ei_traits > : ei_traits > +template +struct ei_traits > : ei_traits > {}; -template +template class MappedSparseMatrix - : public SparseMatrixBase > + : public SparseMatrixBase > { public: - EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(MappedSparseMatrix) + EIGEN_SPARSE_PUBLIC_INTERFACE(MappedSparseMatrix) protected: enum { IsRowMajor = Base::IsRowMajor }; - Index m_outerSize; - Index m_innerSize; - Index m_nnz; - Index* m_outerIndex; - Index* m_innerIndices; + Index m_outerSize; + Index m_innerSize; + Index m_nnz; + Index* m_outerIndex; + Index* m_innerIndices; Scalar* m_values; public: @@ -135,8 +135,8 @@ class MappedSparseMatrix inline ~MappedSparseMatrix() {} }; -template -class MappedSparseMatrix::InnerIterator +template +class MappedSparseMatrix::InnerIterator { public: InnerIterator(const MappedSparseMatrix& mat, Index outer) diff --git a/Eigen/src/Sparse/SparseBlock.h b/Eigen/src/Sparse/SparseBlock.h index bf8b5adc7..8e530182d 100644 --- a/Eigen/src/Sparse/SparseBlock.h +++ b/Eigen/src/Sparse/SparseBlock.h @@ -29,6 +29,7 @@ template struct ei_traits > { typedef typename ei_traits::Scalar Scalar; + typedef typename ei_traits::Index Index; typedef typename ei_traits::StorageKind StorageKind; typedef MatrixXpr XprKind; enum { @@ -50,7 +51,7 @@ class SparseInnerVectorSet : ei_no_assignment_operator, enum { IsRowMajor = ei_traits::IsRowMajor }; - EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(SparseInnerVectorSet) + EIGEN_SPARSE_PUBLIC_INTERFACE(SparseInnerVectorSet) class InnerIterator: public MatrixType::InnerIterator { public: @@ -111,7 +112,7 @@ class SparseInnerVectorSet, Size> enum { IsRowMajor = ei_traits::IsRowMajor }; - EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(SparseInnerVectorSet) + EIGEN_SPARSE_PUBLIC_INTERFACE(SparseInnerVectorSet) class InnerIterator: public MatrixType::InnerIterator { public: @@ -209,7 +210,7 @@ class SparseInnerVectorSet, Size> enum { IsRowMajor = ei_traits::IsRowMajor }; - EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(SparseInnerVectorSet) + EIGEN_SPARSE_PUBLIC_INTERFACE(SparseInnerVectorSet) class InnerIterator: public MatrixType::InnerIterator { public: diff --git a/Eigen/src/Sparse/SparseDiagonalProduct.h b/Eigen/src/Sparse/SparseDiagonalProduct.h index 70b35bc23..f5da2c269 100644 --- a/Eigen/src/Sparse/SparseDiagonalProduct.h +++ b/Eigen/src/Sparse/SparseDiagonalProduct.h @@ -43,6 +43,8 @@ struct ei_traits > typedef typename ei_cleantype::type _Lhs; typedef typename ei_cleantype::type _Rhs; typedef typename _Lhs::Scalar Scalar; + typedef typename ei_promote_index_type::Index, + typename ei_traits::Index>::type Index; typedef Sparse StorageKind; typedef MatrixXpr XprKind; enum { @@ -82,7 +84,7 @@ class SparseDiagonalProduct public: - EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(SparseDiagonalProduct) + EIGEN_SPARSE_PUBLIC_INTERFACE(SparseDiagonalProduct) typedef ei_sparse_diagonal_product_inner_iterator_selector <_LhsNested,_RhsNested,SparseDiagonalProduct,LhsMode,RhsMode> InnerIterator; diff --git a/Eigen/src/Sparse/SparseLDLT.h b/Eigen/src/Sparse/SparseLDLT.h index b6a51c6a6..ae1a96b4f 100644 --- a/Eigen/src/Sparse/SparseLDLT.h +++ b/Eigen/src/Sparse/SparseLDLT.h @@ -339,7 +339,7 @@ bool SparseLDLT::solveInPlace(MatrixBase &b) const // FIXME should be .adjoint() but it fails to compile... if (m_matrix.nonZeros()>0) // otherwise L==I - m_matrix.transpose().template triangularView().solveInPlace(b); + m_matrix.adjoint().template triangularView().solveInPlace(b); return true; } diff --git a/Eigen/src/Sparse/SparseLLT.h b/Eigen/src/Sparse/SparseLLT.h index 37c6c3f9a..4ec3ee009 100644 --- a/Eigen/src/Sparse/SparseLLT.h +++ b/Eigen/src/Sparse/SparseLLT.h @@ -132,7 +132,7 @@ void SparseLLT::compute(const MatrixType& a) m_matrix.resize(size, size); // allocate a temporary vector for accumulations - AmbiVector tempVector(size); + AmbiVector tempVector(size); RealScalar density = a.nonZeros()/RealScalar(size*size); // TODO estimate the number of non zeros @@ -177,7 +177,7 @@ void SparseLLT::compute(const MatrixType& a) RealScalar rx = ei_sqrt(ei_real(x)); m_matrix.insert(j,j) = rx; // FIXME use insertBack Scalar y = Scalar(1)/rx; - for (typename AmbiVector::Iterator it(tempVector, m_precision*rx); it; ++it) + for (typename AmbiVector::Iterator it(tempVector, m_precision*rx); it; ++it) { // FIXME use insertBack m_matrix.insert(it.index(), j) = it.value() * y; diff --git a/Eigen/src/Sparse/SparseMatrix.h b/Eigen/src/Sparse/SparseMatrix.h index 22a7d149a..e8e947eea 100644 --- a/Eigen/src/Sparse/SparseMatrix.h +++ b/Eigen/src/Sparse/SparseMatrix.h @@ -37,14 +37,16 @@ * \param _Scalar the scalar type, i.e. the type of the coefficients * \param _Options Union of bit flags controlling the storage scheme. Currently the only possibility * is RowMajor. The default is 0 which means column-major. + * \param _Index the type of the indices. Default is \c int. * * See http://www.netlib.org/linalg/html_templates/node91.html for details on the storage scheme. * */ -template -struct ei_traits > +template +struct ei_traits > { typedef _Scalar Scalar; + typedef _Index Index; typedef Sparse StorageKind; typedef MatrixXpr XprKind; enum { @@ -58,12 +60,12 @@ struct ei_traits > }; }; -template +template class SparseMatrix - : public SparseMatrixBase > + : public SparseMatrixBase > { public: - EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(SparseMatrix) + EIGEN_SPARSE_PUBLIC_INTERFACE(SparseMatrix) EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(SparseMatrix, +=) EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(SparseMatrix, -=) // FIXME: why are these operator already alvailable ??? @@ -80,7 +82,7 @@ class SparseMatrix Index m_outerSize; Index m_innerSize; Index* m_outerIndex; - CompressedStorage m_data; + CompressedStorage m_data; public: @@ -570,8 +572,8 @@ class SparseMatrix EIGEN_DEPRECATED void endFill() { finalize(); } }; -template -class SparseMatrix::InnerIterator +template +class SparseMatrix::InnerIterator { public: InnerIterator(const SparseMatrix& mat, Index outer) diff --git a/Eigen/src/Sparse/SparseMatrixBase.h b/Eigen/src/Sparse/SparseMatrixBase.h index 6f34b5c4e..a2b527e53 100644 --- a/Eigen/src/Sparse/SparseMatrixBase.h +++ b/Eigen/src/Sparse/SparseMatrixBase.h @@ -43,7 +43,7 @@ template class SparseMatrixBase : public EigenBase typedef typename ei_traits::Scalar Scalar; typedef typename ei_packet_traits::type PacketScalar; typedef typename ei_traits::StorageKind StorageKind; - typedef typename ei_index::type Index; + typedef typename ei_traits::Index Index; typedef SparseMatrixBase StorageBaseType; diff --git a/Eigen/src/Sparse/SparseProduct.h b/Eigen/src/Sparse/SparseProduct.h index 1cb676132..2f86b2b2d 100644 --- a/Eigen/src/Sparse/SparseProduct.h +++ b/Eigen/src/Sparse/SparseProduct.h @@ -57,6 +57,8 @@ struct ei_traits > typedef typename ei_cleantype::type _LhsNested; typedef typename ei_cleantype::type _RhsNested; typedef typename _LhsNested::Scalar Scalar; + typedef typename ei_promote_index_type::Index, + typename ei_traits<_RhsNested>::Index>::type Index; enum { LhsCoeffReadCost = _LhsNested::CoeffReadCost, @@ -236,7 +238,7 @@ static void ei_sparse_product_impl(const Lhs& lhs, const Rhs& rhs, ResultType& r ei_assert(lhs.outerSize() == rhs.innerSize()); // allocate a temporary buffer - AmbiVector tempVector(rows); + AmbiVector tempVector(rows); // estimate the number of non zero entries float ratioLhs = float(lhs.nonZeros())/(float(lhs.rows())*float(lhs.cols())); @@ -264,7 +266,7 @@ static void ei_sparse_product_impl(const Lhs& lhs, const Rhs& rhs, ResultType& r } } res.startVec(j); - for (typename AmbiVector::Iterator it(tempVector); it; ++it) + for (typename AmbiVector::Iterator it(tempVector); it; ++it) res.insertBackByOuterInner(j,it.index()) = it.value(); } res.finalize(); diff --git a/Eigen/src/Sparse/SparseRedux.h b/Eigen/src/Sparse/SparseRedux.h index ea2ce1870..241be6c2e 100644 --- a/Eigen/src/Sparse/SparseRedux.h +++ b/Eigen/src/Sparse/SparseRedux.h @@ -37,17 +37,17 @@ SparseMatrixBase::sum() const return res; } -template -typename ei_traits >::Scalar -SparseMatrix<_Scalar,_Options>::sum() const +template +typename ei_traits >::Scalar +SparseMatrix<_Scalar,_Options,_Index>::sum() const { ei_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); return Matrix::Map(&m_data.value(0), m_data.size()).sum(); } -template -typename ei_traits >::Scalar -SparseVector<_Scalar,_Options>::sum() const +template +typename ei_traits >::Scalar +SparseVector<_Scalar,_Options,_Index>::sum() const { ei_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix"); return Matrix::Map(&m_data.value(0), m_data.size()).sum(); diff --git a/Eigen/src/Sparse/SparseUtil.h b/Eigen/src/Sparse/SparseUtil.h index d94f5ce8c..f780f4087 100644 --- a/Eigen/src/Sparse/SparseUtil.h +++ b/Eigen/src/Sparse/SparseUtil.h @@ -56,30 +56,13 @@ EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \ EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \ EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=) -#define _EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(Derived, BaseClass) \ - typedef BaseClass Base; \ - typedef typename Eigen::ei_traits::Scalar Scalar; \ - typedef typename Eigen::NumTraits::Real RealScalar; \ - typedef typename Eigen::ei_nested::type Nested; \ - typedef typename Eigen::ei_traits::StorageKind StorageKind; \ - typedef typename Eigen::ei_index::type Index; \ - enum { RowsAtCompileTime = Eigen::ei_traits::RowsAtCompileTime, \ - ColsAtCompileTime = Eigen::ei_traits::ColsAtCompileTime, \ - Flags = Eigen::ei_traits::Flags, \ - CoeffReadCost = Eigen::ei_traits::CoeffReadCost, \ - SizeAtCompileTime = Base::SizeAtCompileTime, \ - IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; - -#define EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(Derived) \ - _EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::SparseMatrixBase) - #define _EIGEN_SPARSE_PUBLIC_INTERFACE(Derived, BaseClass) \ typedef BaseClass Base; \ typedef typename Eigen::ei_traits::Scalar Scalar; \ typedef typename Eigen::NumTraits::Real RealScalar; \ typedef typename Eigen::ei_nested::type Nested; \ typedef typename Eigen::ei_traits::StorageKind StorageKind; \ - typedef typename Eigen::ei_index::type Index; \ + typedef typename Eigen::ei_traits::Index Index; \ enum { RowsAtCompileTime = Eigen::ei_traits::RowsAtCompileTime, \ ColsAtCompileTime = Eigen::ei_traits::ColsAtCompileTime, \ Flags = Eigen::ei_traits::Flags, \ @@ -92,12 +75,6 @@ EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=) #define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) \ _EIGEN_SPARSE_PUBLIC_INTERFACE(Derived, Eigen::SparseMatrixBase) -template<> -struct ei_index -{ typedef EIGEN_DEFAULT_SPARSE_INDEX_TYPE type; }; - -typedef ei_index::type SparseIndex; - enum SparseBackend { DefaultBackend, Taucs, @@ -128,10 +105,10 @@ enum { }; template class SparseMatrixBase; -template class SparseMatrix; -template class DynamicSparseMatrix; -template class SparseVector; -template class MappedSparseMatrix; +template class SparseMatrix; +template class DynamicSparseMatrix; +template class SparseVector; +template class MappedSparseMatrix; template class SparseInnerVectorSet; template class SparseTriangularView; diff --git a/Eigen/src/Sparse/SparseVector.h b/Eigen/src/Sparse/SparseVector.h index b15ab8220..dd81b749e 100644 --- a/Eigen/src/Sparse/SparseVector.h +++ b/Eigen/src/Sparse/SparseVector.h @@ -34,10 +34,11 @@ * See http://www.netlib.org/linalg/html_templates/node91.html for details on the storage scheme. * */ -template -struct ei_traits > +template +struct ei_traits > { typedef _Scalar Scalar; + typedef _Index Index; typedef Sparse StorageKind; typedef MatrixXpr XprKind; enum { @@ -53,12 +54,12 @@ struct ei_traits > }; }; -template +template class SparseVector - : public SparseMatrixBase > + : public SparseMatrixBase > { public: - EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(SparseVector) + EIGEN_SPARSE_PUBLIC_INTERFACE(SparseVector) EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(SparseVector, +=) EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(SparseVector, -=) // EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(SparseVector, =) @@ -69,11 +70,11 @@ class SparseVector typedef SparseMatrixBase SparseBase; enum { IsColVector = ei_traits::IsColVector }; - CompressedStorage m_data; + CompressedStorage m_data; Index m_size; - CompressedStorage& _data() { return m_data; } - CompressedStorage& _data() const { return m_data; } + CompressedStorage& _data() { return m_data; } + CompressedStorage& _data() const { return m_data; } public: @@ -370,8 +371,8 @@ class SparseVector EIGEN_DEPRECATED void endFill() {} }; -template -class SparseVector::InnerIterator +template +class SparseVector::InnerIterator { public: InnerIterator(const SparseVector& vec, Index outer=0) @@ -380,7 +381,7 @@ class SparseVector::InnerIterator ei_assert(outer==0); } - InnerIterator(const CompressedStorage& data) + InnerIterator(const CompressedStorage& data) : m_data(data), m_id(0), m_end(static_cast(m_data.size())) {} @@ -401,7 +402,7 @@ class SparseVector::InnerIterator inline operator bool() const { return (m_id < m_end); } protected: - const CompressedStorage& m_data; + const CompressedStorage& m_data; Index m_id; const Index m_end; }; diff --git a/Eigen/src/Sparse/SuperLUSupport.h b/Eigen/src/Sparse/SuperLUSupport.h index 18a967539..d93f69df8 100644 --- a/Eigen/src/Sparse/SuperLUSupport.h +++ b/Eigen/src/Sparse/SuperLUSupport.h @@ -267,8 +267,8 @@ SluMatrix SparseMatrixBase::asSluMatrix() } /** View a Super LU matrix as an Eigen expression */ -template -MappedSparseMatrix::MappedSparseMatrix(SluMatrix& sluMat) +template +MappedSparseMatrix::MappedSparseMatrix(SluMatrix& sluMat) { if ((Flags&RowMajorBit)==RowMajorBit) { diff --git a/Eigen/src/Sparse/TaucsSupport.h b/Eigen/src/Sparse/TaucsSupport.h index 2a1963f5b..c189e0127 100644 --- a/Eigen/src/Sparse/TaucsSupport.h +++ b/Eigen/src/Sparse/TaucsSupport.h @@ -63,8 +63,8 @@ taucs_ccs_matrix SparseMatrixBase::asTaucsMatrix() return res; } -template -MappedSparseMatrix::MappedSparseMatrix(taucs_ccs_matrix& taucsMat) +template +MappedSparseMatrix::MappedSparseMatrix(taucs_ccs_matrix& taucsMat) { m_innerSize = taucsMat.m; m_outerSize = taucsMat.n; diff --git a/Eigen/src/Sparse/TriangularSolver.h b/Eigen/src/Sparse/TriangularSolver.h index 039424bf0..7528ba534 100644 --- a/Eigen/src/Sparse/TriangularSolver.h +++ b/Eigen/src/Sparse/TriangularSolver.h @@ -207,10 +207,12 @@ template struct ei_sparse_solve_triangular_sparse_selector { typedef typename Rhs::Scalar Scalar; + typedef typename ei_promote_index_type::Index, + typename ei_traits::Index>::type Index; static void run(const Lhs& lhs, Rhs& other) { const bool IsLower = (UpLo==Lower); - AmbiVector tempVector(other.rows()*2); + AmbiVector tempVector(other.rows()*2); tempVector.setBounds(0,other.rows()); Rhs res(other.rows(), other.cols()); @@ -266,7 +268,7 @@ struct ei_sparse_solve_triangular_sparse_selector int count = 0; // FIXME compute a reference value to filter zeros - for (typename AmbiVector::Iterator it(tempVector/*,1e-12*/); it; ++it) + for (typename AmbiVector::Iterator it(tempVector/*,1e-12*/); it; ++it) { ++ count; // std::cerr << "fill " << it.index() << ", " << col << "\n";