mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-06 14:14:46 +08:00
Avoid division by zero in nonZerosEstimate() for empty blocks.
This commit is contained in:
parent
ac2eca6b11
commit
acab22c205
@ -446,9 +446,13 @@ struct unary_evaluator<Block<ArgType,BlockRows,BlockCols,InnerPanel>, IteratorBa
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
inline Index nonZerosEstimate() const {
|
inline Index nonZerosEstimate() const {
|
||||||
Index nnz = m_block.nonZeros();
|
const Index nnz = m_block.nonZeros();
|
||||||
if(nnz<0)
|
if(nnz < 0) {
|
||||||
return m_argImpl.nonZerosEstimate() * m_block.size() / m_block.nestedExpression().size();
|
// Scale the non-zero estimate for the underlying expression linearly with block size.
|
||||||
|
// Return zero if the underlying block is empty.
|
||||||
|
const Index nested_sz = m_block.nestedExpression().size();
|
||||||
|
return nested_sz == 0 ? 0 : m_argImpl.nonZerosEstimate() * m_block.size() / nested_sz;
|
||||||
|
}
|
||||||
return nnz;
|
return nnz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user