From 9ea1050281ffe315d9277fe88f44a451832c8b39 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Mon, 26 Jan 2009 14:01:16 +0000 Subject: [PATCH] fix MatrixNase::fillrand bug --- Eigen/src/Sparse/SparseMatrix.h | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Eigen/src/Sparse/SparseMatrix.h b/Eigen/src/Sparse/SparseMatrix.h index b2665cfe6..23766d516 100644 --- a/Eigen/src/Sparse/SparseMatrix.h +++ b/Eigen/src/Sparse/SparseMatrix.h @@ -175,7 +175,6 @@ class SparseMatrix { const int outer = IsRowMajor ? row : col; const int inner = IsRowMajor ? col : row; - if (m_outerIndex[outer+1]==0) { // we start a new inner vector @@ -188,14 +187,14 @@ class SparseMatrix } m_outerIndex[outer+1] = m_outerIndex[outer]; } -// std::cerr << this << " " << outer << " " << inner << " - " << m_outerIndex[outer] << " " << m_outerIndex[outer+1] << "\n"; assert(size_t(m_outerIndex[outer+1]) == m_data.size() && "invalid outer index"); size_t startId = m_outerIndex[outer]; - size_t id = m_outerIndex[outer+1]-1; + // FIXME let's make sure sizeof(long int) == sizeof(size_t) + size_t id = m_outerIndex[outer+1]; ++m_outerIndex[outer+1]; float reallocRatio = 1; - if (m_data.allocatedSize()= startId) && (m_data.index(id) > inner) ) + while ( (id > startId) && (m_data.index(id-1) > inner) ) { - m_data.index(id+1) = m_data.index(id); - m_data.value(id+1) = m_data.value(id); + m_data.index(id) = m_data.index(id-1); + m_data.value(id) = m_data.value(id-1); --id; } - m_data.index(id+1) = inner; - return (m_data.value(id+1) = 0); + + m_data.index(id) = inner; + return (m_data.value(id) = 0); } -// inline void - inline void endFill() { -// std::cerr << this << " endFill\n"; int size = m_data.size(); int i = m_outerSize; // find the last filled column