numpy sum ( np.diagonal) code example
Example: sum of diagonal numpy
arr= np.arange(16)
arr= np.reshape(arr,(4,4))
a=np.diagonal(arr, 0,0,1)
result=sum(a)
print(result)
arr= np.arange(16)
arr= np.reshape(arr,(4,4))
a=np.diagonal(arr, 0,0,1)
result=sum(a)
print(result)