# Construct a generalised Kronecker sum

I would like to construct a Kronecker sum function in Mathematica that is similar to the answers to this post, but a more generalised construction.

Presume I have a set of $$2\times 2$$ matrices denoted through the set $$\{X,Y,Z\}$$. I would like to construct all of the possible $$4\times4$$ matrices from the direct sum of this set. Some examples are

$$X \oplus Y$$ $$1_2 \oplus X$$ $$1 \oplus X \oplus 1$$

etc, where $$1_2$$ denotes an identity matrix of dimension $$2\times 2$$. How can I create a function that can pick out any of these different combinations.

Thanks very much!

• You perhaps want something like Tuples[] for this: Flatten[Table[Tuples[{i, x, y, z}, k], {k, 2, 4}], 1] – J. M.'s technical difficulties Nov 13 '19 at 6:21