QFTWiredAdder
QuICT.algorithm.arithmetic.adder.QFTWiredAdder ¶
QFTWiredAdder(qreg_size: int, addend: int, num_control: int = 0, in_fourier: bool = False, out_fourier: bool = False, name: str = None)
Bases: CompositeGate
A wired in-place adder in fourier basis. One of the addend is given classically and will be
written into the adder when constructing the gate. For an n-qubit binary encoded addends a
and a classically given integer X, this adder calculates the result and store it in place:
Applying this adder with X = 5 on a 4-qubit sized register looks like:
┌──────────┐┌──────────┐┌──────────┐
q_0: |0>┤0 ├┤ u1(5π/8) ├┤0 ├
│ │├──────────┤│ │
q_1: |0>┤1 ├┤ u1(5π/4) ├┤1 ├
│ cg_yQFT │├──────────┤│ cg_IQFT │
q_2: |0>┤2 ├┤ u1(5π/2) ├┤2 ├
│ │└┬────────┬┘│ │
q_3: |0>┤3 ├─┤ u1(5π) ├─┤3 ├
└──────────┘ └────────┘ └──────────┘
Examples:
from QuICT.core import Circuit
from QuICT.algorithm.arithmetic import RCFourierAdderWired
X = 5
circuit = Circuit(4)
RCFourierAdderWired(4, addend=X) | circuit
References
[1]: "High Performance Quantum Modular Multipliers" by Rich Rines, Isaac Chuang https://arxiv.org/abs/1801.01081
Parameters:
-
qreg_size(int) –Size of the quantum register waiting to be added. Needs to be greater than or equal to 2.
-
addend(int) –The integer that will be added to the qreg.
-
num_control(int, default:0) –Indicates the number of qubits for controlling the wired adder, up to 2 qubits. If not 0, the control bits will be on the highest bits.
-
in_fourier(bool, default:False) –If True, assuming the input register is already in qft basis.
-
out_fourier(bool, default:False) –If True, after the addition, the qreg will be left in qft basis.
-
name(str, default:None) –Name of the wired adder gate.
Raises:
GateParametersAssignedError: If qreg_size is smaller than 2.