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() */
| 619 | * \sa reserve(), setZero() |
| 620 | */ |
| 621 | void resize(Index rows, Index cols) |
| 622 | { |
| 623 | const Index outerSize = IsRowMajor ? rows : cols; |
| 624 | m_innerSize = IsRowMajor ? cols : rows; |
| 625 | m_data.clear(); |
| 626 | if (m_outerSize != outerSize || m_outerSize==0) |
| 627 | { |
| 628 | std::free(m_outerIndex); |
| 629 | m_outerIndex = static_cast<StorageIndex*>(std::malloc((outerSize + 1) * sizeof(StorageIndex))); |
| 630 | if (!m_outerIndex) internal::throw_std_bad_alloc(); |
| 631 | |
| 632 | m_outerSize = outerSize; |
| 633 | } |
| 634 | if(m_innerNonZeros) |
| 635 | { |
| 636 | std::free(m_innerNonZeros); |
| 637 | m_innerNonZeros = 0; |
| 638 | } |
| 639 | memset(m_outerIndex, 0, (m_outerSize+1)*sizeof(StorageIndex)); |
| 640 | } |
| 641 | |
| 642 | /** \internal |
| 643 | * Resize the nonzero vector to \a size */ |
no test coverage detected