Imagine the following diagonal matrix: $$\mathbf A = \begin{bmatrix}a\\ & \ddots\\ && a\\ &&& b\\ &&&& \ddots\\ &&&&& b\\ &&&&&& \ddots \end{bmatrix}\tag{1} $$ I need the entries $a$, $b$ etc. replicated equally many times $M$ along the diagonal of $\mathbf A$. Now, obviously there is a lot of redundancy in this matrix, and I would like to boil it down to a more compact description in which $$\mathbf A = f(\mathbf a)$$ where $$\mathbf a = \begin{bmatrix}a & b & \dots\end{bmatrix}$$ However, I still have not quite figured out what $f(\cdot)$ should be. I have thought of $\mathbf a \otimes \mathbf I_M$ (Kronecker product), but this becomes: $$\mathbf a \otimes \mathbf I_M = \begin{bmatrix}a\\ & \ddots\\ && a\\ b\\ & \ddots\\ && b\\ & \vdots \end{bmatrix},$$ so I am not quite there. Similarly, $\mathbf I_M \otimes \mathbf a$ does not quite fit the bill either: $$\mathbf I_M \otimes \mathbf a= \begin{bmatrix}\mathbf a\\ & \mathbf a\\ && \ddots\\ &&& \mathbf a \end{bmatrix}$$
The central requirement here is that I would like to keep $\mathbf a$, but it is less important what $f$ I get.
I think I have found a way now: if we let: $$\operatorname{diag}(\mathbf a) = \begin{bmatrix} a\\ & b\\ && \ddots\end{bmatrix},$$ then $$\mathbf A = \operatorname{diag}(\mathbf a) \otimes \mathbf I_M$$