Generation of coherent radiation by a relativistic-electron beam in an undulator