I have a volume of matrices, say a = np.zeros((5, 7, 4, 4))
I want to set the diagonal to some value, across all matrices.
Just like I can get the diagonal with diag = np.diagonal(a, axis1=2, axis2=3)
, I would like to set the diagonal.
However, np.fill_diagonal does not support axis=
.
How can I still achieve this?