Resizes the matrix to a \a rows x \a cols matrix and initializes it to zero. * * This function does not free the currently allocated memory. To release as much as memory as possible, * call \code mat.data().squeeze(); \endcode after resizing it. * * \sa reserve(), setZero() */
| 737 | * \sa reserve(), setZero() |
| 738 | */ |
| 739 | void resize(Index rows, Index cols) |
| 740 | { |
| 741 | const Index outerSize = IsRowMajor ? rows : cols; |
| 742 | m_innerSize = IsRowMajor ? cols : rows; |
| 743 | m_data.clear(); |
| 744 | |
| 745 | if ((m_outerIndex == 0) || (m_outerSize != outerSize)) { |
| 746 | m_outerIndex = internal::conditional_aligned_realloc_new_auto<StorageIndex, true>(m_outerIndex, outerSize + 1, m_outerSize + 1); |
| 747 | m_outerSize = outerSize; |
| 748 | } |
| 749 | |
| 750 | internal::conditional_aligned_delete_auto<StorageIndex, true>(m_innerNonZeros, m_outerSize); |
| 751 | m_innerNonZeros = 0; |
| 752 | |
| 753 | std::fill_n(m_outerIndex, m_outerSize + 1, StorageIndex(0)); |
| 754 | } |
| 755 | |
| 756 | /** \internal |
| 757 | * Resize the nonzero vector to \a size */ |
no test coverage detected