
    z	ix'                         S r SSKJrJr  SSKrSSKJrJr  SSKJ	r	J
r
Jr  SSK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\" \SSS9 " S S\
5      5       rg)zZ, CZ and CCZ gates.    )OptionalUnionN)with_gate_arraywith_controlled_gate_array)SingletonGateSingletonControlledGatestdlib_singleton_key)StandardGate   )	PhaseGatec            
          ^  \ 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S\S\4S jjrS rSrU =r$ )ZGate   u`  The single-qubit Pauli-Z gate (:math:`\sigma_z`).

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

Matrix representation:

.. math::

    Z = \begin{pmatrix}
            1 & 0 \\
            0 & -1
        \end{pmatrix}

Circuit symbol:

.. code-block:: text

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

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

.. note::

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

    .. math::

        RZ(\pi) = \begin{pmatrix}
                    -i & 0 \\
                    0 & i
                  \end{pmatrix}
                = -i Z

The gate is equivalent to a phase flip.

.. math::

    |0\rangle \rightarrow |0\rangle \\
    |1\rangle \rightarrow -|1\rangle
labelc                 &   > [         TU ]  SS/ US9  g)z2
Args:
    label: An optional label for the gate.
zr   r   N)super__init__)selfr   	__class__s     a/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/circuit/library/standard_gates/z.pyr   ZGate.__init__M   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
   Z_get_definitionparamsr    
definitionr   r   s     r   _defineZGate._defineV   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-Z gate.

One control returns a CZ 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,   )CZGater   r   control)r   r*   r   r+   r,   gater   s         r   r0   ZGate.controlc   sN    , _1$**UD  7? /%#	 # D r   c                     [        5       $ )aj  Return inverted Z 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:
    ZGate: inverse gate (self-inverse).
)r   r   r,   s     r   inverseZGate.inverse   s     wr   exponentc                 :    [        [        R                  U-  5      $ N)r   numpypi)r   r7   r,   s      r   powerZGate.power   s    H,--r   c                 "    [        U[        5      $ r9   )
isinstancer   r   others     r   __eq__ZGate.__eq__   s    %''r   r&   r9   )r   NNFF)__name__
__module____qualname____firstlineno____doc__r
   r#   _standard_gater   strr   r	   _singleton_lookup_keyr(   intr   boolr0   r5   floatr<   rB   __static_attributes____classcell__r   s   @r   r   r      s    +Z "^^N2hsm 2 2 12
  !#04 } U38_-	
  B .e . .( (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-Z gate.

This is a Clifford and symmetric gate.

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

Circuit symbol:

.. code-block:: text

    q_0: ─■─
          │
    q_1: ─■─

Matrix representation:

.. math::

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

In the computational basis, this gate flips the phase of
the target qubit if the control qubit is in the :math:`|1\rangle` state.
Nr.   r   r+   c                :   > [         TU ]  SS/ USU[        US9S9  g)zCreate new CZ gate.cz   r   r   r   r*   r+   	base_gateNr   r   r   r   r   r+   r.   r   s       r   r   CZGate.__init__   s1     	!+. 	 	
r   r   rT   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
   CZr$   r%   r    r&   r'   s     r   r(   CZGate._define   sA     	2 );;OO++DKK8SWS\S\ < 
r   r,   c                 (    [        U R                  S9$ )al  Return inverted CZ 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:
    CZGate: inverse gate (self-inverse).
r+   )r/   r+   r4   s     r   r5   CZGate.inverse   s     11r   c                 b    [        U[        5      =(       a    U R                  UR                  :H  $ r9   )r?   r/   r+   r@   s     r   rB   CZGate.__eq__   s#    %(PT__@P@P-PPr   rD   NNrE   )rF   rG   rH   rI   rJ   r
   ra   rK   r   rL   r   rN   r   r	   rM   r(   rO   r5   rB   rQ   rR   rS   s   @r   r/   r/      s}    @ "__N  $04

 
}
 U38_-
 
$ 1C
2 2Q Qr   r/   rZ   )   )r*   cached_statesc            	          ^  \ 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$ )CCZGate   u  CCZ gate.

This is a symmetric gate.

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

Circuit symbol:

.. code-block:: text

    q_0: ─■─
          │
    q_1: ─■─
          │
    q_2: ─■─

Matrix representation:

.. math::

    CCZ\ q_0, q_1, q_2 =
        I \otimes I \otimes |0\rangle\langle 0| + CZ \otimes |1\rangle\langle 1| =
        \begin{pmatrix}
            1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
            0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\
            0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\
            0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\
            0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\
            0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\
            0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\
            0 & 0 & 0 & 0 & 0 & 0 & 0 & -1
        \end{pmatrix}

In the computational basis, this gate flips the phase of
the target qubit if the control qubits are in the :math:`|11\rangle` state.
NrW   r   r+   c                :   > [         TU ]  SS/ USU[        US9S9  g)zCreate new CCZ gate.cczri   rZ   r   r[   Nr]   r^   s       r   r   CCZGate.__init__  s1     	!+. 	 	
r   rZ   rT   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
   CCZr$   r%   r    r&   r'   s     r   r(   CCZGate._define/  sC     	2 );;,,T[[9TXT]T] < 
r   r,   c                 (    [        U R                  S9$ )an  Return inverted CCZ 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:
    CCZGate: inverse gate (self-inverse).
rd   )rl   r+   r4   s     r   r5   CCZGate.inverse?  s     $//22r   c                 b    [        U[        5      =(       a    U R                  UR                  :H  $ r9   )r?   rl   r+   r@   s     r   rB   CCZGate.__eq__M  s#    %)QdooAQAQ.QQr   rD   rh   rE   )rF   rG   rH   rI   rJ   r
   rr   rK   r   rL   r   rN   r   r	   rM   r(   rO   r5   rB   rQ   rR   rS   s   @r   rl   rl      s    $L "%%N  $04

 
}
 U38_-
 
$ 1C
 3 3R Rr   rl   )rJ   typingr   r   r:   qiskit.circuit._utilsr   r   qiskit.circuit.singletonr   r   r	   qiskit._accelerate.circuitr
   pr   _Z_ARRAYr   r/   rl    r   r   <module>r      s     "  M a a 3 FQG y(M y( y(x Ha8TQ$ TQ 9TQn HatL\R% \R M\Rr   