# Category of matrices

In mathematics, the category of matrices, often denoted $\mathbf {Mat}$, is the category whose objects are natural numbers and whose morphisms are matrices, with composition given by matrix multiplication.

## Construction

Let $A$ be an $n\times m$ real matrix, i.e. a matrix with $n$ rows and $m$ columns. Given a $p\times q$ matrix $B$, we can form the matrix multiplication $BA$ or $B\circ A$ only when $q=n$, and in that case the resulting matrix is of dimension $p\times m$.
In other words, we can only multiply matrices $A$ and $B$ when the number of rows of $A$ matches the number of columns of $B$. One can keep track of this fact by declaring an $n\times m$ matrix to be of type $m\to n$, and similarly a $p\times q$ matrix to be of type $q\to p$. This way, when $q=n$ the two arrows have matching source and target, $m\to n\to p$, and can hence be composed to an arrow of type $m\to p$.
This is precisely captured by the mathematical concept of a category, where the arrows, or morphisms, are the matrices, and they can be composed only when their domain and codomain are compatible (similar to what happens with functions). In detail, the category $\mathbf {Mat} _{\mathbb {R} }$ is constructed as follows:
* It has natural numbers as objects;
* Given numbers $m$ and $n$, a morphism $m\to n$ is an $n\times m$ matrix, i.e. a matrix with $n$ rows and $m$ columns;
* The identity morphism at each object $n$ is given by the $n\times n$ identity matrix;
* The composition of morphisms $A:m\to n$ and $B:n\to p$ (i.e. of matrices $n\times m$ and $p\times n$) is given by matrix multiplication.
More generally, one can define the category $\mathbf {Mat} _{\mathbb {F} }$ of matrices over a fixed field $\mathbb {F}$, such as the one of complex numbers.

## Properties

* The category of matrices $\mathbf {Mat} _{\mathbb {R} }$ is equivalent to the category of finite-dimensional real vector spaces and linear maps. This is witnessed by the functor mapping the number $n$ to the vector space $\mathbb {R} ^{n}$, and an $n\times m$ matrix to the corresponding linear map $\mathbb {R} ^{m}\to \mathbb {R} ^{n}$. A possible interpretation of this fact is that, as mathematical theories, abstract finite-dimensional vector spaces and concrete matrices have the same expressive power.
* More generally, the category of matrices $\mathbf {Mat} _{\mathbb {F} }$ is equivalent to the category of finite-dimensional vector spaces over the field $\mathbb {F}$ and $\mathbb {F}$-linear maps.
* A linear row operation on a $n\times m$ matrix $A$ can be equivalently obtained by applying the same operation to the $n\times n$ identity matrix, and then multiplying the resulting $n\times n$ matrix with $A$. In particular, elementary row operations correspond to elementary matrices. This fact can be seen as an instance of the Yoneda lemma for the category of matrices.
* The transpose operation makes the category of matrices a dagger category. The same can be said about the conjugate transpose in the case of complex numbers.

## Particular subcategories

* For every fixed $n$, the morphisms $n\to n$ of $\mathbf {Mat} _{\mathbb {R} }$ are the $n\times n$ matrices, and form a monoid, canonically isomorphic to the monoid of linear endomorphisms of $\mathbb {R} ^{n}$. In particular, the invertible $n\times n$ matrices form a group. The same can be said for a generic field $\mathbb {F}$.
* A stochastic matrix is a real matrix of nonnegative entries, such that the sum of each column is one. Stochastic matrices include the identity and are closed under composition, and so they form a subcategory of $\mathbf {Mat} _{\mathbb {R} }$.

## Citations

* ↑ Riehl (2016), pp. 4–5
* 1 2 Perrone (2024), pp. 99–100
* 1 2 Riehl (2016), p. 30
* ↑ Riehl (2016), pp. 60–61
* ↑ Perrone (2024), pp. 119–120
* ↑ Perrone (2024), pp. 302–303