New user self-registration is disabled due to spam. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Before reporting a bug, please make sure that your Eigen version is up-to-date!
Bug 1271 - Add view to nonZeros of SparseMatrix
Add view to nonZeros of SparseMatrix
 Status: CONFIRMED None Eigen Unclassified Sparse (show other bugs) 3.4 (development) All All Normal Feature Request Nobody 1104 Show dependency tree / graph

 Reported: 2016-08-05 03:48 UTC by Darcy 2016-08-29 10:14 UTC (History) 3 users (show) chtz darcy gael.guennebaud

Attachments

 Darcy 2016-08-05 03:48:23 UTC ```DESIRED FEATURE: The ability to call a method that zeros the coefficients in a sparse matrix. Currently the setZero() method zeros all allocated memory but it would be nice to set the Aij coefficients to zero, while keeping the row and column arrays allocated and populated.``` Gael Guennebaud 2016-08-22 09:04:20 UTC ```Exposing a dense "view" on the non-zeros would solve this issue, e.g.: mat.nonZerosView().setZero(); while enabling many more efficient manipulations on the non zero coefficients. I've suggested this solution several times, e.g. in bug 1104. Implementing it for compressed matrices is just a matter of returning a 1D dense Eigen::Map. For un-compressed ones, this is much more tricky because we would need to return a list of dense Map for which random access would be extremely inefficient.``` Christoph Hertzberg 2016-08-23 12:29:34 UTC ```I like the idea of providing a nonZerosView(). If it is to complicated for un-compressed matrices, I think simply restricting this feature to compressed matrices would be ok. Minor question: Should the return value be a vector or an array? I'm tending towards array, since nonZerosView() would behave more like independent scalars.``` Gael Guennebaud 2016-08-23 14:24:49 UTC `I agree with the two suggestions (compressed-only + array).` Gael Guennebaud 2016-08-29 10:08:38 UTC ```Done for compressed mode: https://bitbucket.org/eigen/eigen/commits/614aeef Supporting non compressed mode would require a more general expression to concatenate an arbitrary number of vectors/matrices.``` Darcy 2016-08-29 10:14:21 UTC `Fantastic, suits my purposes. Many thanks!`

 Note You need to log in before you can comment on or make changes to this bug.