calculate the DOS/spectral function