From 66ae0085749b645c7db6645d03c6b7aae1390716 Mon Sep 17 00:00:00 2001 From: AlexanderIvrii Date: Sun, 10 Nov 2024 10:59:32 +0200 Subject: [PATCH 1/5] fixing docstrings of new adder gates and adding these gates to toctree --- qiskit/circuit/library/__init__.py | 8 ++++++-- qiskit/circuit/library/arithmetic/adders/adder.py | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/qiskit/circuit/library/__init__.py b/qiskit/circuit/library/__init__.py index 71628640400..eb9d7d6306b 100644 --- a/qiskit/circuit/library/__init__.py +++ b/qiskit/circuit/library/__init__.py @@ -36,7 +36,7 @@ circuit.append(gate, [0, 1, 4, 2, 3]) circuit.draw('mpl') -The library is organized in several sections. The function +The library is organized in several sections. The function :func:`.get_standard_gate_name_mapping` allows you to see the available standard gates and operations. .. autofunction:: get_standard_gate_name_mapping @@ -280,6 +280,9 @@ CDKMRippleCarryAdder VBERippleCarryAdder WeightedAdder + ModularAdderGate + HalfAdderGate + FullAdderGate Multipliers ----------- @@ -290,6 +293,7 @@ HRSCumulativeMultiplier RGQFTMultiplier + MultiplierGate Comparators ----------- @@ -386,7 +390,7 @@ Data encoding circuits ====================== -The following functions return a parameterized :class:`.QuantumCircuit` to use as data +The following functions return a parameterized :class:`.QuantumCircuit` to use as data encoding circuits in a series of variational quantum algorithms: .. autosummary:: diff --git a/qiskit/circuit/library/arithmetic/adders/adder.py b/qiskit/circuit/library/arithmetic/adders/adder.py index 9330f8a8ee8..34a9a0fa190 100644 --- a/qiskit/circuit/library/arithmetic/adders/adder.py +++ b/qiskit/circuit/library/arithmetic/adders/adder.py @@ -21,7 +21,7 @@ class Adder(QuantumCircuit): r"""Compute the sum of two equally sized qubit registers. - For two registers :math:`|a\rangle_n` and :math:|b\rangle_n` with :math:`n` qubits each, an + For two registers :math:`|a\rangle_n` and :math:`|b\rangle_n` with :math:`n` qubits each, an adder performs the following operation .. math:: @@ -74,7 +74,7 @@ def num_state_qubits(self) -> int: class HalfAdderGate(Gate): r"""Compute the sum of two equally-sized qubit registers, including a carry-out bit. - For two registers :math:`|a\rangle_n` and :math:|b\rangle_n` with :math:`n` qubits each, an + For two registers :math:`|a\rangle_n` and :math:`|b\rangle_n` with :math:`n` qubits each, an adder performs the following operation .. math:: @@ -120,7 +120,7 @@ def num_state_qubits(self) -> int: class ModularAdderGate(Gate): r"""Compute the sum modulo :math:`2^n` of two :math:`n`-sized qubit registers. - For two registers :math:`|a\rangle_n` and :math:|b\rangle_n` with :math:`n` qubits each, an + For two registers :math:`|a\rangle_n` and :math:`|b\rangle_n` with :math:`n` qubits each, an adder performs the following operation .. math:: @@ -166,7 +166,7 @@ def num_state_qubits(self) -> int: class FullAdderGate(Gate): r"""Compute the sum of two :math:`n`-sized qubit registers, including carry-in and -out bits. - For two registers :math:`|a\rangle_n` and :math:|b\rangle_n` with :math:`n` qubits each, an + For two registers :math:`|a\rangle_n` and :math:`|b\rangle_n` with :math:`n` qubits each, an adder performs the following operation .. math:: From c8ab663bd1fa542ad443d84e3c5370b05de5fec0 Mon Sep 17 00:00:00 2001 From: Julien Gacon Date: Mon, 11 Nov 2024 08:19:17 +0100 Subject: [PATCH 2/5] move random_bitwise_xor to table --- qiskit/circuit/library/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit/circuit/library/__init__.py b/qiskit/circuit/library/__init__.py index eb9d7d6306b..7ecad228918 100644 --- a/qiskit/circuit/library/__init__.py +++ b/qiskit/circuit/library/__init__.py @@ -221,10 +221,10 @@ OrGate XOR BitwiseXorGate + random_bitwise_xor InnerProduct InnerProductGate -.. autofunction:: random_bitwise_xor Basis Change Circuits ===================== From 9b3fdc9fdc4d0eaa81141998dac70ae206ef8393 Mon Sep 17 00:00:00 2001 From: AlexanderIvrii Date: Mon, 11 Nov 2024 10:39:22 +0200 Subject: [PATCH 3/5] adding qaoa to toctree --- qiskit/circuit/library/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/qiskit/circuit/library/__init__.py b/qiskit/circuit/library/__init__.py index 7ecad228918..e619b541b57 100644 --- a/qiskit/circuit/library/__init__.py +++ b/qiskit/circuit/library/__init__.py @@ -366,6 +366,7 @@ real_amplitudes pauli_two_design excitation_preserving + qaoa_ansatz hamiltonian_variational_ansatz evolved_operator_ansatz From 4ae8d4c8eddf72f02a33816e5aeb31b7d149cbfe Mon Sep 17 00:00:00 2001 From: AlexanderIvrii Date: Mon, 11 Nov 2024 11:43:59 +0200 Subject: [PATCH 4/5] adding missing parenthesis to docstring --- qiskit/circuit/library/arithmetic/adders/adder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit/circuit/library/arithmetic/adders/adder.py b/qiskit/circuit/library/arithmetic/adders/adder.py index 34a9a0fa190..7fa3411d043 100644 --- a/qiskit/circuit/library/arithmetic/adders/adder.py +++ b/qiskit/circuit/library/arithmetic/adders/adder.py @@ -171,7 +171,7 @@ class FullAdderGate(Gate): .. math:: - |c_{\text{in}\rangle_1 |a\rangle_n |b\rangle_n + |c_{\text{in}}\rangle_1 |a\rangle_n |b\rangle_n \mapsto |a\rangle_n |c_{\text{in}} + a + b \rangle_{n + 1}. The quantum register :math:`|a\rangle_n` (and analogously :math:`|b\rangle_n`) From a4b551cd56fa0435370b4d12ba4effd48b3ad0e3 Mon Sep 17 00:00:00 2001 From: Alexander Ivrii Date: Wed, 13 Nov 2024 09:47:37 +0200 Subject: [PATCH 5/5] addressing Shelly's comments --- qiskit/circuit/library/__init__.py | 36 ++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/qiskit/circuit/library/__init__.py b/qiskit/circuit/library/__init__.py index e619b541b57..283f5b287a5 100644 --- a/qiskit/circuit/library/__init__.py +++ b/qiskit/circuit/library/__init__.py @@ -325,29 +325,40 @@ Particular Quantum Circuits =========================== +The following gates and quantum circuits define specific +quantum circuits of interest: + .. autosummary:: :toctree: ../stubs/ :template: autosummary/class_no_inherited_members.rst FourierChecking - fourier_checking GraphState GraphStateGate HiddenLinearFunction - hidden_linear_function IQP - iqp - random_iqp QuantumVolume - quantum_volume PhaseEstimation - phase_estimation GroverOperator - grover_operator PhaseOracle PauliEvolutionGate HamiltonianGate UnitaryOverlap + +For circuits that have a well-defined structure it is preferrable +to use the following functions to construct them: + +.. autosummary:: + :toctree: ../stubs/ + :template: autosummary/class_no_inherited_members.rst + + fourier_checking + hidden_linear_function + iqp + random_iqp + quantum_volume + phase_estimation + grover_operator unitary_overlap @@ -412,6 +423,17 @@ PauliFeatureMap ZFeatureMap ZZFeatureMap + + +Data preparation circuits +========================= + +The following operations are used for state preparation: + +.. autosummary:: + :toctree: ../stubs/ + :template: autosummary/class_no_inherited_members.rst + StatePreparation Initialize