Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Less-than comparison with a constant #318

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Conversation

msoeken
Copy link
Member

@msoeken msoeken commented Aug 31, 2020

This operation implements an optimised version of Fig. 17 in arXiv:1902.02134. Constant input bits are propagated into the circuits, and no qubits are allocated for them. Further optimisations are applied for trailing 0s in the bit representation of the constant. The circuit uses AND gates instead of Toffoli gates to further reduce costs.

API review is necessary for consistent naming of arithmetic operations (e.g., compare to CompareUsingRippleCarry which performs greater-than comparison.)

@msoeken msoeken requested a review from cgranade August 31, 2020 07:38
@msoeken msoeken added the Status-NeedsApiReview This PR requires an API review before merging in. label Aug 31, 2020
Copy link
Contributor

@cgranade cgranade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, modulo a few comments here and there. Happy to approve once we complete API review. Thanks!

Standard/tests/ArithmeticTests.qs Outdated Show resolved Hide resolved
Standard/src/Arithmetic/Arithmetic.qs Show resolved Hide resolved
Standard/src/Arithmetic/Comparators.qs Outdated Show resolved Hide resolved
Standard/src/Arithmetic/Comparators.qs Outdated Show resolved Hide resolved
Standard/src/Arithmetic/Comparators.qs Outdated Show resolved Hide resolved
Standard/src/Arithmetic/Comparators.qs Outdated Show resolved Hide resolved
/// Dominic W. Berry, Craig Gidney, Mario Motta, Jarrod R. McClean, Ryan Babbush
/// Quantum 3, 208 (2019)
/// https://arxiv.org/abs/1902.02134v4
operation LessThanConstantUsingRippleCarry(c : BigInt, x : LittleEndian, output : Qubit)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can defer to API review, but I'd suggest maybe something like "CompareLessThanConstantUsingRippleCarry"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, but we need further discussion because we also have CompareUsingRippleCarry at the moment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point; that can definitely create some confusion. Agreed with the need for further discussion.

@msoeken
Copy link
Member Author

msoeken commented Sep 2, 2020

Thanks for your feedback @cgranade, I have incorporated your comments.

@microsoft-github-updates microsoft-github-updates bot changed the base branch from master to main September 9, 2020 07:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Status-NeedsApiReview This PR requires an API review before merging in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants