Fix #1974: assertion when reserving an empty sparse matrix

This commit is contained in:
Gael Guennebaud
2020-08-26 12:32:20 +02:00
committed by Gael Guennebaud
parent efd72cddcd
commit 94f66fc32e
2 changed files with 10 additions and 1 deletions

View File

@@ -327,7 +327,8 @@ class SparseMatrix
m_outerIndex[j] = newOuterIndex[j];
m_innerNonZeros[j] = innerNNZ;
}
m_outerIndex[m_outerSize] = m_outerIndex[m_outerSize-1] + m_innerNonZeros[m_outerSize-1] + reserveSizes[m_outerSize-1];
if(m_outerSize>0)
m_outerIndex[m_outerSize] = m_outerIndex[m_outerSize-1] + m_innerNonZeros[m_outerSize-1] + reserveSizes[m_outerSize-1];
m_data.resize(m_outerIndex[m_outerSize]);
}