[SciPy-user] linalg.eigvalsh

Nils Wagner nwagner at iam.uni-stuttgart.de
Mon May 14 04:33:02 EDT 2007


Hi,

linalg.eigvalsh returns eigenvalues even when the matrix is not Hermitian.

>>> H(4)
array([[ 0.+840000.j,  0.     +0.j,  0.     +0.j,  0.     +0.j],
       [ 0.     +0.j,  0.     +0.j,  0.     +0.j,  0.     +0.j],
       [ 0.     +0.j,  0.     +0.j,  0.+840000.j, -0.-840000.j],
       [ 0.     +0.j,  0.     +0.j, -0.-840000.j,  0.+840000.j]])
>>> linalg.eigvalsh(H(4))
array([-840000.,       0.,       0.,  840000.])

Is this behaviour expected ?

I would prefer a warning similar to
 >>> linalg.cho_factor(H(4))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib64/python2.4/site-packages/scipy/linalg/decomp.py", line
560, in cho_factor
    if info>0: raise LinAlgError, "matrix not positive definite"
numpy.linalg.linalg.LinAlgError: matrix not positive definite

e.g. raise LinAlgError,"matrix not Hermitian".

Any comment ?

Nils




More information about the SciPy-User mailing list