Here is some code that hopefully clearly illustrates what I'm doing:
>>> sp.linalg.eig(d)[0].real; sp.linalg.eigh(d)[0]; d; sp.linalg.eig(d)[1]; sp.linalg.eigh(d)[1]
array([ 1., -1.])
array([-1., 1.])
matrix([[ 0, -1],
[-1, 0]])
array([[ 0.70710678, 0.70710678],
[-0.70710678, 0.70710678]])
array([[-0.70710678, -0.70710678],
[-0.70710678, 0.70710678]])
To explain the code a little, the first two array()
's are the eigenvalues from eig()
and eigh()
respectively, where the latter is only for Hermitian matrices. Then I show the matrix d
, and then the eigenvectors are shown as the columns of the following two matrices, in the same order as the eigenvalues.
Here, what I'm doing is taking a matrix d
which in this case is simply $\sigma_x$, the Pauli x-spin matrix. I'm doing adiabatic quantum simulation, so I'm getting the ground state here of a transverse magnetic field for a 1-qubit case. Higher qubit cases have initial state vector that corresponds to the lowest energy for:
$D = -\sum_i^N I \otimes I \otimes ...\otimes ~\sigma_x^i \otimes...\otimes ~I$
So what I'm doing now is using the general LAPACK eigensolver zgeev with the eig()
call and zheevd with the eigh()
call, which is general and Hermitian solvers, respectively.
Why do I get the ground state eigenvector as one thing from eig()
, but with eigh()
I get the same thing but with an overall negative? And does it matter at all?
It's worth noting that this problem does NOT arise if I say $D$ has positive values instead of negative ones. That bit really confuses me.