Suppose I have a table of matrices, $[A,B,C,D,...,Z]$ and a vector $v$. I would like to efficiently compute both $ABCD...Zv$ and the table $[A,AB,ABC,ABCD,...,ABCD....Z]$.

I know that to compute the product of the entire table I can do something like


But how can I efficiently find the products of different length? I would like to avoid loops and explicitly limiting lengths in a table if possible, for speed.

The matrices themselves will be quite large, $\sim400 \times 400$, always square, and have complex values inside them.

  • 6
    $\begingroup$ Looks like something FoldList[] was built for: FoldList[Dot, {A, B, C}]. Just multiply the last in the series with your vector afterwards. $\endgroup$ – J. M. is away Mar 10 at 15:03
  • $\begingroup$ Thanks, this helped! And what about if I wanted to compute the table $[Av,ABv,ABCv,...]$? $\endgroup$ – Spherical Cow Mar 10 at 15:48
  • 2
    $\begingroup$ You could just Map[] #.v & into your list of matrices. However, if the question is how to generate that list of vectors without keeping those intermediate matrices around, that is a little more interesting. $\endgroup$ – J. M. is away Mar 10 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.