From 3994c45f84af38cabdfa15801d4648c50ce0b14b Mon Sep 17 00:00:00 2001 From: Alexander Ivrii Date: Wed, 13 Nov 2024 12:01:07 +0200 Subject: [PATCH] Adding new arithmetic gates to toctree (#13418) * fixing docstrings of new adder gates and adding these gates to toctree * move random_bitwise_xor to table * adding qaoa to toctree * adding missing parenthesis to docstring * addressing Shelly's comments --------- Co-authored-by: Julien Gacon (cherry picked from commit 3a5257d89704bb617501733bc67c22f7c1eb7a90) --- qiskit/circuit/library/__init__.py | 47 +++++++++++++++---- .../library/arithmetic/adders/adder.py | 10 ++-- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/qiskit/circuit/library/__init__.py b/qiskit/circuit/library/__init__.py index 71628640400..283f5b287a5 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 @@ -221,10 +221,10 @@ OrGate XOR BitwiseXorGate + random_bitwise_xor InnerProduct InnerProductGate -.. autofunction:: random_bitwise_xor Basis Change Circuits ===================== @@ -280,6 +280,9 @@ CDKMRippleCarryAdder VBERippleCarryAdder WeightedAdder + ModularAdderGate + HalfAdderGate + FullAdderGate Multipliers ----------- @@ -290,6 +293,7 @@ HRSCumulativeMultiplier RGQFTMultiplier + MultiplierGate Comparators ----------- @@ -321,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 @@ -362,6 +377,7 @@ real_amplitudes pauli_two_design excitation_preserving + qaoa_ansatz hamiltonian_variational_ansatz evolved_operator_ansatz @@ -386,7 +402,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:: @@ -407,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 diff --git a/qiskit/circuit/library/arithmetic/adders/adder.py b/qiskit/circuit/library/arithmetic/adders/adder.py index 9330f8a8ee8..7fa3411d043 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,12 +166,12 @@ 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:: - |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`)