# Understanding matrix multiply analogously

When I was introduced to vectors, I was taught that we can view each element $e_{i}$ in vectors of the same size as being of the same "type". For example, if we have two vectors each of size 2, each $e_{1}$ in the vectors could represent the number of apples and each $e_{2}$ could represent the number of oranges in a grocery basket.

And when we sum vectors, we only add each corresponding type.

Now the difficulty I'm having is trying to extend this analogy of sorts to matrix multiplication. I understand that the dot product tells us about how two vectors are related to each other in terms of direction, but a matrix-matrix multiply seems like taking many of these dot products and sticking them together, mixing up and adding "apples" and "oranges" or mixing and matching different dimensions. The original analogy doesn't seem to hold to me and I was wondering if anyone could explain this and whether I should be thinking about things differently.

It's more of a function composition, like if you compose $f:X\to Y$ and $g:Y\to Z$ you'd get $g\circ f:X\to Z$.
In linear algebra, a matrix $A$ of size $m\times n$ represent a linear map from $\Bbb R^n$ to $\Bbb R^m$ and an $n\times p$ matrix $B$ represent a linear map from $\Bbb R^p$ to $\Bbb R^n$. You can view $C=AB$ as a linear map $C:\Bbb R^p\to \Bbb R^m$.