Fixed an error for the quadratic matrix elements in genHamMatrix2