guppyalgos.primitives.subroutines.equality¶
Equality-check primitives.
Functions
|
Flip |
- guppyalgos.primitives.subroutines.equality.equality_test(cnx_box, lhs, rhs, flag)¶
Flip
flagwhen two same-sized registers encode the same basis state.The routine computes the bitwise XOR of
lhsandrhsintorhs, so the temporaryrhsregister is all-zero exactly when the original registers were equal. It then usescnx_boxto flipflagon that all-zero condition by surrounding the multi-controlled X with bit flips on the temporary register. Finally, it uncomputes the XOR so both input registers are restored to their original values.- Parameters:
cnx_box – Exact multi-controlled X implementation acting on the temporary comparison register and the flag qubit.
lhs – First input register.
rhs – Second input register, used as temporary workspace during the comparison and restored before returning.
flag – Target qubit flipped iff the original input registers were equal.