Issue
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.
Solution
If X
is your array and c
is the factor,
X[np.diag_indices_from(X)] /= c
See diag_indices_from
in the Numpy manual.
Answered By - Fred Foo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.