[Numpy-discussion] What is diagonal for nd>2?

Pierre GM pgmdevlist at mailcan.com
Thu Apr 6 13:51:04 EDT 2006


> Does anyone know when this change was introduced and why?

Isn't it more a problem of default values ?
By default, x.diagonal() == x.diagonal(0,0,1)

x.diagonal()
array([[ 0, 20],
       [ 1, 21],
       [ 2, 22],
       [ 3, 23]])

If you want the paired diagonal:
x.diagonal(0,1,-1)
array([[ 0,  5, 10, 15],
       [16, 21, 26, 31]])




More information about the NumPy-Discussion mailing list