σ
    Σz	i<  γ                  σ   S r SSKJr  SSKrSSKJrJr  SSKJr  SSK	J
r
Jr  SSKJrJrJr  SSKJr  S	S
KJrJr  S	SKJr  \R,                  (       a  SSKr        S                   SS jjr " S S\5      rg)z!The EfficientSU2 2-local circuit.ι    )ΪannotationsN)ΪCallableΪIterable)Ϊpi)ΪQuantumCircuitΪGate)ΪRYGateΪRZGateΪCXGate)Ϊdeprecate_funcι   )Ϊn_localΪBlockEntanglement)ΪTwoLocalΪEfficientSU2c	                σP    Uc  SS/nU S:  a  S/O/ n	[        U UU	UUUUSUUU5      $ )uS  The hardware-efficient :math:`SU(2)` 2-local circuit.

The ``efficient_su2`` circuit consists of layers of single qubit operations spanned by
:math:`SU(2)` and CX entanglements. This is a heuristic pattern that can be used to prepare trial
wave functions for variational quantum algorithms or classification circuit for machine learning.

:math:`SU(2)` is the special unitary group of degree 2, its elements are :math:`2 \times 2`
unitary matrices with determinant 1, such as the Pauli rotation gates.

On 3 qubits and using the Pauli :math:`Y` and :math:`Z` rotations as single qubit gates, the
this circuit is represented by:

.. parsed-literal::

    ββββββββββββββββββββββββ β            β       β ββββββββββββββββββββββββββ
    β€ RY(ΞΈ[0]) ββ€ RZ(ΞΈ[3]) ββββββββββββ βββββ ... ββββ€ RY(ΞΈ[12]) ββ€ RZ(ΞΈ[15]) β
    ββββββββββββ€ββββββββββββ€ β      βββ΄ββ β       β βββββββββββββ€βββββββββββββ€
    β€ RY(ΞΈ[1]) ββ€ RZ(ΞΈ[4]) βββββββ βββ€ X ββββ ... ββββ€ RY(ΞΈ[13]) ββ€ RZ(ΞΈ[16]) β
    ββββββββββββ€ββββββββββββ€ β βββ΄βββββββ β       β βββββββββββββ€βββββββββββββ€
    β€ RY(ΞΈ[2]) ββ€ RZ(ΞΈ[5]) βββββ€ X βββββββββ ... ββββ€ RY(ΞΈ[14]) ββ€ RZ(ΞΈ[17]) β
    ββββββββββββββββββββββββ β βββββ      β       β ββββββββββββββββββββββββββ

Examples:

Per default, the ``"reverse_linear"`` entanglement is used, which, in the case of
CX gates, is equivalent to an all-to-all entanglement:

.. plot::
    :alt: Circuit diagram output by the previous code.
    :include-source:
    :context:

    from qiskit.circuit.library import efficient_su2

    circuit = efficient_su2(3, reps=1)
    circuit.draw("mpl")

To specify which SU(2) gates should be used in the rotation layer, we can set the
``su2_gates`` argument. In addition, we can change the entanglement structure.
For example:

.. plot::
    :alt: Circuit diagram output by the previous code.
    :include-source:
    :context: close-figs

    circuit = efficient_su2(4, su2_gates=["rx", "y"], entanglement="circular", reps=1)
    circuit.draw("mpl")

Args:
    num_qubits: The number of qubits.
    su2_gates: The :math:`SU(2)` single qubit gates to apply in single qubit gate layers.
        If only one gate is provided, the same gate is applied to each qubit.
        If a list of gates is provided, all gates are applied to each qubit in the provided
        order.
    reps: Specifies how often the structure of a rotation layer followed by an entanglement
        layer is repeated.
    entanglement: The indices specifying on which qubits the input blocks act.
        See :func:`.n_local` for detailed information.
    skip_final_rotation_layer: Whether a final rotation layer is added to the circuit.
    skip_unentangled_qubits: If ``True``, the rotation gates act only on qubits that
        are entangled. If ``False``, the rotation gates act on all qubits.
    parameter_prefix: The name of the free parameters.
    insert_barriers: If True, barriers are inserted in between each layer. If False,
        no barriers are inserted.
    name: The name of the circuit.

Returns:
    An efficient-SU(2) circuit.
ΪryΪrzr   ΪcxT)r   )
Ϊ
num_qubitsΪ	su2_gatesΪentanglementΪrepsΪskip_unentangled_qubitsΪskip_final_rotation_layerΪparameter_prefixΪinsert_barriersΪnameΪentanglement_blockss
             Ϊf/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/circuit/library/n_local/efficient_su2.pyΪefficient_su2r!      sT    πj ΡΨ4L	π %/°£N4&ΈΠδΨΨΨΨΨΨΨΨΨ!ΨΨσπ σ    c                  σ’   ^  \ rS rSrSr\" SSSS9           S
                       SU 4S jjj5       r\SS j5       rS	r	U =r
$ )r   ι   u  The hardware efficient SU(2) 2-local circuit.

The ``EfficientSU2`` circuit consists of layers of single qubit operations spanned by SU(2)
and :math:`CX` entanglements. This is a heuristic pattern that can be used to prepare trial wave
functions for variational quantum algorithms or classification circuit for machine learning.

SU(2) stands for special unitary group of degree 2, its elements are :math:`2 \times 2`
unitary matrices with determinant 1, such as the Pauli rotation gates.

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:

.. code-block:: text

    ββββββββββββββββββββββββ β            β       β ββββββββββββββββββββββββββ
    β€ RY(ΞΈ[0]) ββ€ RZ(ΞΈ[3]) ββββββββββββ βββββ ... ββββ€ RY(ΞΈ[12]) ββ€ RZ(ΞΈ[15]) β
    ββββββββββββ€ββββββββββββ€ β      βββ΄ββ β       β βββββββββββββ€βββββββββββββ€
    β€ RY(ΞΈ[1]) ββ€ RZ(ΞΈ[4]) βββββββ βββ€ X ββββ ... ββββ€ RY(ΞΈ[13]) ββ€ RZ(ΞΈ[16]) β
    ββββββββββββ€ββββββββββββ€ β βββ΄βββββββ β       β βββββββββββββ€βββββββββββββ€
    β€ RY(ΞΈ[2]) ββ€ RZ(ΞΈ[5]) βββββ€ X βββββββββ ... ββββ€ RY(ΞΈ[14]) ββ€ RZ(ΞΈ[17]) β
    ββββββββββββββββββββββββ β βββββ      β       β ββββββββββββββββββββββββββ

See :class:`~qiskit.circuit.library.RealAmplitudes` for more detail on the possible arguments
and options such as skipping unentanglement qubits, which apply here too.

Examples:

    >>> circuit = EfficientSU2(3, reps=1)
    >>> print(circuit.decompose())
         ββββββββββββββββββββββββ          ββββββββββββββββββββββββ
    q_0: β€ RY(ΞΈ[0]) ββ€ RZ(ΞΈ[3]) ββββ βββββ βββ€ RY(ΞΈ[6]) ββ€ RZ(ΞΈ[9]) ββββββββββββββ
         ββββββββββββ€ββββββββββββ€βββ΄ββ  β  ββββββββββββββββββββββββ€βββββββββββββ
    q_1: β€ RY(ΞΈ[1]) ββ€ RZ(ΞΈ[4]) ββ€ X ββββΌββββββββ βββββββ€ RY(ΞΈ[7]) ββ€ RZ(ΞΈ[10]) β
         ββββββββββββ€ββββββββββββ€ββββββββ΄ββ   βββ΄ββ    ββββββββββββ€βββββββββββββ€
    q_2: β€ RY(ΞΈ[2]) ββ€ RZ(ΞΈ[5]) βββββββ€ X βββββ€ X ββββββ€ RY(ΞΈ[8]) ββ€ RZ(ΞΈ[11]) β
         ββββββββββββββββββββββββ     βββββ   βββββ    βββββββββββββββββββββββββ

    >>> ansatz = EfficientSU2(4, su2_gates=['rx', 'y'], entanglement='circular', reps=1,
    ... flatten=True)
    >>> qc = QuantumCircuit(4)  # create a circuit and append the RY variational form
    >>> qc.compose(ansatz, inplace=True)
    >>> qc.draw()
         ββββββββββββββββββββββ     ββββββββββββ   βββββ
    q_0: β€ RX(ΞΈ[0]) ββ€ Y ββ€ X ββββ βββ€ RX(ΞΈ[4]) βββββ€ Y ββββββββββββββββββββββ
         ββββββββββββ€βββββ€βββ¬βββββ΄ββββββββββββββββββ΄ββββ΄ββββ   βββββ
    q_1: β€ RX(ΞΈ[1]) ββ€ Y ββββΌβββ€ X βββββββ βββββββ€ RX(ΞΈ[5]) βββββ€ Y ββββββββββ
         ββββββββββββ€βββββ€  β  βββββ   βββ΄ββ    ββββββββββββββββ΄ββββ΄βββββββββ
    q_2: β€ RX(ΞΈ[2]) ββ€ Y ββββΌβββββββββββ€ X βββββββββββ βββββββ€ RX(ΞΈ[6]) ββ€ Y β
         ββββββββββββ€βββββ€  β          βββββ       βββ΄ββ    ββββββββββββ€βββββ€
    q_3: β€ RX(ΞΈ[3]) ββ€ Y ββββ βββββββββββββββββββββββ€ X ββββββ€ RX(ΞΈ[7]) ββ€ Y β
         βββββββββββββββββ                         βββββ    βββββββββββββββββ

.. seealso::

    The :func:`.efficient_su2` function constructs a functionally equivalent circuit, but faster.

z2.1z>Use the function qiskit.circuit.library.efficient_su2 instead.zin Qiskit 3.0)ΪsinceΪadditional_msgΪremoval_timelinec                σ\   > Uc  [         [        /n[        TU ]  UU[        UUUUUUU	U
US9  g)aΩ  
Args:
    num_qubits: The number of qubits of the EfficientSU2 circuit.
    reps: Specifies how often the structure of a rotation layer followed by an entanglement
        layer is repeated.
    su2_gates: The SU(2) single qubit gates to apply in single qubit gate layers.
        If only one gate is provided, the same gate is applied to each qubit.
        If a list of gates is provided, all gates are applied to each qubit in the provided
        order.
    entanglement: Specifies the entanglement structure. Can be a string
        ('full', 'linear', 'reverse_linear', 'pairwise', 'circular', or 'sca'),
        a list of integer-pairs specifying the indices of qubits entangled with one another,
        or a callable returning such a list provided with the index of the entanglement layer.
        Defaults to 'reverse_linear' entanglement.
        Note that 'reverse_linear' entanglement provides the same unitary as 'full'
        with fewer entangling gates.
        See the Examples section of :class:`~qiskit.circuit.library.TwoLocal` for more
        detail.
    initial_state: A `QuantumCircuit` object to prepend to the circuit.
    skip_unentangled_qubits: If True, the single qubit gates are only applied to qubits
        that are entangled with another qubit. If False, the single qubit gates are applied
        to each qubit in the Ansatz. Defaults to False.
    skip_final_rotation_layer: If False, a rotation layer is added at the end of the
        ansatz. If True, no rotation layer is added.
    parameter_prefix: The parameterized gates require a parameter to be defined, for which
        we use :class:`~qiskit.circuit.ParameterVector`.
    insert_barriers: If True, barriers are inserted in between each layer. If False,
        no barriers are inserted.
    flatten: Set this to ``True`` to output a flat circuit instead of nesting it inside multiple
        layers of gate objects. By default currently the contents of
        the output circuit will be wrapped in nested objects for
        cleaner visualization. However, if you're using this circuit
        for anything besides visualization its **strongly** recommended
        to set this flag to ``True`` to avoid a large performance
        overhead for parameter binding.
N)r   Ϊrotation_blocksr   r   r   r   r   r   r   Ϊinitial_stater   Ϊflatten)r	   r
   ΪsuperΪ__init__r   )Ϊselfr   r   r   r   r   r   r   r   r*   r   r+   Ϊ	__class__s               r    r-   ΪEfficientSU2.__init__Δ   sL   ψ π| Ρά€Π(IάΡΨ!Ψ%ά &Ψ%ΨΨ$;Ψ&?Ψ-Ψ+Ψ'ΨΨπ 	ς 	
r"   c                σ8    U R                   [        * [        4/-  $ )zAReturn the parameter bounds.

Returns:
    The parameter bounds.
)Ϊnum_parametersr   )r.   s    r    Ϊparameter_boundsΪEfficientSU2.parameter_bounds  s    π Χ"Ρ"¬ s¬B i [Ρ0Π0r"   © )NNΪreverse_linearι   FFυ   ΞΈFNr   N)r   z
int | Noner   zstr | type | qiskit.circuit.Instruction | QuantumCircuit | list[str | type | qiskit.circuit.Instruction | QuantumCircuit] | Noner   z2str | list[list[int]] | Callable[[int], list[int]]r   Ϊintr   Ϊboolr   r:   r   Ϊstrr   r:   r*   zQuantumCircuit | Noner   r;   r+   zbool | NoneΪreturnΪNone)r<   zlist[tuple[float, float]])Ϊ__name__Ϊ
__module__Ϊ__qualname__Ϊ__firstlineno__Ϊ__doc__r   r-   Ϊpropertyr3   Ϊ__static_attributes__Ϊ__classcell__)r/   s   @r    r   r      sκ   ψ ρ8ρt ΨΨWΨ(ρπ "&π ΨK[ΨΨ(-Ψ*/Ψ $Ψ %Ψ/3Ψ"Ψ#π'H
ΰπH
ππ	H
π IπH
π πH
π "&πH
π $(πH
π πH
π  π!H
π" -π#H
π$ π%H
π& π'H
π( 
χ)H
σπ
H
πT σ1σ φ1r"   )Nr6   r7   FFr8   Fr   )r   r9   r   z(str | Gate | Iterable[str | Gate] | Noner   zrBlockEntanglement | Iterable[BlockEntanglement] | Callable[[int], BlockEntanglement | Iterable[BlockEntanglement]]r   r9   r   r:   r   r:   r   r;   r   r:   r   r;   r<   r   )rB   Ϊ
__future__r   ΪtypingΪcollections.abcr   r   Ϊnumpyr   Ϊqiskit.circuitr   r   Ϊ%qiskit.circuit.library.standard_gatesr	   r
   r   Ϊqiskit.utils.deprecationr   r   r   Ϊ	two_localr   ΪTYPE_CHECKINGΪqiskitr!   r   r5   r"   r    Ϊ<module>rP      sΠ   πρ (ε "Ϋ ί .ε η /ί HΡ Hέ 3ί /έ ΰ	ΧΧΫπ
 ;?π
 	ΨΨ$)Ψ&+Ψ Ψ!ΨπgΨπgΰ7πgπ	Kπ	gπ πgπ "πgπ  $πgπ πgπ πgπ πgπ υgτTQ18υ Q1r"   