本文介绍了为什么用numpy计算2 x 2矩阵的特征向量会使我的Python会话崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试执行以下操作:
import numpy as np
from numpy import linalg as la
w, v = la.eig(np.array([[1, -1], [1, 1]]))
结果是我的python会话崩溃,并显示以下消息:
As a result I have a crash of the python session with the following message:
Illegal instruction (core dumped)
我尝试使用scipy而不是numpy.结果是一样的.
I tried to use scipy instead of numpy. The result is the same.
推荐答案
我怀疑您在安装python/numpy/scipy时遇到问题,因为我尝试时没有问题.
I suspect that there is a problem with your installation of python/numpy/scipy as when I try it I have no problems.
Python 2.7.4 (default, Sep 26 2013, 03:20:26)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> from numpy import linalg as la
>>> w, v = la.eig(np.array([[1, -1], [1, 1]]))
>>> w
array([ 1.+1.j, 1.-1.j])
>>> v
array([[ 0.70710678+0.j , 0.70710678+0.j ],
[ 0.00000000-0.70710678j, 0.00000000+0.70710678j]])
>>>
我建议您尝试全新安装.
I would suggest that you try a fresh installation.
这篇关于为什么用numpy计算2 x 2矩阵的特征向量会使我的Python会话崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!