Repository navigation
Reversible arithmetic, point 3 of #336: modular arithmetic - #339
Merged
Merged
Conversation
…_add_mod, multiply_mod, power_mod
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Point 3 of #336. Builds on #337 and #338 (contains their commits until they are merged).
add_registers_mod: |a, b⟩ → |a, (a+b) mod N⟩ (Vedral, Barenco, Ekert, quant-ph/9511018, Sect. III.B)add_constant_mod: classical addend, optional controls (Beauregard, quant-ph/0205095, Sect. 2.2, doubly controlled φADD(a)MOD(N))multiply_add_mod: |x, b⟩ → |x, (b + a·x) mod N⟩, optional controls (Beauregard Sect. 2.3 CMULT; Vedral Sect. III.C)multiply_mod: in place x → a·x mod N for gcd(a, N) = 1, optional controls (Vedral Sect. II; Beauregard Fig. 7); N = 2^n with odd a is plain multiplicationpower_mod: |x, y⟩ → |x, y·a^x mod N⟩, with y = 1 the modular exponentiation of Shor's algorithm (Vedral Eq. 1, Sect. III.D)Values ≥ N are left unchanged so every map stays a permutation (unitary).
Tests compare each function with the paper's construction built from already-tested blocks and engine gates, on every basis state: Beauregard modular adder (Fig. 5), sum of controlled modular additions (Eq. 2), controlled-U_a with controlled swap (Fig. 7), chain of controlled multiplications (Vedral III.D); plus 7^x mod 15, plain ×odd mod 2^n, norm on random states, coprime check.
Docs: Step 6 (7^x mod 15) on
api/arithmetic.md, details, nav label, README line.