Skip to content
Advertisement

numpy filling the diagonal 0 for 3D array

Suppose I have a 3D array, how can I fill the diag of the first two dimensions to zero. For example

JavaScript

Is there a way to replace the for loop?

Advertisement

Answer

The following is one of the solution

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement