§
    ¹³Ùgi  ã                  óÎ   — d Z ddlmZ ddlZddlZddlmZ ddlZddlm	Z	m
Z
 ddlZddlm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mZ ddlmZ dZ G d„ de¦  «        ZdS )a—  
A generic quantum instruction.

Instructions can be implementable on hardware (u, cx, etc.) or in simulation
(snapshot, noise, etc.).

Instructions can be unitary (a.k.a Gate) or non-unitary.

Instructions are identified by the following:

    name: A string to identify the type of instruction.
          Used to request a specific instruction on the backend, or in visualizing circuits.

    num_qubits, num_clbits: dimensions of the instruction.

    params: List of parameters to specialize a specific instruction instance.

Instructions do not have any context about where they are in a circuit (which qubits/clbits).
The circuit itself keeps this context.
é    )ÚannotationsN)Úzip_longest)ÚListÚType)ÚCircuitError)ÚClassicalRegisterÚClbit)ÚQasmQobjInstruction)ÚParameterExpression)Ú	Operation)ÚAnnotatedOperationÚInverseModifier)Údeprecate_funcç»½×Ùß|Û=c                  óö  — e Zd ZdZdZdZdCd„ZedDd„¦   «         ZedEd
„¦   «         Z	d„ Z
e eddd¬¦  «        d„ ¦   «         ¦   «         Zej        d„ ¦   «         Zd„ ZdFd„ZdGd„Zd„ Zed„ ¦   «         Zej        d„ ¦   «         Zd„ Zd„ Zed„ ¦   «         Zej        d„ ¦   «         Zed„ ¦   «         Zej        d „ ¦   «         Zd!„ Ze edd"d¬¦  «        d#„ ¦   «         ¦   «         Zej        d$„ ¦   «         Ze edd"d¬¦  «        d%„ ¦   «         ¦   «         Zej        d&„ ¦   «         Z ed'd(d)¬*¦  «        d+„ ¦   «         Zd,„ ZedFd-„¦   «         Zej        dHd/„¦   «         Zd0„ ZdIdJd2„Z edd¬3¦  «        d4„ ¦   «         ZdKd5„Z dKd6„Z!d7„ Z"d8„ Z#d9„ Z$e eddd¬¦  «        dLd;„¦   «         ¦   «         Z%ed<„ ¦   «         Z&e&j        d=„ ¦   «         Z&ed>„ ¦   «         Z'e'j        d?„ ¦   «         Z'ed@„ ¦   «         Z(e(j        dA„ ¦   «         Z(dB„ Z)dS )MÚInstructionzGeneric quantum instruction.FNÚdtc                ó8  — t          |t          ¦  «        rt          |t          ¦  «        st          d¦  «        ‚|dk     s|dk     rt          d|› d|› d�¦  «        ‚|| _        || _        || _        g | _        t          | d¦  «        s-|�$t          |t          ¦  «        st          d¦  «        ‚|| _
        d| _        d| _        |�t          j        d	t          d
¬¦  «         || _        |�"|dk    rt          j        dt          d
¬¦  «         || _        || _        dS )aø  Create a new instruction.

        .. deprecated:: 1.3
           The parameters ``duration`` and ``unit`` are deprecated since
           Qiskit 1.3, and they will be removed in 2.0 or later.
           An instruction's duration is defined in a backend's Target object.

        Args:
            name (str): instruction name
            num_qubits (int): instruction's qubit width
            num_clbits (int): instruction's clbit width
            params (list[int|float|complex|str|ndarray|list|ParameterExpression]):
                list of parameters
            duration (int|float): (DEPRECATED) instruction's duration. it must be
                an integer if ``unit`` is ``'dt'``
            unit (str): (DEPRECATED) time unit of duration
            label (str or None): An optional label for identifying the instruction.

        Raises:
            CircuitError: when the register is not in the correct format.
            TypeError: when the optional label is provided, but it is not a string.
        z*num_qubits and num_clbits must be integer.r   zbad instruction dimensions: z	 qubits, z clbits.Ú_labelNúlabel expects a string or Nonez²Setting a custom duration per instruction is deprecated as of Qiskit 1.3.0. It will be removed in Qiskit 2.0.0. An instruction's duration is defined in a backend's Target object.é   )Ú
stacklevelr   zÝSetting a custom unit for duration per instruction is deprecated as of Qiskit 1.3.0. It will be removed in Qiskit 2.0.0. An instruction's duration is defined in a backend's Target object which has a fixed unit in seconds.)Ú
isinstanceÚintr   Ú_nameÚ_num_qubitsÚ_num_clbitsÚ_paramsÚhasattrÚstrÚ	TypeErrorr   Ú
_conditionÚ_definitionÚwarningsÚwarnÚDeprecationWarningÚ	_durationÚ_unitÚparams)ÚselfÚnameÚ
num_qubitsÚ
num_clbitsr)   ÚdurationÚunitÚlabels           úP/granary/edev/quantum/lib/python3.11/site-packages/qiskit/circuit/instruction.pyÚ__init__zInstruction.__init__@   sa  € õ. ˜*¥cÑ*Ô*ð 	Mµ*¸ZÍÑ2MÔ2Mð 	MÝÐKÑLÔLÐLØ˜Š>ˆ>˜Z¨!š^˜^ÝØX¨zÐXÐXÀJÐXÐXÐXñô ð ð ˆŒ
Ø%ˆÔØ%ˆÔàˆŒõ
 �t˜XÑ&Ô&ð 	 ØÐ ­°E½3Ñ)?Ô)?Ð ÝÐ @ÑAÔAÐAØˆDŒKð ˆŒð  ˆÔØÐÝŒMð;õ #Øðñ ô ð ð "ˆŒØÐ ¨¢ ÝŒMð]õ #Øðñ ô ð ð ˆŒ
àˆŒˆˆó    ÚreturnúType[Instruction]c                ó    — t          | ¦  «        S )aR  Get the base class of this instruction.  This is guaranteed to be in the inheritance tree
        of ``self``.

        The "base class" of an instruction is the lowest class in its inheritance tree that the
        object should be considered entirely compatible with for _all_ circuit applications.  This
        typically means that the subclass is defined purely to offer some sort of programmer
        convenience over the base class, and the base class is the "true" class for a behavioral
        perspective.  In particular, you should *not* override :attr:`base_class` if you are
        defining a custom version of an instruction that will be implemented differently by
        hardware, such as an alternative measurement strategy, or a version of a parametrized gate
        with a particular set of parameters for the purposes of distinguishing it in a
        :class:`.Target` from the full parametrized gate.

        This is often exactly equivalent to ``type(obj)``, except in the case of singleton instances
        of standard-library instructions.  These singleton instances are special subclasses of their
        base class, and this property will return that base.  For example::

            >>> isinstance(XGate(), XGate)
            True
            >>> type(XGate()) is XGate
            False
            >>> XGate().base_class is XGate
            True

        In general, you should not rely on the precise class of an instruction; within a given
        circuit, it is expected that :attr:`Instruction.name` should be a more suitable
        discriminator in most situations.
        )Útype©r*   s    r1   Ú
base_classzInstruction.base_class…   s   € õ< �D‰zŒzÐr3   Úboolc                ó   — dS )zªIs this instance is a mutable unique instance or not.

        If this attribute is ``False`` the gate instance is a shared singleton
        and is not mutable.
        T© r8   s    r1   ÚmutablezInstruction.mutable¥   s	   € ð ˆtr3   c                ó*   — |                       ¦   «         S )a8  Return a mutable copy of this gate.

        This method will return a new mutable copy of this gate instance.
        If a singleton instance is being used this will be a new unique
        instance that can be mutated. If the instance is already mutable it
        will be a deepcopy of that instance.
        )Úcopyr8   s    r1   Ú
to_mutablezInstruction.to_mutable®   s   € ð �yŠy‰{Œ{Ðr3   z1.3.0zin 2.0.0T)ÚsinceÚremoval_timelineÚis_propertyc                ó   — | j         S )z+The classical condition on the instruction.©r"   r8   s    r1   Ú	conditionzInstruction.condition¸   s   € ð ŒÐr3   c                ó   — || _         d S ©NrE   )r*   rF   s     r1   rF   zInstruction.condition¾   s   € à#ˆŒˆˆr3   c                ó.  — t          |t          ¦  «        rN| j        |j        us@| j        |j        k    s0| j        |j        k    s | j        |j        k    s| j        |j        k    rdS t          | j        |j        ¦  «        D �]\  }}t          |t          j
        ¦  «        rt          j        ||¦  «        rŒ6n||k    rŒ>	 t          j        |¦  «        }t          j        |¦  «        }t          j        |¦  «        t          j        |¦  «        k    rt          j        ||t          d¬¦  «        rŒ¯n# t           t"          f$ r Y nw xY w	 t          j        t'          |¦  «        t'          |¦  «        t          d¬¦  «        r�Œn# t"          $ r Y nw xY w dS dS )zìTwo instructions are the same if they have the same name,
        same dimensions, and same params.

        Args:
            other (instruction): other instruction

        Returns:
            bool: are self and other equal.
        Fr   )ÚatolÚrtolT)r   r   r9   r+   r,   r-   Ú
definitionr   r)   ÚnumpyÚndarrayÚarray_equalÚasarrayÚshapeÚallcloseÚ_CUTOFF_PRECISIONÚ
ValueErrorr!   ÚiscloseÚfloat)r*   ÚotherÚ
self_paramÚother_paramÚself_asarrayÚother_asarrays         r1   Ú__eq__zInstruction.__eq__Â   sÐ  € õ ˜5¥+Ñ.Ô.ð	àŒ eÔ&6Ð6Ð6ØŒy˜EœJÒ&Ð&ØŒ %Ô"2Ò2Ð2ØŒ %Ô"2Ò2Ð2ØŒ %Ô"2Ò2Ð2à�5å'2°4´;ÀÄÑ'MÔ'Mð 	ñ 	Ñ#ˆJ˜Ý˜*¥e¤mÑ4Ô4ð ÝÔ$ Z°Ñ=Ô=ð Øðð  Ò,Ð,ØðÝ$œ}¨ZÑ8Ô8�Ý %¤¨kÑ :Ô :�Ý”;˜|Ñ,Ô,µ´¸MÑ0JÔ0JÒJÐJÍuÌ~Ø Õ2CÈ!ðPñ Pô PÐJð øøÝ¥	Ð*ð ð ð Ø�ðøøøðÝ”=Ý˜*Ñ%Ô%¥u¨[Ñ'9Ô'9Õ@QÐXYðñ ô ð ñ ðøõ ð ð ð Ø�ðøøøð �5�5àˆts%   Â?A/D0Ä0EÅEÅ7FÆ
FÆFr    c           	     óH   — d| j         › d| j        › d| j        › d| j        › d�	S )zëGenerates a representation of the Instruction object instance
        Returns:
            str: A representation of the Instruction instance with the name,
                 number of qubits, classical bits and params( if any )
        zInstruction(name='z', num_qubits=z, num_clbits=z	, params=ú)©r+   r,   r-   r)   r8   s    r1   Ú__repr__zInstruction.__repr__ô   sU   € ðC ¤ð Cð C¸$¼/ð Cð CØœ/ðCð CØ48´KðCð Cð Cð	
r3   rW   ú'Instruction'c                ó®  — | j         |j         k    sJ| j        |j        k    s:| j        |j        k    s*t          | j        ¦  «        t          |j        ¦  «        k    rdS t          | j        |j        ¦  «        D ]Ý\  }}t          |t          ¦  «        st          |t          ¦  «        rŒ0t          |t          j	        ¦  «        rbt          |t          j	        ¦  «        rHt          j
        |¦  «        t          j
        |¦  «        k    rt          j        ||t          ¬¦  «        rŒ«n/	 t          j        ||t          ¬¦  «        rŒÊn# t          $ r Y nw xY w dS dS )a®  
        Soft comparison between gates. Their names, number of qubits, and classical
        bit numbers must match. The number of parameters must match. Each parameter
        is compared. If one is a ParameterExpression then it is not taken into
        account.

        Args:
            other (instruction): other instruction.

        Returns:
            bool: are self and other equal up to parameter expressions.
        F)rJ   T)r+   r,   r-   Úlenr)   r   r   r   rM   rN   rQ   rR   rS   rU   r!   )r*   rW   rX   rY   s       r1   Úsoft_comparezInstruction.soft_compareÿ   sl  € ð ŒI˜œÒ#Ð#ØŒ %Ô"2Ò2Ð2ØŒ %Ô"2Ò2Ð2Ý�4”;ÑÔ¥3 u¤|Ñ#4Ô#4Ò4Ð4à�5å'2°4´;ÀÄÑ'MÔ'Mð 	ð 	Ñ#ˆJ˜Ý˜*Õ&9Ñ:Ô:ð ½jØÕ0ñ?ô ?ð ð Ý˜*¥e¤mÑ4Ô4ð 
½ÀKÕQVÔQ^Ñ9_Ô9_ð 
Ý”;˜zÑ*Ô*­e¬k¸+Ñ.FÔ.FÒFÐFÍ5Ì>Ø Õ2CðLñ Lô LÐFð øðÝ”} Z°ÕCTÐUÑUÔUð !Ø ð!øå ð ð ð Ø�Dðøøøð �5�5àˆts   Ä$EÅ
EÅEc                ó   — dS )a‡  Populate the cached :attr:`_definition` field of this :class:`Instruction`.

        Subclasses should implement this method to provide lazy construction of their public
        :attr:`definition` attribute.  A subclass can use its :attr:`params` at the time of the
        call.  The method should populate :attr:`_definition` with a :class:`.QuantumCircuit` and
        not return a value.Nr<   r8   s    r1   Ú_definezInstruction._define)  s	   € ð 	ˆr3   c                ó   — | j         S )zPThe parameters of this :class:`Instruction`.  Ideally these will be gate angles.)r   r8   s    r1   r)   zInstruction.params2  s   € ð Œ|Ðr3   c                óØ   — g | _         |D ]_}t          |t          ¦  «        r| j                              |¦  «         Œ2| j                              |                      |¦  «        ¦  «         Œ`d S rH   )r   r   r   ÚappendÚvalidate_parameter)r*   Ú
parametersÚsingle_params      r1   r)   zInstruction.params7  sz   € àˆŒØ&ð 	Kð 	KˆLÝ˜,Õ(;Ñ<Ô<ð KØ”×#Ò# LÑ1Ô1Ð1Ð1à”×#Ò# D×$;Ò$;¸LÑ$IÔ$IÑJÔJÐJÐJð		Kð 	Kr3   c                ó   — |S )z:Instruction parameters has no validation or normalization.r<   )r*   Ú	parameters     r1   rj   zInstruction.validate_parameter@  s   € àÐr3   c                ó>   — t          d„ | j        D ¦   «         ¦  «        S )zzReturn whether the :class:`Instruction` contains :ref:`compile-time parameters
        <circuit-compile-time-parameters>`.c              3  óN   K  — | ] }t          |t          ¦  «        o|j        V — Œ!d S rH   )r   r   rk   )Ú.0Úparams     r1   ú	<genexpr>z/Instruction.is_parameterized.<locals>.<genexpr>G  sF   è è € ð 
ð 
ØLQ�J�uÕ1Ñ2Ô2ÐG°uÔ7Gð
ð 
ð 
ð 
ð 
ð 
r3   )Úanyr   r8   s    r1   Úis_parameterizedzInstruction.is_parameterizedD  s5   € õ ð 
ð 
ØUYÔUað
ñ 
ô 
ñ 
ô 
ð 	
r3   c                óF   — | j         €|                      ¦   «          | j         S )z0Return definition in terms of other basic gates.)r#   rf   r8   s    r1   rL   zInstruction.definitionK  s#   € ð ÔÐ#Ø�LŠL‰NŒNˆNØÔÐr3   c                ó   — || _         dS )zSet gate representationN)r#   )r*   Úarrays     r1   rL   zInstruction.definitionR  s   € ð !ˆÔÐÐr3   c                ó8   — ddl m} |                     | ¦  «        S )zMGet the decompositions of the instruction from the SessionEquivalenceLibrary.r   ©ÚSessionEquivalenceLibrary)Ú"qiskit.circuit.equivalence_libraryr{   Ú	get_entry)r*   Úsels     r1   ÚdecompositionszInstruction.decompositionsW  s)   € ð 	XÐWÐWÐWÐWÐWà�}Š}˜TÑ"Ô"Ð"r3   c                ó>   — ddl m} |                     | |¦  «         dS )zMSet the decompositions of the instruction from the SessionEquivalenceLibrary.r   rz   N)r|   r{   Ú	set_entry)r*   r   r~   s      r1   r   zInstruction.decompositions_  s1   € ð 	XÐWÐWÐWÐWÐWà�Š�d˜NÑ+Ô+Ð+Ð+Ð+r3   c                ó>   — ddl m} |                     | |¦  «         dS )zHAdd a decomposition of the instruction to the SessionEquivalenceLibrary.r   rz   N)r|   r{   Úadd_equivalence)r*   Údecompositionr~   s      r1   Úadd_decompositionzInstruction.add_decompositiong  s3   € ð 	XÐWÐWÐWÐWÐWà×Ò˜D -Ñ0Ô0Ð0Ð0Ð0r3   zin Qiskit 2.0.0c                ó   — | j         S )zGet the duration.©r'   r8   s    r1   r.   zInstruction.durationn  s   € ð Œ~Ðr3   c                ó   — || _         dS )zSet the duration.Nr‡   ©r*   Úvalues     r1   r.   zInstruction.durationt  s   € ð ˆŒˆˆr3   c                ó   — | j         S )zGet the time unit of duration.©r(   r8   s    r1   r/   zInstruction.unity  s   € ð ŒzÐr3   c                ó   — || _         dS )zSet the time unit of duration.NrŒ   r‰   s     r1   r/   zInstruction.unit  s   € ð ˆŒ
ˆ
ˆ
r3   z1.2zin the 2.0 releasezÿThe `Qobj` class and related functionality are part of the deprecated `BackendV1` workflow,  and no longer necessary for `BackendV2`. If a user workflow requires `Qobj` it likely relies on deprecated functionality and should be updated to use `BackendV2`.)rA   rB   Úadditional_msgc                ó*   — |                       ¦   «         S )zAssemble a QasmQobjInstruction)Ú	_assembler8   s    r1   ÚassemblezInstruction.assemble„  s   € ð �~Š~ÑÔÐr3   c                óü  — t          j        ¦   «         5  t          j        dt          d¬¦  «         t	          | j        ¬¦  «        }d d d ¦  «         n# 1 swxY w Y   | j        rd„ | j        D ¦   «         }||_        | j        r&t          t          | j        ¦  «        ¦  «        |_
        | j        r&t          t          | j        ¦  «        ¦  «        |_        | j        r| j        |_        | j        r| j        |_        |S )NÚignoreÚqiskit)ÚcategoryÚmodule©r+   c                ó\   — g | ])}t          |d ¦  «        r|                     |¦  «        n|‘Œ*S )Úevalf)r   r™   )rq   Úxs     r1   ú
<listcomp>z)Instruction._assemble.<locals>.<listcomp>—  s5   € ÐTÐTÐTÀ1¥G¨A¨wÑ$7Ô$7Ð>�a—g’g˜a‘j”j�j¸QÐTÐTÐTr3   )r$   Úcatch_warningsÚfilterwarningsr&   r
   r+   r)   r,   ÚlistÚrangeÚqubitsr-   Úmemoryr0   r"   )r*   Úinstructionr)   s      r1   r�   zInstruction._assemble�  s3  € ÝÔ$Ñ&Ô&ð 	>ð 	>åÔ# HÕ7IÐRZÐ[Ñ[Ô[Ð[Ý-°4´9Ð=Ñ=Ô=ˆKð	>ð 	>ð 	>ñ 	>ô 	>ð 	>ð 	>ð 	>ð 	>ð 	>ð 	>øøøð 	>ð 	>ð 	>ð 	>ð
 Œ;ð 	(ØTÐTÈÌÐTÑTÔTˆFØ!'ˆKÔàŒ?ð 	>Ý!%¥e¨D¬OÑ&<Ô&<Ñ!=Ô!=ˆKÔØŒ?ð 	>Ý!%¥e¨D¬OÑ&<Ô&<Ñ!=Ô!=ˆKÔàŒ:ð 	+Ø $¤
ˆKÔð Œ?ð 	5Ø%)¤_ˆKÔ"ØÐs   ”2AÁAÁAc                ó   — | j         S )zReturn instruction label)r   r8   s    r1   r0   zInstruction.label¨  s   € ð Œ{Ðr3   r+   c                óz   — t          |t          t          d¦  «        f¦  «        r	|| _        dS t	          d¦  «        ‚)zµSet instruction label to name

        Args:
            name (str or None): label to assign instruction

        Raises:
            TypeError: name is not string or None.
        Nr   )r   r    r7   r   r!   ©r*   r+   s     r1   r0   zInstruction.label­  s;   € õ �d�S¥$ t¡*¤*Ð-Ñ.Ô.ð 	>ØˆDŒKˆKˆKåÐ<Ñ=Ô=Ð=r3   c                ód  — | j         r| j        s|                      ¦   «         S |                      | j        dz   ¬¦  «        }| j                              ¦   «         }t          | j         ¦  «        D ]:}|                     |j                             ¦   «         |j	        |j
        ¦  «         Œ;||_        |S )a2  For a composite instruction, reverse the order of sub-instructions.

        This is done by recursively reversing all sub-instructions.
        It does not invert any gate.

        Returns:
            qiskit.circuit.Instruction: a new instruction with
                sub-instructions reversed.
        Ú_reverser—   )r#   r=   r?   r+   Úcopy_empty_likeÚreversedri   Ú	operationÚreverse_opsr    ÚclbitsrL   )r*   Úreverse_instÚreversed_definitionÚinsts       r1   r«   zInstruction.reverse_ops¼  s®   € ð  Ôð 	 t¤|ð 	Ø—9’9‘;”;Ðà—y’y d¤i°*Ñ&<�yÑ=Ô=ˆØ"Ô.×>Ò>Ñ@Ô@ÐÝ˜TÔ-Ñ.Ô.ð 	_ð 	_ˆDØ×&Ò& t¤~×'AÒ'AÑ'CÔ'CÀTÄ[ÐRVÔR]Ñ^Ô^Ð^Ð^Ø"5ˆÔØÐr3   Ú	annotatedc                ó¸  — |rt          | t          ¦   «         ¦  «        S | j        €t          d| j        › d�¦  «        ‚ddlm} | j                             d¦  «        r| j        dd…         }n
| j        dz   }| j        r5t          || j
        | j        | j                             ¦   «         ¬¦  «        }n* ||| j
        | j                             ¦   «         ¬	¦  «        }| j                             ¦   «         }|j         |_        t!          | j        ¦  «        D ]:}|                     |j                             ¦   «         |j        |j        ¦  «         Œ;||_        |S )
a.  Invert this instruction.

        If `annotated` is `False`, the inverse instruction is implemented as
        a fresh instruction with the recursively inverted definition.

        If `annotated` is `True`, the inverse instruction is implemented as
        :class:`.AnnotatedOperation`, and corresponds to the given instruction
        annotated with the "inverse modifier".

        Special instructions inheriting from Instruction can
        implement their own inverse (e.g. T and Tdg, Barrier, etc.)
        In particular, they can choose how to handle the argument ``annotated``
        which may include ignoring it and always returning a concrete gate class
        if the inverse is defined as a standard gate.

        Args:
            annotated: if set to `True` the output inverse gate will be returned
                as :class:`.AnnotatedOperation`.

        Returns:
            The inverse operation.

        Raises:
            CircuitError: if the instruction is not composite
                and an inverse has not been implemented for it.
        Nzinverse() not implemented for ú.r   )ÚGateÚ_dgéýÿÿÿr_   )r+   r,   r)   )r   r   rL   r   r+   Úqiskit.circuitr³   Úendswithr-   r   r,   r)   r?   r#   r¨   Úglobal_phaser©   Ú_appendrª   Úinverser    r¬   )r*   r°   r³   r+   Úinverse_gateÚinverse_definitionr¯   s          r1   rº   zInstruction.inverseÖ  so  € ð6 ð 	?Ý% d­OÑ,=Ô,=Ñ>Ô>Ð>àŒ?Ð"ÝÐLÀÄ	ÐLÐLÐLÑMÔMÐMà'Ð'Ð'Ð'Ð'Ð'àŒ9×Ò˜eÑ$Ô$ð 	%Ø”9˜S˜b˜S”>ˆDˆDà”9˜uÑ$ˆDØŒ?ð 		bÝ&ØØœ?Øœ?Ø”{×'Ò'Ñ)Ô)ð	ñ ô ˆLˆLð  ˜4 T°d´oÈdÌk×N^ÒN^ÑN`ÔN`ÐaÑaÔaˆLà!Ô-×=Ò=Ñ?Ô?ÐØ+=Ô+JÐ*JÐÔ'Ý˜TÔ-Ñ.Ô.ð 	[ð 	[ˆDØ×&Ò& t¤~×'=Ò'=Ñ'?Ô'?ÀÄÈdÌkÑZÔZÐZÐZØ"4ˆÔØÐr3   )rA   rB   c                óà   — t          |t          t          f¦  «        st          d¦  «        ‚|dk     rt          d¦  «        ‚t          |t          ¦  «        rt	          |¦  «        }||f| _        | S )aD  Set a classical equality condition on this instruction between the register or cbit
        ``classical`` and value ``val``.

        .. note::

            This is a setter method, not an additive one.  Calling this multiple times will silently
            override any previously set condition; it does not stack.
        z<c_if must be used with a classical register or classical bitr   z&condition value should be non-negative)r   r   r	   r   r:   r"   )r*   Ú	classicalÚvals      r1   Úc_ifzInstruction.c_if  st   € õ ˜)Õ&7½Ð%?Ñ@Ô@ð 	_ÝÐ]Ñ^Ô^Ð^Ø�Š7ˆ7ÝÐGÑHÔHÐHÝ�i¥Ñ'Ô'ð 	õ �s‘)”)ˆCØ$ cÐ*ˆŒØˆr3   c                ó@   — |                       ¦   «         }|r||_        |S )a5  
        Copy of the instruction.

        Args:
            name (str): name to be given to the copied circuit, if ``None`` then the name stays the same.

        Returns:
            qiskit.circuit.Instruction: a copy of the current instruction, with the name updated if it
            was provided
        )Ú__deepcopy__r+   )r*   r+   Úcpys      r1   r?   zInstruction.copy$  s)   € ð ×ÒÑ!Ô!ˆàð 	ØˆCŒHØˆ
r3   c                ó¶   — t          j         | ¦  «        }t          j         | j        ¦  «        |_        | j        rt          j        | j        |¦  «        |_        |S rH   )r?   r   r#   Údeepcopy)r*   ÚmemorÃ   s      r1   rÂ   zInstruction.__deepcopy__5  sI   € ÝŒi˜‰oŒoˆÝ”i ¤Ñ-Ô-ˆŒØÔð 	DÝ"œm¨DÔ,<¸dÑCÔCˆCŒOØˆ
r3   c              #  óF  K  — t          |¦  «        | j        k    r(t          dt          |¦  «        › d| j        › d�¦  «        ‚t          |¦  «        | j        k    r(t          dt          |¦  «        › d| j        › d�¦  «        ‚d„ |D ¦   «         }d„ |D ¦   «         }||fV — dS )a   
        Validation of the arguments.

        Args:
            qargs (List): List of quantum bit arguments.
            cargs (List): List of classical bit arguments.

        Yields:
            Tuple(List, List): A tuple with single arguments.

        Raises:
            CircuitError: If the input is not valid. For example, the number of
                arguments does not match the gate expectation.
        zThe amount of qubit arguments z- does not match the instruction expectation (z).zThe amount of clbit arguments c                ó   — g | ]	}|D ]}|‘ŒŒ
S r<   r<   )rq   ÚsublistÚqargs      r1   r›   z3Instruction.broadcast_arguments.<locals>.<listcomp>W  ó%   € ÐDÐDÐD˜w¸GÐDÐD°D�dÐDÐDÐDÐDr3   c                ó   — g | ]	}|D ]}|‘ŒŒ
S r<   r<   )rq   rÉ   Úcargs      r1   r›   z3Instruction.broadcast_arguments.<locals>.<listcomp>X  rË   r3   N)rc   r,   r   r-   )r*   ÚqargsÚcargsÚ
flat_qargsÚ
flat_cargss        r1   Úbroadcast_argumentszInstruction.broadcast_arguments<  sö   è è € õ ˆu‰:Œ:˜œÒ(Ð(ÝðEµ°U±´ð Eð EØ15´ðEð Eð Eñô ð õ ˆu‰:Œ:˜œÒ(Ð(ÝðEµ°U±´ð Eð EØ15´ðEð Eð Eñô ð ð EÐD¨%ÐDÑDÔDˆ
ØDÐD¨%ÐDÑDÔDˆ
Ø˜*Ð$Ð$Ð$Ð$Ð$Ð$r3   c                óZ   — t          | j        › d|› �| j        | j        | j        ¬¦  «        S )NÚ*r_   )r   r+   r,   r-   r)   )r*   Úexponents     r1   Ú_return_repeatzInstruction._return_repeat[  s;   € ÝØ”IÐ*Ð* Ð*Ð*Ø”Ø”Ø”;ð	
ñ 
ô 
ð 	
r3   c                ó0  — t          |¦  «        |k    s|dk     rt          d¦  «        ‚t          |¦  «        }|                      |¦  «        }|j        €¬ddlm}m}  || j        | j        ¦  «        }t          |j
        ¦  «        }t          |j        ¦  «        }|                      ¦   «         }| j        r|                     ¦   «         }d|_        dg|z  D ]"}	|                      ||||¦  «        ¦  «         Œ#||_        | j        r |j        | j        Ž }|S )aÈ  Creates an instruction with ``self`` repeated :math`n` times.

        If this operation has a conditional, the output instruction will have the same conditional
        and the inner repeated operations will be unconditional; instructions within a compound
        definition cannot be conditioned on registers within Qiskit's data model.  This means that
        it is not valid to apply a repeated instruction to a clbit that it both writes to and reads
        from in its condition.

        Args:
            n (int): Number of times to repeat the instruction

        Returns:
            qiskit.circuit.Instruction: Containing the definition.

        Raises:
            CircuitError: If n < 1.
        é   z9Repeat can only be called with strictly positive integer.Nr   )ÚQuantumCircuitÚCircuitInstruction)r   r   rÖ   rL   r¶   rÙ   rÚ   r,   r-   Útupler    r¬   r?   r"   r@   rF   r¹   rÀ   )
r*   Únr¢   rÙ   rÚ   ÚqcrÎ   rÏ   ÚbaseÚ_s
             r1   ÚrepeatzInstruction.repeatc  s.  € õ$ ˆq‰6Œ6�QŠ;ˆ;˜!˜aš%˜%ÝÐZÑ[Ô[Ð[å�‰FŒFˆà×)Ò)¨!Ñ,Ô,ˆØÔ!Ð)àIÐIÐIÐIÐIÐIÐIÐIà� ¤°´ÑAÔAˆBÝ˜"œ)Ñ$Ô$ˆEÝ˜"œ)Ñ$Ô$ˆEØ—9’9‘;”;ˆDØŒð &à—’Ñ(Ô(�Ø!%�”Ø�V˜a‘Zð Cð C�Ø—
’
Ð-Ð-¨d°E¸5ÑAÔAÑBÔBÐBÐBà%'ˆKÔ"ØŒ?ð 	=Ø*˜+Ô*¨D¬OÐ<ˆKØÐr3   úList[Clbit]c                ód   — ddl m} | j        €g S t           || j        ¦  «        j        ¦  «        S )zGet Clbits in condition.r   )Úcondition_resources)Úqiskit.circuit.controlflowrã   r"   rž   r¬   )r*   rã   s     r1   Úcondition_bitszInstruction.condition_bits�  sC   € ð 	CÐBÐBÐBÐBÐBàŒ?Ð"ØˆIÝÐ'Ð'¨¬Ñ8Ô8Ô?Ñ@Ô@Ð@r3   c                ó   — | j         S )zReturn the name.©r   r8   s    r1   r+   zInstruction.name™  s   € ð ŒzÐr3   c                ó   — || _         dS )zSet the name.Nrç   r¥   s     r1   r+   zInstruction.namež  s   € ð ˆŒ
ˆ
ˆ
r3   c                ó   — | j         S )zReturn the number of qubits.©r   r8   s    r1   r,   zInstruction.num_qubits£  ó   € ð ÔÐr3   c                ó   — || _         dS )zSet num_qubits.Nrê   )r*   r,   s     r1   r,   zInstruction.num_qubits¨  ó   € ð &ˆÔÐÐr3   c                ó   — | j         S )zReturn the number of clbits.©r   r8   s    r1   r-   zInstruction.num_clbits­  rë   r3   c                ó   — || _         dS )zSet num_clbits.Nrï   )r*   r-   s     r1   r-   zInstruction.num_clbits²  rí   r3   c                ó²   — t          | j        |j        ¦  «        D ];\  }}	 t          j        ||dd¬¦  «        s dS Œ"# t          $ r ||k    rY  dS Y Œ8w xY wdS )Nr   r   )Úrel_tolÚabs_tolFT)Úzipr)   ÚmathrU   r!   )r*   rW   rš   Úys       r1   Ú_compare_parameterszInstruction._compare_parameters·  sŠ   € Ý˜œ U¤\Ñ2Ô2ð 	!ð 	!‰DˆAˆqð!Ý”| A q°!¸UÐCÑCÔCð !Ø ˜5˜5ð!øåð !ð !ð !Ø˜’6�6Ø ˜5˜5˜5ð �6ð!øøøð ˆts   ¡=½AÁA)Nr   N)r4   r5   )r4   r:   )r4   r    )rW   ra   r4   r:   )r+   r    )F)r°   r:   rH   )r4   rá   )*Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
_directiveÚ_standard_gater2   Úpropertyr9   r=   r@   r   rF   Úsetterr\   r`   rd   rf   r)   rj   ru   rL   r   r…   r.   r/   r‘   r�   r0   r«   rº   rÀ   r?   rÂ   rÒ   rÖ   rà   rå   r+   r,   r-   r÷   r<   r3   r1   r   r   8   sé  € € € € € Ø&Ð&ð €JØ€NðCð Cð Cð CðJ ðð ð ñ „Xðð> ðð ð ñ „Xððð ð ð Ø€^˜'°JÈDÐQÑQÔQðð ñ RÔQñ „Xðð Ôð$ð $ñ Ôð$ð0ð 0ð 0ðd	
ð 	
ð 	
ð 	
ð(ð (ð (ð (ðTð ð ð ðð ñ „Xðð „]ðKð Kñ „]ðKðð ð ð
ð 
ð 
ð ð ð  ñ „Xð ð Ôð!ð !ñ Ôð!ð ð#ð #ñ „Xð#ð Ôð,ð ,ñ Ôð,ð1ð 1ð 1ð Ø€^˜'Ð4EÐSWÐXÑXÔXðð ñ YÔXñ „Xðð „_ðð ñ „_ðð Ø€^˜'Ð4EÐSWÐXÑXÔXðð ñ YÔXñ „Xðð 
„[ðð ñ „[ðð €^ØØ-ð0ðñ ô ð ð  ñô ð ðð ð ð0 ðð ð ñ „Xðð „\ð>ð >ð >ñ „\ð>ðð ð ð47ð 7ð 7ð 7ð 7ðr €^˜'°JÐ?Ñ?Ô?ðð ñ @Ô?ðð(ð ð ð ð"ð ð ð ð%ð %ð %ð>
ð 
ð 
ð*ð *ð *ðX Ø€^˜'°JÈDÐQÑQÔQðAð Að Añ RÔQñ „XðAð ðð ñ „Xðð 
„[ðð ñ „[ðð ð ð  ñ „Xð ð Ôð&ð &ñ Ôð&ð ð ð  ñ „Xð ð Ôð&ð &ñ Ôð&ðð ð ð ð r3   r   )rû   Ú
__future__r   r?   r$   Ú	itertoolsr   rõ   Útypingr   r   rM   Úqiskit.circuit.exceptionsr   Ú qiskit.circuit.classicalregisterr   r	   Úqiskit.qobj.qasm_qobjr
   Úqiskit.circuit.parameterr   Úqiskit.circuit.operationr   Ú"qiskit.circuit.annotated_operationr   r   Úqiskit.utilsr   rS   r   r<   r3   r1   ú<module>r
     s?  ððð ð* #Ð "Ð "Ð "Ð "Ð "à €€€Ø €€€Ø !Ð !Ð !Ð !Ð !Ð !Ø €€€Ø Ð Ð Ð Ð Ð Ð Ð à €€€à 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø EÐ EÐ EÐ EÐ EÐ EÐ EÐ EØ 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø .Ð .Ð .Ð .Ð .Ð .à RÐ RÐ RÐ RÐ RÐ RÐ RÐ RØ 'Ð 'Ð 'Ð 'Ð 'Ð 'àÐ ðG
ð G
ð G
ð G
ð G
�)ñ G
ô G
ð G
ð G
ð G
r3   