RGQFTMultiplier
class qiskit.circuit.library.RGQFTMultiplier(num_state_qubits, num_result_qubits=None, name='RGQFTMultiplier')
Bases: Multiplier
A QFT multiplication circuit to store product of two input registers out-of-place.
Multiplication in this circuit is implemented using the procedure of Fig. 3 in [1], where weighted sum rotations are implemented as given in Fig. 5 in [1]. QFT is used on the output register and is followed by rotations controlled by input registers. The rotations transform the state into the product of two input registers in QFT base, which is reverted from QFT base using inverse QFT. As an example, a circuit that performs a modular QFT multiplication on two 2-qubit sized input registers with an output register of 2 qubits, is as follows:
a_0: ────────────────────────────────────────■───────■──────■──────■────────────────
│ │ │ │
a_1: ─────────■───────■───────■───────■──────┼───────┼──────┼──────┼────────────────
│ │ │ │ │ │ │ │
b_0: ─────────┼───────┼───────■───────■──────┼───────┼──────■──────■────────────────
│ │ │ │ │ │ │ │
b_1: ─────────■───────■───────┼───────┼──────■───────■──────┼──────┼────────────────
┌──────┐ │P(4π) │ │P(2π) │ │P(2π) │ │P(π) │ ┌───────┐
out_0: ┤0 ├─■───────┼───────■───────┼──────■───────┼──────■──────┼───────┤0 ├
│ qft │ │P(2π) │P(π) │P(π) │P(π/2) │ iqft │
out_1: ┤1 ├─────────■───────────────■──────────────■─────────────■───────┤1 ├
└──────┘ └───────┘
The MultiplierGate
objects represents a multiplication, like this circuit class, but allows 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 Multiplier=["qft_r17"]
.
References:
[1] Ruiz-Perez et al., Quantum arithmetic with the Quantum Fourier Transform, 2017. arXiv:1411.5949
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.
- num_result_qubits (int | None) – The number of result qubits to limit the output to. If number of result qubits is , multiplication modulo is performed to limit the output to the specified number of qubits. Default value is
2 * num_state_qubits
to represent any possible result from the multiplication of the two inputs. - name (str) – The name of the circuit object.
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