Substitute for numpy broadcasting using scipy.sparse.csc_matrix
问题 I have in my code the following expression: a = (b / x[:, np.newaxis]).sum(axis=1) where b is an ndarray of shape (M, N) , and x is an ndarray of shape (M,) . Now, b is actually sparse, so for memory efficiency I would like to substitute in a scipy.sparse.csc_matrix or csr_matrix . However, broadcasting in this way is not implemented (even though division or multiplication is guaranteed to maintain sparsity) (the entries of x are non-zero), and raises a NotImplementedError . Is there a sparse