§
    ¹³ÙgQ  ã                   óz   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ  G d	„ d
e¦  «        ZdS )zD
Simulator command to perform multiple pauli gates in a single pass
é    )ÚCircuitInstruction)ÚQuantumRegister)ÚXGate)ÚYGate)ÚZGate)ÚGate)ÚCircuitErrorc                   óD   ‡ — e Zd ZdZˆ fd„Zd„ Zd
defd„Zdd„Zd	„ Z	ˆ xZ
S )Ú	PauliGateaæ  A multi-qubit Pauli gate.

    This gate exists for optimization purposes for the
    quantum statevector simulation, since applying multiple
    pauli gates to different qubits at once can be done via
    a single pass on the statevector.

    The functionality is equivalent to applying
    the pauli gates sequentially using standard Qiskit gates.

    Can be applied to a :class:`~qiskit.circuit.QuantumCircuit`
    with the :meth:`~qiskit.circuit.QuantumCircuit.pauli` method.
    c                 ój   •— t          ¦   «                              dt          |¦  «        |g¦  «         d S )NÚpauli)ÚsuperÚ__init__Úlen)ÚselfÚlabelÚ	__class__s     €úd/granary/edev/quantum/lib/python3.11/site-packages/qiskit/circuit/library/generalized_gates/pauli.pyr   zPauliGate.__init__)   s-   ø€ Ý‰Œ×Ò˜¥# e¡*¤*¨u¨gÑ6Ô6Ð6Ð6Ð6ó    c                 ó¾  — ddl m} t          t          t          dœ}t          t          | j        d         ¦  «        d¦  «        } ||| j        › d| j        d         › d�¬¦  «        }| j        d         }t          t          |¦  «        ¦  «        D ]E\  }}|dk    rŒ|                     t           ||         ¦   «         ||         fd	¦  «        ¦  «         ŒF|| _        d
S )zF
        gate pauli (p1 a1,...,pn an) { p1 a1; ... ; pn an; }
        r   )ÚQuantumCircuit)ÚXÚYÚZÚqú(ú))ÚnameÚI© N)Úqiskit.circuit.quantumcircuitr   r   r   r   r   r   Úparamsr   Ú	enumerateÚreversedÚ_appendr   Ú
definition)r   r   Úgatesr   ÚqcÚpaulisÚiÚps           r   Ú_definezPauliGate._define,   sé   € ð
 	AÐ@Ð@Ð@Ð@Ð@å¥%­eÐ4Ð4ˆÝ�C ¤¨A¤Ñ/Ô/°Ñ5Ô5ˆØˆ^˜A t¤yÐ$DÐ$D°4´;¸q´>Ð$DÐ$DÐ$DÐEÑEÔEˆà”˜Q”ˆÝ�h vÑ.Ô.Ñ/Ô/ð 	Dð 	D‰DˆAˆqØ�CŠxˆxØØ�JŠJÕ)¨(¨%°¬(©*¬*°q¸´t°g¸rÑBÔBÑCÔCÐCÐCØˆŒˆˆr   FÚ	annotatedc                 ó6   — t          | j        d         ¦  «        S )z$Return inverted pauli gate (itself).r   )r   r"   )r   r-   s     r   ÚinversezPauliGate.inverse>   s   € å˜œ QœÑ(Ô(Ð(r   Nc                 ód   — ddl m}  || j        d         ¦  «                             ||¬¦  «        S )zRReturn a Numpy.array for the pauli gate.
        i.e. tensor product of the paulisr   )ÚPauli)ÚdtypeÚcopy)Úqiskit.quantum_info.operatorsr1   r"   Ú	__array__)r   r2   r3   r1   s       r   r5   zPauliGate.__array__B   s?   € ð 	8Ð7Ð7Ð7Ð7Ð7àˆu�T”[ ”^Ñ$Ô$×.Ò.°UÀÐ.ÑFÔFÐFr   c                 ó®   — t          |t          ¦  «        r.t          d„ |D ¦   «         ¦  «        r|S t          d|› d�¦  «        ‚t          d|› d�¦  «        ‚)Nc              3   ó   K  — | ]}|d v V — Œ	dS ))r   r   r   r   Nr    )Ú.0Úcs     r   ú	<genexpr>z/PauliGate.validate_parameter.<locals>.<genexpr>L   s(   è è € Ð@Ð@°�1Ð,Ð,Ð@Ð@Ð@Ð@Ð@Ð@r   zParameter string z2 should contain only 'I', 'X', 'Y', 'Z' charactersz
Parameter z4 should be a string of 'I', 'X', 'Y', 'Z' characters)Ú
isinstanceÚstrÚallr	   )r   Ú	parameters     r   Úvalidate_parameterzPauliGate.validate_parameterJ   s{   € Ý�i¥Ñ%Ô%ð 
	ÝÐ@Ð@°iÐ@Ñ@Ô@Ñ@Ô@ð Ø Ð å"Øe¨	ÐeÐeÐeñô ð õ Ø\˜YÐ\Ð\Ð\ñô ð r   )F)NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r,   Úboolr/   r5   r?   Ú__classcell__)r   s   @r   r   r      s˜   ø€ € € € € ðð ð7ð 7ð 7ð 7ð 7ðð ð ð$)ð ) ð )ð )ð )ð )ðGð Gð Gð Gðð ð ð ð ð ð r   r   N)rC   Ú!qiskit.circuit.quantumcircuitdatar   Úqiskit.circuit.quantumregisterr   Ú'qiskit.circuit.library.standard_gates.xr   Ú'qiskit.circuit.library.standard_gates.yr   Ú'qiskit.circuit.library.standard_gates.zr   Úqiskit.circuit.gater   Úqiskit.circuit.exceptionsr	   r   r    r   r   ú<module>rM      sÄ   ððð ð AÐ @Ð @Ð @Ð @Ð @Ø :Ð :Ð :Ð :Ð :Ð :Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9à $Ð $Ð $Ð $Ð $Ð $Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2ð;ð ;ð ;ð ;ð ;�ñ ;ô ;ð ;ð ;ð ;r   