[go: up one dir, main page]

SparseMatrixBase<Derived>::nonZeros() is broken for most types of Derived

Submitted by Henrik Friberg

Assigned to Nobody

Link to original bugzilla bug (#875)
Version: 3.3 (current stable)

Description

The call to nonZeros() on a SparseSparseProduct object leads to an infinite recursion smacking the stack. This can be seen by running valgrind with the verbose "-v" parameter on the following example:


#include "Eigen/SparseCore"
#include <iostream>

using namespace Eigen;

typedef SparseMatrix<double, ColMajor> SpMat;

int main(int argc, char **argv)
{
const int m = 3;

SpMat A(m,m);  
A.insert(0,0) = 1.0;  
A.insert(1,1) = 2.0;  
A.insert(2,2) = 3.0;  
A.makeCompressed();  

SpMat B(m,m);  
B.insert(0,0) = 1.0;  
B.insert(1,1) = 2.0;  
B.insert(2,2) = 3.0;  
B.makeCompressed();  

int nnz = (A * B).nonZeros();  

std::cout << nnz << std::endl;  

}

Blocking

#558 (closed)

Edited by Eigen Bugzilla