SparseCore: add operator==/!= to SparseCompressedBase InnerIterator (#1192)

libeigen/eigen!2571

Closes #1192

Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
Rasmus Munk Larsen
2026-05-18 22:16:43 +00:00
committed by Charles Schlosser
co-authored by Rasmus Munk Larsen
parent 18532ea270
commit edc053f1b7
2 changed files with 39 additions and 0 deletions
+26
View File
@@ -981,6 +981,32 @@ void sparse_basic(const SparseMatrixType& ref) {
iters[1] = IteratorType(m2, m2.outerSize() - 1);
}
// test InnerIterator equality (bug #1192)
{
typedef typename SparseMatrixType::InnerIterator IteratorType;
SparseMatrixType m2(rows, cols);
DenseMatrix refMat2 = DenseMatrix::Zero(rows, cols);
initSparse<Scalar>(density, refMat2, m2);
Index outer_with_two = -1;
for (Index o = 0; o < m2.outerSize(); ++o)
if (m2.innerVector(o).nonZeros() >= 2) {
outer_with_two = o;
break;
}
if (outer_with_two >= 0) {
IteratorType a(m2, outer_with_two), b(m2, outer_with_two);
VERIFY(a == b);
++b;
VERIFY(a != b);
VERIFY(!(a == b));
++a;
VERIFY(a == b);
while (a) ++a;
while (b) ++b;
VERIFY(a == b);
}
}
// test reserve with empty rows/columns
{
SparseMatrixType m1(0, cols);