For a given matrix A with eigevalues eigval
and eigevectors eigvec
, here's what I want to do:
- Find the eigenvalues with multiplicity > 1
- Find the corresponding eigenvectors. Perform some calculations on these eigenvectors
- Create
eigvec
with these new vectors replacing the old ones
Most importantly, if there are say 2 degenerate sets of eigenvalues with multiplicty 3 each, I want the two sets of eigenvectors to be treated separately. Here's what I have tried so far:
import numpy as np
import numpy.linalg as linalg
A = [[1,0,0], [0, 1, 0], [6, 7, 3]]
eigval, eigvec = linalg.eig(A)
idx = eigval.argsort()[::-1]
eigval = eigval[idx]
eigvec = eigvec[:,idx]
unique, counts,indices = np.unique(eigval,return_counts=True,return_index=True)
uni_count = dict(zip(counts, indices))
qr_counter = []
for key,val in uni_count.items():
if val > 1:
qr_counter.append(key)
print('For the dict: the key is the index, the value is mulplicity')
non_unique_eigvec = np.empty((len(qr_counter),), dtype=object)
for int in qr_counter:
np.concatenate(non_unique_eigvec, eigvec[int])
Now the problem is that eigvec
are np arrays and I don't know how to work with modifying that.
Any help would be appreciated! Thanks!