I have a square matrix $U$ of dimension $L\times L$, I am interested in the following quantity
$U_{1,j}U_{2,k}U_{3,l}U_{4,m}\cdots U_{L,q}$
summed over all permutations of the letter indices, e.g., $\{j,k,l,m,\cdots q\}$ is an element of Permutations[Range[L]]
. What is a fast and efficient way of doing this? I am using the following function:
f[mat_, l_] := Total[Product[Part[mat, j, #[[j]]], {j, l}] & /@ Permutations[Range[l]]]
which is very inefficient. In fact it even runs out of memory for $L>11$
Permanent[]
is a built-in function, but it is not very fast. You might want to look at the solutions here. $\endgroup$