Sets *this to the identity matrix. * This function also turns the matrix into compressed mode, and drop any reserved memory. */
| 854 | /** Sets *this to the identity matrix. |
| 855 | * This function also turns the matrix into compressed mode, and drop any reserved memory. */ |
| 856 | inline void setIdentity() |
| 857 | { |
| 858 | eigen_assert(m_outerSize == m_innerSize && "ONLY FOR SQUARED MATRICES"); |
| 859 | internal::conditional_aligned_delete_auto<StorageIndex, true>(m_innerNonZeros, m_outerSize); |
| 860 | m_innerNonZeros = 0; |
| 861 | m_data.resize(m_outerSize); |
| 862 | // is it necessary to squeeze? |
| 863 | m_data.squeeze(); |
| 864 | std::iota(m_outerIndex, m_outerIndex + m_outerSize + 1, StorageIndex(0)); |
| 865 | std::iota(innerIndexPtr(), innerIndexPtr() + m_outerSize, StorageIndex(0)); |
| 866 | std::fill_n(valuePtr(), m_outerSize, Scalar(1)); |
| 867 | } |
| 868 | |
| 869 | inline SparseMatrix& operator=(const SparseMatrix& other) |
| 870 | { |