I'm working with trace of matrices. Trace is defined for square matrix and there are some useful rule, i.e. $\text{tr}(AB) = \text{tr}(BA)$, with $A$ and $B$ square, and more in general trace is invariant under cyclic permutation.
I was wondering if the formula $\text{tr}(AB) = \text{tr}(BA)$ holds even if $A$ and $B$ are rectangular, namely $A$ is $n$-by-$m$ and $B$ is $m$-by-$n$.
I figured out that if one completes the involved matrices to be square by adding zero entries in the right places, then the formula still works... but I want to be sure about this!