SparseMatrix::sum incorrect
Submitted by Matt Shannon
Assigned to Nobody
Link to original bugzilla bug (#1238)
Version: 3.2
Operating system: Linux
Description
The specialized sum routine used by SparseMatrix is incorrect, and appears to access uninitialized values. To reproduce:
int main() {
for (int i = 0; i < 100; ++i) {
Eigen::SparseMatrix<float> mat(10, 10);
mat.coeffRef(0, 2) = 1.0;
mat.coeffRef(2, 3) = 1.0;
mat.coeffRef(9, 9) = 1.0;
if (mat.sum() != 3) {
return 1;
}
}
return 0;
}
You may need to increase the upper loop limit to reproduce. If I remove SparseMatrix::sum (which a comment states is "Overloaded for performance") and use the implementation from SparseMatrixBase::sum instead then everything works fine.
Edited by Eigen Bugzilla