Open msoeken opened 2 years ago
The fixed point and LittleEndian
sets of comparisons differ - there is no "a FixedPoint
register and a constant with arbitrary action on target". Do we need to add that one as well?
Yes, we can add them. They might not be as optimized as the ones for LittleEndian
though.
Comment from @cgranade during June 2022 API review
Does the
action
input toApplyControlledOnLessThanFxP
need to be adjointable? Should there be a separateAdj
variant? We may also want to describe quickly how this proposal works with the outstanding proposal for numerics refactoring all-up (https://github.com/microsoft/QuantumLibraries/issues/337).
The operation action
must at least have Ctl
as a requirement to the implementation of ApplyControlledOnLessThanFxP
. It is possible to have action
not be adjointable, however, I think that this is a very uncommon case. Adding variants for the two different cases (adjointable vs. non-adjointable) would make the more common case a special case in the operation name (A
suffix vs. no suffix). I think this is different to more general building blocks such as ApplyToEach
or SinglyControlled
that are used equally likely with different variants.
I added a reference to https://github.com/microsoft/QuantumLibraries/issues/337. That issue suggests a lot of changes, both new operations and new data types. Similarly, https://github.com/microsoft/QuantumLibraries/issues/423 is a superset of this issue, with more arithmetic operations. It's difficult to address such large issues, so that's why I started with this one aiming to first improve consistency in the arithmetic APIs, and then tackle https://github.com/microsoft/QuantumLibraries/issues/337 for UDTs when all the operations are in place.
Comparison operations
Conceptual overview
Provides operations for
<
,<=
,=>
,>
forin
Standard
:LittleEndian
registers withX
on targetLittleEndian
registers with arbitrary action on targetLittleEndian
register and a constant withX
on targetLittleEndian
register and a constant with arbitrary action on targetin
Numerics
:FixedPoint
registers withX
on targetFixedPoint
registers with arbitrary action on targetFixedPoint
register and a constant (withX
on target)Current status
Comparison operations are not readily available for all 4 cases and no specializations with constants exists. The constant variants are optimized and do not lead to additional qubit overhead.
User feedback
Useful for resource estimation.
Proposal
We describe all operations for the case
LessThan
(<
), but analogously operations are introduced forLessThanOrEqual
(<=
),GreaterThanOrEqual
(>=
), andGreaterThan
(>
)New and modified functions, operations, and UDTs
Relationship to other proposals
(see comments below)