Fix sparse triangular view iterator

Reference issue

What does this implement/fix?

The sparse triangular iterator had its row() and col() functions commented out (over 8 years ago), seemingly by accident. This causes bizarre results, and even segfaults. This bug is as old as 3.3.4!!!

Thanks to sarah8389 on the discord channel for pointing this out.

#include <Eigen/SparseCore>
#include <iostream>
using namespace Eigen;
auto main() -> int {
  using Mat = SparseMatrix<double, ColMajor, int>;
  Mat m(4, 4);
  m.setIdentity();
  std::cout << m.triangularView<UnitLower>().toDense();
}

prints

0 0 0 1
1 0 0 0
0 1 0 0
0 0 1 0

Additional information

https://godbolt.org/z/je5q6P6aY

Edited by Charles Schlosser

Merge request reports

Loading