[Matrix-SIG] bug in Numeric.diagonal?

Konrad Hinsen hinsen@ibs.ibs.fr
Wed, 18 Mar 1998 17:18:42 +0100


> Looking through Numeric, I noticed what looks like a bug in diagonal. Can
> anyone confirm this as a bug? (I'd be happier if someone who understands
> higher dimensional diagonals tested this).
> 
> def diagonal(a, offset=0, axis1=-2, axis2=-1):
>  if axis1 != -2: a = swapaxes(a, axis1, -2)
>  if axis2 != -1: a = swapaxes(a, axis2, -1)
>  s = __diagonal(a, offset)
>  if axis1 != -2: s = swapaxes(s, axis1, -2)
>  if axis2 != -1: s = swapaxes(a, axis2, -1) <<-- replace a with s?
>  return s

You are right, that should be s. How could this ever work?
Well, it works well for 2D arrays, which is the most important case...
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                          | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire   | Tel.: +33-4.76.88.99.28
Institut de Biologie Structurale       | Fax:  +33-4.76.88.54.94
41, av. des Martyrs                    | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France         | Nederlands/Francais
-------------------------------------------------------------------------------