https://en.wikipedia.org/wiki/Trace_(linear_algebra)
In linear algebra, the trace of an n-by-n square matrix A is defined to be the sum of the elements on the main diagonal (the diagonal from the upper left to the lower right) of A, i.e.,
tr(AB)=tr(BA)