Prune does not work as documented
Submitted by Kolja Brix
Assigned to Nobody
Link to original bugzilla bug (#597)
Created attachment 336
Test code for bugs in prune() method in sparse matrix
Pruning (deleting entries with an absolute value smaller than a threshold) sparse matrices does not work as documented, please see the test code attached.
The problem arises in version 3.1.6 and newer.
The documentation states (taken from current http://eigen.tuxfamily.org/dox/TutorialSparse.html):
The second algorithm prunes on the fly the explicit zeros, or the values smaller than a given threshold. It is enabled and controlled through the prune() functions:
sm3 = (sm1 * sm2).prune(); // removes numerical zeros
sm3 = (sm1 * sm2).prune(ref); // removes elements much smaller than ref
sm3 = (sm1 * sm2).prune(ref,epsilon); // removes elements smaller than ref*epsilon
But none of the three methods works, the code does not compile.
The compiler error is "'const Type' has no member named 'prune'" in all three cases.
Moreover, calling the method prune for a SparseMatrix<double> does not work when no argument is specified, at least ref must be given.
The compiler error message is "no matching function for call to 'Eigen::SparseMatrix<double>::prune()'".
I would like to propose to set the default value of ref to 1.0.
Furthermore, prune() seems to only work in-place. Would it be possible to provide also a version for assignment, e.g. "sm2 = sm1.prune();"?
Attachment 336, "Test code for bugs in prune() method in sparse matrix":