Created attachment 321 [details]
Support for the sparse reduction
We are thinking about adding support for the reductions in the sparse modules. See a beginning in the attached patch.
However, most of them have a very ambiguous meaning on sparse matrices : should we consider or not the implicit zero elements ?
If yes, mincoeff() or prod() should always return 0. maxcoeff() as well if the matrix is negative. Should mean() take only the nonzeros counts ?
If we work only the nonzero elements (or explicitly stored zero), then we might consider adding a proxy to let the user know that he is working only on nonzero elements. something like spmat.nonzeroCoeffs().minCoeff().
What do you think about this ?
This would be useful to me, I just hit the limitation. It would be great if partial reductions (row and column wise) would be possible as well.
In my opinion implicit zeros should be considered in methods meant to be parallel to the dense Matrix API => principle of least surprise. Those zeros are part of the matrix just as any other value, they are just stored more compactly - implicitly.
In practice mincoeff() or prod() would practically always return 0 in a complete reduction. However, this would not be so much the case when reducing partially rowwise or columnwise. I can imagine cases where most of the rows would have mostly zeros but a few might have no zero at all.
In any case, sum() and mean() would be extremely useful.