# outer product of matrices

When I calculate the outer product of two matrices I get a correct result but the output is a matrix which has matrices as entries which is really annoying to deal with when I want to use it for further calculations later. For example:

a={{0,1},{1,0}};
Outer[Times,a,IdentityMatrix[2]]


while I would like to get directly the following output:

{{0,0,1,0},{0,0,0,1},{1,0,0,0},{0,1,0,0}}


Thank you

• KroneckerProduct[a, IdentityMatrix[2]]? – kglr Dec 11 '17 at 10:37
• I guess you are looking for ArrayFlatten, see e.g. Proof of the Dirac-γ matrices identity – Artes Dec 11 '17 at 10:38

KroneckerProduct[a, IdentityMatrix[2]]


{{0, 0, 1, 0}, {0, 0, 0, 1}, {1, 0, 0, 0}, {0, 1, 0, 0}}

Alternatively, as suggested by Artes in comments,

ArrayFlatten[Outer[Times, a, IdentityMatrix[2]]] == %


True

• Then TensorProduct is also helpful? – Αλέξανδρος Ζεγγ Dec 12 '17 at 1:58
• @AlexanderZeng, yes, great point. – kglr Dec 12 '17 at 3:01