[R] Matrix Mulitplication: A*B*C*D...?

Uwe Ligges ligges at statistik.tu-dortmund.de
Sun Jun 16 15:14:49 CEST 2013



On 16.06.2013 04:35, G Vishwanath wrote:
> Is there a R package or function that will multiple an arbitrary number of matrices supplied to it, preferably optimizing the sequence
>
> R_function(matA, matB, matC,  matD,....)
>     return matA %*%  matB %*%  matC %matD %....
>
> and optimizing wether it is better to do A(BC) or (AB)C ?


For part 1) or your question:

Reduce("%*%", list(matA, matB, matC, matD, ...)

for part 2): No idea.

Best,
Uwe Ligges



>
> Thanks,
> Shiv
> 	[[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list