Linear algebra question with rank-1 matrices Suppose I have a column vector $v \in \mathbb{R}^n$ and I want to find solutions $X \in \mathbb{R}^{n\times n}$ such that
$$
X^T v v^T X = v v^T
$$
The solutions I found are
$$
X = \frac{v v^T}{v^T v}, \qquad X = \pm I
$$
However, suppose I have two column vectors $u,v \in \mathbb{R}^n$ which may be assumed to be orthogonal ($u^T v = 0$). Then do there exist solutions $X$ to
$$
X^T \left( u u^T + v v^T \right) X = u u^T + v v^T
$$
Do any solutions exist besides the trivial $X = \pm I$?
 A: Set 
$$A:=\frac{u\,u^\top}{u^\top u}+\frac{v\,v^\top}{v^\top v}\,.$$
Because $u^\top \,v=0$ and $v^\top\,u=0$, as $u$ and $v$ are orthogonal, we conclude that $X=A$ is a solution to
$$X^\top\,\left(u\,u^\top+v\,v^\top\right)\,X=u\,u^\top+v\,v^\top\,.$$
If $N$ is an $n$-by-$n$ matrix such that $u$ and $v$ are in $\ker(N)$, then $X=A+N^\top$ is also a solution.  For $n\geq 3$, there are infinitely many such $N$.  Furthermore, $X=I+N^\top$ is also a nontrivial solution.

For a fixed positive integer $m\leq n$, let $u_1,u_2,\ldots,u_m$ be (not necessarily orthogonal) linearly independent elements of $\mathbb{R}^n$.  Write $$J:=\sum_{j=1}^m\,u_j\,u_j^\top\,.$$
I shall find all solutions $X\in\text{Mat}_{n\times n}(\mathbb{R})$ such that
$$X^\top \, J \,X=J\,.$$
Let $e_1,e_2,\ldots,e_n$ be the standard basis vectors of $\mathbb{R}^n$.  Choose an invertible matrix $V\in\text{GL}_n(\mathbb{R})$ such that $V\,u_j=e_j$ for $j=1,2,\ldots,m$.  Define the matrix $K$ to be $$K:=\sum_{j=1}^m\,e_j\,e_j^\top=V\,\left(\sum_{j=1}^m\,u_j\,u_j^\top\right)\,V^\top=V\,J\,V^\top\,.$$
Setting $Y:=V^{-1}\,X\,V^\top$, we see that $X^\top\,J\,X=J$ if and only if $$Y^\top\,K\,Y=K\,.$$
Write
$$Y=\begin{bmatrix}P&Q\\R&S\end{bmatrix}\,,$$
where $P\in\text{Mat}_{m\times m}(\mathbb{R})$, $Q\in\text{Mat}_{m\times (n-m)}(\mathbb{R})$, $R\in\text{Mat}_{(n-m)\times m}(\mathbb{R})$, and $S\in\text{Mat}_{(n-m)\times(n-m)}(\mathbb{R})$.  Also, $$K=\begin{bmatrix}I_{m\times m}&0_{m\times (n-m)}\\0_{(n-m)\times m}&0_{m\times m}\end{bmatrix}\,,$$
where $I_{k\times k}$ is the $k$-by-$k$ identity matrix and $0_{r\times s}$ is the $r$-by-$s$ zero matrix.
Thus, the condition $Y^\top\,K\,Y=K$ means that
$$\begin{align}
\begin{bmatrix}I_{m\times m}&0_{m\times (n-m)}\\0_{(n-m)\times m}&0_{m\times m}\end{bmatrix}
&=K=Y^\top\,K\,Y
\\
&=
\begin{bmatrix} P^\top& R^\top\\Q^\top &S^\top\end{bmatrix}\begin{bmatrix}I_{m\times m}&0_{m\times (n-m)}\\0_{(n-m)\times m}&0_{m\times m}\end{bmatrix}\begin{bmatrix}P&Q\\ R&S\end{bmatrix}
\\
&=\begin{bmatrix} P^\top& R^\top\\Q^\top &S^\top\end{bmatrix}\begin{bmatrix} P&Q\\ 0_{(n-m)\times m}&0_{m\times m}\end{bmatrix}=\begin{bmatrix}P^\top\, P&P^\top\, Q\\ Q^\top\, P &Q^\top \,Q\end{bmatrix}
\end{align}\,.$$ 
That is, $Q^\top\, Q=0_{(n-m)\times (n-m)}$.  This shows that $Q=0_{(n-m)\times (n-m)}$.  Furthermore, we have
$$P^\top\,P =I_{m\times m}\text{ or }P\in O_m(\mathbb{R})\,.$$
There are no other conditions on $R$ and $S$.  
Since $X=V\,Y\,\left(V^{-1}\right)^\top$, we conclude that all solutions $X$ to $X^\top\,J\,X=J$ take the form
$$V\,\begin{bmatrix}P&0_{m\times(n-m)}\\R&S\end{bmatrix}\,\left(V^{-1}\right)^\top\,,$$
where $P\in O_m(\mathbb{R})$ is a real orthogonal matrix, $R\in\text{Mat}_{(n-m)\times n}(\mathbb{R})$, and $S\in\text{Mat}_{(n-m)\times (n-m)}(\mathbb{R})$.
The solution set is therefore a smooth real manifold, which is diffeomorphic to
$$O_m(\mathbb{R})\times \mathbb{R}^{m(n-m)+(n-m)^2}\,.$$
Hence, the solution set is of dimension $$\frac{m(m-1)}{2}+m(n-m)+(n-m)^2=n(n-m)+\frac{m(m-1)}{2}\geq \frac{n(n-1)}{2}\,.$$
There are therefore infinitely many nontrivial solutions when $n\geq2$.
A: With reference to
$$X^T v v^T X = v v^T$$
assuming $X^T=\frac{vv^T}{|v|^2}$ that is a projection matrix onto $\operatorname{span}(v)$ we have
$$X^T v v^T X = \frac{vv^T}{|v|^2}v v^T\frac{vv^T}{|v|^2}=vv^T$$
For
$$X^T \left( u u^T + v v^T \right) X = u u^T + v v^T$$
we can assume $X^T$ as a projection matrix onto $\operatorname{span}(v,u)$.
