In a textbook I'm reading, the author uses the relation $\mathrm{Tr}(A B) = \sum\limits_{i j}A_{ij} B_{ji}$ without further explanation. How can this be the same as the usual definition, $\mathrm{Tr}(A B) = \sum\limits_{i}(A B)_{ii}$? It seems like the author's definition would include additional off-diagonal elements from the matrices.
(It is assumed that $A$ and $B$ are both $N$x$N$ matrices and the sums go from 1 to $N$.)
How are the diagonal entries of $AB $ calculated? $(AB)_{ii}=\sum_j A_{ij}B_{ji} $.