bug #1088: fix setIdenity for non-compressed sparse-matrix

This commit is contained in:
Gael Guennebaud
2015-10-25 22:01:58 +01:00
parent 89a222ce50
commit f8b88d21a6
2 changed files with 18 additions and 1 deletions

View File

@@ -691,7 +691,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");
@@ -699,6 +700,8 @@ class SparseMatrix
Eigen::Map<Matrix<Index, Dynamic, 1> >(&this->m_data.index(0), rows()).setLinSpaced(0, rows()-1);
Eigen::Map<Matrix<Scalar, Dynamic, 1> >(&this->m_data.value(0), rows()).setOnes();
Eigen::Map<Matrix<Index, Dynamic, 1> >(this->m_outerIndex, rows()+1).setLinSpaced(0, rows());
std::free(m_innerNonZeros);
m_innerNonZeros = 0;
}
inline SparseMatrix& operator=(const SparseMatrix& other)
{