# Closest unitary matrix with additional structure

Given a $$2n \times 2n$$ square matrix $$B$$, I would like to find the square matrix $$U$$ which is closest to $$B$$ in a suitable norm (say Frobenius or 2-norm), while satisfying two conditions:

$$\begin{equation} U U^{\dagger} = \mathbf{1}_{2n} \tag{1} \label{eq1} \end{equation}$$ $$\begin{equation} U^{*} = \gamma U \gamma, \quad\text{with} \quad \gamma = \begin{pmatrix}\mathbf{0} _{n}& \mathbf{1} _{n}\\ \mathbf{1}_{n} &\mathbf{0} _{n}\end{pmatrix} \tag{2} \label{eq2} \end{equation}$$

Here $$\dagger$$ and $$^{*}$$ denote the conjugate transpose and complex conjugation respectively.

On its own Eq. \eqref{eq1} just says that $$U$$ should live in $$\mathrm{U}(2n)$$. Eq. \eqref{eq2} imposes additional structure which means that the set of matrices satisfying these two conditions forms a group isomorphic to $$\mathrm{O}(2n)$$.

If we only required Eq. \eqref{eq1} then $$U$$ would be given by the polar decomposition of $$B$$, namely $$U = B H^{-1}$$ with $$H = \sqrt{B^{\dagger} B}$$. Is there a similar procedure to find the closest $$U$$ to $$B$$ that satisfies both equations \eqref{eq1} and \eqref{eq2}? It would be preferable if such a procedure were efficient in the sense of computational complexity.