I have a table that looks like
Table[m, {k, 10}, {j, k}, {i, j}]
where, m
is a square matrix that depends on the indices $i, j$, and $k$. I want to add all of the m matrices in the table. What is the most efficient way to do it?
If there are only two indices, I can do
Total[Apply[Join, Table[m, {k, 10}, {j, k}]]]
But this is not very fast.
I am trying to avoid nested sums, any suggestions are greatly appreciated!
Flatten[result,2]//Total
(result being the result of your table) should do what you're after... $\endgroup$Table
toSum
. $\endgroup$Sum
as commented by 2021rcampion is cleaner... $\endgroup$