Sun, 11 Sep 2011 03:03:26 -0500, Pengkui Luo wrote:
[clip]
> However, converting a large sparse matrix to dense would easily eat up
> the memory. Is there a way for np.sign (as well as other ufunc) to take
> a sparse matrix as parameter, and return a sparse matrix?

For CSR, CSC, and DIA you can do

        x.data = some_ufunc(x.data)

to operate on the nonzero entries. If some_ufunc(0) == 0, that's all you
need. Otherwise, the matrix becomes dense.

        Pauli

_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to