In abstract algebra, a **matrix ring** is a set of matrices with entries in a ring *R* that form a ring under matrix addition and matrix multiplication.^{[1]} The set of all *n* × *n* matrices with entries in *R* is a matrix ring denoted M_{n}(*R*)^{[2]}^{[3]}^{[4]}^{[5]} (alternative notations: Mat_{n}(*R*)^{[3]} and *R*^{n×n}^{[6]}). Some sets of infinite matrices form **infinite matrix rings**. A subring of a matrix ring is again a matrix ring. Over a rng, one can form matrix rngs.

When *R* is a commutative ring, the matrix ring M_{n}(*R*) is an associative algebra over *R*, and may be called a **matrix algebra**. In this setting, if *M* is a matrix and *r* is in *R*, then the matrix *rM* is the matrix *M* with each of its entries multiplied by *r*.

- The set of all
*n*×*n*square matrices over*R*, denoted M_{n}(*R*). This is sometimes called the "full ring of*n*-by-*n*matrices". - The set of all upper triangular matrices over
*R*. - The set of all lower triangular matrices over
*R*. - The set of all diagonal matrices over
*R*. This subalgebra of M_{n}(*R*) is isomorphic to the direct product of*n*copies of*R*. - For any index set
*I*, the ring of endomorphisms of the right*R*-module is isomorphic to the ring^{[citation needed]}of**column finite matrices**whose entries are indexed by*I*×*I*and whose columns each contain only finitely many nonzero entries. The ring of endomorphisms of*M*considered as a left*R*-module is isomorphic to the ring of**row finite matrices**. - If
*R*is a Banach algebra, then the condition of row or column finiteness in the previous point can be relaxed. With the norm in place, absolutely convergent series can be used instead of finite sums. For example, the matrices whose column sums are absolutely convergent sequences form a ring.^{[dubious – discuss]}Analogously of course, the matrices whose row sums are absolutely convergent series also form a ring.^{[dubious – discuss]}This idea can be used to represent operators on Hilbert spaces, for example. - The intersection of the row-finite and column-finite matrix rings forms a ring .
- If
*R*is commutative, then M_{n}(*R*) has a structure of a *-algebra over*R*, where the involution * on M_{n}(*R*) is matrix transposition. - If
*A*is a C*-algebra, then M_{n}(*A*) is another C*-algebra. If*A*is non-unital, then M_{n}(*A*) is also non-unital. By the Gelfand–Naimark theorem, there exists a Hilbert space*H*and an isometric *-isomorphism from*A*to a norm-closed subalgebra of the algebra*B*(*H*) of continuous operators; this identifies M_{n}(*A*) with a subalgebra of*B*(*H*^{⊕n}). For simplicity, if we further suppose that*H*is separable and*A**B*(*H*) is a unital C*-algebra, we can break up*A*into a matrix ring over a smaller C*-algebra. One can do so by fixing a projection*p*and hence its orthogonal projection 1 −*p*; one can identify*A*with , where matrix multiplication works as intended because of the orthogonality of the projections. In order to identify*A*with a matrix ring over a C*-algebra, we require that*p*and 1 −*p*have the same "rank"; more precisely, we need that*p*and 1 −*p*are Murray–von Neumann equivalent, i.e., there exists a partial isometry*u*such that*p*=*uu** and 1 −*p*=*u***u*. One can easily generalize this to matrices of larger sizes. - Complex matrix algebras M
_{n}(**C**) are, up to isomorphism, the only finite-dimensional simple associative algebras over the field**C**of complex numbers. Prior to the invention of matrix algebras, Hamilton in 1853 introduced a ring, whose elements he called biquaternions^{[7]}and modern authors would call tensors in**C**⊗_{R}**H**, that was later shown to be isomorphic to M_{2}(**C**). One basis of M_{2}(**C**) consists of the four matrix units (matrices with one 1 and all other entries 0); another basis is given by the identity matrix and the three Pauli matrices. - A matrix ring over a field is a Frobenius algebra, with Frobenius form given by the trace of the product:
*σ*(*A*,*B*) = tr(*AB*).

- The matrix ring M
_{n}(*R*) can be identified with the ring of endomorphisms of the free right*R*-module of rank*n*; that is, M_{n}(*R*) ≅ End_{R}(*R*^{n}). Matrix multiplication corresponds to composition of endomorphisms. - The ring M
_{n}(*D*) over a division ring*D*is an Artinian simple ring, a special type of semisimple ring. The rings and are*not*simple and not Artinian if the set*I*is infinite, but they are still full linear rings. - The Artin–Wedderburn theorem states that every semisimple ring is isomorphic to a finite direct product , for some nonnegative integer
*r*, positive integers*n*_{i}, and division rings*D*_{i}. - When we view M
_{n}(**C**) as the ring of linear endomorphisms of**C**^{n}, those matrices which vanish on a given subspace*V*form a left ideal. Conversely, for a given left ideal*I*of M_{n}(**C**) the intersection of null spaces of all matrices in*I*gives a subspace of**C**^{n}. Under this construction, the left ideals of M_{n}(**C**) are in bijection with the subspaces of**C**^{n}. - There is a bijection between the two-sided ideals of M
_{n}(*R*) and the two-sided ideals of*R*. Namely, for each ideal*I*of*R*, the set of all*n*×*n*matrices with entries in*I*is an ideal of M_{n}(*R*), and each ideal of M_{n}(*R*) arises in this way. This implies that M_{n}(*R*) is simple if and only if*R*is simple. For*n*≥ 2, not every left ideal or right ideal of M_{n}(*R*) arises by the previous construction from a left ideal or a right ideal in*R*. For example, the set of matrices whose columns with indices 2 through*n*are all zero forms a left ideal in M_{n}(*R*). - The previous ideal correspondence actually arises from the fact that the rings
*R*and M_{n}(*R*) are Morita equivalent. Roughly speaking, this means that the category of left*R*-modules and the category of left M_{n}(*R*)-modules are very similar. Because of this, there is a natural bijective correspondence between the*isomorphism classes*of left*R*-modules and left M_{n}(*R*)-modules, and between the isomorphism classes of left ideals of*R*and left ideals of M_{n}(*R*). Identical statements hold for right modules and right ideals. Through Morita equivalence, M_{n}(*R*) inherits any Morita-invariant properties of*R*, such as being simple, Artinian, Noetherian, prime.

- If
*S*is a subring of*R*, then M_{n}(*S*) is a subring of M_{n}(*R*). For example, M_{n}(**Z**) is a subring of M_{n}(**Q**). - The matrix ring M
_{n}(*R*) is commutative if and only if*n*= 0,*R*= 0, or*R*is commutative and*n*= 1. In fact, this is true also for the subring of upper triangular matrices. Here is an example showing two upper triangular 2 × 2 matrices that do not commute, assuming 1 ≠ 0 in*R*:- and

- For
*n*≥ 2, the matrix ring M_{n}(*R*) over a nonzero ring has zero divisors and nilpotent elements; the same holds for the ring of upper triangular matrices. An example in 2 × 2 matrices would be - The center of M
_{n}(*R*) consists of the scalar multiples of the identity matrix,*I*_{n}, in which the scalar belongs to the center of*R*. - The unit group of M
_{n}(*R*), consisting of the invertible matrices under multiplication, is denoted GL_{n}(*R*). - If
*F*is a field, then for any two matrices*A*and*B*in M_{n}(*F*), the equality*AB*=*I*_{n}implies*BA*=*I*_{n}. This is not true for every ring*R*though. A ring*R*whose matrix rings all have the mentioned property is known as a stably finite ring (Lam 1999, p. 5).

In fact, *R* needs to be only a semiring for M_{n}(*R*) to be defined. In this case, M_{n}(*R*) is a semiring, called the **matrix semiring**. Similarly, if *R* is a commutative semiring, then M_{n}(*R*) is a **matrix semialgebra**.

For example, if *R* is the Boolean semiring (the two-element Boolean algebra *R* = {0, 1} with 1 + 1 = 1),^{[8]} then M_{n}(*R*) is the semiring of binary relations on an *n*-element set with union as addition, composition of relations as multiplication, the empty relation (zero matrix) as the zero, and the identity relation (identity matrix) as the unity.^{[9]}