§
    ¹³Ùg¤  ã                   ó´   — d Z ddlmZ ddlZddlmZmZ ddlm	Z	 ddl
mZ ddlmZ dd	lmZ  eg d
¢g d¢g d¢g d¢g¦  «         G d„ de¦  «        ¦   «         ZdS )ziSWAP gate.é    )ÚOptionalN)ÚSingletonGateÚstdlib_singleton_key)ÚQuantumRegister)Úwith_gate_array)ÚStandardGateé   )ÚXXPlusYYGate)r	   r   r   r   )r   r   ù              ð?r   )r   r   r   r   )r   r   r   r	   c                   ó~   ‡ — e Zd ZdZej        Zddddœdee         fˆ fd„Z	 e
¦   «         Zd„ Zdd	ed
efd„Zd„ Zˆ xZS )Ú	iSwapGateu®  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}
    NÚdt)ÚdurationÚunitÚlabelc                óV   •— t          ¦   «                              ddg |||¬¦  «         dS )zCreate new iSwap gate.Úiswapé   )r   r   r   N)ÚsuperÚ__init__)Úselfr   r   r   Ú	__class__s       €úa/granary/edev/quantum/lib/python3.11/site-packages/qiskit/circuit/library/standard_gates/iswap.pyr   ziSwapGate.__init__[   s.   ø€ å‰Œ×Ò˜ ! R¨u¸xÈdÐÑSÔSÐSÐSÐSó    c                 óÌ  — ddl m} ddlm} ddlm} ddlm} t          dd¦  «        } ||| j	        ¬	¦  «        } |¦   «         |d         gg f |¦   «         |d         gg f |¦   «         |d         gg f |¦   «         |d         |d         gg f |¦   «         |d         |d         gg f |¦   «         |d         gg fg}|D ]\  }}	}
| 
                    ||	|
¦  «         Œ|| _        d
S )z°
        gate iswap a,b {
            s q[0];
            s q[1];
            h q[0];
            cx q[0],q[1];
            cx q[1],q[0];
            h q[1];
        }
        r   )ÚQuantumCircuitr	   )ÚHGate)ÚSGate)ÚCXGater   Úq)ÚnameN)Úqiskit.circuit.quantumcircuitr   Úhr   Úsr   Úxr   r   r!   Ú_appendÚ
definition)r   r   r   r   r   r    ÚqcÚrulesÚinstrÚqargsÚcargss              r   Ú_defineziSwapGate._definea   sE  € ð 	AÐ@Ð@Ð@Ð@Ð@àÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐå˜A˜sÑ#Ô#ˆØˆ^˜A D¤IÐ.Ñ.Ô.ˆàˆU‰WŒW�q˜”t�f˜bÐ!ØˆU‰WŒW�q˜”t�f˜bÐ!ØˆU‰WŒW�q˜”t�f˜bÐ!ØˆV‰XŒX˜˜!œ˜a œd�| RÐ(ØˆV‰XŒX˜˜!œ˜a œd�| RÐ(ØˆU‰WŒW�q˜”t�f˜bÐ!ð
ˆð $)ð 	,ð 	,ÑˆE�5˜%Ø�JŠJ�u˜e UÑ+Ô+Ð+Ð+àˆŒˆˆr   FÚexponentÚ	annotatedc                 ó<   — t          t          j         |z  ¦  «        S ©N)r
   ÚnpÚpi)r   r.   r/   s      r   ÚpowerziSwapGate.power‚   s   € Ý�RœU˜F XÑ-Ñ.Ô.Ð.r   c                 ó,   — t          |t          ¦  «        S r1   )Ú
isinstancer   )r   Úothers     r   Ú__eq__ziSwapGate.__eq__…   s   € Ý˜%¥Ñ+Ô+Ð+r   r1   )F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ú	ISwapGateÚ_standard_gater   Ústrr   r   Ú_singleton_lookup_keyr-   ÚfloatÚboolr4   r8   Ú__classcell__)r   s   @r   r   r      sÑ   ø€ € € € € ð:ð :ðx "Ô+€NðTÀÈ4ð Tð Tð T˜h sœmð Tð Tð Tð Tð Tð Tð 1Ð0Ñ2Ô2Ððð ð ðB/ð /˜eð /°ð /ð /ð /ð /ð,ð ,ð ,ð ,ð ,ð ,ð ,r   r   )r<   Útypingr   Únumpyr2   Úqiskit.circuit.singletonr   r   Úqiskit.circuit.quantumregisterr   Úqiskit.circuit._utilsr   Úqiskit._accelerate.circuitr   Ú
xx_plus_yyr
   r   © r   r   ú<module>rL      sú   ðð Ð à Ð Ð Ð Ð Ð à Ð Ð Ð à HÐ HÐ HÐ HÐ HÐ HÐ HÐ HØ :Ð :Ð :Ð :Ð :Ð :Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3à $Ð $Ð $Ð $Ð $Ð $ð €�,�,�,   ¨}¨}¨}¸l¸l¸lÐKÑLÔLðj,ð j,ð j,ð j,ð j,�ñ j,ô j,ñ MÔLðj,ð j,ð j,r   