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