§
    ¹³Ùg­  ã            
       óô   — d Z ddlmZ ddlZddlmZ ddlmZ ddl	m
Z
mZ ddlmZ dd	lmZ dd
lmZ  e ed¦  «         ej        g d¢g d¢g d¢g d¢g¦  «        z  ¦  «         G d„ de
¦  «        ¦   «         ZdS )zTwo-qubit ZX-rotation gate.é    )ÚsqrtN)Úwith_gate_array)ÚQuantumRegister)ÚSingletonGateÚstdlib_singleton_key)ÚStandardGateé   )ÚRZXGate)ÚXGateg      à?)r   r	   r   ù              ð?)r	   r   ù       €      ð¿r   )r   r   r   r	   )r   r   r	   r   c                   óh   ‡ — e Zd ZdZej        Zddddœˆ fd„Z e¦   «         Z	d„ Z
ddefd	„Zd
„ Zˆ xZS )ÚECRGateu	  An echoed cross-resonance gate.

    This gate is maximally entangling and is equivalent to a CNOT up to
    single-qubit pre-rotations. The echoing procedure mitigates some
    unwanted terms (terms other than ZX) to cancel in an experiment.
    More specifically, this gate implements :math:`\frac{1}{\sqrt{2}}(IX-XY)`.

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

    **Circuit Symbol:**

    .. code-block:: text

             â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”�            â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”�â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”�â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”�
        q_0: â”¤0        â”œ       q_0: â”¤0           â”œâ”¤ RX(pi) â”œâ”¤0            â”œ
             â”‚   ECR   â”‚   =        â”‚  RZX(pi/4) â”‚â””â”€â”€â”€â”€â”€â”€â”€â”€â”˜â”‚  RZX(-pi/4) â”‚
        q_1: â”¤1        â”œ       q_1: â”¤1           â”œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¤1            â”œ
             â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜            â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜          â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜

    **Matrix Representation:**

    .. math::

        ECR\ q_0, q_1 = \frac{1}{\sqrt{2}}
            \begin{pmatrix}
                0   & 1   &  0  & i \\
                1   & 0   &  -i & 0 \\
                0   & i   &  0  & 1 \\
                -i  & 0   &  1  & 0
            \end{pmatrix}

    .. note::

        In Qiskit's convention, higher qubit indices are more significant
        (little endian convention). In the above example we apply the gate
        on (q_0, q_1) which results in the :math:`X \otimes Z` tensor order.
        Instead, if we apply it on (q_1, q_0), the matrix will
        be :math:`Z \otimes X`:

        .. code-block:: text

                 â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”�
            q_0: â”¤1        â”œ
                 â”‚   ECR   â”‚
            q_1: â”¤0        â”œ
                 â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜

        .. math::

            ECR\ q_0, q_1 = \frac{1}{\sqrt{2}}
                \begin{pmatrix}
                    0   & 0   &  1  & i \\
                    0   & 0   &  i  & 1 \\
                    1   & -i  &  0  & 0 \\
                    -i  & 1   &  0  & 0
                \end{pmatrix}
    NÚdt)ÚdurationÚunitc                óV   •— t          ¦   «                              ddg |||¬¦  «         dS )zCreate new ECR gate.Úecré   )Úlabelr   r   N)ÚsuperÚ__init__)Úselfr   r   r   Ú	__class__s       €ú_/granary/edev/quantum/lib/python3.11/site-packages/qiskit/circuit/library/standard_gates/ecr.pyr   zECRGate.__init__Z   s.   ø€ å‰Œ×Ò˜  2¨U¸XÈDÐÑQÔQÐQÐQÐQó    c                 óˆ  — ddl m} t          dd¦  «        } ||| j        ¬¦  «        }t	          t
          j        dz  ¦  «        |d         |d         gg ft          ¦   «         |d         gg ft	          t
          j         dz  ¦  «        |d         |d         gg fg}|D ]\  }}}|                     |||¦  «         Œ|| _	        dS )	zH
        gate ecr a, b { rzx(pi/4) a, b; x a; rzx(-pi/4) a, b;}
        r   )ÚQuantumCircuitr   Úq)Únameé   r	   N)
Úqiskit.circuit.quantumcircuitr   r   r    r
   ÚnpÚpir   Ú_appendÚ
definition)r   r   r   ÚqcÚrulesÚinstrÚqargsÚcargss           r   Ú_definezECRGate._define`   sÝ   € ð
 	AÐ@Ð@Ð@Ð@Ð@å˜A˜sÑ#Ô#ˆØˆ^˜A D¤IÐ.Ñ.Ô.ˆå•R”U˜Q‘YÑÔ ! A¤$¨¨!¬ ¨rÐ2Ý‰WŒW�q˜”t�f˜bÐ!Ý•b”e�V˜a‘ZÑ Ô  1 Q¤4¨¨1¬ ,°Ð3ð
ˆð
 $)ð 	,ð 	,ÑˆE�5˜%Ø�JŠJ�u˜e UÑ+Ô+Ð+Ð+àˆŒˆˆr   FÚ	annotatedc                 ó   — t          ¦   «         S )a­  Return inverse ECR gate (itself).

        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 this gate
                is self-inverse.

        Returns:
            ECRGate: inverse gate (self-inverse).
        )r   )r   r-   s     r   ÚinversezECRGate.inverses   s   € õ ‰yŒyÐr   c                 ó,   — t          |t          ¦  «        S ©N)Ú
isinstancer   )r   Úothers     r   Ú__eq__zECRGate.__eq__�   s   € Ý˜%¥Ñ)Ô)Ð)r   r1   )F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú_standard_gater   r   Ú_singleton_lookup_keyr,   Úboolr/   r4   Ú__classcell__)r   s   @r   r   r      s·   ø€ € € € € ð9ð 9ðv "Ô)€NðR¨t¸$ð Rð Rð Rð Rð Rð Rð Rð 1Ð0Ñ2Ô2Ððð ð ð&ð  ð ð ð ð ð*ð *ð *ð *ð *ð *ð *r   r   )r8   Úmathr   Únumpyr#   Úqiskit.circuit._utilsr   Úqiskit.circuit.quantumregisterr   Úqiskit.circuit.singletonr   r   Úqiskit._accelerate.circuitr   Úrzxr
   Úxr   Úarrayr   © r   r   ú<module>rG      s1  ðð "Ð !Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð à 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø :Ð :Ð :Ð :Ð :Ð :Ø HÐ HÐ HÐ HÐ HÐ HÐ HÐ HØ 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð ð €Ø€Dˆ�I„I��”˜/˜/˜/Ð+;Ð+;Ð+;¸_¸_¸_ÐN^ÐN^ÐN^Ð_Ñ`Ô`Ñ`ñô ðf*ð f*ð f*ð f*ð f*ˆmñ f*ô f*ñô ðf*ð f*ð f*r   