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.
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]&
.
Dot @@@ Tuples[{{a, b, c}, {x, y}}]
give what you need? $\endgroup$Join @@ Transpose@Outer[Dot, {a, b, c}, {x, y}]
? $\endgroup${a.x, a.y,....}
but it doesn't matter. Thanks! $\endgroup$