diff options
author | 2009-02-10 10:00:00 +0000 | |
---|---|---|
committer | 2009-02-10 10:00:00 +0000 | |
commit | e75bef95231ab6c21bf8d990bd890a3494c8a839 (patch) | |
tree | b85f749a7c08e657b5b3f67682b69fc6e99fb877 /Eigen/src/Sparse | |
parent | 169696a078892671915289280c678f9d7be8486c (diff) |
various minor fixes in Sparse module
Diffstat (limited to 'Eigen/src/Sparse')
-rw-r--r-- | Eigen/src/Sparse/DynamicSparseMatrix.h | 13 | ||||
-rw-r--r-- | Eigen/src/Sparse/SparseDiagonalProduct.h | 2 | ||||
-rw-r--r-- | Eigen/src/Sparse/SparseMatrix.h | 9 |
3 files changed, 15 insertions, 9 deletions
diff --git a/Eigen/src/Sparse/DynamicSparseMatrix.h b/Eigen/src/Sparse/DynamicSparseMatrix.h index 72930bfcc..7119a84bd 100644 --- a/Eigen/src/Sparse/DynamicSparseMatrix.h +++ b/Eigen/src/Sparse/DynamicSparseMatrix.h @@ -128,11 +128,14 @@ class DynamicSparseMatrix /** Set the matrix to zero and reserve the memory for \a reserveSize nonzero coefficients. */ inline void startFill(int reserveSize = 1000) { - int reserveSizePerVector = std::max(reserveSize/outerSize(),4); - for (int j=0; j<outerSize(); ++j) + if (outerSize()>0) { - m_data[j].clear(); - m_data[j].reserve(reserveSizePerVector); + int reserveSizePerVector = std::max(reserveSize/outerSize(),4); + for (int j=0; j<outerSize(); ++j) + { + m_data[j].clear(); + m_data[j].reserve(reserveSizePerVector); + } } } @@ -218,7 +221,7 @@ class DynamicSparseMatrix } inline DynamicSparseMatrix() - : m_innerSize(0) + : m_innerSize(0), m_data(0) { ei_assert(innerSize()==0 && outerSize()==0); } diff --git a/Eigen/src/Sparse/SparseDiagonalProduct.h b/Eigen/src/Sparse/SparseDiagonalProduct.h index 983823a0c..932daf220 100644 --- a/Eigen/src/Sparse/SparseDiagonalProduct.h +++ b/Eigen/src/Sparse/SparseDiagonalProduct.h @@ -42,7 +42,7 @@ struct ei_traits<SparseDiagonalProduct<Lhs, Rhs> > : ei_traits<SparseProduct<Lhs typedef typename ei_cleantype<Lhs>::type _Lhs; typedef typename ei_cleantype<Rhs>::type _Rhs; enum { - SparseFlags = ((int(_Lhs::Flags)&Diagonal)==Diagonal) ? _Rhs::Flags : _Lhs::Flags, + SparseFlags = ((int(_Lhs::Flags)&Diagonal)==Diagonal) ? int(_Rhs::Flags) : int(_Lhs::Flags), Flags = SparseBit | (SparseFlags&RowMajorBit) }; }; diff --git a/Eigen/src/Sparse/SparseMatrix.h b/Eigen/src/Sparse/SparseMatrix.h index 8aebe4ae2..8ac98d074 100644 --- a/Eigen/src/Sparse/SparseMatrix.h +++ b/Eigen/src/Sparse/SparseMatrix.h @@ -138,7 +138,6 @@ class SparseMatrix */ inline void startFill(int reserveSize = 1000) { -// std::cerr << this << " startFill\n"; setZero(); m_data.reserve(reserveSize); } @@ -161,6 +160,10 @@ class SparseMatrix } m_outerIndex[outer+1] = m_outerIndex[outer]; } + else + { + ei_assert(m_data.index(m_data.size()-1)<inner && "wrong sorted insertion"); + } assert(size_t(m_outerIndex[outer+1]) == m_data.size()); int id = m_outerIndex[outer+1]; ++m_outerIndex[outer+1]; @@ -390,11 +393,11 @@ class SparseMatrix s << std::endl; s << std::endl; s << "Column pointers:\n"; - for (int i=0; i<m.cols(); ++i) + for (int i=0; i<m.outerSize(); ++i) { s << m.m_outerIndex[i] << " "; } - s << std::endl; + s << " $" << std::endl; s << std::endl; ); s << static_cast<const SparseMatrixBase<SparseMatrix>&>(m); |