
    z	i                    n    S r SSKJr  SSKrSSKJr  SSKrSSKJr  SSK	J
r
Jr  SSKJr   " S S	\5      rg)
zTwo-qubit XX-rotation gate.    )annotationsN)Optional)Gate)ParameterValueTypeParameterExpression)StandardGatec                     ^  \ rS rSrSr\R                  rSSU 4S jjjrS r	    S       SU 4S jjjr
SSS jjrSS jrSSS jjrS	 rS
rU =r$ )RXXGate   u  A parametric 2-qubit :math:`X \otimes X` interaction (rotation about XX).

This gate is symmetric, and is maximally entangling at :math:`\theta = \pi/2`.

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

Circuit symbol:

.. code-block:: text

         ┌─────────┐
    q_0: ┤1        ├
         │  Rxx(ϴ) │
    q_1: ┤0        ├
         └─────────┘

Matrix representation:

.. math::

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

    R_{XX}(\theta) = \exp\left(-i \rotationangle X{\otimes}X\right) =
        \begin{pmatrix}
            \cos\left(\rotationangle\right) & 0 & 0 & -i\sin\left(\rotationangle\right) \\
            0 & \cos\left(\rotationangle\right) & -i\sin\left(\rotationangle\right) & 0 \\
            0 & -i\sin\left(\rotationangle\right) & \cos\left(\rotationangle\right) & 0 \\
            -i\sin\left(\rotationangle\right) & 0 & 0 & \cos\left(\rotationangle\right)
        \end{pmatrix}

Examples:

.. math::

    R_{XX}(\theta = 0) = I

.. math::

    R_{XX}(\theta = \pi) = -i X \otimes X

.. math::

    R_{XX}\left(\theta = \frac{\pi}{2}\right) = \frac{1}{\sqrt{2}}
                            \begin{pmatrix}
                                1  & 0  & 0  & -i \\
                                0  & 1  & -i & 0 \\
                                0  & -i & 1  & 0 \\
                                -i & 0  & 0  & 1
                            \end{pmatrix}
c                (   > [         TU ]  SSU/US9  g)zQ
Args:
    theta: The rotation angle.
    label: An optional label for the gate.
rxx   )labelN)super__init__)selfthetar   	__class__s      c/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/circuit/library/standard_gates/rxx.pyr   RXXGate.__init__P   s     	E7%8    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   RXX_get_definitionparamsr   
definition)r   r   s     r   _defineRXXGate._defineX   sC     	2 );;,,T[[9TXT]T] < 
r   c                f   > Uc  [        S U R                   5       5      n[        TU ]  UUUUS9nU$ )aC  Return a (multi-)controlled-RXX gate.

Args:
    num_ctrl_qubits: number of control qubits.
    label: An optional label for the gate [Default: ``None``]
    ctrl_state: control state expressed as integer,
        string (e.g.``'110'``), or ``None``. If ``None``, use all 1s.
    annotated: indicates whether the controlled gate should be implemented
        as an annotated gate. If ``None``, this is set to ``True`` if
        the gate contains free parameters, in which case it cannot
        yet be synthesized.

Returns:
    ControlledGate: controlled version of this gate.
c              3  B   #    U  H  n[        U[        5      v   M     g 7fN)
isinstancer   ).0ps     r   	<genexpr>"RXXGate.control.<locals>.<genexpr>~   s     T1Jq*=>>s   )num_ctrl_qubitsr   
ctrl_state	annotated)anyr    r   control)r   r,   r   r-   r.   gater   s         r   r0   RXXGate.controlg   sE    , TTTIw+!	  
 r   c                4    [        U R                  S   * 5      $ )a  Return inverse RXX gate (i.e. with the negative rotation angle).

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

Returns:
    RXXGate: inverse gate.
r   )r
   r    )r   r.   s     r   inverseRXXGate.inverse   s     A''r   c           	        USL a  [        S5      e[        U R                  S   5      S-  n[        R                  " U5      nS[        R
                  " U5      -  n[        R                  " USSU* /SXE* S/SU* US/U* SSU//US9$ )z&Return a Numpy.array for the RXX gate.Fz9unable to avoid copy while creating an array as requestedr   r   y              ?)dtype)
ValueErrorfloatr    mathcossinnumpyarray)r   r7   copytheta2r;   isins         r   	__array__RXXGate.__array__   s    5=XYYt{{1~&*hhvDHHV$${{1a$!S%!3a$Q5G4%QRTUWZI[\
 	
r   c                8    U R                   u  n[        X-  5      $ r&   )r    r
   )r   exponentr.   r   s       r   powerRXXGate.power   s    ;;x'((r   c                P    [        U[        5      (       a  U R                  U5      $ g)NF)r'   r
   _compare_parameters)r   others     r   __eq__RXXGate.__eq__   s#    eW%%++E22r   )r!   r&   )r   r   r   zOptional[str])   NNN)r,   intr   z
str | Noner-   zstr | int | Noner.   zbool | None)F)r.   bool)NN)rE   r9   r.   rO   )__name__
__module____qualname____firstlineno____doc__r   r   _standard_gater   r"   r0   r4   rB   rF   rK   __static_attributes____classcell__)r   s   @r   r
   r
      s}    2h "%%N9 9
"  ! '+!%  %	
  B(

) r   r
   )rT   
__future__r   r:   typingr   r=   qiskit.circuit.gater   "qiskit.circuit.parameterexpressionr   r   qiskit._accelerate.circuitr   r
    r   r   <module>r^      s-    " "    $ V 3Pd Pr   