CompareUsingRippleCarry operation
Warning
This documentation refers to the Classic QDK, which has been replaced by the Modern QDK.
Please see https://aka.ms/qdk.api for the API documentation for the Modern QDK.
Namespace: Microsoft.Quantum.Arithmetic
Package: Microsoft.Quantum.Standard
This operation tests if an integer represented by a register of qubits is greater than another integer, applying an XOR of the result onto an output qubit.
operation CompareUsingRippleCarry (x : Microsoft.Quantum.Arithmetic.LittleEndian, y : Microsoft.Quantum.Arithmetic.LittleEndian, output : Qubit) : Unit is Adj + Ctl
Description
Given two integers x
and y
stored in equal-size qubit registers,
this operation checks if they satisfy x > y
. If true, 1 is
XORed into an output qubit. Otherwise, 0 is XORed into an output qubit.
In other words, this operation can be represented by the unitary
$$
\begin{align}
U\ket{x}\ket{y}\ket{z} = \ket{x}\ket{y}\ket{z\oplus (x>y)}.
\end{align}
$$
Input
x : LittleEndian
First number to be compared stored in LittleEndian
format in a qubit register.
y : LittleEndian
Second number to be compared stored in LittleEndian
format in a qubit register.
output : Qubit
Qubit that stores the result of the comparison $x>y$.
Output : Unit
References
- A new quantum ripple-carry addition circuit Steven A. Cuccaro, Thomas G. Draper, Samuel A. Kutin, David Petrie Moulton https://arxiv.org/abs/quant-ph/0410184
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for