
    z	i                     j    S r SSK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%Rotation around an axis in x-y plane.    N)exp)Optional)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S\S\4S jjrS rSrU =r$ )RGate   u  Rotation :math:`\theta` around the :math:`\cos(\phi)x + \sin(\phi)y` axis.

Can be applied to a :class:`~qiskit.circuit.QuantumCircuit`
with the :meth:`~qiskit.circuit.QuantumCircuit.r` method.

Circuit symbol:

.. code-block:: text

           ┌────────┐
    q_0:   ┤ R(θ,ϕ) ├ 
           └────────┘


Matrix representation:

.. math::

    \newcommand{\rotationangle}{\frac{\theta}{2}}

    R(\theta, \phi) = e^{-i \rotationangle \left(\cos{\phi} x + \sin{\phi} y\right)} =
        \begin{pmatrix}
            \cos\left(\rotationangle\right) & -i e^{-i \phi} \sin\left(\rotationangle\right) \\
            -i e^{i \phi} \sin\left(\rotationangle\right) & \cos\left(\rotationangle\right)
        \end{pmatrix}
thetaphilabelc                 (   > [         TU ]  SSX/US9  g)z
Args:
    theta: The rotation angle :math:`\theta`.
    phi: The angle specifying the rotation axis, given by :math:`\cos(\phi) x + \sin(\phi)y`.
    label: An optional label for the gate.
r   )r   N)super__init__)selfr   r   r   	__class__s       a/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/circuit/library/standard_gates/r.pyr   RGate.__init__6   s     	a%U;    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   R_get_definitionparamsr   
definition)r   r   s     r   _defineRGate._defineD   sA     	2 );;NN**4;;7tRVR[R[ < 
r   	annotatedc                 P    [        U R                  S   * U R                  S   5      $ )u  Invert this gate as: :math:`R(θ, φ)^{\dagger} = R(-θ, φ)`

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:`.RGate` with an inverted parameter value.

Returns:
    RGate: inverse gate.
r   r   )r	   r    )r   r$   s     r   inverseRGate.inverseQ   s#     dkk!n_dkk!n55r   c                 j   USL a  [        S5      e[        U R                  S   5      [        U R                  S   5      pC[        R                  " US-  5      n[        R
                  " US-  5      n[        SU-  5      n[        SU-  5      n[        R                  " USU-  U-  /SU-  U-  U//US9$ )	z$Return a numpy.array for the R gate.Fz9unable to avoid copy while creating an array as requestedr   r      y             y              ?)dtype)	
ValueErrorfloatr    mathcossinr   numpyarray)	r   r*   copyr   r   r.   r/   exp_mexp_ps	            r   	__array__RGate.__array___   s    5=XYY4;;q>*E$++a.,Ashhuqy!hhuqy!C#IBH{{S#+"34sU{S7H#6NOW\]]r   exponentc                 :    U R                   u  p4[        X-  U5      $ N)r    r	   )r   r7   r$   r   r   s        r   powerRGate.powerj   s    [[
X%s++r   c                 P    [        U[        5      (       a  U R                  U5      $ g)NF)
isinstancer	   _compare_parameters)r   others     r   __eq__RGate.__eq__n   s#    eU##++E22r   )r!   r9   )F)NN)__name__
__module____qualname____firstlineno____doc__r   r   _standard_gater   r   strr   r"   boolr&   r5   r,   r:   r@   __static_attributes____classcell__)r   s   @r   r	   r	      sv    6 "^^N  $	<!<  < }	< <
6 6	^,e , , r   r	   )rF   r-   cmathr   typingr   r0   qiskit.circuit.gater   "qiskit.circuit.parameterexpressionr   qiskit._accelerate.circuitr   r	    r   r   <module>rR      s-    ,     $ A 3YD Yr   