MuThCtrlAdder
QuICT.algorithm.arithmetic.adder.MuThCtrlAdder ¶
Bases: CompositeGate
A controlled ripple-carry in-place half adder that in total requires 2n + 3 qubits.
For two n-qubit binary encoded integers a and b, calculate their sum and store
the result on the second register only when the control bit is 1:
Applying this gate on two 2-qubit sized register, \(a:=\vert{q_1q_2}\rangle\) and \(b:=\vert{q_4q_5}\rangle\) with the control bit on \(\vert{q_0}\rangle\), output carry on \(\vert{q_3}\rangle\) and one ancilla qubit on \(\vert{q_6}\rangle\) looks like:
q_0: |0>─────────■────────────────────■─────────────■─────────────■─────────
│ ┌─────┐ │ │ ┌─────┐ │
q_1: |0>──■──────■───┤ ccx ├───■──────┼──────■──────■───┤ ccx ├───┼─────■───
│ │ └──┬──┘ │ │ │ │ └──┬──┘ │ │
q_2: |0>──┼──────┼──────■──────┼──────┼──────┼──────┼──────■──────■─────┼───
│ ┌──┴──┐ │ │ ┌──┴──┐ │ │ │ │ │
q_3: |0>──┼───┤ ccx ├───┼──────┼───┤ ccx ├───┼──────┼──────┼──────┼─────┼───
┌─┴──┐└─────┘ │ │ └──┬──┘ │ ┌──┴──┐ │ │ ┌─┴──┐
q_4: |0>┤ cx ├──────────┼──────■──────┼──────■───┤ ccx ├───┼──────┼───┤ cx ├
└────┘ │ │ │ │ └─────┘ │ ┌──┴──┐└────┘
q_5: |0>────────────────■──────┼──────┼──────┼─────────────■───┤ ccx ├──────
┌──┴──┐ │ ┌──┴──┐ └─────┘
q_6: |0>────────────────────┤ ccx ├───■───┤ ccx ├───────────────────────────
└─────┘ └─────┘
Examples:
from QuICT.core import Circuit
from QuICT.algorithm.arithmetic import MuThCtrlAdder
circuit = Circuit(7)
MuThCtrlAdder(2) | circuit
Implementation Details(Asymptotic)
| Parameter | Info |
|---|---|
| Input Size | \(n\) |
| num. ctrl | \(1\) |
| Input carry | \(0\) |
| Output carry | \(1\) |
| num. ancilla | \(1\) |
| Gate set | \(CCX, CX\) |
| Width | \(2n+3\) |
| Depth | \(5n-1\) |
| Size | \(7n-4\) |
| CX count | \(4n-6\) |
| CCX count | \(3n+2\) |
References
[1]: "Quantum Circuit Design of a T-count Optimized Integer Multiplier" by Edgard Muñoz-Coreas and Himanshu Thapliyal https://ieeexplore.ieee.org/document/8543237.
Parameters:
-
qreg_size(int) –Input register size for both addends. Needs to be greater than or euqal to 2.
-
name(str, default:None) –Name of the adder gate.
Raises:
GateParametersAssignedError: If the qreg_size is smaller than 2.