is there any way in numpy to get a reference to the array diagonal? I want my array diagonal to be divided by a certain factor Thanks
If X is your array and c is the factor,
X
c
X[np.diag_indices_from(X)] /= c
See diag_indices_from in the Numpy manual.
diag_indices_from
1.4m articles
1.4m replys
5 comments
57.0k users