Efficient calculation of the Green's function for electromagnetic scattering by gratings.