
    z	i                    j    S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
Jr  SSKJr   " S S	\5      rg
)zTwo-qubit ZZ-rotation gate.    )annotations)exp)Optional)Gate)ParameterValueTypeParameterExpression)StandardGatec                     ^  \ rS rSrSr\R                  rSSU 4S jjjrS r	    S       SU 4S jjjr
SSS jjrSS jrSSS jjrS	 rS
rU =r$ )RZZGate   u  A parametric 2-qubit :math:`Z \otimes Z` interaction (rotation about ZZ).

This gate is symmetric, and is maximally entangling at :math:`\theta = \pi/2`.

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

Circuit symbol:

.. code-block:: text

    q_0: ───■────
            │zz(θ)
    q_1: ───■────

Matrix representation:

.. math::

    \newcommand{\rotationangle}{\frac{\theta}{2}}

    R_{ZZ}(\theta) = \exp\left(-i \rotationangle Z{\otimes}Z\right) =
        \begin{pmatrix}
            e^{-i \rotationangle} & 0 & 0 & 0 \\
            0 & e^{i \rotationangle} & 0 & 0 \\
            0 & 0 & e^{i \rotationangle} & 0 \\
            0 & 0 & 0 & e^{-i \rotationangle}
        \end{pmatrix}

This is a direct sum of RZ rotations, so this gate is equivalent to a
uniformly controlled (multiplexed) RZ gate:

.. math::

    R_{ZZ}(\theta) =
        \begin{pmatrix}
            RZ(\theta) & 0 \\
            0 & RZ(-\theta)
        \end{pmatrix}

Examples:

.. math::

    R_{ZZ}(\theta = 0) = I

.. math::

    R_{ZZ}(\theta = 2\pi) = -I

.. math::

    R_{ZZ}(\theta = \pi) = - i Z \otimes Z

.. math::

    R_{ZZ}\left(\theta = \frac{\pi}{2}\right) = \frac{1}{\sqrt{2}}
                            \begin{pmatrix}
                                1-i & 0 & 0 & 0 \\
                                0 & 1+i & 0 & 0 \\
                                0 & 0 & 1+i & 0 \\
                                0 & 0 & 0 & 1-i
                            \end{pmatrix}
c                (   > [         TU ]  SSU/US9  g)zQ
Args:
    theta: The rotation angle.
    label: An optional label for the gate.
rzz   )labelN)super__init__)selfthetar   	__class__s      c/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/circuit/library/standard_gates/rzz.pyr   RZZGate.__init__\   s     	E7%8    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	   RZZ_get_definitionparamsr   
definition)r   r   s     r   _defineRZZGate._defined   sC     	2 );;,,T[[9TXT]T] < 
r   c                f   > Uc  [        S U R                   5       5      n[        TU ]  UUUUS9nU$ )aC  Return a (multi-)controlled-RZZ 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. If ``None``, this is set to ``True`` if
        the gate contains free parameters, in which case it cannot
        yet be synthesized.

Returns:
    ControlledGate: controlled version of this gate.
c              3  B   #    U  H  n[        U[        5      v   M     g 7fN)
isinstancer   ).0ps     r   	<genexpr>"RZZGate.control.<locals>.<genexpr>   s     T1Jq*=>>s   )num_ctrl_qubitsr   
ctrl_state	annotated)anyr!   r   control)r   r-   r   r.   r/   gater   s         r   r1   RZZGate.controlr   sE    , TTTIw+!	  
 r   c                4    [        U R                  S   * 5      $ )a  Return inverse RZZ gate (i.e. with the negative rotation angle).

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 the inverse
        of this gate is always a :class:`.RZZGate` with an inverted parameter value.

Returns:
    RZZGate: inverse gate.
r   )r   r!   )r   r/   s     r   inverseRZZGate.inverse   s     A''r   c                    SSK nUSL a  [        S5      eS[        U R                  S   5      -  S-  nUR	                  [        U* 5      SSS/S[        U5      SS/SS[        U5      S/SSS[        U* 5      //US9$ )z&Return a numpy.array for the RZZ gate.r   NFz9unable to avoid copy while creating an array as requestedy              ?r   )dtype)numpy
ValueErrorfloatr!   arrayr   )r   r8   copyr9   itheta2s        r   	__array__RZZGate.__array__   s    5=XYYuT[[^,,q0{{gX1a(CL!Q'As7|Q'Aq#wh-(	   
 	
r   c                8    U R                   u  n[        X-  5      $ r'   )r!   r   )r   exponentr/   r   s       r   powerRZZGate.power   s    ;;x'((r   c                P    [        U[        5      (       a  U R                  U5      $ g)NF)r(   r   _compare_parameters)r   others     r   __eq__RZZGate.__eq__   s#    eW%%++E22r   )r"   r'   )r   r   r   zOptional[str])   NNN)r-   intr   z
str | Noner.   zstr | int | Noner/   zbool | None)F)r/   bool)NN)rB   r;   r/   rL   )__name__
__module____qualname____firstlineno____doc__r	   r   _standard_gater   r#   r1   r5   r?   rC   rH   __static_attributes____classcell__)r   s   @r   r   r      s}    ?B "%%N9 9
   ! '+!%  %	
  B(
") r   r   N)rQ   
__future__r   cmathr   typingr   qiskit.circuit.gater   "qiskit.circuit.parameterexpressionr   r   qiskit._accelerate.circuitr	   r    r   r   <module>r\      s*    " "   $ V 3ad ar   