I have a matrix of dimension (…, N, N). I use torch.linalg.eig to get the eigenvalues and eigenvectors. How to select the eigenvector which has the largest eigenvalue?
Sample code here:
m = torch.rand(2, 100, 8, 8, dtype=torch.cdouble)
w, v = torch.linalg.eig(m)
_, indices = torch.sort(w.abs(), dim=-1, descending=True)
v_max = f(indices) # the shape of v_max should be (2, 100, 8)