From 5d1836b18244bfb863aad5b848e9d9da9c5b8b16 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 20 Sep 2011 02:04:03 +0200 Subject: [PATCH] accept both STL and Eigen's containers for reserve() --- Eigen/src/Sparse/SparseMatrix.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Eigen/src/Sparse/SparseMatrix.h b/Eigen/src/Sparse/SparseMatrix.h index 61b4d6896..9f0cbc2b7 100644 --- a/Eigen/src/Sparse/SparseMatrix.h +++ b/Eigen/src/Sparse/SparseMatrix.h @@ -179,13 +179,30 @@ class SparseMatrix m_data.reserve(reserveSize); } + #ifdef EIGEN_PARSED_BY_DOXYGEN /** Preallocates \a reserveSize non zeros. * * Precondition: the matrix must be in compressed mode. */ template + inline void reserve(const SizesType& reserveSizes); + #else + template inline void reserve(const SizesType& reserveSizes, const typename SizesType::value_type& enableif = typename SizesType::value_type()) { EIGEN_UNUSED_VARIABLE(enableif); + reserveInnerVectors(reserveSizes); + } + template + inline void reserve(const SizesType& reserveSizes, const typename SizesType::Scalar& enableif = typename SizesType::Scalar()) + { + EIGEN_UNUSED_VARIABLE(enableif); + reserveInnerVectors(reserveSizes); + } + #endif // EIGEN_PARSED_BY_DOXYGEN + protected: + template + inline void reserveInnerVectors(const SizesType& reserveSizes) + { if(compressed()) { @@ -266,6 +283,7 @@ class SparseMatrix } } + public: //--- low level purely coherent filling --- @@ -677,11 +695,11 @@ class SparseMatrix template inline SparseMatrix& operator=(const ReturnByValue& other) - { return Base::operator=(other); } + { return Base::operator=(other.derived()); } template inline SparseMatrix& operator=(const EigenBase& other) - { return Base::operator=(other); } + { return Base::operator=(other.derived()); } #endif template