[Edited to simplify the question]

I am trying to associate the eigenvalues $E$ of a matrix $H$ to the original rows of the matrix.

Moreover, it would be trivial to sort the eigenvalues in ascending order, however this throws away some of the information. For my purpose the matrix is a Hamiltonian where the different rows have physical meaning. I always want the eigenvalue that corresponds to a given row.

I have tried to sort the eigenvalues according to the dominant contribution. To do this I get the magnitudes of the eigenvectors (they are complex) for each row and pick the largest. I use this index to sort the eigenvalues.

# Get eigenvalues and vector of the Hamiltonian
E, V = eig(H) 

# Now sort the eigenvalues by dominant contribution
sorted_order = []
for i in range(len(E)):
    row = V[i,:]
    row = np.absolute(row)           # length of complex number <-- correct?
    largest_index = np.argmax(row)   # the index of the largest value

E_sorted = E[sorted_order]

The sorting approach works fairly well when the eigenvector matrix is dominated by the diagonal. However, if the matrix is more homogeneous the this sorting method fails.

This leads me to believe that my method of sorting is probably incorrect. Or I am running in to accuracy issues with the eig function.

Does anyone have suggestion on an alternative way to sort by the dominant contribution?


I am doing a $\mathbf{k}\cdot\mathbf{p}$ simulation for semiconductor band structure. The eigenvalues for the $\mathbf{k}\cdot\mathbf{p}$ Hamiltonian (the 8x8 matrix below) corresponds to the different semiconductor bands and the eigenvectors are the wavefunctions.

10 band Hamiltonian, <code>http://dx.doi.org/10.1103/PhysRevB.73.125348</code>

(NB I have removed two rows and columns because I am not interested in their effect for by purpose.)

Sorting errors.

Figure: In the plot the y-axis is the eigenvalues, the x-axis corresponds to a k-space vector which changes values in the Hamiltonian. A definition: at $k=0.5$ the system is unperturbed and the eigenvectors are dominated by the diagonal terms. This also illustrates why I cannot do a simple energy sort: because at some points the bands cross. The bands have different physical meaning which I want to preserve.

Comment. The sorting approach (the Python code above) works fairly well when $k=0.5$ because the contribution is dominated by the diagonal of the eigenvectors. However, moving away from the centre of k-space ($k>0.5$ and $k<0.5$) the eigenvector matrix becomes more homogeneous and this method of sorting fails. I am surprised that it is failing intermittently.

  • $\begingroup$ What's the goal here? $\endgroup$
    – Bill Barth
    Feb 5, 2014 at 11:50
  • $\begingroup$ Well actually physics. I had written a more physics type question (an earlier version) which explain the background. Basically I am solving a k.p hamiltonian and I want to be able to attribute its eigenvalues (the semiconductor bands) to a particular row in the Hamiltonian, where the row indicated how I should interpret the eigenvalue; i.e. it's a conduction band, valence band etc. Maybe I can reinstate some of the physics. $\endgroup$
    – boyfarrell
    Feb 5, 2014 at 12:38
  • $\begingroup$ I don't think it works that way. The eigen-decomposition for your presumably Hermitian matrix gives you a basis for $\mathbb{C}^n$ in which you can represent your right-hand side and solution. Each eigenvalue can only really be said to attribute anything to its associated eigenvector(s). That being said, you should be able to look at the eigenvectors associated with the eigenvalues that interest you and say something about which physical bands they are associated with. $\endgroup$
    – Bill Barth
    Feb 5, 2014 at 14:35
  • $\begingroup$ Thanks for the comments. I interpret this to mean that the wavefunctions by the very nature are mixed in character (they have components from all 8 bands), so there is not a unique band. I'm trying to get a method that associates the eigenvalues to the physical bands by the dominant contribution. For each band I have been using the largest $|\Psi_j|^2$ in each row (where $j$ is the row index) maybe that method is floored? Maybe there is another way to associate the eigenvalues with a band? Any clever ideas? $\endgroup$
    – boyfarrell
    Feb 5, 2014 at 15:25
  • $\begingroup$ What do the eigenvectors associated with the largest (in magnitude) eigenvalues look like? Do those give you the "bands". I'm not a semiconductor person, so I'm not sure what a band is. $\endgroup$
    – Bill Barth
    Feb 5, 2014 at 16:04

1 Answer 1


You'd like to sort eigenvalues/eigenvectors in a way that is continuous as you move through momentum. This highly constrains the sorting - for most k-points, you must sort the eigenvalues to be a close as possible to the eigenvalues from a neighboring k-point. Only at eigenvalue crossings are you allowed to permute the order of bands. Furthermore, in many scenarios crossings don't actually occur - instead, with sufficient resolution, you would see an "avoided crossing", and true continuity of the eigenvalues would require the eigenvalues to stay in increasing order throughout. In the case of avoided crossings, it may still make sense to allow the band assignment to swap, depending on your situation.

One situation where true crossings due occur is if your bands have different symmetry representations, and thus cannot mix. In this case, you can order your eigenvectors first by symmetry sector and then by increasing eigenvalues.

If you cannot use symmetry, then I'd suggest the following strategy:

Pick a initial momentum point, and sort the eigenvectors at that point based on increasing energy. For each additional momentum, match each eigenvector with one at the previous momentum point by finding the maximum overlap. If the momentum spacing is very small, these identifications should only allow changes in order at a level crossing.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.