Row Division in Scipy Sparse Matrix

后端 未结 3 1225
时光取名叫无心
时光取名叫无心 2020-12-12 00:11

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,         


        
3条回答
  •  孤城傲影
    2020-12-12 00:34

    If you first cast D to type numpy.matrix (which I'm assuming you can do unless D is too big to fit into memory), then you can just run

    C.multiply(1.0 / D.T)
    

    to get what you want.

提交回复
热议问题