I'm trying to take the hilbert schmidt inner product of two matices.
For two matrices A, B this operation requires the matrix product of the Hermitian conjugate of A times B followed by the trace (summing down the diagonal). As you only need the diagonal entries, it is pointless to find the full matrix product, as the off diagonal terms are not needed.
In effect one needs to compute: