aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/SparseCore/SparseMatrix.h
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2015-10-25 22:01:58 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2015-10-25 22:01:58 +0100
commit8a211bb1a96ae7b0512a719e23058660af1bad2b (patch)
tree5f648f504600adbb287f0ce1a2831aa892a4d6a0 /Eigen/src/SparseCore/SparseMatrix.h
parentac6b2266b939200dfdcbe415b6ca592293f6d401 (diff)
bug #1088: fix setIdenity for non-compressed sparse-matrix
Diffstat (limited to 'Eigen/src/SparseCore/SparseMatrix.h')
-rw-r--r--Eigen/src/SparseCore/SparseMatrix.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/Eigen/src/SparseCore/SparseMatrix.h b/Eigen/src/SparseCore/SparseMatrix.h
index b27061f9e..272f1d7b4 100644
--- a/Eigen/src/SparseCore/SparseMatrix.h
+++ b/Eigen/src/SparseCore/SparseMatrix.h
@@ -729,7 +729,8 @@ class SparseMatrix
m_data.swap(other.m_data);
}
- /** Sets *this to the identity matrix */
+ /** Sets *this to the identity matrix.
+ * This function also turns the matrix into compressed mode, and drop any reserved memory. */
inline void setIdentity()
{
eigen_assert(rows() == cols() && "ONLY FOR SQUARED MATRICES");
@@ -737,6 +738,8 @@ class SparseMatrix
Eigen::Map<IndexVector>(&this->m_data.index(0), rows()).setLinSpaced(0, StorageIndex(rows()-1));
Eigen::Map<ScalarVector>(&this->m_data.value(0), rows()).setOnes();
Eigen::Map<IndexVector>(this->m_outerIndex, rows()+1).setLinSpaced(0, StorageIndex(rows()));
+ std::free(m_innerNonZeros);
+ m_innerNonZeros = 0;
}
inline SparseMatrix& operator=(const SparseMatrix& other)
{