eigenvalues, eigenvectors = linalg.eig(K)
How can I print just eigenvectors of len(K)
. So if there is K
, 2x2 matrix, I get 4 eigenvectors, how can I print just 2 of them if there is len(K)=2
....
Many thanks
eigenvalues, eigenvectors = linalg.eig(K)
How can I print just eigenvectors of len(K)
. So if there is K
, 2x2 matrix, I get 4 eigenvectors, how can I print just 2 of them if there is len(K)=2
....
Many thanks
You are getting two vectors of length two, not four vectors. For example:
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]
.
From the manual:
The normalized eigenvector corresponding to the eigenvalue
w[i]
is the columnv[:,i]
.
© 2022 - 2024 — McMap. All rights reserved.
print eigenvectors[:len(K)]
? – Puglieseeig
and the exact results you're getting back. – Garmonprint eigenvectors[: eigenvalues.index(<index of first almost zero eigenvalue>)]
– Pugliese