Conflicting eigen vector outputs between Matlab and Numpy

前端 未结 1 1992
自闭症患者
自闭症患者 2021-01-18 00:27

I am calculating eigenvectors in Matlab and Numpy, but getting different results. I was under the impression there was only one set of eigenvectors for a given matrix, howev

1条回答
  •  礼貌的吻别
    2021-01-18 00:53

    It's not immediately obvious, but the eigenvectors you are being returned are actually the same in both cases. Try the following:

    >>> matlab_eigvec = np.array([[0.0896+0.6789j, 0.0953+0.7225j],
    ...                           [-0.7288+0.j, 0.6848+0.j]])
    >>> 
    >>> f1, f2 = matlab_eigvec.T # matlab eigenvectors
    >>> e1, e2 = eig_vec.T # numpy eigenvectors
    >>> f1/e1
    array([-0.13084653-0.99142531j, -0.13079065-0.99146862j])
    >>> f2/e2
    array([-0.13077050-0.99141326j, -0.13078845-0.99145198j])
    

    So you can get the matlab eigenvectors by multiplying the numpy ones by -0.13-0.99j, i.e. they are colinear and therefore the same as far as eigenvectors are concerned.

    0 讨论(0)
提交回复
热议问题