Multiply lists of matrices

Hello I would like to multiply a list of matrices by another list of matrices and return all elements. I.e.

K={A,B,C}
L={X,Y}

And the result should be

K.L={A.X,B.X,C.X,A.Y,B.Y,C.Y}

I tried

Outer[Dot,A,B]

but it did not work.

• Does Dot @@@ Tuples[{{a, b, c}, {x, y}}] give what you need? – kglr Jan 19 '17 at 1:00
• .. or Join @@ Transpose@Outer[Dot, {a, b, c}, {x, y}]? – kglr Jan 19 '17 at 1:05
• It does! The order is slightly different - it is {a.x, a.y,....} but it doesn't matter. Thanks! – MathsAndBlocks Jan 19 '17 at 1:11
• @kglr, make an answer dude and we will upvote it!! – ivbc Jan 19 '17 at 1:29

Dot @@@ Tuples[{{a, b, c}, {x, y}}]
(* or *) Join @@ Transpose@Outer[Dot, {a, b, c}, {x, y}]
(* or *) Distribute[{{a, b, c}, {x, y}}, List, List, List, Dot]

{a.x, a.y, b.x, b.y, c.x, c.y}

If the order matters use SortBy:

Dot @@@ Tuples[{{a, b, c}, {x, y}}] // SortBy[#, Last]&

{a.x, b.x, c.x, a.y, b.y, c.y}

Or, if you have version 10 or 11, just SortBy[Last] instead of SortBy[#, Last]&.