
    z	i              
          S 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
Jr  SSKJr  \" \" S5      \R                  " / S	Q/ S
Q/ SQ/ SQ/5      -  5       " S S\
5      5       rg)zTwo-qubit ZX-rotation gate.    )annotations)sqrtN)with_gate_array)SingletonGatestdlib_singleton_key)StandardGateg      ?)r      r                 ?)r	   r                r   )r   r
   r   r	   )r   r   r	   r   c                  t   ^  \ rS rSrSr\R                  rSS	U 4S jjjr\	" 5       r
S rS
SS jjrS rSrU =r$ )ECRGate   u  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

                           global phase: 7π/4
         ┌─────────┐            ┌───┐      ┌───┐
    q_0: ┤0        ├       q_0: ┤ S ├───■──┤ X ├
         │   ECR   │   =        ├───┴┐┌─┴─┐└───┘
    q_1: ┤1        ├       q_1: ┤ √X ├┤ X ├─────
         └─────────┘            └────┘└───┘


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}
c                &   > [         TU ]  SS/ US9  g)z2
Args:
    label: An optional label for the gate.
ecr   )labelN)super__init__)selfr   	__class__s     c/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/circuit/library/standard_gates/ecr.pyr   ECRGate.__init__[   s    
 	2U3    c                    SSK Jn  UR                  [        R                  R                  U R                  5      SU R                  S9U l        g)z7Default definition (in terms of simpler Clifford gates)r   )QuantumCircuitT)legacy_qubitsnameN)	qiskit.circuitr   _from_circuit_datar   ECR_get_definitionparamsr   
definition)r   r   s     r   _defineECRGate._defined   sC     	2 );;,,T[[9TXT]T] < 
r   c                    [        5       $ )am  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   	annotateds     r   inverseECRGate.inverset   s     yr   c                "    [        U[        5      $ N)
isinstancer   )r   others     r   __eq__ECRGate.__eq__   s    %))r   )r#   r+   )r   z
str | NonereturnNone)F)r'   bool)__name__
__module____qualname____firstlineno____doc__r   r    _standard_gater   r   _singleton_lookup_keyr$   r(   r.   __static_attributes____classcell__)r   s   @r   r   r      s?    ;z "%%N4 4 12
 * *r   r   )r7   
__future__r   mathr   numpynpqiskit.circuit._utilsr   qiskit.circuit.singletonr   r   qiskit._accelerate.circuitr   arrayr    r   r   <module>rE      s_    " "   1 H 3 I/+;_N^_``h*m h*h*r   