  Implementing the modal method in the electromagnetic grating diffraction
problem delivered by the curvilinear coordinate transformation yields a general
analytical solution to the 1D grating diffraction problem in a form of a
T-matrix. Simultaneously it is shown that the validity of the Rayleigh
expansion is defined by the validity of the modal expansion in a transformed
medium delivered by the coordinate transformation.
