How to list the pairwise matrix products of two lists of matrices

 How to list the pairwise matrix products of two lists of matrices

I have two lists of 3×3 matrices, of equal length. I would like to make a list of their pairwise matrix products. Is there a more elegant way to do it than this ?

rotationmatrices={{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, {{0, 1, 0}, {-1, 0, 0}, {0, 0, 1}}, {{1, 0, 0}, {0, 0, -1}, {0, 1, 0}}, {{0, 1, 0}, {-1, 0, 0}, {0, 0, 1}}};
scalematrices={{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, {{1, 0, 0}, {0, 2, 0}, {0, 0, 1}}, {{2, 0, 0}, {0, 1, 0}, {0, 0, 2}}};
Map[Apply[Dot, Transpose[{rotationmatrices, scalematrices}][[#]]] &, Range[Length[rotationmatrices]]]

I also tried

Inner[Dot, rotationmatrices, scalematrices, List]

and

Inner[Dot[#1, #2] &, rotationmatrices, scalematrices, List]

but neither of these worked.

Let’s block ads! (Why?)

Recent Questions – Mathematica Stack Exchange