MuThMultiplier
QuICT.algorithm.arithmetic.multiplier.MuThMultiplier ¶
Bases: CompositeGate
An out-of-place reversible quantum multiplier using schoolbook method. For qreg_size equals n,
this gate requires in total 4n+1 qubits. For two binary encoded n-qubits integers a and b,
calculates their product and store the result on 2n clean qubits.
Applying this multiplier on two 3-qubit sized register, \(a:=\vert{q_0q_1q_2}\rangle\) and \(b:=\vert{q_3q_4q_5}\rangle\) with output register \(\vert{q_6...q_{11}}\rangle\) and ancilla qubit \(\vert{q_{12}}\rangle\) looks like:
┌──────────┐
q_0: |0>─────────────────────────────────┤0 ├
┌──────────┐│ │
q_1: |0>─────────────────────┤0 ├┤ ├
│ ││ │
q_2: |0>───■──────■──────■───┤ ├┤ ├
│ │ │ │ ││ │
q_3: |0>───┼──────┼──────■───┤1 ├┤1 ├
│ │ │ │ ││ │
q_4: |0>───┼──────■──────┼───┤2 ├┤2 ├
│ │ │ │ ││ │
q_5: |0>───■──────┼──────┼───┤3 ├┤3 ├
│ │ │ │ ││ │
q_6: |0>───┼──────┼──────┼───┤ ├┤4 cg_cAdd ├
│ │ │ │ cg_cAdd ││ │
q_7: |0>───┼──────┼──────┼───┤4 ├┤5 ├
│ │ │ │ ││ │
q_8: |0>───┼──────┼──────┼───┤5 ├┤6 ├
│ │ ┌──┴──┐│ ││ │
q_9: |0>───┼──────┼───┤ ccx ├┤6 ├┤7 ├
│ ┌──┴──┐└─────┘│ ││ │
q_10: |0>───┼───┤ ccx ├───────┤7 ├┤ ├
┌──┴──┐└─────┘ │ ││ │
q_11: |0>┤ ccx ├──────────────┤ ├┤ ├
└─────┘ │ ││ │
q_12: |0>─────────────────────┤8 ├┤8 ├
└──────────┘└──────────┘
Examples:
from QuICT.core import Circuit
from QuICT.algorithm.arithmetic import MuThMultiplier
circuit = Circuit(13)
MuThMultiplier(3) | circuit
Implementation Details(Asymptotic)
| Parameter | Info |
|---|---|
| Input Size | \(n\) |
| num. ancilla | \(1\) |
| Gate set | \(CCX, CX\) |
| Width | \(4n+1\) |
| Depth | \(5n^2-5n+1\) |
| Size | \(7n^2-10n+4\) |
| CX count | \(4n^2-10n+6\) |
| CCX count | \(3n^2-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) –Register size for the first input register.
-
qreg_size_b(int | None, default:None) –Register size for the second input register, will be the same as the first input register if not given.
-
name(str, default:None) –Name of the multiplier gate.
Raises:
GateParametersAssignedError: If the qreg_size or qreg_size_b is smaller than 2.