I want to calculate the diagonal of a matrix in different basis $V' A V$ where $V$ is the unitary matrix and $A$ is the matrix. What is the least computational expensive way?
If I calculate $V' A V$ and throw away all elements other than diagonal, it would be inefficient. I am using Matlab.