Is this a ruby's bug in class Matrix?

Viewed 98

I use Matrix class in ruby to caculate eigenvalues and eigenvectors. With this code:

m = Matrix[[0.6868,0.6067],[0.6067,0.5978]]
v, d, v_inv = m.eigensystem

the correct result should be:

[ 1.25057433  0.03398123]
[[ 0.73251454 -0.68075138]
 [ 0.68075138  0.73251454]]

which I confirmed with numpy using Python.

However, I got the result below:

d=[[0.033970204576497576,   0],
 [0,    1.2506297954235022]]

v=[[0.6807528514962294, 0.7325131774785713],
 [-0.7325131774785713,  0.6807528514962294]]

Is this a ruby's bug? My ruby's version below:

ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
1 Answers
Related