Sets *this to the identity matrix. * This function also turns the matrix into compressed mode, and drop any reserved memory. */
| 833 | /** Sets *this to the identity matrix. |
| 834 | * This function also turns the matrix into compressed mode, and drop any reserved memory. */ |
| 835 | inline void setIdentity() { |
| 836 | eigen_assert(m_outerSize == m_innerSize && "ONLY FOR SQUARED MATRICES"); |
| 837 | internal::conditional_aligned_delete_auto<StorageIndex, true>(m_innerNonZeros, m_outerSize); |
| 838 | m_innerNonZeros = 0; |
| 839 | m_data.resize(m_outerSize); |
| 840 | // is it necessary to squeeze? |
| 841 | m_data.squeeze(); |
| 842 | std::iota(m_outerIndex, m_outerIndex + m_outerSize + 1, StorageIndex(0)); |
| 843 | std::iota(innerIndexPtr(), innerIndexPtr() + m_outerSize, StorageIndex(0)); |
| 844 | std::fill_n(valuePtr(), m_outerSize, Scalar(1)); |
| 845 | } |
| 846 | |
| 847 | inline SparseMatrix& operator=(const SparseMatrix& other) { |
| 848 | if (other.isRValue()) { |