I need to store sparse matrix data.
Size of data is 10^6 10^4 columns.
In each column I store a vector of 0’s except of few values where it’s true.
Then I need to sum over columns in each matrix, and multiply each row with a scalar.
I tried dictionaries, but they fail when I need to sum, and multiply.
What would You use?
PS. numpy.zeros is too small
How about two dicts? Assuming this is the matrix (
xforTrue):You’d only need to store
You could easily transform this into
using something like
and then sum over columns (
sum(1 for x in column[2])) or over rows and multiply the result with whatever you want.