[SciPy-User] Eigenvalue decomposition bug

Ian Goodfellow goodfellow.ian at gmail.com
Tue May 11 16:04:00 EDT 2010


I've find that (scipy/numpy).linalg.eig have a problem where given a
symmetric matrix they return complex eigenvalues. I can use scipy.io
to save this matrix in matlab format, load it in matlab, and use
matlab's eig function to succesfully decompose it with real
eigenvalues, so the problem seems to be with scipy/numpy or their
dependencies, not with my matrix. Is this a known issue? And is there
a good workaround?

I saw another mailing post elsewhere that recommended using
scipy.sparse.linalg.eigen.arpack.eigen as an alternative but it
doesn't seem to work at all. Can anyone recommend some other way of
getting an eigenvalue decomposition in scipy or explain how to use
arpack?

My failed attempts at using arpack are below.

Thanks,
Ian

>>> A = N.random.randn(3,3)
>>> B = arpack.eigen(A)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/u/lisa/local/export.soft.lisa.master/linux-x86_64-fc9.x86_64//lib64/python2.5/site-packages/scip
                y/sparse/linalg/eigen/arpack/arpack.py", line 172, in
eigen
    raise ValueError("ncv must be k<=ncv<=n, ncv=%s"%ncv)
ValueError: ncv must be k<=ncv<=n, ncv=3
>>> B = arpack.eigen(A,3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/u/lisa/local/export.soft.lisa.master/linux-x86_64-fc9.x86_64//lib64/python2.5/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py",
line 165, in eigen
    raise ValueError("k must be less than rank(A), k=%d"%k)
ValueError: k must be less than rank(A), k=3
>>> B = arpack.eigen(A,2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/u/lisa/local/export.soft.lisa.master/linux-x86_64-fc9.x86_64//lib64/python2.5/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py",
line 220, in eigen
    raise RuntimeError("Error info=%d in arpack"%info)
RuntimeError: Error info=-3 in arpack
>>> B = arpack.eigen(A,2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/u/lisa/local/export.soft.lisa.master/linux-x86_64-fc9.x86_64//lib64/python2.5/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py",
line 220, in eigen
    raise RuntimeError("Error info=%d in arpack"%info)
RuntimeError: Error info=-3 in arpack



More information about the SciPy-User mailing list