mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
bug #1088: fix setIdenity for non-compressed sparse-matrix
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user