I am trying to understand a solution to a problem and stuck at the step where it mentions
$$ \sum^n_{k=1} x^T_ky_iy^T_ix_k = tr(x^Ty_iy^T_ix)$$ , $$ x_k,y_i \in \mathbb{R^d}$$
I understand that the centre term $$ y_iy^T_i$$ will give an outer product with square terms at the diagonal. But how to then include the other terms on the left and right?
Can someone help me visualise this, as a product of matrix and vectors and then relate it with the trace?
$y y^t$ is a positive semi-definite matrix, so you can change bases (orthogonally) to make $y = e_1$ (this does not affect the trace). The computation then becomes easy.