Solving slab lamellar grating problems by the singular-value-decomposition method