Sets *this to the identity matrix. * This function also turns the matrix into compressed mode, and drop any reserved memory. */
| 742 | /** Sets *this to the identity matrix. |
| 743 | * This function also turns the matrix into compressed mode, and drop any reserved memory. */ |
| 744 | inline void setIdentity() |
| 745 | { |
| 746 | eigen_assert(rows() == cols() && "ONLY FOR SQUARED MATRICES"); |
| 747 | this->m_data.resize(rows()); |
| 748 | Eigen::Map<IndexVector>(this->m_data.indexPtr(), rows()).setLinSpaced(0, StorageIndex(rows()-1)); |
| 749 | Eigen::Map<ScalarVector>(this->m_data.valuePtr(), rows()).setOnes(); |
| 750 | Eigen::Map<IndexVector>(this->m_outerIndex, rows()+1).setLinSpaced(0, StorageIndex(rows())); |
| 751 | std::free(m_innerNonZeros); |
| 752 | m_innerNonZeros = 0; |
| 753 | } |
| 754 | inline SparseMatrix& operator=(const SparseMatrix& other) |
| 755 | { |
| 756 | if (other.isRValue()) |