# Combine submatrices of different sizes

Let's say I have generated a bunch of matrices which should be submatrices of some larger matrix. For example, I may have:

 Table[WignerD[{j, m1, m2}, \[Alpha], \[Beta], \[Gamma]],
{j, 0, jmax}, {m1, -j, j}, {m2, -j, j}]


which returns a set of matrices, so sizes 1x1, 3x3, etc. I want to combine these into one large matrix, where any entry that wasn't filled in with the code block above is given a zero. What is the most efficient way to do this?

Is this what you are looking for?

jmax = 2;
mat = Join @@
Table[WignerD[{j, m1, m2}, \[Alpha], \[Beta], \[Gamma]], {j, 0,
jmax}, {m1, -j, j}, {m2, -j, j}];
dim = Join @@ {Dimensions[mat], Dimensions[mat]};



$$\left( \begin{array}{cccc} 1 & 0 & 0 & 0 \\ e^{-i \alpha -i \gamma } \cos ^2\left(\frac{\beta }{2}\right) & -\sqrt{2} e^{-i \alpha } \cos \left(\frac{\beta }{2}\right) \sin \left(\frac{\beta }{2}\right) & e^{i \gamma -i \alpha } \sin ^2\left(\frac{\beta }{2}\right) & 0 \\ \sqrt{2} e^{-i \gamma } \cos \left(\frac{\beta }{2}\right) \sin \left(\frac{\beta }{2}\right) & \cos (\beta ) & -\sqrt{2} e^{i \gamma } \cos \left(\frac{\beta }{2}\right) \sin \left(\frac{\beta }{2}\right) & 0 \\ e^{i \alpha -i \gamma } \sin ^2\left(\frac{\beta }{2}\right) & \sqrt{2} e^{i \alpha } \cos \left(\frac{\beta }{2}\right) \sin \left(\frac{\beta }{2}\right) & e^{i \alpha +i \gamma } \cos ^2\left(\frac{\beta }{2}\right) & 0 \\ \end{array}\right)$$

I believe this is what you're looking for?

jmax = 1;
mat = Table[
WignerD[{j, m1, m2}, \[Alpha], \[Beta], \[Gamma]], {j, 0,
jmax}, {m1, -j, j}, {m2, -j, j}];

Fold[ArrayFlatten[{{#, 0}, {0, #2}}] &,
First@mat, Rest@mat] // MatrixForm


$$\left( \begin{array}{cccc} 1 & 0 & 0 & 0 \\ 0 & e^{-i \alpha -i \gamma } \cos ^2\left(\frac{\beta }{2}\right) & -\sqrt{2} e^{-i \alpha } \cos \left(\frac{\beta }{2}\right) \sin \left(\frac{\beta }{2}\right) & e^{i \gamma -i \alpha } \sin ^2\left(\frac{\beta }{2}\right) \\ 0 & \sqrt{2} e^{-i \gamma } \cos \left(\frac{\beta }{2}\right) \sin \left(\frac{\beta }{2}\right) & \cos (\beta ) & -\sqrt{2} e^{i \gamma } \cos \left(\frac{\beta }{2}\right) \sin \left(\frac{\beta }{2}\right) \\ 0 & e^{i \alpha -i \gamma } \sin ^2\left(\frac{\beta }{2}\right) & \sqrt{2} e^{i \alpha } \cos \left(\frac{\beta }{2}\right) \sin \left(\frac{\beta }{2}\right) & e^{i \alpha +i \gamma } \cos ^2\left(\frac{\beta }{2}\right) \\ \end{array} \right)$$