Skip to content

Commit

Permalink
Merge branch 'main' into dag-concatenate
Browse files Browse the repository at this point in the history
  • Loading branch information
raynelfss authored Oct 18, 2024
2 parents ffb1d28 + 68a1eca commit 3d776fa
Show file tree
Hide file tree
Showing 165 changed files with 1,089 additions and 942 deletions.
4 changes: 2 additions & 2 deletions qiskit/circuit/library/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
print(gate.power(1/2).to_matrix()) # √X gate
print(gate.control(1).to_matrix()) # CX (controlled X) gate
.. parsed-literal::
.. code-block:: text
[[0.+0.j 1.+0.j]
[1.+0.j 0.+0.j]]
Expand Down Expand Up @@ -160,7 +160,7 @@
diagonal = Diagonal([1, 1, 1, 1])
print(diagonal.num_qubits)
.. parsed-literal::
.. code-block:: text
1
2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CDKMRippleCarryAdder(Adder):
As an example, a ripple-carry adder circuit that performs addition on two 3-qubit sized
registers with a carry-in bit (``kind="full"``) is as follows:
.. parsed-literal::
.. code-block:: text
┌──────┐ ┌──────┐
cin_0: ┤2 ├─────────────────────────────────────┤2 ├
Expand Down Expand Up @@ -54,7 +54,7 @@ class CDKMRippleCarryAdder(Adder):
The circuit diagram for the fixed-point adder (``kind="fixed"``) on 3-qubit sized inputs is
.. parsed-literal::
.. code-block:: text
┌──────┐┌──────┐ ┌──────┐┌──────┐
a_0: ┤0 ├┤2 ├────────────────┤2 ├┤0 ├
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DraperQFTAdder(Adder):
As an example, a non-fixed_point QFT adder circuit that performs addition on two 2-qubit sized
registers is as follows:
.. parsed-literal::
.. code-block:: text
a_0: ─────────■──────■────────────────────────■────────────────
│ │ │
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class VBERippleCarryAdder(Adder):
As an example, a classical adder circuit that performs full addition (i.e. including
a carry-in bit) on two 2-qubit sized registers is as follows:
.. parsed-literal::
.. code-block:: text
┌────────┐ ┌───────────┐┌──────┐
cin_0: ┤0 ├───────────────────────┤0 ├┤0 ├
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class LinearPauliRotations(FunctionalPauliRotations):
For a register of state qubits :math:`|x\rangle`, a target qubit :math:`|0\rangle` and the
basis ``'Y'`` this circuit acts as:
.. parsed-literal::
.. code-block:: text
q_0: ─────────────────────────■───────── ... ──────────────────────
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class HRSCumulativeMultiplier(Multiplier):
the default adder is as follows (where ``Adder`` denotes the
``CDKMRippleCarryAdder``):
.. parsed-literal::
.. code-block:: text
a_0: ────■─────────────────────────
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RGQFTMultiplier(Multiplier):
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:
.. parsed-literal::
.. code-block:: text
a_0: ────────────────────────────────────────■───────■──────■──────■────────────────
│ │ │ │
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/arithmetic/weighted_adder.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class WeightedAdder(BlueprintCircuit):
For an example where the state of 4 qubits is added into a sum register, the circuit can
be schematically drawn as
.. parsed-literal::
.. code-block:: text
┌────────┐
state_0: ┤0 ├ | state_0 * weights[0]
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/boolean_logic/inner_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class InnerProduct(QuantumCircuit):
where the inner product of the top and bottom registers is 1. Otherwise it keeps
the input intact.
.. parsed-literal::
.. code-block:: text
q0_0: ─■──────────
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/data_preparation/_z_feature_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ZFeatureMap(PauliFeatureMap):
On 3 qubits and with 2 repetitions the circuit is represented by:
.. parsed-literal::
.. code-block:: text
┌───┐┌─────────────┐┌───┐┌─────────────┐
┤ H ├┤ P(2.0*x[0]) ├┤ H ├┤ P(2.0*x[0]) ├
Expand Down
11 changes: 6 additions & 5 deletions qiskit/circuit/library/data_preparation/_zz_feature_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ZZFeatureMap(PauliFeatureMap):
For 3 qubits and 1 repetition and linear entanglement the circuit is represented by:
.. parsed-literal::
.. code-block:: text
┌───┐┌────────────────┐
┤ H ├┤ P(2.0*φ(x[0])) ├──■───────────────────────────■───────────────────────────────────
Expand All @@ -44,7 +44,8 @@ class ZZFeatureMap(PauliFeatureMap):
prep = ZZFeatureMap(2, reps=1)
print(prep.decompose())
.. parsed-literal::
.. code-block:: text
┌───┐┌─────────────┐
q_0: ┤ H ├┤ P(2.0*x[0]) ├──■──────────────────────────────────────■──
├───┤├─────────────┤┌─┴─┐┌────────────────────────────────┐┌─┴─┐
Expand All @@ -57,15 +58,15 @@ class ZZFeatureMap(PauliFeatureMap):
classifier = ZZFeatureMap(3).compose(EfficientSU2(3))
classifier.num_parameters
.. parsed-literal::
.. code-block:: text
27
.. code-block::
classifier.parameters # 'x' for the data preparation, 'θ' for the SU2 parameters
.. parsed-literal::
.. code-block:: text
ParameterView([
ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
Expand All @@ -88,7 +89,7 @@ class ZZFeatureMap(PauliFeatureMap):
classifier.count_ops()
.. parsed-literal::
.. code-block:: text
OrderedDict([('ZZFeatureMap', 1), ('EfficientSU2', 1)])
Expand Down
8 changes: 4 additions & 4 deletions qiskit/circuit/library/data_preparation/pauli_feature_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def pauli_feature_map(
which will produce blocks of the form
.. parsed-literal::
.. code-block:: text
┌───┐┌─────────────┐┌──────────┐ ┌───────────┐
┤ H ├┤ P(2.0*x[0]) ├┤ RX(pi/2) ├──■──────────────────────────────────────■──┤ RX(-pi/2) ├
Expand Down Expand Up @@ -183,7 +183,7 @@ def z_feature_map(
On 3 qubits and with 2 repetitions the circuit is represented by:
.. parsed-literal::
.. code-block:: text
┌───┐┌─────────────┐┌───┐┌─────────────┐
┤ H ├┤ P(2.0*x[0]) ├┤ H ├┤ P(2.0*x[0]) ├
Expand Down Expand Up @@ -262,7 +262,7 @@ def zz_feature_map(
For 3 qubits and 1 repetition and linear entanglement the circuit is represented by:
.. parsed-literal::
.. code-block:: text
┌───┐┌────────────────┐
┤ H ├┤ P(2.0*φ(x[0])) ├──■───────────────────────────■───────────────────────────────────
Expand Down Expand Up @@ -353,7 +353,7 @@ class PauliFeatureMap(NLocal):
which will produce blocks of the form
.. parsed-literal::
.. code-block:: text
┌───┐┌─────────────┐┌──────────┐ ┌───────────┐
┤ H ├┤ P(2.0*x[0]) ├┤ RX(pi/2) ├──■──────────────────────────────────────■──┤ RX(-pi/2) ├
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/generalized_gates/diagonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Diagonal(QuantumCircuit):
Circuit symbol:
.. parsed-literal::
.. code-block:: text
┌───────────┐
q_0: ┤0 ├
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/generalized_gates/gms.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class GMS(QuantumCircuit):
**Circuit symbol:**
.. parsed-literal::
.. code-block:: text
┌───────────┐
q_0: ┤0 ├
Expand Down
8 changes: 4 additions & 4 deletions qiskit/circuit/library/generalized_gates/gr.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class GR(QuantumCircuit):
**Circuit symbol:**
.. parsed-literal::
.. code-block:: text
┌──────────┐
q_0: ┤0 ├
Expand Down Expand Up @@ -75,7 +75,7 @@ class GRX(GR):
**Circuit symbol:**
.. parsed-literal::
.. code-block:: text
┌──────────┐
q_0: ┤0 ├
Expand Down Expand Up @@ -123,7 +123,7 @@ class GRY(GR):
**Circuit symbol:**
.. parsed-literal::
.. code-block:: text
┌──────────┐
q_0: ┤0 ├
Expand Down Expand Up @@ -171,7 +171,7 @@ class GRZ(QuantumCircuit):
**Circuit symbol:**
.. parsed-literal::
.. code-block:: text
┌──────────┐
q_0: ┤0 ├
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class LinearFunction(Gate):
**Example:** the circuit
.. parsed-literal::
.. code-block:: text
q_0: ──■──
┌─┴─┐
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/generalized_gates/mcmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MCMT(QuantumCircuit):
For example, the H gate controlled on 3 qubits and acting on 2 target qubit is represented as:
.. parsed-literal::
.. code-block:: text
───■────
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/generalized_gates/rv.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class RVGate(Gate):
**Circuit symbol:**
.. parsed-literal::
.. code-block:: text
┌─────────────────┐
q_0: ┤ RV(v_x,v_y,v_z) ├
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/grover_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class GroverOperator(QuantumCircuit):
Note that you can easily construct a phase oracle from a bitflip oracle by sandwiching the
controlled X gate on the result qubit by a X and H gate. For instance
.. parsed-literal::
.. code-block:: text
Bitflip oracle Phaseflip oracle
q_0: ──■── q_0: ────────────■────────────
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/n_local/efficient_su2.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class EfficientSU2(TwoLocal):
On 3 qubits and using the Pauli :math:`Y` and :math:`Z` su2_gates as single qubit gates, the
hardware efficient SU(2) circuit is represented by:
.. parsed-literal::
.. code-block:: text
┌──────────┐┌──────────┐ ░ ░ ░ ┌───────────┐┌───────────┐
┤ RY(θ[0]) ├┤ RZ(θ[3]) ├─░────────■───░─ ... ─░─┤ RY(θ[12]) ├┤ RZ(θ[15]) ├
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/n_local/n_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class NLocal(BlueprintCircuit):
For instance, a rotation block on 2 qubits and an entanglement block on 4 qubits using
``'linear'`` entanglement yields the following circuit.
.. parsed-literal::
.. code-block:: text
┌──────┐ ░ ┌──────┐ ░ ┌──────┐
┤0 ├─░─┤0 ├──────────────── ... ─░─┤0 ├
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/n_local/pauli_two_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PauliTwoDesign(TwoLocal):
For instance, the circuit could look like this (but note that choosing a different seed
yields different Pauli rotations).
.. parsed-literal::
.. code-block:: text
┌─────────┐┌──────────┐ ░ ┌──────────┐ ░ ┌──────────┐
q_0: ┤ RY(π/4) ├┤ RZ(θ[0]) ├─■─────░─┤ RY(θ[4]) ├─■─────░──┤ RZ(θ[8]) ├
Expand Down
3 changes: 2 additions & 1 deletion qiskit/circuit/library/n_local/real_amplitudes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class RealAmplitudes(TwoLocal):
For example a ``RealAmplitudes`` circuit with 2 repetitions on 3 qubits with ``'reverse_linear'``
entanglement is
.. parsed-literal::
.. code-block:: text
┌──────────┐ ░ ░ ┌──────────┐ ░ ░ ┌──────────┐
┤ Ry(θ[0]) ├─░────────■───░─┤ Ry(θ[3]) ├─░────────■───░─┤ Ry(θ[6]) ├
├──────────┤ ░ ┌─┴─┐ ░ ├──────────┤ ░ ┌─┴─┐ ░ ├──────────┤
Expand Down
3 changes: 2 additions & 1 deletion qiskit/circuit/library/standard_gates/dcx.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class DCXGate(SingletonGate):
Can be applied to a :class:`~qiskit.circuit.QuantumCircuit`
with the :meth:`~qiskit.circuit.QuantumCircuit.dcx` method.
.. parsed-literal::
.. code-block:: text
┌───┐
q_0: ──■──┤ X ├
┌─┴─┐└─┬─┘
Expand Down
4 changes: 2 additions & 2 deletions qiskit/circuit/library/standard_gates/ecr.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ECRGate(SingletonGate):
**Circuit Symbol:**
.. parsed-literal::
.. code-block:: text
┌─────────┐ ┌────────────┐┌────────┐┌─────────────┐
q_0: ┤0 ├ q_0: ┤0 ├┤ RX(pi) ├┤0 ├
Expand Down Expand Up @@ -66,7 +66,7 @@ class ECRGate(SingletonGate):
Instead, if we apply it on (q_1, q_0), the matrix will
be :math:`Z \otimes X`:
.. parsed-literal::
.. code-block:: text
┌─────────┐
q_0: ┤1 ├
Expand Down
7 changes: 4 additions & 3 deletions qiskit/circuit/library/standard_gates/h.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class HGate(SingletonGate):
**Circuit symbol:**
.. parsed-literal::
.. code-block:: text
┌───┐
q_0: ┤ H ├
Expand Down Expand Up @@ -142,7 +142,7 @@ class CHGate(SingletonControlledGate):
**Circuit symbol:**
.. parsed-literal::
.. code-block:: text
q_0: ──■──
┌─┴─┐
Expand Down Expand Up @@ -170,7 +170,8 @@ class CHGate(SingletonControlledGate):
which in our case would be q_1. Thus a textbook matrix for this
gate will be:
.. parsed-literal::
.. code-block:: text
┌───┐
q_0: ┤ H ├
└─┬─┘
Expand Down
3 changes: 2 additions & 1 deletion qiskit/circuit/library/standard_gates/i.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class IGate(SingletonGate):
**Circuit symbol:**
.. parsed-literal::
.. code-block:: text
┌───┐
q_0: ┤ I ├
└───┘
Expand Down
Loading

0 comments on commit 3d776fa

Please sign in to comment.