changing the values of the diagonal of a matrix in numpy

前端 未结 7 881
孤城傲影
孤城傲影 2020-12-08 19:20

how can I change the values of the diagonal of a matrix in numpy?

I checked Numpy modify ndarray diagonal, but the function there is not implemented in numpy v 1.3.0

7条回答
  •  北海茫月
    2020-12-08 19:42

    Did you try numpy.fill_diagonal? See the following answer and this discussion. Or the following from the documentation (although currently broken):

    http://docs.scipy.org/doc/numpy/reference/generated/numpy.fill_diagonal.html

提交回复
热议问题