Spectral representation of the electromagnetic field in anisotropic optical waveguides