mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-05-21 20:17:35 +08:00
SparseMatrix::resize() always resets the matrix to an empty one
This commit is contained in:
parent
55de162cf6
commit
d97d307fcf
@ -363,9 +363,11 @@ class SparseMatrix
|
|||||||
m_data.resize(k,0);
|
m_data.resize(k,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Resizes the matrix to a \a rows x \a cols matrix and initializes it to zero
|
||||||
|
* \sa resizeNonZeros(int), reserve(), setZero()
|
||||||
|
*/
|
||||||
void resize(int rows, int cols)
|
void resize(int rows, int cols)
|
||||||
{
|
{
|
||||||
// std::cerr << this << " resize " << rows << "x" << cols << "\n";
|
|
||||||
const int outerSize = IsRowMajor ? rows : cols;
|
const int outerSize = IsRowMajor ? rows : cols;
|
||||||
m_innerSize = IsRowMajor ? cols : rows;
|
m_innerSize = IsRowMajor ? cols : rows;
|
||||||
m_data.clear();
|
m_data.clear();
|
||||||
@ -374,8 +376,8 @@ class SparseMatrix
|
|||||||
delete[] m_outerIndex;
|
delete[] m_outerIndex;
|
||||||
m_outerIndex = new int [outerSize+1];
|
m_outerIndex = new int [outerSize+1];
|
||||||
m_outerSize = outerSize;
|
m_outerSize = outerSize;
|
||||||
memset(m_outerIndex, 0, (m_outerSize+1)*sizeof(int));
|
|
||||||
}
|
}
|
||||||
|
memset(m_outerIndex, 0, (m_outerSize+1)*sizeof(int));
|
||||||
}
|
}
|
||||||
void resizeNonZeros(int size)
|
void resizeNonZeros(int size)
|
||||||
{
|
{
|
||||||
|
@ -192,7 +192,6 @@ static void ei_sparse_product_impl(const Lhs& lhs, const Rhs& rhs, ResultType& r
|
|||||||
float ratioRes = std::min(ratioLhs * avgNnzPerRhsColumn, 1.f);
|
float ratioRes = std::min(ratioLhs * avgNnzPerRhsColumn, 1.f);
|
||||||
|
|
||||||
res.resize(rows, cols);
|
res.resize(rows, cols);
|
||||||
res.setZero();
|
|
||||||
res.reserve(int(ratioRes*rows*cols));
|
res.reserve(int(ratioRes*rows*cols));
|
||||||
for (int j=0; j<cols; ++j)
|
for (int j=0; j<cols; ++j)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user