Matrix algebras (or matrix rings) may be defined over any ring S. We shall regard such a matrix algebra as an S-algebra. Let us denote the complete algebra of n x n matrices over S by Mn(S). It will often be convenient to regard Mn(S) as the endomorphism ring of the free S-module S(n). We will then speak of S(n) as the natural S-module associated with Mn(S).
Matrix algebras have type AlgMat and their elements have type AlgMatElt. These types inherit from AlgMatV and AlgMatVElt respectively (which cover both ordinary matrix algebras and matrix Lie algebras).