bug fix in sparse hamiltonian