
    z	i?                         S r SSKJrJr  SSKJrJrJr  SSKJ	r	J
r
  SSKJr  SS/SS//r\	" \5       " S S	\5      5       r\
" \S
S9 " S S\5      5       rg)zY and CY gates.    )OptionalUnion)SingletonGateSingletonControlledGatestdlib_singleton_key)with_gate_arraywith_controlled_gate_array)StandardGatey             y              ?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\\	   S\\\	\4      S\4U 4S	 jjjrSS\4S
 jjrS rSrU =r$ )YGate   uj  The single-qubit Pauli-Y gate (:math:`\sigma_y`).

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

Matrix representation:

.. math::

    Y = \begin{pmatrix}
            0 & -i \\
            i & 0
        \end{pmatrix}

Circuit symbol:

.. code-block:: text

         ┌───┐
    q_0: ┤ Y ├
         └───┘

Equivalent to a :math:`\pi` radian rotation about the Y axis.

.. note::

    A global phase difference exists between the definitions of
    :math:`RY(\pi)` and :math:`Y`.

    .. math::

        RY(\pi) = \begin{pmatrix}
                    0 & -1 \\
                    1 & 0
                  \end{pmatrix}
                = -i Y

The gate is equivalent to a bit and phase flip.

.. math::

    |0\rangle \rightarrow i|1\rangle \\
    |1\rangle \rightarrow -i|0\rangle
labelc                 &   > [         TU ]  SS/ US9  g)z2
Args:
    label: An optional label for the gate.
y   r   N)super__init__)selfr   	__class__s     a/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/circuit/library/standard_gates/y.pyr   YGate.__init__J   s    
 	a51    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
   Y_get_definitionparamsr   
definitionr   r   s     r   _defineYGate._defineS   sA     	2 );;NN**4;;7tRVR[R[ < 
r   num_ctrl_qubits
ctrl_state	annotatedc                 n   > U(       d  US:X  a  [        X#U R                  S9nU$ [        TU ]  UUUUS9nU$ )a  Return a (multi-)controlled-Y gate.

One control returns a CY 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.

Returns:
    ControlledGate: controlled version of this gate.
r   )r   r)   _base_label)r(   r   r)   r*   )CYGater   r   control)r   r(   r   r)   r*   gater   s         r   r.   YGate.control`   sN    , _1$**UD  7? /%#	 # D r   c                     [        5       $ )az  Return inverted Y gate (:math:`Y^{\dagger} = Y`)

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:
    YGate: inverse gate (self-inverse).
)r   r   r*   s     r   inverseYGate.inverse   s     wr   c                 "    [        U[        5      $ N)
isinstancer   r   others     r   __eq__YGate.__eq__   s    %''r   r$   r6   )r   NNFF)__name__
__module____qualname____firstlineno____doc__r
   r!   _standard_gater   strr   r   _singleton_lookup_keyr&   intr   boolr.   r3   r:   __static_attributes____classcell__r   s   @r   r   r      s    +Z "^^N2hsm 2 2 12
  !#04 } U38_-	
  B ( (r   r   r   r(   c            	          ^  \ rS rSrSr\R                  r  SSS.S\\	   S\\
\	\4      4U 4S jjjjr\" SS	9rS
 rSS\4S jjrS rSrU =r$ )r-      u   Controlled-Y gate.

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

Circuit symbol:

.. code-block:: text

    q_0: ──■──
         ┌─┴─┐
    q_1: ┤ Y ├
         └───┘

Matrix representation:

.. math::

    CY\ q_0, q_1 =
    I \otimes |0 \rangle\langle 0| + Y \otimes |1 \rangle\langle 1|  =
        \begin{pmatrix}
            1 & 0 & 0 & 0 \\
            0 & 0 & 0 & -i \\
            0 & 0 & 1 & 0 \\
            0 & i & 0 & 0
        \end{pmatrix}


.. note::

    In Qiskit's convention, higher qubit indices are more significant
    (little endian convention). In many textbooks, controlled gates are
    presented with the assumption of more significant qubits as control,
    which in our case would be q_1. Thus a textbook matrix for this
    gate will be:

    .. code-block:: text

             ┌───┐
        q_0: ┤ Y ├
             └─┬─┘
        q_1: ──■──

    .. math::

        CY\ q_1, q_0 =
            |0 \rangle\langle 0| \otimes I + |1 \rangle\langle 1| \otimes Y =
            \begin{pmatrix}
                1 & 0 & 0 & 0 \\
                0 & 1 & 0 & 0 \\
                0 & 0 & 0 & -i \\
                0 & 0 & i & 0
            \end{pmatrix}

N)r,   r   r)   c                :   > [         TU ]  SS/ SUU[        US9S9  g)zCreate new CY gate.cy   r   r   )r(   r   r)   	base_gateN)r   r   r   )r   r   r)   r,   r   s       r   r   CYGate.__init__   s1     	!+. 	 	
r   r   rK   c                     SSK Jn  UR                  [        R                  R                  U R                  5      SU R                  S9U l        gr   )	r   r   r    r
   CYr"   r#   r   r$   r%   s     r   r&   CYGate._define   sA     	2 );;OO++DKK8SWS\S\ < 
r   r*   c                 (    [        U R                  S9$ )al  Return inverted CY 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:
    CYGate: inverse gate (self-inverse).
)r)   )r-   r)   r2   s     r   r3   CYGate.inverse   s     11r   c                 b    [        U[        5      =(       a    U R                  UR                  :H  $ r6   )r7   r-   r)   r8   s     r   r:   CYGate.__eq__   s#    %(PT__@P@P-PPr   r<   )NNr=   )r>   r?   r@   rA   rB   r
   rT   rC   r   rD   r   rF   r   r   rE   r&   rG   r3   r:   rH   rI   rJ   s   @r   r-   r-      s}    6p "__N  $04

 
}
 U38_-
 
$ 1C
2 2Q Qr   r-   N)rB   typingr   r   qiskit.circuit.singletonr   r   r   qiskit.circuit._utilsr   r	   qiskit._accelerate.circuitr
   _Y_ARRAYr   r-    r   r   <module>r`      s{     " b a M 3Hr1g v(M v( v(r Ha8lQ$ lQ 9lQr   