Skip to content

Commit

Permalink
Update library/signed/src/Comparison.qs
Browse files Browse the repository at this point in the history
Co-authored-by: César Zaragoza Cortés <[email protected]>
  • Loading branch information
sezna and cesarzc authored Aug 22, 2024
1 parent 9081137 commit e3e04ee
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions library/signed/src/Comparison.qs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ import Utils.ApplyCCNOTChain;
/// Will be flipped if $xs > ys$
operation CompareGTSI(xs : Qubit[], ys : Qubit[], result : Qubit) : Unit is Adj + Ctl {
use tmp = Qubit();
CNOT(Tail(xs), tmp);
CNOT(Tail(ys), tmp);
X(tmp);
Controlled CompareGTI([tmp], (xs, ys, result));
X(tmp);
CCNOT(tmp, Tail(ys), result);
CNOT(Tail(xs), tmp);
CNOT(Tail(ys), tmp);
within {
CNOT(Tail(xs), tmp);
CNOT(Tail(ys), tmp);
} apply {
X(tmp);
Controlled CompareGTI([tmp], (xs, ys, result));
X(tmp);
CCNOT(tmp, Tail(ys), result);
}
}


Expand Down

0 comments on commit e3e04ee

Please sign in to comment.