Solution (source code)

= Solution

Taking the diagonal sum of the <matrix product> gives
$$
\boxed{\operatorname{tr}(AB)=a_{ij}b_{ji}.}
$$
Both repeated indices are summed from one to $n$.