Row Division in Scipy Sparse Matrix
问题 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 ? 回答1: Approach #1 Here's a sparse matrix solution using manual replication with indexing - from scipy.sparse