[SciPy-user] fast max() on sparse matrices
Mon Jan 5 16:40:44 CST 2009
On Mon, Jan 5, 2009 at 4:43 PM, nicky van foreest <email@example.com> wrote:
> A few days ago I encountered just the same problem, and solved by
> taking the max of the values(), just as suggested below. However, it
> took me some minutes to fiugre this out, and I first, of course, tried
> the max() function. Thus, I suggest that the max function will be
> added to the sparse class. Is there a reason not to do so?
It should be added, but it's not as straightforward as you might think.
For conformity with dense matrices, max() should return zero if the
nonzero entries of the matrix are all negative and there is at least
one missing value in the matrix. This might surprise people who
expect the largest nonzero value instead. For instance,
csr_matrix([[0,-1]]).max() should be 0.
Another minor problem is that some matrices permit duplicate entries.
Currently, we implicitly sum duplicate values together (e.g. when
computing sparse matrix-vector products) and when converting to other
formats. We'd probably want to make max() and min() agree with this
Nathan Bell firstname.lastname@example.org
More information about the SciPy-user