Generalized Matrix Algebras and Their Applications