Selective phase rotation (source code)

= Selective phase rotation

For a unit vector $|\psi\rangle$ and real $\phi$,
$$
R_\psi^\phi=I-(1-e^{i\phi})|\psi\rangle\langle\psi|
$$
multiplies the component parallel to $|\psi\rangle$ by $e^{i\phi}$ and fixes its orthogonal complement. The case $\phi=\pi$ is a <reflection operator>.

A reflection operator is a unitary involution that changes sign on one orthogonal subspace and fixes its orthogonal complement. For a unit vector $|\psi\rangle$, $I-2|\psi\rangle\langle\psi|$ reflects in the hyperplane perpendicular to $|\psi\rangle$.