§
    ¹³Ùg-  ã                   óJ  — d Z ddlZddlmZ ddlmZ ddlZddlmZmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZ  ed
dgdd ej        d¦  «        z  gg¦  «         G d„ de¦  «        ¦   «         Z ed
dgdd ej        d¦  «        z  gg¦  «         G d„ de¦  «        ¦   «         ZdS )zT and Tdg gate.é    N)Úpi)ÚOptional)ÚSingletonGateÚstdlib_singleton_key)Ú	PhaseGate)ÚQuantumRegister)Úwith_gate_array)ÚStandardGateé   y      ð?      ð?é   c                   óŒ   ‡ — e Zd ZdZej        Zddddœdee         fˆ fd„Z	 e
¦   «         Zd„ Zdd	efd
„Zdded	efd„Zd„ Zˆ xZS )ÚTGateuÌ  Single qubit T gate (Z**0.25).

    It induces a :math:`\pi/4` phase, and is sometimes called the pi/8 gate
    (because of how the RZ(\pi/4) matrix looks like).

    This is a non-Clifford gate and a fourth-root of Pauli-Z.

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

    **Matrix Representation:**

    .. math::

        T = \begin{pmatrix}
                1 & 0 \\
                0 & e^{i\pi/4}
            \end{pmatrix}

    **Circuit symbol:**

    .. code-block:: text

             â”Œâ”€â”€â”€â”�
        q_0: â”¤ T â”œ
             â””â”€â”€â”€â”˜

    Equivalent to a :math:`\pi/4` radian rotation about the Z axis.
    NÚdt©ÚdurationÚunitÚlabelc                óV   •— t          ¦   «                              ddg |||¬¦  «         dS )zCreate new T gate.Útr   ©r   r   r   N©ÚsuperÚ__init__©Úselfr   r   r   Ú	__class__s       €ú]/granary/edev/quantum/lib/python3.11/site-packages/qiskit/circuit/library/standard_gates/t.pyr   zTGate.__init__=   s.   ø€ å‰Œ×Ò˜˜a ¨5¸8È$ÐÑOÔOÐOÐOÐOó    c                 óì   — ddl m} ddlm} t	          dd¦  «        } ||| j        ¬¦  «        } |t          dz  ¦  «        |d         gg fg}|D ]\  }}}|                     |||¦  «         Œ|| _        dS )	z*
        gate t a { u1(pi/4) a; }
        r   ©ÚQuantumCircuitr   ©ÚU1GateÚq©Únameé   N©	Úqiskit.circuit.quantumcircuitr!   Úu1r#   r   r&   r   Ú_appendÚ
definition©	r   r!   r#   r$   ÚqcÚrulesÚinstrÚqargsÚcargss	            r   Ú_definezTGate._defineC   s©   € ð
 	AÐ@Ð@Ð@Ð@Ð@àÐÐÐÐÐå˜A˜sÑ#Ô#ˆØˆ^˜A D¤IÐ.Ñ.Ô.ˆØ�&�˜a™‘.”. 1 Q¤4 &¨"Ð-Ð.ˆØ#(ð 	,ð 	,ÑˆE�5˜%Ø�JŠJ�u˜e UÑ+Ô+Ð+Ð+àˆŒˆˆr   FÚ	annotatedc                 ó   — t          ¦   «         S )aÈ  Return inverse T gate (i.e. Tdg).

        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:`.TdgGate`.

        Returns:
            TdgGate: inverse of :class:`.TGate`
        )ÚTdgGate©r   r4   s     r   ÚinversezTGate.inverseT   s   € õ ‰yŒyÐr   Úexponentc                 ó@   — t          dt          j        z  |z  ¦  «        S )Ng      Ð?©r   Únumpyr   ©r   r9   r4   s      r   ÚpowerzTGate.powerb   s   € Ý˜¥¤™¨8Ñ3Ñ4Ô4Ð4r   c                 ó,   — t          |t          ¦  «        S ©N)Ú
isinstancer   ©r   Úothers     r   Ú__eq__zTGate.__eq__e   s   € Ý˜%¥Ñ'Ô'Ð'r   r@   ©F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   r   Ú_standard_gater   Ústrr   r   Ú_singleton_lookup_keyr3   Úboolr8   Úfloatr>   rD   Ú__classcell__©r   s   @r   r   r      sï   ø€ € € € € ðð ð< "Ô'€NðPÀÈ4ð Pð Pð P˜h sœmð Pð Pð Pð Pð Pð Pð 1Ð0Ñ2Ô2Ððð ð ð"ð  ð ð ð ð ð5ð 5˜eð 5°ð 5ð 5ð 5ð 5ð(ð (ð (ð (ð (ð (ð (r   r   y      ð?      ð¿c                   óŒ   ‡ — e Zd ZdZej        Zddddœdee         fˆ fd„Z	 e
¦   «         Zd„ Zdd	efd
„Zdded	efd„Zd„ Zˆ xZS )r6   uŽ  Single qubit T-adjoint gate (~Z**0.25).

    It induces a :math:`-\pi/4` phase.

    This is a non-Clifford gate and a fourth-root of Pauli-Z.

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

    **Matrix Representation:**

    .. math::

        Tdg = \begin{pmatrix}
                1 & 0 \\
                0 & e^{-i\pi/4}
            \end{pmatrix}

    **Circuit symbol:**

    .. code-block:: text

             â”Œâ”€â”€â”€â”€â”€â”�
        q_0: â”¤ Tdg â”œ
             â””â”€â”€â”€â”€â”€â”˜

    Equivalent to a :math:`-\pi/4` radian rotation about the Z axis.
    Nr   r   r   c                óV   •— t          ¦   «                              ddg |||¬¦  «         dS )zCreate new Tdg gate.Útdgr   r   Nr   r   s       €r   r   zTdgGate.__init__Š   s.   ø€ å‰Œ×Ò˜  2¨U¸XÈDÐÑQÔQÐQÐQÐQr   c                 óî   — ddl m} ddlm} t	          dd¦  «        } ||| j        ¬¦  «        } |t           dz  ¦  «        |d         gg fg}|D ]\  }}}|                     |||¦  «         Œ|| _        dS )	z,
        gate tdg a { u1(pi/4) a; }
        r   r    r   r"   r$   r%   r'   Nr(   r-   s	            r   r3   zTdgGate._define�   s«   € ð
 	AÐ@Ð@Ð@Ð@Ð@àÐÐÐÐÐå˜A˜sÑ#Ô#ˆØˆ^˜A D¤IÐ.Ñ.Ô.ˆØ�&�"˜˜q™‘/”/ A a¤D 6¨2Ð.Ð/ˆØ#(ð 	,ð 	,ÑˆE�5˜%Ø�JŠJ�u˜e UÑ+Ô+Ð+Ð+àˆŒˆˆr   Fr4   c                 ó   — t          ¦   «         S )aÆ  Return inverse Tdg gate (i.e. T).

        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:`.TGate`.

        Returns:
            TGate: inverse of :class:`.TdgGate`
        )r   r7   s     r   r8   zTdgGate.inverse¡   s   € õ ‰wŒwˆr   r9   c                 ó@   — t          dt          j        z  |z  ¦  «        S )Ng      Ð¿r;   r=   s      r   r>   zTdgGate.power¯   s   € Ý˜¥¤Ñ)¨HÑ4Ñ5Ô5Ð5r   c                 ó,   — t          |t          ¦  «        S r@   )rA   r6   rB   s     r   rD   zTdgGate.__eq__²   s   € Ý˜%¥Ñ)Ô)Ð)r   r@   rE   )rF   rG   rH   rI   r
   r6   rJ   r   rK   r   r   rL   r3   rM   r8   rN   r>   rD   rO   rP   s   @r   r6   r6   i   sï   ø€ € € € € ðð ð: "Ô)€NðRÀÈ4ð Rð Rð R˜h sœmð Rð Rð Rð Rð Rð Rð 1Ð0Ñ2Ô2Ððð ð ð"ð  ð ð ð ð ð6ð 6˜eð 6°ð 6ð 6ð 6ð 6ð*ð *ð *ð *ð *ð *ð *r   r6   )rI   Úmathr   Útypingr   r<   Úqiskit.circuit.singletonr   r   Ú'qiskit.circuit.library.standard_gates.pr   Úqiskit.circuit.quantumregisterr   Úqiskit.circuit._utilsr	   Úqiskit._accelerate.circuitr
   Úsqrtr   r6   © r   r   ú<module>ra      s|  ðð Ð Ø €€€Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à €€€à HÐ HÐ HÐ HÐ HÐ HÐ HÐ HØ =Ð =Ð =Ð =Ð =Ð =Ø :Ð :Ð :Ð :Ð :Ð :Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3ð €�1�a�&˜1˜v¨¨¬°1©¬Ñ5Ð6Ð7Ñ8Ô8ðJ(ð J(ð J(ð J(ð J(ˆMñ J(ô J(ñ 9Ô8ðJ(ðZ €�1�a�&˜1˜v¨¨¬°1©¬Ñ5Ð6Ð7Ñ8Ô8ðI*ð I*ð I*ð I*ð I*ˆmñ I*ô I*ñ 9Ô8ðI*ð I*ð I*r   