TITLE: Can we have a matrix whose elements are other matrices as well as other things similar to sets?
QUESTION [5 upvotes]: Basically, what I am asking is this: Is a matrix just like an ordered sequence, of which the elements can be anything? It would seem silly to restrict a matrix down to limited uses such as only for numbers, but I get the impression that I cant multiply two matrices whose elements are the planets in our solar system. So we only allow numbers in matrices.
Does this also mean that I cannot have a matrix of matrices? I feel like I should be able to since if I wanted to multiply two matrices of matrices, then although tedious by hand it can be done since I can add/subtract and multiply normal matrices. Although I do not know many of the other operations so I do not know if everything else can be done with such constructs.

REPLY [4 votes]: There's no real need for matrices to have only numbers for entries. Given any collection $\mathcal{O}$ of objects, we can think of an $m$ by $n$ matrix $A$ of the objects of $\mathcal{O}$ as a function $$A:\{1,...,m\}\times\{1,...,n\}\to\mathcal{O}.$$ We typically denote $A(i,j)$ by $A_{i,j}$. Now, if we want to have some matrix operations, then we will need some associative binary operations $+$ and $\cdot$ defined on $\mathcal{O}$. Let's suppose we've got such things.
Given matrices $A,B$ of objects of $\mathcal{O}$ with the same domain (dimensions), we can define the matrix $A\oplus B$ by $$(A\oplus B)_{i,j}:=A_{i,j}+B_{i,j}.$$
Given matrices $A,B$, with $A$ being $l$ by $m$ and $B$ being $m$ by $n$, we can define the matrix $A\odot B$ by $$(A\odot B)_{i,j}:=A_{i,1}\cdot B_{1,j}+\cdots+A_{i,m}\cdot A_{m,j}.$$
If the operations $+$ and $\cdot$ have all the usual properties, then $\oplus$ and $\odot$ will have all the properties we've come to expect from regular matrix multiplication. Otherwise, there may be some differences.