A Matrix Basis Formulation for the Dyadic Green's Functions of Maxwell's Equations in Layered Media