[Numpy-discussion] One question about the numpy.linalg.eig() routine

Matthew Brett matthew.brett@gmail....
Mon Apr 2 20:15:56 CDT 2012


Hi,

2012/4/2 Hongbin Zhang <hongbin_zhang82@hotmail.com>:
> Dear Python-users,
>
> I am currently very confused about the Scipy routine to obtain the
> eigenvectors of a complex matrix.
> In attached you find two files to diagonalize a 2X2 complex Hermitian
> matrix, however, on my computer,
>
> If I run python, I got:
>
> [[ 0.80322132+0.j          0.59500941+0.02827207j]
>  [-0.59500941+0.02827207j  0.80322132+0.j        ]]
>
> If I compile the fortran code, I got:
>
>  ( -0.595009410289, -0.028272068905) (  0.802316135182,  0.038122316497)
>  ( -0.803221321796,  0.000000000000) ( -0.595680709955,  0.000000000000)
>
> From the scipy webpage, it is said that numpy.linalg.eig() provides nothing
> but
> an interface to lapack zheevd subroutine, which is used in my fortran code.
>
> < /div>
> Would somebody be kind to tell me how to get consistent results?

I should also point out that matlab and octave give the same answer as
your Fortran routine:

octave:15> H=[0.6+0.0j, -1.97537668-0.09386068j;
-1.97537668+0.09386068j, -0.6+0.0j]
H =

   0.60000 + 0.00000i  -1.97538 - 0.09386i
  -1.97538 + 0.09386i  -0.60000 + 0.00000i

Best,

Matthew


More information about the NumPy-Discussion mailing list