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() */
| 728 | * \sa reserve(), setZero() |
| 729 | */ |
| 730 | void resize(Index rows, Index cols) { |
| 731 | const Index outerSize = IsRowMajor ? rows : cols; |
| 732 | m_innerSize = IsRowMajor ? cols : rows; |
| 733 | m_data.clear(); |
| 734 | |
| 735 | if ((m_outerIndex == 0) || (m_outerSize != outerSize)) { |
| 736 | m_outerIndex = internal::conditional_aligned_realloc_new_auto<StorageIndex, true>(m_outerIndex, outerSize + 1, |
| 737 | m_outerSize + 1); |
| 738 | m_outerSize = outerSize; |
| 739 | } |
| 740 | |
| 741 | internal::conditional_aligned_delete_auto<StorageIndex, true>(m_innerNonZeros, m_outerSize); |
| 742 | m_innerNonZeros = 0; |
| 743 | |
| 744 | std::fill_n(m_outerIndex, m_outerSize + 1, StorageIndex(0)); |
| 745 | } |
| 746 | |
| 747 | /** \internal |
| 748 | * Resize the nonzero vector to \a size */ |
no test coverage detected