quilc
quilc copied to clipboard
scale-out-matrix-phases should have a lenient alternative
scale-out-matrix-phases takes matrices $A$ and $B$ and attempts to find a value $\phi := e^{i\theta}$ that most accurately allows $B[:,0] \approx \phi A[:,0]$. Here, '$\approx$' means double~. If, for any entry, it finds that there is no $\phi$ within double-noodle precision, it'll error saying that they're not in the same projective class.
I like to have another function that calculates something like
$$ \operatorname{argmin}_{\theta\in[0,2\pi)} \Vert B- e^{i\theta} A\Vert, $$
for some suitable choice of norm (operator norm? vectorized norm?). Maybe it's already in quilc and I just don't know about it.
(Note that some of this work has already been implemented and merged by @aijony by printing a phase-invariant distance $\sqrt{1-\frac{1}{n}|\operatorname{Tr} AB^\dagger|}$ in the -m option if you have a TOLERANCE pragma.)