General analytical solution for the electromagnetic grating diffraction problem.