DraperAdder
QuICT.algorithm.arithmetic.adder.DraperAdder ¶
DraperAdder(qreg_size: int, qreg_size_b: Optional[int] = None, in_fourier: bool = False, out_fourier: bool = False, name: str = None)
Bases: CompositeGate
A qft based in-place adder that in total requires 2n qubits. For two n-qubit binary
encoded addends a and b, calculates the result and store it on the second register:
Applying this adder on two 3-qubit sized registers, \(a:=\vert{q_0q_1q_2}\rangle\) and \(b:=\vert{q_3q_4q_5}\rangle\), looks like:
q_0: |0>─────────────────────────────────────────────────■───────────────
│
q_1: |0>───────────────────────────────────■──────■──────┼───────────────
│ │ │
q_2: |0>──────────────■──────■──────■──────┼──────┼──────┼───────────────
┌─────────┐┌──┴──┐ │ │ ┌──┴──┐ │ ┌──┴──┐┌──────────┐
q_3: |0>┤0 ├┤ cu1 ├───┼──────┼───┤ cu1 ├───┼───┤ cu1 ├┤0 ├
│ │└─────┘┌──┴──┐ │ └─────┘┌──┴──┐└─────┘│ │
q_4: |0>┤1 cg_QFT ├───────┤ cu1 ├───┼──────────┤ cu1 ├───────┤1 cg_IQFT ├
│ │ └─────┘┌──┴──┐ └─────┘ │ │
q_5: |0>┤2 ├──────────────┤ cu1 ├─────────────────────┤2 ├
└─────────┘ └─────┘ └──────────┘
Examples:
from QuICT.core import Circuit
from QuICT.algorithm.arithmetic import DraperAdder
circuit = Circuit(6)
DraperAdder(3) | circuit
Implementation Details(Asymptotic)
| Parameter | Info |
|---|---|
| Input Size | \(n\) |
| num. ancilla | 0 |
| Gate set | \(CU_1, H\) |
| Width | \(2n\) |
| Depth | \(4n-1\) |
| Size | \(\frac{3}{2}n(n+1)\) |
| Two-qubit gate | \({3\over2}n^2-{1\over2}n\) |
References
[1]: "Addition on a Quantum Computer" by Thomas G. Draper https://arxiv.org/abs/quant-ph/0008033v1.
[2]: "Quantum arithmetic with the Quantum Fourier Transform" by Lidia Ruiz-Perez and Juan Carlos Garcia-Escartin https://arxiv.org/abs/1411.5949v2.
Parameters:
-
qreg_size(int) –Input register size for both addends. Needs to be larger than 1.
-
in_fourier(bool, default:False) –If True, will assume the input register is already in fourier basis.
-
out_fourier(bool, default:False) –If True, after the addition, the register will be left in fourier basis.
-
name(str, default:None) –Name of the adder gate.
Raises:
GateParametersAssignedError: If qreg_size is smaller than 2.