Somewhere in a proof I used the fact that for a vector $a\in\mathbb R^n$, the matrix $a a^T$ is symmetric and can thus be diagonalised into $a a^T = Q^T D Q$, with $Q$ orthogonal and $D$ diagonal. I needed this to prove that, given $x\in \mathbb R^n$, there exist orthogonal matrix $Q$ and diagonal matrix $D$ s.t. $x^T a a^T x = (Qx)^T D Qx$.
Now I need to say something about the reverse of this, so my question is: given diagonal matrix $D$, under what conditions does there exist a vector $a$ and orthogonal matrix $Q$ s.t. $(Qx)^T D Qx$ can be written as $x^T a a^T x$, with $a_1,\ldots ,a_n \neq 0$ ?
I think the condition is that $D$ has positive elements but I don't know how to prove this.