# Multiply all matrices in an array

Disclaimer: I'm new to Mathematica.

I have an array $\gamma[i]$ of length $n$, each element of which holds an $m\times m$-matrix. I would like to multiply all of them, $$\prod_{i=1}^n \gamma[i].$$ I started out thinking this should be incredibly simple but after searching through the documentation and on StackExchange for over an hour, the only information I could find is this post, in which the best answer suggests Apply[Dot, matrixList]. Since my matrices are not in a list this doesn't seem to help me much.

• In Mathematica lingo an array is a list. Do you mean each matrix is store in a separate "variable" named gamma, gamma, and so forth (not gamma[] as in a list-array)? – Michael E2 Aug 11 '16 at 1:11
• @MichaelE2 Correct. – Casimir Aug 11 '16 at 1:12
• Apply[Dot, Array[gamma, n]]? – Michael E2 Aug 11 '16 at 1:12
• Module[{res = gamma}, Do[res = res . gamma[i], {i, 2, n}]; res] is a C-like way to go....The previous might be more efficient. Would have to test. – Michael E2 Aug 11 '16 at 1:16
• Yes, AFAIK there is no KroneckerPower-like function. I would use KroneckerProduct @@ Table[m, {n}]. (@@ is short infix for Apply.) Table will copy only pointers to m, so it's memory-efficient. But the Kronecker product will be so much bigger, that's not a major consideration here. – Michael E2 Aug 11 '16 at 11:21

For a sequence of matrices, gamma, gamma,..., gamma[n], you can use Array and apply Dot as in the linked question, I need to multiply a series of matrices:
Apply[Dot, Array[gamma, n]]
`