# Order of eigenvalue problem using c++ Eigen library

I have the following 6x6 matrix (taken from Google Books p. 129):

For background info: All the entries depend on the momentum $k$. Getting the eigenvalues of this matrix for each $k$ corresponds to the electronic energies of electrons for 6 different electronic bands and the eigenvectors are coefficients (lets call them $a$) to compute the electrons wave function.

I could also write this eigenvalue problem as:

$\sum_{j'}H^{LK}_{j,j'}a_{j'} = E_ja_j$

and I know which j is which electronic band. But: when I introduce a numerical grid and solve this eigenvalue problem (using c++ and ComplexEigenSolver from the Eigen library) and I look at the very first eigenvalue, it does not correspond to $j=1$ (whose value is known). It rather corresponds to another j. This is due to that the eigensolver does not give the eigenvalues in a particular order. But I need this order to not confuse eigenvalues or eigenvectors of different $j$. Both eigenvalues and vectors can in principle be complex. Is there a way to get the eigenvalues and vectors so that their order corresponds to my matrix definition?

• What distinguishes A from B in your underlying problem? Feb 10, 2015 at 14:34
• Actually, I want to calculate an electronic band structure, so the quantum numbers distinguish the different bands, here A and B. I'm not sure if this is helpful or even what you meant. Feb 10, 2015 at 14:42
• Right, but is the label A or B arbitrary? How are the bands distinguished? If you can just always say that band A is the largest eigenvalue and B the smallest, does it matter if they swap places? Feb 10, 2015 at 15:29
• In general, I cannot say if A is always smaller or larger than B... Feb 11, 2015 at 10:05
• This is helpful, but the question remains, how is it that you know the $j=1$ eigenvalue is supposed to be that one? Is the label arbitrary or did something about the physics determine that? Can you employ that knowledge to sort the eigenvalues returned by your eigensolver? Feb 11, 2015 at 18:09

This has nothing to do with Eigen: if you cannot, just by looking at a matrix, determine how eigenvalues should be labelled, you cannot expect Eigen to do it for you. Also, it is up to you to define precisely, mathematically, how the labels should be assigned.

Judging from your example plot, you seem to be assuming that labelled eigenvalues form smooth curves. So the obvious thing to try is extrapolation from previous grid points (on a one-dimensional grid): at the grid point $k$ extrapolate from two or three previous grid points where the next term is expected, $$(A_{k-3}, A_{k-2}, A_{k-1})\mapsto A^{extrap}_k, \qquad (B_{k-3},B_{k-2},B_{k-1})\mapsto B^{extrap}_k.$$ Then calculate your eigenvalues $\lambda_{1,2}$ and assign each to $A$ or $B$ depending on which it is closer to. For example, you can try assigning the labels to minimize the value of $$|\lambda_{a}-A_k^{extrap}|+|\lambda_{b}-B_k^{extrap}|.$$ This would work with your example graph, maybe even just linear extrapolation might work.

You might also need to tweak extrapolation order, or try different kinds of extrapolation to see what works.

Edit (The question changed). So if you have your eigenvalues $E_j(k)$ as functions of $k$, basically the same approach might work. If you assume that $E_j(k)$ is a smooth function of $k$, for each $j$, then when assigning labels $j$ at the next value of $k$ you can extrapolate each past eigenvalue to $E_j(k)$, then assign labels based on minimizing something like sum of squared extrapolation errors, $$\sum_j \big| \lambda_{\sigma(j)} - E_j \big|^2,$$ where $\sigma$ is the permutation that assigns labels to unlabelled eigenvalues.