Python native vectors

eigenvalues, eigenvectors = linalg.eig(K) 

How to print only eigenvectors len(K) . So, if there is a K , 2x2 matrix, I get 4 eigenvectors, how can I print only 2 of them, if there is len(K)=2 ....

Many thanks

+6
source share
2 answers

You get two vectors of length two, not four vectors. For instance:

 In [1]: import numpy as np In [2]: K=np.random.normal(size=(2,2)) In [3]: eigenvalues, eigenvectors = np.linalg.eig(K) In [4]: eigenvectors Out[4]: array([[ 0.83022467+0.j , 0.83022467+0.j ], [ 0.09133956+0.54989461j, 0.09133956-0.54989461j]]) In [5]: eigenvectors.shape Out[5]: (2, 2) 

The first vector is eigenvectors[:,0] , the second is eigenvectors[:,1] .

+8
source

From the manual:

The normalized eigenvector corresponding to the eigenvalue w[i] is the column v[:,i] .

0
source

Source: https://habr.com/ru/post/887746/


All Articles