
    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  SSKJr  \	" / S	Q/ S
Q/ SQ/ SQ/5       " S S\5      5       rg)ziSWAP gate.    )OptionalN)SingletonGatestdlib_singleton_key)with_gate_array)StandardGate   )XXPlusYYGate)r   r   r   r   )r   r                 ?r   )r   r
   r   r   )r   r   r   r   c                      ^  \ rS rSrSr\R                  rSS\\	   4U 4S jjjr
\" 5       rS rSS\S\4S jjrS	 rS
rU =r$ )	iSwapGate   u  iSWAP gate.

A 2-qubit XX+YY interaction.
This is a Clifford and symmetric gate. Its action is to swap two qubit
states and phase the :math:`|01\rangle` and :math:`|10\rangle`
amplitudes by i.

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

Circuit symbol:

.. code-block:: text

    q_0: ─⨂─
          │
    q_1: ─⨂─

Reference implementation:

.. code-block:: text

         ┌───┐┌───┐     ┌───┐
    q_0: ┤ S ├┤ H ├──■──┤ X ├─────
         ├───┤└───┘┌─┴─┐└─┬─┘┌───┐
    q_1: ┤ S ├─────┤ X ├──■──┤ H ├
         └───┘     └───┘     └───┘

Matrix representation:

.. math::

    iSWAP = R_{XX+YY}\left(-\frac{\pi}{2}\right)
      = \exp\left(i \frac{\pi}{4} \left(X{\otimes}X+Y{\otimes}Y\right)\right) =
        \begin{pmatrix}
            1 & 0 & 0 & 0 \\
            0 & 0 & i & 0 \\
            0 & i & 0 & 0 \\
            0 & 0 & 0 & 1
        \end{pmatrix}

This gate is equivalent to a SWAP up to a diagonal.

.. math::

     iSWAP =
        \begin{pmatrix}
            1 & 0 & 0 & 0 \\
            0 & 0 & 1 & 0 \\
            0 & 1 & 0 & 0 \\
            0 & 0 & 0 & 1
        \end{pmatrix}
     .  \begin{pmatrix}
            1 & 0 & 0 & 0 \\
            0 & i & 0 & 0 \\
            0 & 0 & i & 0 \\
            0 & 0 & 0 & 1
        \end{pmatrix}
labelc                 &   > [         TU ]  SS/ US9  g)z2
Args:
    label: An optional label for the gate.
iswap   )r   N)super__init__)selfr   	__class__s     e/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/circuit/library/standard_gates/iswap.pyr   iSwapGate.__init__Z   s    
 	!Ru5    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   ISwap_get_definitionparamsr   
definition)r   r   s     r   _defineiSwapGate._definec   sC     	2 );;..t{{;4VZV_V_ < 
r   exponent	annotatedc                 <    [        [        R                  * U-  5      $ N)r	   nppi)r   r%   r&   s      r   poweriSwapGate.powerr   s    RUUFX-..r   c                 "    [        U[        5      $ r(   )
isinstancer   )r   others     r   __eq__iSwapGate.__eq__u   s    %++r   )r"   r(   )F)__name__
__module____qualname____firstlineno____doc__r   r   _standard_gater   strr   r   _singleton_lookup_keyr#   floatboolr+   r0   __static_attributes____classcell__)r   s   @r   r   r      sX    :x "''N6hsm 6 6 12
/e / /, ,r   r   )r6   typingr   numpyr)   qiskit.circuit.singletonr   r   qiskit.circuit._utilsr   qiskit._accelerate.circuitr   
xx_plus_yyr	   r    r   r   <module>rE      sI       H 1 3 $ ,}lKL[, [, M[,r   