Im studying quantum computation and have encountered an interesting problem.
I need to find an unitary matrix $U$, such that
$$U\begin{bmatrix}1 \\ 1 \\ 1\\ \vdots \\ -1 \\ \vdots \\ 1\end{bmatrix} = \frac1k\begin{bmatrix}0 \\ 0 \\ 0\\ \vdots \\ 1 \\ \vdots \\ 0\end{bmatrix}$$
where the vector is $n\times1$ and $k$ is a constant (as necessary). Essentially, every $1$ element goes to $0$, and $-1$ goes to $1$. The $-1$ element can be present anywhere in any row the column vector, and the corresponding row in the image vector should have $1$ at that place and $0$ everywhere else.
Can we solve for $U$? If yes,how? (It need not be unique)
The constraints on $U$ can be collected into the single equation $$U(\mathbb 1_n-2I_n)=\frac1kI_n$$ where $\mathbb 1_n$ is an $n\times n$ matrix of all ones. This has the unique solution $$U=\frac1k(\mathbb 1_n-2I_n)^{-1}=\frac1{2k}\left(\frac1{n-2}\mathbb1_n-I_n\right)$$ for $n\gt2$. This $U$ is real and symmetric, so $UU^*=U^2$, which is diagonal only for $n=4$, so it doesn’t seem possible in general to construct a unitary matrix that will perform this mapping.