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

 

 

posted on 2016-08-18 00:13  qqhfeng16  阅读(2971)  评论(0编辑  收藏  举报