I want to divide a sparse matrix's rows by scalars given in an array.
For example, I have a csr_matrix
C
:
C = [[2,4,6], [5,10,15]]
D = [2,5]
I want the result of C
after division to be :
result = [[1, 2, 3], [1, 2, 3]]
I have tried this using the method that we use for numpy
arrays:
result = C / D[:,None]
But this seems really slow. How to do this efficiently in sparse matrices?