mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-08 09:49:03 +08:00
accept both STL and Eigen's containers for reserve()
This commit is contained in:
parent
e0a6ce50dd
commit
5d1836b182
@ -179,13 +179,30 @@ class SparseMatrix
|
|||||||
m_data.reserve(reserveSize);
|
m_data.reserve(reserveSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
||||||
/** Preallocates \a reserveSize non zeros.
|
/** Preallocates \a reserveSize non zeros.
|
||||||
*
|
*
|
||||||
* Precondition: the matrix must be in compressed mode. */
|
* Precondition: the matrix must be in compressed mode. */
|
||||||
template<class SizesType>
|
template<class SizesType>
|
||||||
|
inline void reserve(const SizesType& reserveSizes);
|
||||||
|
#else
|
||||||
|
template<class SizesType>
|
||||||
inline void reserve(const SizesType& reserveSizes, const typename SizesType::value_type& enableif = typename SizesType::value_type())
|
inline void reserve(const SizesType& reserveSizes, const typename SizesType::value_type& enableif = typename SizesType::value_type())
|
||||||
{
|
{
|
||||||
EIGEN_UNUSED_VARIABLE(enableif);
|
EIGEN_UNUSED_VARIABLE(enableif);
|
||||||
|
reserveInnerVectors(reserveSizes);
|
||||||
|
}
|
||||||
|
template<class SizesType>
|
||||||
|
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<class SizesType>
|
||||||
|
inline void reserveInnerVectors(const SizesType& reserveSizes)
|
||||||
|
{
|
||||||
|
|
||||||
if(compressed())
|
if(compressed())
|
||||||
{
|
{
|
||||||
@ -266,6 +283,7 @@ class SparseMatrix
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public:
|
||||||
|
|
||||||
//--- low level purely coherent filling ---
|
//--- low level purely coherent filling ---
|
||||||
|
|
||||||
@ -677,11 +695,11 @@ class SparseMatrix
|
|||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
inline SparseMatrix& operator=(const ReturnByValue<OtherDerived>& other)
|
inline SparseMatrix& operator=(const ReturnByValue<OtherDerived>& other)
|
||||||
{ return Base::operator=(other); }
|
{ return Base::operator=(other.derived()); }
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
inline SparseMatrix& operator=(const EigenBase<OtherDerived>& other)
|
inline SparseMatrix& operator=(const EigenBase<OtherDerived>& other)
|
||||||
{ return Base::operator=(other); }
|
{ return Base::operator=(other.derived()); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user