DraperQFTAdder
class qiskit.circuit.library.DraperQFTAdder(num_state_qubits, kind='fixed', name='DraperQFTAdder')
Bases: Adder
A circuit that uses QFT to perform in-place addition on two qubit registers.
For registers with qubits, the QFT adder can perform addition modulo (with kind="fixed"
) or ordinary addition by adding a carry qubits (with kind="half"
).
As an example, a non-fixed_point QFT adder circuit that performs addition on two 2-qubit sized registers is as follows:
a_0: ─────────■──────■────────────────────────■────────────────
│ │ │
a_1: ─────────┼──────┼────────■──────■────────┼────────────────
┌──────┐ │P(π) │ │ │ │ ┌───────┐
b_0: ┤0 ├─■──────┼────────┼──────┼────────┼───────┤0 ├
│ │ │P(π/2) │P(π) │ │ │ │
b_1: ┤1 qft ├────────■────────■──────┼────────┼───────┤1 iqft ├
│ │ │P(π/2) │P(π/4) │ │
cout_0: ┤2 ├────────────────────────■────────■───────┤2 ├
└──────┘ └───────┘
The following generic gate objects perform additions, like this circuit class, but allow the compiler to select the optimal decomposition based on the context. Specific implementations can be set via the HLSConfig
, e.g. this circuit can be chosen via Adder=["qft_d00"]
.
ModularAdderGate
: A generic inplace adder, modulo . This
is functionally equivalent to kind="fixed"
.
AdderGate
: A generic inplace adder. This
is functionally equivalent to kind="half"
.
References:
[1] T. G. Draper, Addition on a Quantum Computer, 2000. arXiv:quant-ph/0008033
[2] Ruiz-Perez et al., Quantum arithmetic with the Quantum Fourier Transform, 2017. arXiv:1411.5949
[3] Vedral et al., Quantum Networks for Elementary Arithmetic Operations, 1995. arXiv:quant-ph/9511018
Parameters
- num_state_qubits (int) – The number of qubits in either input register for state or . The two input registers must have the same number of qubits.
- kind (str) – The kind of adder, can be
'half'
for a half adder or'fixed'
for a fixed-sized adder. A half adder contains a carry-out to represent the most-significant bit, but the fixed-sized adder doesn’t and hence performs addition modulo2 ** num_state_qubits
. - name (str) – The name of the circuit object.
Raises
ValueError – If num_state_qubits
is lower than 1.
Attributes
name
Type: str
A human-readable name for the circuit.
Example
from qiskit import QuantumCircuit
qc = QuantumCircuit(2, 2, name="my_circuit")
print(qc.name)
my_circuit