[Numpy-discussion] Problem with numpy.linalg.eig?

Michael McNeil Forbes mforbes@physics.ubc...
Thu Nov 15 04:47:32 CST 2007


On 13 Nov 2007, at 9:43 AM, Geoffrey Zhu wrote:
> On Nov 13, 2007 2:37 AM, David Cournapeau <david@ar.media.kyoto- 
> u.ac.jp> wrote:
>> Geoffrey Zhu wrote:
>>> Pointer problems are usually random...
...
> The original MSI version hangs on numpy.test() if I open IDLE and type
>
> import numpy
> numpy.test()
>
> If I try the OP's test first, once it hang on "from numpy.linalg
> import eig" and the other time it ran successfully. After it ran
> successfully, it ran numpy.test() successfully, too.
>
> As you said, it is random.


I have also been having random problems with the latest numpy from  
svn built on an Intel core 2 Duo Linux box running in 64 bit mode  
under Red Hat 3.4.6-8 with the gcc 3.4.6 20060404 and ATLAS 3.8.0.

I am having a problem with numpy.linalg.eigh and complex Hermitian  
matrices.  Randomly, I get seemingly correct answers, and then  
eigenvectors full of Nan's (though not completely.  The first row the  
the eigenvectors seem to be numbers, but incorrect.)

Sometimes, I can stop just after the error with pdb and "play".   
Calling eigh from the debugger sometimes gives a correct answer, and  
then other times gives eigenvalues and eigenvectors full of Nan's  
(not completely full mind you).  For example:

(Pdb) p numpy.linalg.eigh(HH)
(array([-50.50589438, -45.86305013, -40.56713543, -35.57216233,   
38.1497506 ,  40.17291371,  43.35773763,  46.59527636,   
49.42413434,          NaN,          NaN,
                 NaN,          NaN,          NaN,           
NaN,          NaN,          NaN,          NaN,          NaN,           
NaN,          NaN,          NaN,
                 NaN,          NaN,          NaN,           
NaN,          NaN,          NaN,          NaN,          NaN,           
NaN,          NaN,          NaN,
                 NaN]), array([[-0.00072424 +0.j, -0.00136655 +0.j,   
0.00200233 +0.j, ...,  0.00000000 +0.j,  0.00000000 +0.j,  0.00000000  
+0.j],
        [        NaN NaNj,         NaN NaNj,         NaN  
NaNj, ...,         NaN NaNj,         NaN NaNj,         NaN NaNj],
        [        NaN NaNj,         NaN NaNj,         NaN  
NaNj, ...,         NaN NaNj,         NaN NaNj,         NaN NaNj],
        ...,
        [        NaN NaNj,         NaN NaNj,         NaN  
NaNj, ...,         NaN NaNj,         NaN NaNj,         NaN NaNj],
        [        NaN NaNj,         NaN NaNj,         NaN  
NaNj, ...,         NaN NaNj,         NaN NaNj,         NaN NaNj],
        [        NaN NaNj,         NaN NaNj,         NaN  
NaNj, ...,         NaN NaNj,         NaN NaNj,         NaN NaNj]]))
(Pdb) p numpy.linalg.eigh(HH)
(array([-51.06208813, -48.50332834, -48.49643331, -46.25814405,  
-46.25813858, -44.33668063, -44.33668063, -42.73548661, -42.73548661,  
-41.45454929, -41.45454929,
        -40.49386126, -40.49386126, -39.85344006, -39.85344006,  
-39.53308677, -39.53308677,  37.91885011,  37.91885011,   
38.2392034 ,  38.2392034 ,  38.8796246 ,
         38.8796246 ,  39.84031263,  39.84031263,  41.12124995,   
41.12124995,  42.72244397,  42.72244398,  44.64390192,  44.6439074 ,   
46.88219666,  46.88909168,
         49.44785148]), array([[ -5.28060016e-04 +0.00000000e+00j,   
-3.92271866e-05 +0.00000000e+00j,   7.72453920e-04 +0.00000000e 
+00j, ...,  -3.36896226e-01 +0.00000000e+00j,
           6.28651296e-02 +0.00000000e+00j,  -2.42202473e-01  
+0.00000000e+00j],
        [  1.48818848e-03 +2.78190640e-04j,   1.06069959e-03  
+1.98279117e-04j,  -1.88322135e-03 -3.52035081e-04j, ...,    
2.86677919e-01 +5.35893907e-02j,
          -1.77188491e-01 -3.31222694e-02j,   2.38244862e-01  
+4.45356831e-02j],
        [ -2.14234988e-03 -8.29950766e-04j,  -2.44246082e-03  
-9.46214364e-04j,   1.92200953e-03 +7.44590459e-04j, ...,   
-1.92999931e-01 -7.47685718e-02j,
           2.55119386e-01 +9.88337767e-02j,  -2.26238355e-01  
-8.76452055e-02j],
        ...,
        [  2.06281453e-01 -1.27724068e-01j,  -2.32614835e-01  
+1.44029008e-01j,  -1.75975052e-01 +1.08959139e-01j, ...,    
1.75246553e-03 -1.08508072e-03j,
           2.22700685e-03 -1.37890426e-03j,   1.95336925e-03  
-1.20947504e-03j],
        [ -2.26004880e-01 +8.75547569e-02j,   1.68085319e-01  
-6.51165996e-02j,   2.71949658e-01 -1.05353859e-01j, ...,   
-1.78646965e-03 +6.92082029e-04j,
          -1.00620547e-03 +3.89806076e-04j,  -1.41173185e-03  
+5.46907831e-04j],
        [  2.38078516e-01 -4.45045876e-02j,  -6.17947313e-02  
+1.15514373e-02j,  -3.31159928e-01 +6.19045191e-02j, ...,    
7.59301424e-04 -1.41938035e-04j,
           3.85592692e-05 -7.20797663e-06j,   5.19068791e-04  
-9.70307734e-05j]]))

Here is the version info (Everything build from scratch, numpy from  
svn):
 >>> sys.version
'2.5.1 (r251:54863, Nov 10 2007, 00:44:16) \n[GCC 3.4.6 20060404 (Red  
Hat 3.4.6-8)]'
 >>> numpy.version.version
'1.0.5.dev4427'
 >>> scipy.version.version
'0.7.0.dev3511'

Using ATLAS-3.8.0.

This is extremely annoying, and difficult to reproduce.  I will try  
recompiling with some different versions and see if I can reproduce  
the problem.

Running numpy.test() does *not* fail...

Michael.


More information about the Numpy-discussion mailing list