mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-19 08:09:36 +08:00
fix bug #394: innerVector::nonZeros() was broken for uncompressed mode
This commit is contained in:
parent
15d781b64c
commit
50d756b9ea
@ -243,7 +243,7 @@ class SparseInnerVectorSet<SparseMatrix<_Scalar, _Options, _Index>, Size>
|
||||
else if(m_outerSize.value()==0)
|
||||
return 0;
|
||||
else
|
||||
return Map<const Matrix<Index,Size,1> >(m_matrix.innerNonZeroPtr(), m_outerSize.value()).sum();
|
||||
return Map<const Matrix<Index,Size,1> >(m_matrix.innerNonZeroPtr()+m_outerStart, m_outerSize.value()).sum();
|
||||
}
|
||||
|
||||
const Scalar& lastCoeff() const
|
||||
|
@ -237,6 +237,26 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
|
||||
VERIFY_IS_APPROX(m2.innerVector(j0)+m2.innerVector(j1), refMat2.row(j0)+refMat2.row(j1));
|
||||
else
|
||||
VERIFY_IS_APPROX(m2.innerVector(j0)+m2.innerVector(j1), refMat2.col(j0)+refMat2.col(j1));
|
||||
|
||||
SparseMatrixType m3(rows,rows);
|
||||
m3.reserve(VectorXi::Constant(rows,rows/2));
|
||||
for(int j=0; j<rows; ++j)
|
||||
for(int k=0; k<j; ++k)
|
||||
m3.insertByOuterInner(j,k) = k+1;
|
||||
for(int j=0; j<rows; ++j)
|
||||
{
|
||||
VERIFY(j==m3.innerVector(j).nonZeros());
|
||||
if(j>0)
|
||||
VERIFY(j==m3.innerVector(j).lastCoeff());
|
||||
}
|
||||
m3.makeCompressed();
|
||||
for(int j=0; j<rows; ++j)
|
||||
{
|
||||
VERIFY(j==m3.innerVector(j).nonZeros());
|
||||
if(j>0)
|
||||
VERIFY(j==m3.innerVector(j).lastCoeff());
|
||||
}
|
||||
|
||||
//m2.innerVector(j0) = 2*m2.innerVector(j1);
|
||||
//refMat2.col(j0) = 2*refMat2.col(j1);
|
||||
//VERIFY_IS_APPROX(m2, refMat2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user