# Ordering eigenvectors for basis transformation

Let's say I have a matrix $$H$$ represented in some basis, $$a$$, and I'd like to transform this to be represented in a different basis, $$b$$. The only difference between the bases is that $$b$$ is a basis of eigenvectors of a reflection operator, $$\hat{\sigma}$$. So in theory, what I want to do is find the eigenvectors of $$\hat{\sigma}$$, but them into a matrix that I'll call $$U$$, and then compute $$H_b = U^\dagger H U$$. My problem is that the basis $$a$$ is ordered according to an order I want to preserve, but Mathematica by default sorts the eigenvectors of $$\hat{\sigma}$$ by the eigenvalues (which are all either +1 or -1 since this is a reflection operator). How can I keep the ordering of the eigenvectors locked to the original basis so I can indeed use this as a basis transformation without mixing up the subblocks of my existing matrix?

Here's a code example of what I want:

Ha = {{298.1, -0.7, 0., 0., 0., 0., 0., 0.}, {-0.7, 296.8, 0., 0., 0., 0., 0., 0.}, {0., 0., 298.1, -0.7, 0., 0., 0., 0.}, {0., 0., -0.7, 296.8, 0., 0., 0., 0.}, {0., 0., 0., 0., 298.1, -0.7, 0., 0.}, {0., 0., 0., 0., -0.7, 296.8, 0., 0.}, {0., 0., 0., 0., 0., 0., 298.1, -0.7}, {0., 0., 0., 0., 0., 0., -0.7, 296.8}};


Note that Ha is blocked in 4 2x2 blocks. When I change bases, I expect this to become blocked in 2 4x4 blocks.

Now, my operator $$\hat{\sigma}$$ can be represented as:

sigma={{0, 0, 0, 1., 0, 0, 0, 0}, {0, 0, 1., 0, 0, 0, 0, 0}, {0, 1., 0, 0, 0, 0, 0, 0}, {1., 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 1.}, {0, 0, 0, 0, 0, 0, 1., 0}, {0, 0, 0, 0, 0, 1., 0, 0}, {0, 0, 0, 0, 1., 0, 0, 0}};


But then when I call Transpose[Eigenvectors[sigma]].Ha.Eigenvectors[sigma], I get a matrix that is horribly off-diagonal, which is just showing that the eigenvectors of sigma are not sorted properly. So, how do I keep everything sorted correctly?

EDITED TO ADD: The example above is just a simple example with numerics for you to play with. In my real case, the matrix dimensions and values with vary with different simulation cases. I would like a programatic way to do this sorting.

• I do not understand what is meant by b being a matrix of eigenvectors of a reflection matrix,and at the same time being related to the basis in which the matrix H is expressed. If what you want to do is negate certain basis vectors, negate corresponding columns of the matrhix H. Commented Dec 23, 2020 at 18:32
• The point is that the matrix H and the matrix sigma can have simultaneous eigenvectors. I'm trying to go from a basis in which you make use of that fact to one in which you don't make use of the fact. I don't know where you got the idea of negating certain columns? Commented Dec 23, 2020 at 21:39
• Still unclear to me but maybe the two argument eigendecomposition will help. Commented Dec 24, 2020 at 2:55

u = ev[[{1, 3, 5, 6, 2, 4, 7, 8}]];