I separated the hamiltonian building and matrix diagonalization into two routines.