Efficient implementation of the Fourier modal method (RCWA) for the optical simulation of optoelectronics devices