Skip to content

Reversible arithmetic, point 1 of #336: addition and subtraction - #337

Merged
tatopenn-cell merged 2 commits into
mainfrom
arithmetic-gates
Oct 2, 2026
Merged

tatopenn-cell merged 2 commits into
mainfrom
arithmetic-gates

Conversation

@tatopenn-cell

Copy link
Copy Markdown
Owner

Point 1 of #336.

  • add_registers: |a, b⟩ → |a, (a+b) mod 2^len(b)⟩ (Vedral, Barenco, Ekert, quant-ph/9511018, Sect. III.A; modulo 2^n as in Cuccaro et al., quant-ph/0410184, Sect. 4.1)
  • subtract_registers: inverse of the adder, high bit set when b < a
  • add_constant: classical addend, increment/decrement (Draper, quant-ph/0008033, Sect. 5; Beauregard, quant-ph/0205095, Sect. 2.1)

Each operation is a bijection on basis states, applied as an index permutation of the statevector (Vedral et al., Sect. II). Tests compare against the gate-level Cuccaro ripple-carry adder (1–3 bits, every basis state) and the Draper transform adder built from engine gates.

Docs: new API page api/arithmetic.md, nav entry, one README line.

@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
dense_evolution/circuits/arithmetic.py 87.03% 7 Missing ⚠️

📢 Thoughts on this report? Let us know!

@tatopenn-cell
tatopenn-cell merged commit 2e846a7 into main Oct 2, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant