A generalization of the Riemann–Siegel formula