# Diagonalization using LAPACK

Say, we have a Hamiltonian which for simplicity does not mix particle hole sectors. It is just a simple Hamiltonian in real space as shown,

$$H=\sum_{ij,\sigma} A(i,j)(c_{i\sigma}^{\dagger}c_{j\sigma} +h.c.)$$

In a specific spin sector (as spin sectors are decoupled) , we use the transformation $$c_{i\sigma}=\sum_{n} \alpha_{n\sigma}(i)d_{n\sigma}$$ to diagonalize the Hamiltonian to $$H_{d}=\sum_{n,\sigma}E_{n\sigma}d_{n\sigma}^{\dagger}d_{n\sigma}$$.

If we use LAPACK subroutine (dsyev) to diagonalize the Hamiltonian we will get a matrix consisting of the eigenvectors and corresponding eigenvalues. LAPACK organizes eigenvalues and corresponding vectors in increasing order of their value. Now is there any way to label the eigenvalues. Let me be specific. So in a mean field calculation where you solve equations self consistently, you have to refer to the eigenvalues $$E_{n\sigma}$$ in the self consistent equations (which you find out analytically). Now in each iteration LAPACK mixes the order of eigenvalues, so we can not refer to the first eigenvalue that it returns in each iteration as $$E_{1}$$.

Is there a way out?

• By what do you want to label the eigenvalues? Quantum numbers? Their magnitude? Without an extra criterion, all eigenvalues are created equal. Is the problem not present if you use something else then lapack? – Norbert Schuch Feb 11 at 12:08
• @Annie - you need to inspect the eigenvectors and determine which is which. – Jon Custer Feb 11 at 14:31
• This should get migrated back to physics, this question has nothing to do with compsci. – ComptonScattering Feb 11 at 14:53
• @Federico Usually quantum numbers are labelled by irreducible representations of some symmetry action, which one should measure. – Norbert Schuch Feb 11 at 17:34
• @Federico I just want to track the eigenvalues and vectors starting from my first iteration in a self-consistent calculation. And make sure I am referring to the correct eigenvalues and vectors in my self consistent equations in the code. – Annie Feb 12 at 15:11

## 2 Answers

I had the same problem when computing Berry-curvature related quantities within Kubo-formalism. I think the best way to solve your problem is to determine the band index by the eigenvectors. You could pin down your eigenvalues to symmetry properties of the eigenvectors, as these values vary smoothly (or are even constant) with r. If you would jump between two states you would find an unsmooth variation in the properties of your eigenvectors.

• From your suggestion, I feel plotting the eigenvalues with an assumed band index order for each iteration might help. If the order is same, there won't be any discontinuity. Thanks I will try implementing something like this. – Annie Feb 12 at 15:13

If I translate this problem into my language correctly, you have a Hermitian parameter-dependent matrix $$A(t)$$; you diagonalize various nearby samplings $$A(t_1), A(t_2), A(t_3), \dots$$ (so that the matrix changes only slightly between one and the next), and you wish to sort eigenvalues and eigenvectors consistently so that they vary 'smoothly' between nearby samplings.

If that is your problem, this looks on-topic here and should not be closed, in my view.

Observations:

1. The problem may be unsolvable, if you just assume continuity: what happens if your matrix is the following, where $$B$$ and $$C$$ are two different matrices with two different sets of eigenvalues? $$A(t) = \begin{cases} I + tB, & t\geq 0\\ I + tC, & t < 0 \end{cases}$$

2. The problem may not arise often in practice: there is a phenomenon known as eigenvalue avoidance that says that in almost all cases (in the measure-theoretical sense of this word) the eigenvalues of a smooth Hermitian one-parameter function $$A(t)$$ never cross. My knowledge of physics is very rudimentary, but from what I understand this has physical implications and may be meaningful in your application.

3. That said, a quick hack that could do the job in many cases is the following: assume you have computed $$A(t_1) = Q_1 D_1 Q_1^*, A(t_2) = Q_2 D_2 Q_2^*$$. Then, if these eigenvectors really change smoothly, $$Q_1^*Q_2$$ is approximately a permutation matrix. Permute its columns so that it is approximately an identity, and this gives you the consistent ordering.