From e4cea957dfe77239b64c17587f09bed0b297cde2 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 20 Dec 2011 18:37:24 +0100 Subject: [PATCH] fix bug #391: prune was for compressed format only, now it also turns the matrix into compressed form --- Eigen/src/SparseCore/SparseMatrix.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Eigen/src/SparseCore/SparseMatrix.h b/Eigen/src/SparseCore/SparseMatrix.h index 9cea4ca69..587bb0fcd 100644 --- a/Eigen/src/SparseCore/SparseMatrix.h +++ b/Eigen/src/SparseCore/SparseMatrix.h @@ -476,7 +476,7 @@ class SparseMatrix prune(default_prunning_func(reference,epsilon)); } - /** Suppresses all nonzeros which do not satisfy the predicate \a keep. + /** Turns the matrix into compressed format, and suppresses all nonzeros which do not satisfy the predicate \a keep. * The functor type \a KeepFunc must implement the following function: * \code * bool operator() (const Index& row, const Index& col, const Scalar& value) const; @@ -486,6 +486,10 @@ class SparseMatrix template void prune(const KeepFunc& keep = KeepFunc()) { + // TODO optimize the uncompressed mode to avoid moving and allocating the data twice + // TODO also implement a unit test + makeCompressed(); + Index k = 0; for(Index j=0; j