numpy.linalg.eig

1、转置对于二维数组有用,对一位数组无效

2、理解特征值和特征向量的对应关系

a=np.array([[1 ,2, 3],[4, 5, 6],[7, 8, 9]])

a
Out[27]: 
array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]])

w,v = LA.eig(a)

w
Out[29]: array([  1.61168440e+01,  -1.11684397e+00,  -1.30367773e-15])

v
Out[30]: 
array([[-0.23197069, -0.78583024,  0.40824829],
       [-0.52532209, -0.08675134, -0.81649658],
       [-0.8186735 ,  0.61232756,  0.40824829]])

a
Out[31]: 
array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]])

#dot(a[:,:], v[:,i]) = w[i] * v[:,i]

w[0]
Out[33]: 16.116843969807043

v[:,0]
Out[34]: array([-0.23197069, -0.52532209, -0.8186735 ])

w[0]*v[:,0]
Out[35]: array([ -3.73863537,  -8.46653421, -13.19443305])

np.dot(a[:,:],v[:,0])
Out[37]: array([ -3.73863537,  -8.46653421, -13.19443305])

a
Out[38]: 
array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]])

v[:,0]
Out[39]: array([-0.23197069, -0.52532209, -0.8186735 ])

1*-0.23197069+2*-0.52532209+3*-0.8186735
Out[40]: -3.73863537

4*-0.23197069+5*-0.52532209+6*-0.8186735
Out[41]: -8.46653421

v[:,0]
Out[42]: array([-0.23197069, -0.52532209, -0.8186735 ])

v[:,0].T
Out[43]: array([-0.23197069, -0.52532209, -0.8186735 ])

w[0]
Out[44]: 16.116843969807043

w[0]*v[:,0]
Out[45]: array([ -3.73863537,  -8.46653421, -13.19443305])

a
Out[46]: 
array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]])

a.T
Out[47]: 
array([[1, 4, 7],
       [2, 5, 8],
       [3, 6, 9]])

c = v[0]

c
Out[49]: array([-0.23197069, -0.78583024,  0.40824829])

c.T
Out[50]: array([-0.23197069, -0.78583024,  0.40824829])

 

a
Out[55]: 
array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]])

a*v[:,0]
Out[56]: 
array([[-0.23197069, -1.05064419, -2.4560205 ],
       [-0.92788275, -2.62661047, -4.912041  ],
       [-1.62379481, -4.20257675, -7.36806149]])

v[:,0]
Out[57]: array([-0.23197069, -0.52532209, -0.8186735 ])

y = a*v[:,0]

y
Out[59]: 
array([[-0.23197069, -1.05064419, -2.4560205 ],
       [-0.92788275, -2.62661047, -4.912041  ],
       [-1.62379481, -4.20257675, -7.36806149]])

np.sum(y[0,:])
Out[63]: -3.7386353719172973

np.sum(y[1,:])
Out[64]: -8.4665342116284013

np.sum(y[2,:])
Out[65]: -13.194433051339505

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值