
    z	iG                     r    S r SSKJrJr  SSKJr  SSKJr  SSKrSSK	J
r
  SSKJr  SSKJr   " S	 S
\
5      rg)zOne-pulse single-qubit gate.    )sqrtpi)exp)OptionalN)Gate)ParameterValueType)StandardGatec                      ^  \ rS rSrSr\R                  r SS\S\S\	\
   4U 4S jjjrS rSS\4S	 jjrSS
 jrS rSrU =r$ )U2Gate   u  Single-qubit rotation about the X+Z axis.

Implemented using one X90 pulse on IBM Quantum systems:

.. warning::

   This gate is deprecated. Instead, the following replacements should be used

   .. math::

       U2(\phi, \lambda) = U\left(\frac{\pi}{2}, \phi, \lambda\right)

   .. code-block:: python

      circuit = QuantumCircuit(1)
      circuit.u(pi/2, phi, lambda)

Circuit symbol:

.. code-block:: text

         ┌─────────┐
    q_0: ┤ U2(φ,λ) ├
         └─────────┘

Matrix representation:

.. math::

    U2(\phi, \lambda) = \frac{1}{\sqrt{2}}
        \begin{pmatrix}
            1          & -e^{i\lambda} \\
            e^{i\phi} & e^{i(\phi+\lambda)}
        \end{pmatrix}

Examples:

.. math::

    U2(\phi,\lambda) = e^{i \frac{\phi + \lambda}{2}}RZ(\phi)
    RY\left(\frac{\pi}{2}\right) RZ(\lambda)
    = e^{- i\frac{\pi}{4}} P\left(\frac{\pi}{2} + \phi\right)
    \sqrt{X} P\left(\lambda- \frac{\pi}{2}\right)

.. math::

    U2(0, \pi) = H

.. math::

    U2(0, 0) = RY(\pi/2)

.. math::

    U2(-\pi/2, \pi/2) = RX(\pi/2)

.. seealso::

    :class:`~qiskit.circuit.library.standard_gates.U3Gate`:
    U3 is a generalization of U2 that covers all single-qubit rotations,
    using two X90 pulses.
philamlabelc                 (   > [         TU ]  SSX/US9  g)z
Args:
    phi: The rotation angle :math:`\phi`.
    lam: The rotation angle :math:`\lambda`.
    label: An optional label for the gate.
u2   )r   N)super__init__)selfr   r   r   	__class__s       b/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/circuit/library/standard_gates/u2.pyr   U2Gate.__init__Y   s     	q3*E:    c                     SSK Jn  UR                  [        R                  R                  U R                  5      SU R                  S9U l        g)zDefault definitionr   )QuantumCircuitT)legacy_qubitsnameN)	qiskit.circuitr   _from_circuit_datar	   U2_get_definitionparamsr   
definition)r   r   s     r   _defineU2Gate._defineg   sA     	2 );;OO++DKK8SWS\S\ < 
r   	annotatedc                 n    [        U R                  S   * [        -
  U R                  S   * [        -   5      $ )a  Return inverted U2 gate.

:math:`U2(\phi, \lambda)^{\dagger} =U2(-\lambda-\pi, -\phi+\pi))`

Args:
    annotated: when set to ``True``, this is typically used to return an
        :class:`.AnnotatedOperation` with an inverse modifier set instead of a concrete
        :class:`.Gate`. However, for this class this argument is ignored as the inverse
        of this gate is always a :class:`.U2Gate` with inverse parameter values.

Returns:
    U2Gate: inverse gate.
r   r   )r   r"   r   )r   r&   s     r   inverseU2Gate.inverset   s/     t{{1~o*T[[^Ob,@AAr   c           	      4   USL a  [        S5      eS[        S5      -  nU R                  u  pE[        U5      [        U5      pT[        R
                  " U[        SU-  5      * U-  /[        SU-  5      U-  [        SXE-   -  5      U-  //U=(       d    [        S9$ )z%Return a Numpy.array for the U2 gate.Fz9unable to avoid copy while creating an array as requestedr      y              ?)dtype)
ValueErrorr   r"   floatnumpyarrayr   complex)r   r,   copyisqrt2r   r   s         r   	__array__U2Gate.__array__   s    5=XYYT!W;;:uSzS{{#b3h-&01R#X'R39-=)>)GH "7
 	
r   c                 R    [        U[        5      =(       a    U R                  U5      $ N)
isinstancer   _compare_parameters)r   others     r   __eq__U2Gate.__eq__   s    %(LT-E-Ee-LLr   )r#   r7   )F)NN)__name__
__module____qualname____firstlineno____doc__r	   r    _standard_gater   r   strr   r$   boolr(   r4   r;   __static_attributes____classcell__)r   s   @r   r   r      sg    =~ "__N  $	;;  ; }	; ;
B B 
M Mr   r   )rA   mathr   r   cmathr   typingr   r/   qiskit.circuit.gater   "qiskit.circuit.parameterexpressionr   qiskit._accelerate.circuitr	   r    r   r   <module>rN      s/    #     $ A 3}MT }Mr   