§
    ¹³Ùg`‡ ã            	      ó´  — d Z ddlmZ ddlZddlZddlZddlZ	ddl
Z
ddlmZmZmZ ddl
mZmZmZmZmZmZmZmZmZmZmZmZmZ ddl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) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5m6Z6 ddl7m8Z8m9Z9 ddl:m;Z;m<Z< ddl=m>Z>m?Z? ddl@mAZAmBZB ddlCmDZDmEZE ddlFmGZGmHZH ddlImJZJmKZK ddlLmMZMmNZN ddlOmPZPmQZQ ddlRmSZSmTZTmUZUmVZV ddlWmXZXmYZY ddlZm[Z[ dd l\m]Z] dd!l^m_Z_ dd"l`maZa dd#lbmcZc dd$ldmeZe dd%lfmgZgmhZh dd&limjZj dd'lkmlZl e
jm        rddlnZndd(lompZp dd)lqmrZr dd*lsmtZt  ed+d,¦  «        Zu ed-¦  «        Zv ed.¦  «        ZweeTeSexeyeeeTexf                  f         ZzeeYeXexeyeeeYexf                  f         Z{ ed/eTeY¦  «        Z| G d0„ d1¦  «        Z} G d2„ d3e8¦  «        Z~d>d9„Zd?d;„Z€d<„ Z�d=„ Z‚dS )@zQuantum circuit object.é    )ÚannotationsN)ÚOrderedDictÚdefaultdictÚ
namedtuple)ÚUnionÚOptionalÚTupleÚTypeÚTypeVarÚSequenceÚCallableÚMappingÚIterableÚAnyÚDefaultDictÚLiteralÚoverload)ÚCircuitData)ÚStandardGate)Úcompute_estimated_duration)ÚQiskitError)Úis_main_process)ÚInstruction)ÚGate)Ú	Parameter)ÚCircuitError)Údeprecate_func)Údeprecate_pulse_dependencyé   )Ú_classical_resource_map)ÚControlFlowOpÚ_builder_utils)ÚCircuitScopeInterfaceÚControlFlowBuilderBlock)ÚBreakLoopOpÚBreakLoopPlaceholder)ÚContinueLoopOpÚContinueLoopPlaceholder)Ú	ForLoopOpÚForLoopContext)ÚIfElseOpÚ	IfContext)ÚSwitchCaseOpÚSwitchContext)ÚWhileLoopOpÚWhileLoopContext)ÚexprÚtypes)ÚParameterExpressionÚParameterValueType)ÚQuantumRegisterÚQubitÚAncillaRegisterÚAncillaQubit)ÚClassicalRegisterÚClbit)ÚParameterView)ÚParameterVector)ÚInstructionSet)Ú	Operation)ÚRegister)ÚBit)ÚQuantumCircuitDataÚCircuitInstruction)ÚDelay)ÚStore)ÚTranspileLayout)ÚBaseOperator)ÚStatevectorÚBitLocations)ÚindexÚ	registersÚSÚTÚBitTypec                  ó<  — e Zd ZdZdZdZdddddddœ�dÜd„Ze eddd¬¦  «        d„ ¦   «         ¦   «         Z	e	j
        �dÝd„¦   «         Z	e eddd¬¦  «        d„ ¦   «         ¦   «         Zej
        d„ ¦   «         Ze	 �dÞ�dßd&„¦   «         Zedddddd'œ�dàd/„¦   «         Ze�dád1„¦   «         Ze�dâd3„¦   «         Zej
        �dãd6„¦   «         Ze�däd8„¦   «         Ze ed¬9¦  «        �dåd;„¦   «         ¦   «         Zej
         ed¬9¦  «        �dæd=„¦   «         ¦   «         Ze�dåd>„¦   «         Zej
        �dæd?„¦   «         Ze�dçdB„¦   «         Z�dçdC„Ze�dådD„¦   «         Zej
        �dèdE„¦   «         Z�dédG„Z�dêdH„Z�dëdI„ZedJ„ ¦   «         Ze edKdLdM¬N¦  «        �dìdP„¦   «         ¦   «         Ze�dìdQ„¦   «         Ze edKdLdM¬N¦  «        �dédR„¦   «         ¦   «         Ze�dédS„¦   «         Z �dídU„Z!�dîdX„Z"�dïdY„Z#�dïdZ„Z$�dð�dñd\„Z%dd]œ�dòd`„Z&	 �dó�dôdd„Z'	 	 	 	 �dõ�dödj„Z(	 	 	 	 	 �d÷ddddkœ�dødx„Z)�dð�dùdy„Z*e�dúd{„¦   «         Z+e�dûd}„¦   «         Z,e�düd„¦   «         Z-e�dìd€„¦   «         Z.e�dìd�„¦   «         Z/e�dìd‚„¦   «         Z0e�dìdƒ„¦   «         Z1�dýd…„Z2�dýd†„Z3�dýd‡„Z4�dýdˆ„Z5�dþdŠ„Z6�dþd‹„Z7�dÿd�„Z8�dÿdŽ„Z9�dìd�„Z:e;j<        �d d’„¦   «         Z=e;j<        �dd•„¦   «         Z=d–„ Z=e edKdLdM¬N¦  «        �dd›„¦   «         ¦   «         Z>e�ddœ„¦   «         Z? edKdLdM¬N¦  «        �ddŸ„¦   «         Z@�dd „ZA edKdLdM¬N¦  «        �dd£„¦   «         ZB�dd¤„ZC	 	 	 �d�dd¬„ZD	 	 �ddd­œ�dd²„ZEe;j<        �d	d´„¦   «         ZFe;j<        �d
d¸„¦   «         ZF�ddd¹œ�ddº„ZFe;j<        �dd¾„¦   «         ZGe;j<        �d�ddÂ„¦   «         ZG�d�ddÄ„ZG�ddÇ„ZHe;j<        �ddÉ„¦   «         ZIe;j<        �d�ddË„¦   «         ZI�d�ddÌ„ZI�ddÏ„ZJ�ddÑ„ZK�ddÓ„ZL�ddÕ„ZM�ddÖ„ZNe;j<        �ddØ„¦   «         ZOe;j<        �dë�ddÙ„¦   «         ZO	 �dë�ddÚ„ZO�ddÛ„ZP�ddÞ„ZQ�ddá„ZR�ddå„ZS�ddæ„ZT	 	 �d�d dê„ZU	 	 �d�d!dì„ZV	 	 �d"�d#dï„ZW	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 �d$�d%�d	„ZX�d
„ f�d&�d„ZY�d„ f�d'�d„ZZ�dì�d„Z[e�dì�d„¦   «         Z\e�dì�d„¦   «         Z]e�dì�d„¦   «         Z^�d(�d„Z_�dì�d„Z`�d)�d„Za�dð�d*�d„Zb�dì�d„Zc�dì�d„Zd�dë�d+�d„Ze	 �dë�d�dœ�d,�d"„Zf�dí�d#„Zg�d-�d&„Zh�d.�d'„Zi�d/�d)„Zj�d0�d,„Zk�d1�d.„Zl�d2�d3�d/„Zm	 �d4�d5�d1„Zn�d2�d3�d2„Zoe�d6�d4„¦   «         Zpe�d7�d6„¦   «         Zqe�d8�d7„¦   «         Zrerj
        �d9�d9„¦   «         Zre�d:�d;„¦   «         Zse�dì�d<„¦   «         Zt�d;�d>„Zue<	 �dd¿d¿�d?œ�d<�dE„¦   «         Zve<	 �dd¿d¿�d?œ�d=�dG„¦   «         Zv	 �dðdd�d?œ�d>�dH„Zv�d?�dK„Zwd�dLœ�d@�dM„Zx	 	 �dA�dB�dS„Zy�d/�dT„Zz	 	 �d�dC�dW„Z{�d/�dX„Z|�dD�dZ„Z}�dE�d[„Z~	 	 �d�dF�d\„Z	 �dë�dG�d_„Z€�dH�da„Z��dI�de„Z‚�dJ�dh„Zƒ�dK�dj„Z„	 �dë�dL�dk„Z…	 	 �d�dF�dl„Z†�dM�do„Z‡	 �dë�dL�dp„Zˆ	 	 �d�dF�dq„Z‰�dM�dr„ZŠ�dN�ds„Z‹	 	 �d�dF�dt„ZŒ�dM�du„Z��dM�dv„ZŽ�dO�dw„Z��d/�dx„Z��d/�dy„Z‘	 	 �d�dC�dz„Z’	 	 �d�dC�d{„Z“�dO�d|„Z”�dO�d}„Z•	 	 �d�dP�d€„Z–�d/�d�„Z—�d/�d‚„Z˜	 	 �d�dC�dƒ„Z™�d/�d„„Zš�d/�d…„Z›�dQ�d†„Zœ	 	 �d�dR�dˆ„Z��dë�dS�d‰„Zž	 	 �d�dC�dŠ„ZŸ�dO�d‹„Z 	 �dë�dT�dŒ„Z¡	 	 	 �dU�dV�d�„Z¢�d/�d‘„Z£	 	 �d�dC�d’„Z¤�d/�d“„Z¥	 	 �d�dC�d”„Z¦	 	 �d�dW�d•„Z§�dX�d—„Z¨	 	 	 �dY�dZ�d›„Z©	 	 �d[�d\�dœ„Zª	 �dë�d]�dŸ„Z«�d^�d¡„Z¬	 	 	 	 	 �d_�d`�d§„Z­�da�d©„Z®�db�dª„Z¯�db�d«„Z°e;j<        �dc�d°„¦   «         Z±e;j<        �dd�d²„¦   «         Z±�ded�dLœ�d³„Z±e;j<        �df�d¹„¦   «         Z²e;j<        �dg�d»„¦   «         Z²	 �dhd�dLœ�d¼„Z²e;j<        �di�d¿„¦   «         Z³e;j<        d�dLœ�dj�dÁ„¦   «         Z³	 	 	 �ded�dLœ�dÂ„Z³	 �dë�dk�dÅ„Z´e;j<        �dl�dÊ„¦   «         Zµe;j<        �dm�dÌ„¦   «         Zµ�ded�dLœ�dÍ„Zµ�dn�dÎ„Z¶�dn�dÏ„Z·e	 �dë�do�dÔ„¦   «         Z¸�dp�dÖ„Z¹�dp�d×„Zº�dp�dØ„Z»�dq�dr�dÛ„Z¼dS (s  ÚQuantumCircuita?¤  Core Qiskit representation of a quantum circuit.

    .. note::
        For more details setting the :class:`QuantumCircuit` in context of all of the data
        structures that go with it, how it fits into the rest of the :mod:`qiskit` package, and the
        different regimes of quantum-circuit descriptions in Qiskit, see the module-level
        documentation of :mod:`qiskit.circuit`.

    Circuit attributes
    ==================

    :class:`QuantumCircuit` has a small number of public attributes, which are mostly older
    functionality.  Most of its functionality is accessed through methods.

    A small handful of the attributes are intentionally mutable, the rest are data attributes that
    should be considered immutable.

    ========================= ======================================================================
    Mutable attribute         Summary
    ========================= ======================================================================
    :attr:`global_phase`      The global phase of the circuit, measured in radians.
    :attr:`metadata`          Arbitrary user mapping, which Qiskit will preserve through the
                              transpiler, but otherwise completely ignore.
    :attr:`name`              An optional string name for the circuit.
    ========================= ======================================================================

    ========================= ======================================================================
    Immutable data attribute  Summary
    ========================= ======================================================================
    :attr:`ancillas`          List of :class:`AncillaQubit`\ s tracked by the circuit.
    :attr:`calibrations`      Custom user-supplied pulse calibrations for individual instructions.
    :attr:`cregs`             List of :class:`ClassicalRegister`\ s tracked by the circuit.

    :attr:`clbits`            List of :class:`Clbit`\ s tracked by the circuit.
    :attr:`data`              List of individual :class:`CircuitInstruction`\ s that make up the
                              circuit.
    :attr:`duration`          Total duration of the circuit, added by scheduling transpiler passes.
                              This attribute is deprecated and :meth:`.estimate_duration` should
                              be used instead.

    :attr:`layout`            Hardware layout and routing information added by the transpiler.
    :attr:`num_ancillas`      The number of ancilla qubits in the circuit.
    :attr:`num_clbits`        The number of clbits in the circuit.
    :attr:`num_captured_vars` Number of captured real-time classical variables.

    :attr:`num_declared_vars` Number of locally declared real-time classical variables in the outer
                              circuit scope.
    :attr:`num_input_vars`    Number of input real-time classical variables.
    :attr:`num_parameters`    Number of compile-time :class:`Parameter`\ s in the circuit.
    :attr:`num_qubits`        Number of qubits in the circuit.

    :attr:`num_vars`          Total number of real-time classical variables in the outer circuit
                              scope.
    :attr:`op_start_times`    Start times of scheduled operations, added by scheduling transpiler
                              passes.
    :attr:`parameters`        Ordered set-like view of the compile-time :class:`Parameter`\ s
                              tracked by the circuit.
    :attr:`qregs`             List of :class:`QuantumRegister`\ s tracked by the circuit.

    :attr:`qubits`            List of :class:`Qubit`\ s tracked by the circuit.
    :attr:`unit`              The unit of the :attr:`duration` field.
    ========================= ======================================================================

    The core attribute is :attr:`data`.  This is a sequence-like object that exposes the
    :class:`CircuitInstruction`\ s contained in an ordered form.  You generally should not mutate
    this object directly; :class:`QuantumCircuit` is only designed for append-only operations (which
    should use :meth:`append`).  Most operations that mutate circuits in place should be written as
    transpiler passes (:mod:`qiskit.transpiler`).

    .. autoattribute:: data

    Alongside the :attr:`data`, the :attr:`global_phase` of a circuit can have some impact on its
    output, if the circuit is used to describe a :class:`.Gate` that may be controlled.  This is
    measured in radians and is directly settable.

    .. autoattribute:: global_phase

    The :attr:`name` of a circuit becomes the name of the :class:`~.circuit.Instruction` or
    :class:`.Gate` resulting from :meth:`to_instruction` and :meth:`to_gate` calls, which can be
    handy for visualizations.

    .. autoattribute:: name

    You can attach arbitrary :attr:`metadata` to a circuit.  No part of core Qiskit will inspect
    this or change its behavior based on metadata, but it will be faithfully passed through the
    transpiler, so you can tag your circuits yourself.  When serializing a circuit with QPY (see
    :mod:`qiskit.qpy`), the metadata will be JSON-serialized and you may need to pass a custom
    serializer to handle non-JSON-compatible objects within it (see :func:`.qpy.dump` for more
    detail).  This field is ignored during export to OpenQASM 2 or 3.

    .. autoattribute:: metadata

    :class:`QuantumCircuit` exposes data attributes tracking its internal quantum and classical bits
    and registers.  These appear as Python :class:`list`\ s, but you should treat them as
    immutable; changing them will *at best* have no effect, and more likely will simply corrupt
    the internal data of the :class:`QuantumCircuit`.

    .. autoattribute:: qregs
    .. autoattribute:: cregs
    .. autoattribute:: qubits
    .. autoattribute:: ancillas
    .. autoattribute:: clbits

    The :ref:`compile-time parameters <circuit-compile-time-parameters>` present in instructions on
    the circuit are available in :attr:`parameters`.  This has a canonical order (mostly lexical,
    except in the case of :class:`.ParameterVector`), which matches the order that parameters will
    be assigned when using the list forms of :meth:`assign_parameters`, but also supports
    :class:`set`-like constant-time membership testing.

    .. autoattribute:: parameters

    The storage of any :ref:`manual pulse-level calibrations <circuit-calibrations>` for individual
    instructions on the circuit is in :attr:`calibrations`.  This presents as a :class:`dict`, but
    should not be mutated directly; use the methods discussed in :ref:`circuit-calibrations`.

    .. autoattribute:: calibrations

    If you have transpiled your circuit, so you have a physical circuit, you can inspect the
    :attr:`layout` attribute for information stored by the transpiler about how the virtual qubits
    of the source circuit map to the hardware qubits of your physical circuit, both at the start and
    end of the circuit.

    .. autoattribute:: layout

    If your circuit was also *scheduled* as part of a transpilation, it will expose the individual
    timings of each instruction, along with the total :attr:`duration` of the circuit.

    .. autoattribute:: duration
    .. autoattribute:: unit
    .. autoattribute:: op_start_times

    Finally, :class:`QuantumCircuit` exposes several simple properties as dynamic read-only numeric
    attributes.

    .. autoattribute:: num_ancillas
    .. autoattribute:: num_clbits
    .. autoattribute:: num_captured_vars
    .. autoattribute:: num_declared_vars
    .. autoattribute:: num_input_vars
    .. autoattribute:: num_parameters
    .. autoattribute:: num_qubits
    .. autoattribute:: num_vars

    Creating new circuits
    =====================

    =========================  =====================================================================
    Method                     Summary
    =========================  =====================================================================
    :meth:`__init__`           Default constructor of no-instruction circuits.
    :meth:`copy`               Make a complete copy of an existing circuit.
    :meth:`copy_empty_like`    Copy data objects from one circuit into a new one without any
                               instructions.
    :meth:`from_instructions`  Infer data objects needed from a list of instructions.
    :meth:`from_qasm_file`     Legacy interface to :func:`.qasm2.load`.
    :meth:`from_qasm_str`      Legacy interface to :func:`.qasm2.loads`.
    =========================  =====================================================================

    The default constructor (``QuantumCircuit(...)``) produces a circuit with no initial
    instructions. The arguments to the default constructor can be used to seed the circuit with
    quantum and classical data storage, and to provide a name, global phase and arbitrary metadata.
    All of these fields can be expanded later.

    .. automethod:: __init__

    If you have an existing circuit, you can produce a copy of it using :meth:`copy`, including all
    its instructions.  This is useful if you want to keep partial circuits while extending another,
    or to have a version you can mutate in-place while leaving the prior one intact.

    .. automethod:: copy

    Similarly, if you want a circuit that contains all the same data objects (bits, registers,
    variables, etc) but with none of the instructions, you can use :meth:`copy_empty_like`.  This is
    quite common when you want to build up a new layer of a circuit to then use apply onto the back
    with :meth:`compose`, or to do a full rewrite of a circuit's instructions.

    .. automethod:: copy_empty_like

    In some cases, it is most convenient to generate a list of :class:`.CircuitInstruction`\ s
    separately to an entire circuit context, and then to build a circuit from this.  The
    :meth:`from_instructions` constructor will automatically capture all :class:`.Qubit` and
    :class:`.Clbit` instances used in the instructions, and create a new :class:`QuantumCircuit`
    object that has the correct resources and all the instructions.

    .. automethod:: from_instructions

    :class:`QuantumCircuit` also still has two constructor methods that are legacy wrappers around
    the importers in :mod:`qiskit.qasm2`.  These automatically apply :ref:`the legacy compatibility
    settings <qasm2-legacy-compatibility>` of :func:`~.qasm2.load` and :func:`~.qasm2.loads`.

    .. automethod:: from_qasm_file
    .. automethod:: from_qasm_str

    Data objects on circuits
    ========================

    .. _circuit-adding-data-objects:

    Adding data objects
    -------------------

    =============================  =================================================================
    Method                         Adds this kind of data
    =============================  =================================================================
    :meth:`add_bits`               :class:`.Qubit`\ s and :class:`.Clbit`\ s.
    :meth:`add_register`           :class:`.QuantumRegister` and :class:`.ClassicalRegister`.
    :meth:`add_var`                :class:`~.expr.Var` nodes with local scope and initializers.
    :meth:`add_input`              :class:`~.expr.Var` nodes that are treated as circuit inputs.
    :meth:`add_capture`            :class:`~.expr.Var` nodes captured from containing scopes.
    :meth:`add_uninitialized_var`  :class:`~.expr.Var` nodes with local scope and undefined state.
    =============================  =================================================================

    Typically you add most of the data objects (:class:`.Qubit`, :class:`.Clbit`,
    :class:`.ClassicalRegister`, etc) to the circuit as part of using the :meth:`__init__` default
    constructor, or :meth:`copy_empty_like`.  However, it is also possible to add these afterwards.
    Typed classical data, such as standalone :class:`~.expr.Var` nodes (see
    :ref:`circuit-repr-real-time-classical`), can be both constructed and added with separate
    methods.

    New registerless :class:`.Qubit` and :class:`.Clbit` objects are added using :meth:`add_bits`.
    These objects must not already be present in the circuit.  You can check if a bit exists in the
    circuit already using :meth:`find_bit`.

    .. automethod:: add_bits

    Registers are added to the circuit with :meth:`add_register`.  In this method, it is not an
    error if some of the bits are already present in the circuit.  In this case, the register will
    be an "alias" over the bits.  This is not generally well-supported by hardware backends; it is
    probably best to stay away from relying on it.  The registers a given bit is in are part of the
    return of :meth:`find_bit`.

    .. automethod:: add_register

    :ref:`Real-time, typed classical data <circuit-repr-real-time-classical>` is represented on the
    circuit by :class:`~.expr.Var` nodes with a well-defined :class:`~.types.Type`.  It is possible
    to instantiate these separately to a circuit (see :meth:`.Var.new`), but it is often more
    convenient to use circuit methods that will automatically manage the types and expression
    initialization for you.  The two most common methods are :meth:`add_var` (locally scoped
    variables) and :meth:`add_input` (inputs to the circuit).

    .. automethod:: add_var
    .. automethod:: add_input

    In addition, there are two lower-level methods that can be useful for programmatic generation of
    circuits.  When working interactively, you will most likely not need these; most uses of
    :meth:`add_uninitialized_var` are part of :meth:`copy_empty_like`, and most uses of
    :meth:`add_capture` would be better off using :ref:`the control-flow builder interface
    <circuit-control-flow-methods>`.

    .. automethod:: add_uninitialized_var
    .. automethod:: add_capture

    Working with bits and registers
    -------------------------------

    A :class:`.Bit` instance is, on its own, just a unique handle for circuits to use in their own
    contexts.  If you have got a :class:`.Bit` instance and a circuit, just can find the contexts
    that the bit exists in using :meth:`find_bit`, such as its integer index in the circuit and any
    registers it is contained in.

    .. automethod:: find_bit

    Similarly, you can query a circuit to see if a register has already been added to it by using
    :meth:`has_register`.

    .. automethod:: has_register

    Working with compile-time parameters
    ------------------------------------

    .. seealso::
        :ref:`circuit-compile-time-parameters`
            A more complete discussion of what compile-time parametrization is, and how it fits into
            Qiskit's data model.

    Unlike bits, registers, and real-time typed classical data, compile-time symbolic parameters are
    not manually added to a circuit.  Their presence is inferred by being contained in operations
    added to circuits and the global phase.  An ordered list of all parameters currently in a
    circuit is at :attr:`QuantumCircuit.parameters`.

    The most common operation on :class:`.Parameter` instances is to replace them in symbolic
    operations with some numeric value, or another symbolic expression.  This is done with
    :meth:`assign_parameters`.

    .. automethod:: assign_parameters

    The circuit tracks parameters by :class:`.Parameter` instances themselves, and forbids having
    multiple parameters of the same name to avoid some problems when interoperating with OpenQASM or
    other external formats.  You can use :meth:`has_parameter` and :meth:`get_parameter` to query
    the circuit for a parameter with the given string name.

    .. automethod:: has_parameter
    .. automethod:: get_parameter

    .. _circuit-real-time-methods:

    Working with real-time typed classical data
    -------------------------------------------

    .. seealso::
        :mod:`qiskit.circuit.classical`
            Module-level documentation for how the variable-, expression- and type-systems work, the
            objects used to represent them, and the classical operations available.

        :ref:`circuit-repr-real-time-classical`
            A discussion of how real-time data fits into the entire :mod:`qiskit.circuit` data model
            as a whole.

        :ref:`circuit-adding-data-objects`
            The methods for adding new :class:`~.expr.Var` variables to a circuit after
            initialization.

    You can retrive a :class:`~.expr.Var` instance attached to a circuit by using its variable name
    using :meth:`get_var`, or check if a circuit contains a given variable with :meth:`has_var`.

    .. automethod:: get_var
    .. automethod:: has_var

    There are also several iterator methods that you can use to get the full set of variables
    tracked by a circuit.  At least one of :meth:`iter_input_vars` and :meth:`iter_captured_vars`
    will be empty, as inputs and captures are mutually exclusive.  All of the iterators have
    corresponding dynamic properties on :class:`QuantumCircuit` that contain their length:
    :attr:`num_vars`, :attr:`num_input_vars`, :attr:`num_captured_vars` and
    :attr:`num_declared_vars`.

    .. automethod:: iter_vars
    .. automethod:: iter_input_vars
    .. automethod:: iter_captured_vars
    .. automethod:: iter_declared_vars


    .. _circuit-adding-operations:

    Adding operations to circuits
    =============================

    You can add anything that implements the :class:`.Operation` interface to a circuit as a single
    instruction, though most things you will want to add will be :class:`~.circuit.Instruction` or
    :class:`~.circuit.Gate` instances.

    .. seealso::
        :ref:`circuit-operations-instructions`
            The :mod:`qiskit.circuit`-level documentation on the different interfaces that Qiskit
            uses to define circuit-level instructions.

    .. _circuit-append-compose:

    Methods to add general operations
    ---------------------------------

    These are the base methods that handle adding any object, including user-defined ones, onto
    circuits.

    ===============  ===============================================================================
    Method           When to use it
    ===============  ===============================================================================
    :meth:`append`   Add an instruction as a single object onto a circuit.
    :meth:`_append`  Same as :meth:`append`, but a low-level interface that elides almost all error
                     checking.
    :meth:`compose`  Inline the instructions from one circuit onto another.
    :meth:`tensor`   Like :meth:`compose`, but strictly for joining circuits that act on disjoint
                     qubits.
    ===============  ===============================================================================

    :class:`QuantumCircuit` has two main ways that you will add more operations onto a circuit.
    Which to use depends on whether you want to add your object as a single "instruction"
    (:meth:`append`), or whether you want to join the instructions from two circuits together
    (:meth:`compose`).

    A single instruction or operation appears as a single entry in the :attr:`data` of the circuit,
    and as a single box when drawn in the circuit visualizers (see :meth:`draw`).  A single
    instruction is the "unit" that a hardware backend might be defined in terms of (see
    :class:`.Target`).  An :class:`~.circuit.Instruction` can come with a
    :attr:`~.circuit.Instruction.definition`, which is one rule the transpiler (see
    :mod:`qiskit.transpiler`) will be able to fall back on to decompose it for hardware, if needed.
    An :class:`.Operation` that is not also an :class:`~.circuit.Instruction` can
    only be decomposed if it has some associated high-level synthesis method registered for it (see
    :mod:`qiskit.transpiler.passes.synthesis.plugin`).

    A :class:`QuantumCircuit` alone is not a single :class:`~.circuit.Instruction`; it is rather
    more complicated, since it can, in general, represent a complete program with typed classical
    memory inputs and outputs, and control flow.  Qiskit's (and most hardware's) data model does not
    yet have the concept of re-usable callable subroutines with virtual quantum operands.  You can
    convert simple circuits that act only on qubits with unitary operations into a :class:`.Gate`
    using :meth:`to_gate`, and simple circuits acting only on qubits and clbits into a
    :class:`~.circuit.Instruction` with :meth:`to_instruction`.

    When you have an :class:`.Operation`, :class:`~.circuit.Instruction`, or :class:`.Gate`, add it
    to the circuit, specifying the qubit and clbit arguments with :meth:`append`.

    .. automethod:: append

    :meth:`append` does quite substantial error checking to ensure that you cannot accidentally
    break the data model of :class:`QuantumCircuit`.  If you are programmatically generating a
    circuit from known-good data, you can elide much of this error checking by using the fast-path
    appender :meth:`_append`, but at the risk that the caller is responsible for ensuring they are
    passing only valid data.

    .. automethod:: _append

    In other cases, you may want to join two circuits together, applying the instructions from one
    circuit onto specified qubits and clbits on another circuit.  This "inlining" operation is
    called :meth:`compose` in Qiskit.  :meth:`compose` is, in general, more powerful than
    a :meth:`to_instruction`-plus-:meth:`append` combination for joining two circuits, because it
    can also link typed classical data together, and allows for circuit control-flow operations to
    be joined onto another circuit.

    The downsides to :meth:`compose` are that it is a more complex operation that can involve more
    rewriting of the operand, and that it necessarily must move data from one circuit object to
    another.  If you are building up a circuit for yourself and raw performance is a core goal,
    consider passing around your base circuit and having different parts of your algorithm write
    directly to the base circuit, rather than building a temporary layer circuit.

    .. automethod:: compose

    If you are trying to join two circuits that will apply to completely disjoint qubits and clbits,
    :meth:`tensor` is a convenient wrapper around manually adding bit objects and calling
    :meth:`compose`.

    .. automethod:: tensor

    As some rules of thumb:

    * If you have a single :class:`.Operation`, :class:`~.circuit.Instruction` or :class:`.Gate`,
      you should definitely use :meth:`append` or :meth:`_append`.
    * If you have a :class:`QuantumCircuit` that represents a single atomic instruction for a larger
      circuit that you want to re-use, you probably want to call :meth:`to_instruction` or
      :meth:`to_gate`, and then apply the result of that to the circuit using :meth:`append`.
    * If you have a :class:`QuantumCircuit` that represents a larger "layer" of another circuit, or
      contains typed classical variables or control flow, you should use :meth:`compose` to merge it
      onto another circuit.
    * :meth:`tensor` is wanted far more rarely than either :meth:`append` or :meth:`compose`.
      Internally, it is mostly a wrapper around :meth:`add_bits` and :meth:`compose`.

    Some potential pitfalls to beware of:

    * Even if you re-use a custom :class:`~.circuit.Instruction` during circuit construction, the
      transpiler will generally have to "unroll" each invocation of it to its inner decomposition
      before beginning work on it.  This should not prevent you from using the
      :meth:`to_instruction`-plus-:meth:`append` pattern, as the transpiler will improve in this
      regard over time.
    * :meth:`compose` will, by default, produce a new circuit for backwards compatibility.  This is
      more expensive, and not usually what you want, so you should set ``inplace=True``.
    * Both :meth:`append` and :meth:`compose` (but not :meth:`_append`) have a ``copy`` keyword
      argument that defaults to ``True``.  In these cases, the incoming :class:`.Operation`
      instances will be copied if Qiskit detects that the objects have mutability about them (such
      as taking gate parameters).  If you are sure that you will not re-use the objects again in
      other places, you should set ``copy=False`` to prevent this copying, which can be a
      substantial speed-up for large objects.

    Methods to add standard instructions
    ------------------------------------

    The :class:`QuantumCircuit` class has helper methods to add many of the Qiskit standard-library
    instructions and gates onto a circuit.  These are generally equivalent to manually constructing
    an instance of the relevent :mod:`qiskit.circuit.library` object, then passing that to
    :meth:`append` with the remaining arguments placed into the ``qargs`` and ``cargs`` fields as
    appropriate.

    The following methods apply special non-unitary :class:`~.circuit.Instruction` operations to the
    circuit:

    ===============================   ====================================================
    :class:`QuantumCircuit` method    :mod:`qiskit.circuit` :class:`~.circuit.Instruction`
    ===============================   ====================================================
    :meth:`barrier`                   :class:`Barrier`
    :meth:`delay`                     :class:`Delay`
    :meth:`initialize`                :class:`~library.Initialize`
    :meth:`measure`                   :class:`Measure`
    :meth:`reset`                     :class:`Reset`
    :meth:`store`                     :class:`Store`
    ===============================   ====================================================

    These methods apply uncontrolled unitary :class:`.Gate` instances to the circuit:

    ===============================   ============================================
    :class:`QuantumCircuit` method    :mod:`qiskit.circuit.library` :class:`.Gate`
    ===============================   ============================================
    :meth:`dcx`                       :class:`~library.DCXGate`
    :meth:`ecr`                       :class:`~library.ECRGate`
    :meth:`h`                         :class:`~library.HGate`
    :meth:`id`                        :class:`~library.IGate`
    :meth:`iswap`                     :class:`~library.iSwapGate`
    :meth:`ms`                        :class:`~library.MSGate`
    :meth:`p`                         :class:`~library.PhaseGate`
    :meth:`pauli`                     :class:`~library.PauliGate`
    :meth:`prepare_state`             :class:`~library.StatePreparation`
    :meth:`r`                         :class:`~library.RGate`
    :meth:`rcccx`                     :class:`~library.RC3XGate`
    :meth:`rccx`                      :class:`~library.RCCXGate`
    :meth:`rv`                        :class:`~library.RVGate`
    :meth:`rx`                        :class:`~library.RXGate`
    :meth:`rxx`                       :class:`~library.RXXGate`
    :meth:`ry`                        :class:`~library.RYGate`
    :meth:`ryy`                       :class:`~library.RYYGate`
    :meth:`rz`                        :class:`~library.RZGate`
    :meth:`rzx`                       :class:`~library.RZXGate`
    :meth:`rzz`                       :class:`~library.RZZGate`
    :meth:`s`                         :class:`~library.SGate`
    :meth:`sdg`                       :class:`~library.SdgGate`
    :meth:`swap`                      :class:`~library.SwapGate`
    :meth:`sx`                        :class:`~library.SXGate`
    :meth:`sxdg`                      :class:`~library.SXdgGate`
    :meth:`t`                         :class:`~library.TGate`
    :meth:`tdg`                       :class:`~library.TdgGate`
    :meth:`u`                         :class:`~library.UGate`
    :meth:`unitary`                   :class:`~library.UnitaryGate`
    :meth:`x`                         :class:`~library.XGate`
    :meth:`y`                         :class:`~library.YGate`
    :meth:`z`                         :class:`~library.ZGate`
    ===============================   ============================================

    The following methods apply :class:`Gate` instances that are also controlled gates, so are
    direct subclasses of :class:`ControlledGate`:

    ===============================   ======================================================
    :class:`QuantumCircuit` method    :mod:`qiskit.circuit.library` :class:`.ControlledGate`
    ===============================   ======================================================
    :meth:`ccx`                       :class:`~library.CCXGate`
    :meth:`ccz`                       :class:`~library.CCZGate`
    :meth:`ch`                        :class:`~library.CHGate`
    :meth:`cp`                        :class:`~library.CPhaseGate`
    :meth:`crx`                       :class:`~library.CRXGate`
    :meth:`cry`                       :class:`~library.CRYGate`
    :meth:`crz`                       :class:`~library.CRZGate`
    :meth:`cs`                        :class:`~library.CSGate`
    :meth:`csdg`                      :class:`~library.CSdgGate`
    :meth:`cswap`                     :class:`~library.CSwapGate`
    :meth:`csx`                       :class:`~library.CSXGate`
    :meth:`cu`                        :class:`~library.CUGate`
    :meth:`cx`                        :class:`~library.CXGate`
    :meth:`cy`                        :class:`~library.CYGate`
    :meth:`cz`                        :class:`~library.CZGate`
    ===============================   ======================================================

    Finally, these methods apply particular generalized multiply controlled gates to the circuit,
    often with eager syntheses.  They are listed in terms of the *base* gate they are controlling,
    since their exact output is often a synthesized version of a gate.

    ===============================   =================================================
    :class:`QuantumCircuit` method    Base :mod:`qiskit.circuit.library` :class:`.Gate`
    ===============================   =================================================
    :meth:`mcp`                       :class:`~library.PhaseGate`
    :meth:`mcrx`                      :class:`~library.RXGate`
    :meth:`mcry`                      :class:`~library.RYGate`
    :meth:`mcrz`                      :class:`~library.RZGate`
    :meth:`mcx`                       :class:`~library.XGate`
    ===============================   =================================================

    The rest of this section is the API listing of all the individual methods; the tables above are
    summaries whose links will jump you to the correct place.

    .. automethod:: barrier
    .. automethod:: ccx
    .. automethod:: ccz
    .. automethod:: ch
    .. automethod:: cp
    .. automethod:: crx
    .. automethod:: cry
    .. automethod:: crz
    .. automethod:: cs
    .. automethod:: csdg
    .. automethod:: cswap
    .. automethod:: csx
    .. automethod:: cu
    .. automethod:: cx
    .. automethod:: cy
    .. automethod:: cz
    .. automethod:: dcx
    .. automethod:: delay
    .. automethod:: ecr
    .. automethod:: h
    .. automethod:: id
    .. automethod:: initialize
    .. automethod:: iswap
    .. automethod:: mcp
    .. automethod:: mcrx
    .. automethod:: mcry
    .. automethod:: mcrz
    .. automethod:: mcx
    .. automethod:: measure
    .. automethod:: ms
    .. automethod:: p
    .. automethod:: pauli
    .. automethod:: prepare_state
    .. automethod:: r
    .. automethod:: rcccx
    .. automethod:: rccx
    .. automethod:: reset
    .. automethod:: rv
    .. automethod:: rx
    .. automethod:: rxx
    .. automethod:: ry
    .. automethod:: ryy
    .. automethod:: rz
    .. automethod:: rzx
    .. automethod:: rzz
    .. automethod:: s
    .. automethod:: sdg
    .. automethod:: store
    .. automethod:: swap
    .. automethod:: sx
    .. automethod:: sxdg
    .. automethod:: t
    .. automethod:: tdg
    .. automethod:: u
    .. automethod:: unitary
    .. automethod:: x
    .. automethod:: y
    .. automethod:: z


    .. _circuit-control-flow-methods:

    Adding control flow to circuits
    -------------------------------

    .. seealso::
        :ref:`circuit-control-flow-repr`

        Discussion of how control-flow operations are represented in the whole :mod:`qiskit.circuit`
        context.

    ==============================  ================================================================
    :class:`QuantumCircuit` method  Control-flow instruction
    ==============================  ================================================================
    :meth:`if_test`                 :class:`.IfElseOp` with only a ``True`` body.
    :meth:`if_else`                 :class:`.IfElseOp` with both ``True`` and ``False`` bodies.
    :meth:`while_loop`              :class:`.WhileLoopOp`.
    :meth:`switch`                  :class:`.SwitchCaseOp`.
    :meth:`for_loop`                :class:`.ForLoopOp`.
    :meth:`break_loop`              :class:`.BreakLoopOp`.
    :meth:`continue_loop`           :class:`.ContinueLoopOp`.
    ==============================  ================================================================

    :class:`QuantumCircuit` has corresponding methods for all of the control-flow operations that
    are supported by Qiskit.  These have two forms for calling them.  The first is a very
    straightfowards convenience wrapper that takes in the block bodies of the instructions as
    :class:`QuantumCircuit` arguments, and simply constructs and appends the corresponding
    :class:`.ControlFlowOp`.

    The second form, which we strongly recommend you use for constructing control flow, is called
    *the builder interface*.  Here, the methods take only the real-time discriminant of the
    operation, and return `context managers
    <https://docs.python.org/3/library/stdtypes.html#typecontextmanager>`__ that you enter using
    ``with``.  You can then use regular :class:`QuantumCircuit` methods within those blocks to build
    up the control-flow bodies, and Qiskit will automatically track which of the data resources are
    needed for the inner blocks, building the complete :class:`.ControlFlowOp` as you leave the
    ``with`` statement.  It is far simpler and less error-prone to build control flow
    programmatically this way.

    ..
        TODO: expand the examples of the builder interface.

    .. automethod:: break_loop
    .. automethod:: continue_loop
    .. automethod:: for_loop
    .. automethod:: if_else
    .. automethod:: if_test
    .. automethod:: switch
    .. automethod:: while_loop


    Converting circuits to single objects
    -------------------------------------

    As discussed in :ref:`circuit-append-compose`, you can convert a circuit to either an
    :class:`~.circuit.Instruction` or a :class:`.Gate` using two helper methods.

    .. automethod:: to_instruction
    .. automethod:: to_gate


    Helper mutation methods
    -----------------------

    There are two higher-level methods on :class:`QuantumCircuit` for appending measurements to the
    end of a circuit.  Note that by default, these also add an extra register.

    .. automethod:: measure_active
    .. automethod:: measure_all

    There are two "subtractive" methods on :class:`QuantumCircuit` as well.  This is not a use-case
    that :class:`QuantumCircuit` is designed for; typically you should just look to use
    :meth:`copy_empty_like` in place of :meth:`clear`, and run :meth:`remove_final_measurements` as
    its transpiler-pass form :class:`.RemoveFinalMeasurements`.

    .. automethod:: clear
    .. automethod:: remove_final_measurements

    .. _circuit-calibrations:

    Manual calibration of instructions
    ----------------------------------

    :class:`QuantumCircuit` can store :attr:`calibrations` of instructions that define the pulses
    used to run them on one particular hardware backend.  You can

    .. automethod:: add_calibration
    .. automethod:: has_calibration_for


    Circuit properties
    ==================

    Simple circuit metrics
    ----------------------

    When constructing quantum circuits, there are several properties that help quantify
    the "size" of the circuits, and their ability to be run on a noisy quantum device.
    Some of these, like number of qubits, are straightforward to understand, while others
    like depth and number of tensor components require a bit more explanation.  Here we will
    explain all of these properties, and, in preparation for understanding how circuits change
    when run on actual devices, highlight the conditions under which they change.

    Consider the following circuit:

    .. plot::
       :alt: Circuit diagram output by the previous code.
       :include-source:

       from qiskit import QuantumCircuit
       qc = QuantumCircuit(12)
       for idx in range(5):
          qc.h(idx)
          qc.cx(idx, idx+5)

       qc.cx(1, 7)
       qc.x(8)
       qc.cx(1, 9)
       qc.x(7)
       qc.cx(1, 11)
       qc.swap(6, 11)
       qc.swap(6, 9)
       qc.swap(6, 10)
       qc.x(6)
       qc.draw('mpl')

    From the plot, it is easy to see that this circuit has 12 qubits, and a collection of
    Hadamard, CNOT, X, and SWAP gates.  But how to quantify this programmatically? Because we
    can do single-qubit gates on all the qubits simultaneously, the number of qubits in this
    circuit is equal to the :meth:`width` of the circuit::

       assert qc.width() == 12

    We can also just get the number of qubits directly using :attr:`num_qubits`::

       assert qc.num_qubits == 12

    .. important::

       For a quantum circuit composed from just qubits, the circuit width is equal
       to the number of qubits. This is the definition used in quantum computing. However,
       for more complicated circuits with classical registers, and classically controlled gates,
       this equivalence breaks down. As such, from now on we will not refer to the number of
       qubits in a quantum circuit as the width.

    It is also straightforward to get the number and type of the gates in a circuit using
    :meth:`count_ops`::

       qc.count_ops()

    .. code-block:: text

       OrderedDict([('cx', 8), ('h', 5), ('x', 3), ('swap', 3)])

    We can also get just the raw count of operations by computing the circuits
    :meth:`size`::

       assert qc.size() == 19

    .. automethod:: count_ops
    .. automethod:: depth
    .. automethod:: get_instructions
    .. automethod:: num_connected_components
    .. automethod:: num_nonlocal_gates
    .. automethod:: num_tensor_factors
    .. automethod:: num_unitary_factors
    .. automethod:: size
    .. automethod:: width

    Accessing scheduling information
    --------------------------------

    If a :class:`QuantumCircuit` has been scheduled as part of a transpilation pipeline, the timing
    information for individual qubits can be accessed.  The whole-circuit timing information is
    available through the :meth:`estimate_duration` method and :attr:`op_start_times` attribute.

    .. automethod:: estimate_duration
    .. automethod:: qubit_duration
    .. automethod:: qubit_start_time
    .. automethod:: qubit_stop_time

    Instruction-like methods
    ========================

    ..
        These methods really shouldn't be on `QuantumCircuit` at all.  They're generally more
        appropriate as `Instruction` or `Gate` methods.  `reverse_ops` shouldn't be a method _full
        stop_---it was copying a `DAGCircuit` method from an implementation detail of the original
        `SabreLayout` pass in Qiskit.

    :class:`QuantumCircuit` also contains a small number of methods that are very
    :class:`~.circuit.Instruction`-like in detail.  You may well find better integration and more
    API support if you first convert your circuit to an :class:`~.circuit.Instruction`
    (:meth:`to_instruction`) or :class:`.Gate` (:meth:`to_gate`) as appropriate, then call the
    corresponding method.

    .. automethod:: control
    .. automethod:: inverse
    .. automethod:: power
    .. automethod:: repeat
    .. automethod:: reverse_ops

    Visualization
    =============

    Qiskit includes some drawing tools to give you a quick feel for what your circuit looks like.
    This tooling is primarily targeted at producing either a `Matplotlib
    <https://matplotlib.org/>`__- or text-based drawing.  There is also a lesser-featured LaTeX
    backend for drawing, but this is only for simple circuits, and is not as actively maintained.

    .. seealso::
        :mod:`qiskit.visualization`
            The primary documentation for all of Qiskit's visualization tooling.

    .. automethod:: draw

    In addition to the core :meth:`draw` driver, there are two visualization-related helper methods,
    which are mostly useful for quickly unwrapping some inner instructions or reversing the
    :ref:`qubit-labelling conventions <circuit-conventions>` in the drawing.  For more general
    mutation, including basis-gate rewriting, you should use the transpiler
    (:mod:`qiskit.transpiler`).

    .. automethod:: decompose
    .. automethod:: reverse_bits

    Internal utilities
    ==================

    These functions are not intended for public use, but were accidentally left documented in the
    public API during the 1.0 release.  They will be removed in Qiskit 2.0, but will be supported
    until then.

    .. automethod:: cast
    .. automethod:: cbit_argument_conversion
    .. automethod:: cls_instances
    .. automethod:: cls_prefix
    .. automethod:: qbit_argument_conversion
    r   ÚcircuitN© )ÚnameÚglobal_phaseÚmetadataÚinputsÚcapturesÚdeclarationsÚregsúRegister | int | Sequence[Bit]rR   ú
str | NonerS   r4   rT   údict | NonerU   úIterable[expr.Var]rV   rW   úCMapping[expr.Var, expr.Expr] | Iterable[Tuple[expr.Var, expr.Expr]]c               ó~  — t          d„ |D ¦   «         ¦  «        ro	 t          d„ |D ¦   «         ¦  «        }n# t          t          f$ r d}Y nw xY w|s t	          dd„ |D ¦   «         › d|› d�¦  «        ‚t          d„ |D ¦   «         ¦  «        }d	| _        |  	 |€.|                      ¦   «         | _        |                      ¦   «          n2t          |t          ¦  «        st	          d
¦  «        ‚|| _        || _        |                      ¦   «          t          | ¦  «        | _        d	| _        g | _        g | _        	 g | _        	 i | _        i | _        t+          ¦   «         | _        g | _        t1          t2          ¦  «        | _         | j        |Ž  d	| _        || _        i | _        i | _        i | _         |D ]}	|  !                    |	¦  «         Œ|D ]}
|  "                    |
¦  «         Œt          |tF          ¦  «        r| $                    ¦   «         }|D ]\  }}|  %                    ||¦  «         Œd	| _&        d| _'        |€i n|| _(        d	S )az  
        Default constructor of :class:`QuantumCircuit`.

        ..
            `QuantumCirucit` documents its `__init__` method explicitly, unlike most classes where
            it's implicitly appended to the class-level documentation, just because the class is so
            huge and has a lot of introductory material to its class docstring.

        Args:
            regs: The registers to be included in the circuit.

                * If a list of :class:`~.Register` objects, represents the :class:`.QuantumRegister`
                  and/or :class:`.ClassicalRegister` objects to include in the circuit.

                  For example:

                    * ``QuantumCircuit(QuantumRegister(4))``
                    * ``QuantumCircuit(QuantumRegister(4), ClassicalRegister(3))``
                    * ``QuantumCircuit(QuantumRegister(4, 'qr0'), QuantumRegister(2, 'qr1'))``

                * If a list of ``int``, the amount of qubits and/or classical bits to include in
                  the circuit. It can either be a single int for just the number of quantum bits,
                  or 2 ints for the number of quantum bits and classical bits, respectively.

                  For example:

                    * ``QuantumCircuit(4) # A QuantumCircuit with 4 qubits``
                    * ``QuantumCircuit(4, 3) # A QuantumCircuit with 4 qubits and 3 classical bits``

                * If a list of python lists containing :class:`.Bit` objects, a collection of
                  :class:`.Bit` s to be added to the circuit.

            name: the name of the quantum circuit. If not set, an automatically generated string
                will be assigned.
            global_phase: The global phase of the circuit in radians.
            metadata: Arbitrary key value metadata to associate with the circuit. This gets
                stored as free-form data in a dict in the
                :attr:`~qiskit.circuit.QuantumCircuit.metadata` attribute. It will not be directly
                used in the circuit.
            inputs: any variables to declare as ``input`` runtime variables for this circuit.  These
                should already be existing :class:`.expr.Var` nodes that you build from somewhere
                else; if you need to create the inputs as well, use
                :meth:`QuantumCircuit.add_input`.  The variables given in this argument will be
                passed directly to :meth:`add_input`.  A circuit cannot have both ``inputs`` and
                ``captures``.
            captures: any variables that that this circuit scope should capture from a containing
                scope.  The variables given here will be passed directly to :meth:`add_capture`.  A
                circuit cannot have both ``inputs`` and ``captures``.
            declarations: any variables that this circuit should declare and initialize immediately.
                You can order this input so that later declarations depend on earlier ones
                (including inputs or captures). If you need to depend on values that will be
                computed later at runtime, use :meth:`add_var` at an appropriate point in the
                circuit execution.

                This argument is intended for convenient circuit initialization when you already
                have a set of created variables.  The variables used here will be directly passed to
                :meth:`add_var`, which you can use directly if this is the first time you are
                creating the variable.

        Raises:
            CircuitError: if the circuit name, if given, is not valid.
            CircuitError: if both ``inputs`` and ``captures`` are given.
        c              3  ó\   K  — | ]'}t          |t          t          t          f¦  «         V — Œ(d S ©N)Ú
isinstanceÚlistr5   r9   ©Ú.0Úregs     úS/granary/edev/quantum/lib/python3.11/site-packages/qiskit/circuit/quantumcircuit.pyú	<genexpr>z*QuantumCircuit.__init__.<locals>.<genexpr>  s8   è è € Ð_Ð_ÐSV•:˜c¥D­/Õ;LÐ#MÑNÔNÐNÐ_Ð_Ð_Ð_Ð_Ð_ó    c              3  ó<   K  — | ]}|t          |¦  «        k    V — Œd S r`   ©Úintrc   s     rf   rg   z*QuantumCircuit.__init__.<locals>.<genexpr>  s,   è è € Ð$EÐ$E¸ S­C°©H¬H¢_Ð$EÐ$EÐ$EÐ$EÐ$EÐ$Erh   Fz-Circuit args must be Registers or integers. (c                ó6   — g | ]}t          |¦  «        j        ‘ŒS rQ   )ÚtypeÚ__name__rc   s     rf   ú
<listcomp>z+QuantumCircuit.__init__.<locals>.<listcomp>%  s!   € Ð;Ð;Ð;¨s�˜S™	œ	Ô*Ð;Ð;Ð;rh   z 'z' was provided)c              3  ó4   K  — | ]}t          |¦  «        V — Œd S r`   rj   rc   s     rf   rg   z*QuantumCircuit.__init__.<locals>.<genexpr>)  s(   è è € Ð2Ð2 c�˜S™œÐ2Ð2Ð2Ð2Ð2Ð2rh   NzFThe circuit name should be a string (or None to auto-generate a name).Údt))ÚanyÚallÚ
ValueErrorÚ	TypeErrorr   ÚtupleÚ
_base_nameÚ_cls_prefixÚ_name_updatera   ÚstrrR   Ú_increment_instancesÚ_OuterCircuitScopeInterfaceÚ_builder_apiÚ_op_start_timesÚ_control_flow_scopesÚqregsÚcregsÚ_qubit_indicesÚ_clbit_indicesr   Ú_dataÚ	_ancillasr   ÚdictÚ_calibrationsÚadd_registerÚ_layoutrS   Ú_vars_inputÚ_vars_captureÚ_vars_localÚ	add_inputÚadd_capturer   ÚitemsÚadd_varÚ	_durationÚ_unitrT   )ÚselfrR   rS   rT   rU   rV   rW   rX   Úvalid_reg_sizeÚinput_ÚcaptureÚvarÚinitials                rf   Ú__init__zQuantumCircuit.__init__Ñ  sÓ  € õR Ð_Ð_ÐZ^Ð_Ñ_Ô_Ñ_Ô_ð 	3ð'Ý!$Ð$EÐ$EÀÐ$EÑ$EÔ$EÑ!EÔ!E��øÝ¥	Ð*ð 'ð 'ð 'Ø!&���ð'øøøð "ð Ý"ð Ø;Ð;°dÐ;Ñ;Ô;ð ð  Ø?Cð ð  ð  ñô ð õ Ð2Ð2¨TÐ2Ñ2Ô2Ñ2Ô2ˆDØˆŒØˆØ4Øˆ<Ø"×.Ò.Ñ0Ô0ˆDŒOØ×ÒÑÔÐÐÝ˜D¥#Ñ&Ô&ð 	ÝØXñô ð ð #ˆDŒOØˆDŒIØ×!Ò!Ñ#Ô#Ð#õ 8¸Ñ=Ô=ˆÔà#ˆÔð ð 	Ô!ð -/ˆŒ
ð	à.0ˆŒ
ð	ð :<ˆÔØ9;ˆÔõ #.¡-¤-ˆŒ
à-/ˆŒÝALÍTÑARÔARˆÔØˆÔ˜4Ð Ð àˆŒØ(ˆÔð 13ˆÔØ24ˆÔØ02ˆÔØð 	#ð 	#ˆFØ�NŠN˜6Ñ"Ô"Ð"Ð"Øð 	&ð 	&ˆGØ×Ò˜WÑ%Ô%Ð%Ð%Ý�l¥GÑ,Ô,ð 	0Ø'×-Ò-Ñ/Ô/ˆLØ(ð 	'ð 	'‰LˆC�Ø�LŠL˜˜gÑ&Ô&Ð&Ð&àˆŒØˆŒ
Ø&Ð.˜˜°HˆŒð	Yð 	Ys   ›5 µAÁ
Az1.3.0zin Qiskit 2.0.0T)ÚsinceÚremoval_timelineÚis_propertyc                ó   — | j         S )zwThe total duration of the circuit, set by a scheduling transpiler pass.  Its unit is
        specified by :attr:`unit`.©r‘   ©r“   s    rf   ÚdurationzQuantumCircuit.durationx  s   € ð
 Œ~Ðrh   Úvalueúint | float | Nonec                ó   — || _         d S r`   rž   ©r“   r¡   s     rf   r    zQuantumCircuit.duration  s   € àˆŒˆˆrh   c                ó   — | j         S )z/The unit that :attr:`duration` is specified in.©r’   rŸ   s    rf   ÚunitzQuantumCircuit.unitƒ  s   € ð ŒzÐrh   c                ó   — || _         d S r`   r¦   r¤   s     rf   r§   zQuantumCircuit.unit‰  s   € àˆŒ
ˆ
ˆ
rh   FÚdatar   Úadd_regsÚboolÚreturnútyping.Selfc                ó  ‡‡— t          |¬¦  «        }|j        dk    ri|rDt          d|j        ¬¦  «        Š‰g|_        ˆfd„t          |j        ¦  «        D ¦   «         |_        n#d„ t          |j        ¦  «        D ¦   «         |_        |j        dk    ri|rDt          d|j	        ¬¦  «        Š‰g|_
        ˆfd„t          |j	        ¦  «        D ¦   «         |_        n#d	„ t          |j	        ¦  «        D ¦   «         |_        ||_        |S )
z3A private constructor from rust space circuit data.©rR   r   Úq)rR   Úbitsc                ó>   •— i | ]\  }}|t          |‰|fg¦  «        “ŒS rQ   ©rH   )rd   rI   ÚbitÚqrs      €rf   ú
<dictcomp>z5QuantumCircuit._from_circuit_data.<locals>.<dictcomp>˜  ó<   ø€ ð &ð &ð &Ù@JÀÀs�C� e¨r°5¨k¨]Ñ;Ô;ð&ð &ð &rh   c                ó6   — i | ]\  }}|t          |g ¦  «        “ŒS rQ   r³   ©rd   rI   r´   s      rf   r¶   z5QuantumCircuit._from_circuit_data.<locals>.<dictcomp>œ  ó5   € ð &ð &ð &Ù5?°U¸C�C� e¨RÑ0Ô0ð&ð &ð &rh   Úcc                ó>   •— i | ]\  }}|t          |‰|fg¦  «        “ŒS rQ   r³   )rd   rI   r´   Úcrs      €rf   r¶   z5QuantumCircuit._from_circuit_data.<locals>.<dictcomp>¤  r·   rh   c                ó6   — i | ]\  }}|t          |g ¦  «        “ŒS rQ   r³   r¹   s      rf   r¶   z5QuantumCircuit._from_circuit_data.<locals>.<dictcomp>¨  rº   rh   )rO   Ú
num_qubitsr5   Úqubitsr€   Ú	enumerater‚   Ú
num_clbitsr9   Úclbitsr�   rƒ   r„   )Úclsr©   rª   rR   Úoutr½   rµ   s        @@rf   Ú_from_circuit_dataz!QuantumCircuit._from_circuit_data�  sT  øø€ õ
  $Ð'Ñ'Ô'ˆàŒ?˜QÒÐØð 	Ý$¨#°D´KÐ@Ñ@Ô@�Ø˜D�”	ð&ð &ð &ð &ÝNWÐX\ÔXcÑNdÔNdð&ñ &ô &�Ô"Ð"ð&ð &ÝCLÈTÌ[ÑCYÔCYð&ñ &ô &�Ô"ð Œ?˜QÒÐØð 	Ý&¨C°d´kÐBÑBÔB�Ø˜D�”	ð&ð &ð &ð &ÝNWÐX\ÔXcÑNdÔNdð&ñ &ô &�Ô"Ð"ð&ð &ÝCLÈTÌ[ÑCYÔCYð&ñ &ô &�Ô"ð ˆŒ	àˆ
rh   )rÀ   rÃ   rR   rS   rT   Úinstructionsú»Iterable[CircuitInstruction | tuple[qiskit.circuit.Instruction] | tuple[qiskit.circuit.Instruction, Iterable[Qubit]] | tuple[qiskit.circuit.Instruction, Iterable[Qubit], Iterable[Clbit]]]rÀ   úIterable[Qubit]rÃ   úIterable[Clbit]ú'QuantumCircuit'c               ó¶  ‡‡	— t          |||¬¦  «        }t          ¦   «         Š	t          ¦   «         Š|r9t          |¦  «        }|                     |¦  «         ‰	                     |¦  «         |r9t          |¦  «        }|                     |¦  «         ‰                     |¦  «         | D ]¯}t          |t          ¦  «        s	t          |Ž }ˆ	fd„|j        D ¦   «         }ˆfd„|j        D ¦   «         }|                     |¦  «         |                     |¦  «         ‰	                     |¦  «         ‰                     |¦  «         | 	                    |¦  «         Œ°|S )aÜ  Construct a circuit from an iterable of :class:`.CircuitInstruction`\ s.

        Args:
            instructions: The instructions to add to the circuit.
            qubits: Any qubits to add to the circuit. This argument can be used,
                for example, to enforce a particular ordering of qubits.
            clbits: Any classical bits to add to the circuit. This argument can be used,
                for example, to enforce a particular ordering of classical bits.
            name: The name of the circuit.
            global_phase: The global phase of the circuit in radians.
            metadata: Arbitrary key value metadata to associate with the circuit.

        Returns:
            The quantum circuit.
        )rR   rS   rT   c                ó   •— g | ]}|‰v¯|‘Œ	S rQ   rQ   )rd   ÚqubitÚadded_qubitss     €rf   ro   z4QuantumCircuit.from_instructions.<locals>.<listcomp>Ü  ó#   ø€ ÐYÐYÐY ¸uÈLÐ?XÐ?X�eÐ?XÐ?XÐ?Xrh   c                ó   •— g | ]}|‰v¯|‘Œ	S rQ   rQ   )rd   ÚclbitÚadded_clbitss     €rf   ro   z4QuantumCircuit.from_instructions.<locals>.<listcomp>Ý  rÐ   rh   )
rO   Úsetrb   Úadd_bitsÚupdatera   rB   rÀ   rÃ   Ú_append)
rÇ   rÀ   rÃ   rR   rS   rT   rP   ÚinstructionrÓ   rÏ   s
           @@rf   Úfrom_instructionsz QuantumCircuit.from_instructions°  sq  øø€ õ< ! d¸ÐPXÐYÑYÔYˆÝ‘u”uˆÝ‘u”uˆØð 	(Ý˜&‘\”\ˆFØ×Ò˜VÑ$Ô$Ð$Ø×Ò Ñ'Ô'Ð'Øð 	(Ý˜&‘\”\ˆFØ×Ò˜VÑ$Ô$Ð$Ø×Ò Ñ'Ô'Ð'Ø'ð 		)ð 		)ˆKÝ˜kÕ+=Ñ>Ô>ð ?Ý0°+Ð>�ØYÐYÐYÐY¨Ô);ÐYÑYÔYˆFØYÐYÐYÐY¨Ô);ÐYÑYÔYˆFØ×Ò˜VÑ$Ô$Ð$Ø×Ò˜VÑ$Ô$Ð$Ø×Ò Ñ'Ô'Ð'Ø×Ò Ñ'Ô'Ð'Ø�OŠO˜KÑ(Ô(Ð(Ð(Øˆrh   úOptional[TranspileLayout]c                ó   — | j         S )a¯  Return any associated layout information about the circuit

        This attribute contains an optional :class:`~.TranspileLayout`
        object. This is typically set on the output from :func:`~.transpile`
        or :meth:`.PassManager.run` to retain information about the
        permutations caused on the input circuit by transpilation.

        There are two types of permutations caused by the :func:`~.transpile`
        function, an initial layout which permutes the qubits based on the
        selected physical qubits on the :class:`~.Target`, and a final layout
        which is an output permutation caused by :class:`~.SwapGate`\s
        inserted during routing.
        )r‰   rŸ   s    rf   ÚlayoutzQuantumCircuit.layoutå  s   € ð Œ|Ðrh   rA   c                ó    — t          | ¦  «        S )zËThe circuit data (instructions and context).

        Returns:
            QuantumCircuitData: a list-like object containing the :class:`.CircuitInstruction`\ s
            for each instruction.
        )rA   rŸ   s    rf   r©   zQuantumCircuit.dataö  s   € õ " $Ñ'Ô'Ð'rh   Ú
data_inputr   c                ó€  — t          |t          ¦  «        r|                     ¦   «         }nt          |¦  «        }| j                             ¦   «          | j        | _        |sdS t          |d         t          ¦  «        r|D ]}|                      |d¬¦  «         ŒdS |D ]\  }}}|                      |||d¬¦  «         Œ dS )aˆ  Sets the circuit data from a list of instructions and context.

        Args:
            data_input (Iterable): A sequence of instructions with their execution contexts.  The
                elements must either be instances of :class:`.CircuitInstruction` (preferred), or a
                3-tuple of ``(instruction, qargs, cargs)`` (legacy).  In the legacy format,
                ``instruction`` must be an :class:`~.circuit.Instruction`, while ``qargs`` and
                ``cargs`` must be iterables of :class:`~.circuit.Qubit` or :class:`.Clbit`
                specifiers (similar to the allowed forms in calls to :meth:`append`).
        Nr   F©Úcopy)	ra   r   rá   rb   r„   ÚclearrS   rB   Úappend)r“   rÞ   rØ   ÚqargsÚcargss        rf   r©   zQuantumCircuit.data   sí   € õ �j¥+Ñ.Ô.ð 	*Ø#ŸšÑ*Ô*ˆJˆJå˜jÑ)Ô)ˆJØŒ
×ÒÑÔÐà Ô-ˆÔØð 	ØˆFÝ�j ”mÕ%7Ñ8Ô8ð 	CØ)ð 5ð 5�Ø—’˜K¨e�Ñ4Ô4Ð4Ð4ð5ð 5ð .8ð Cð CÑ)�˜U EØ—’˜K¨°¸E�ÑBÔBÐBÐBðCð Crh   ú	list[int]c                ó<   — | j         €t          d¦  «        ‚| j         S )až  Return a list of operation start times.

        This attribute is enabled once one of scheduling analysis passes
        runs on the quantum circuit.

        Returns:
            List of integers representing instruction start times.
            The index corresponds to the index of instruction in :attr:`QuantumCircuit.data`.

        Raises:
            AttributeError: When circuit is not scheduled.
        NznThis circuit is not scheduled. To schedule it run the circuit through one of the transpiler scheduling passes.)r~   ÚAttributeErrorrŸ   s    rf   Úop_start_timeszQuantumCircuit.op_start_times  s0   € ð ÔÐ'Ý ðbñô ð ð Ô#Ð#rh   )rœ   r†   c                ó   — | j         S )z£Return calibration dictionary.

        The custom pulse definition of a given gate is of the form
        ``{'gate_name': {(qubits, params): schedule}}``
        ©Ú_calibrations_proprŸ   s    rf   ÚcalibrationszQuantumCircuit.calibrations3  s   € ð Ô&Ð&rh   rí   c                ó   — || _         dS )zîSet the circuit calibration data from a dictionary of calibration definition.

        Args:
            calibrations (dict): A dictionary of input in the format
               ``{'gate_name': {(qubits, gate_params): schedule}}``
        Nrë   ©r“   rí   s     rf   rí   zQuantumCircuit.calibrations=  s   € ð #/ˆÔÐÐrh   c                ó*   — t          | j        ¦  «        S )úeAn alternative private path to the `calibrations` property for
        avoiding deprecation warnings.)r†   r‡   rŸ   s    rf   rì   z!QuantumCircuit._calibrations_propH  s   € õ �DÔ&Ñ'Ô'Ð'rh   c                ó:   — t          t          |¦  «        | _        dS )rñ   N)r   r†   r‡   rï   s     rf   rì   z!QuantumCircuit._calibrations_propN  s   € õ )­¨|Ñ<Ô<ˆÔÐÐrh   rØ   úCircuitInstruction | tuplec                ó,   — |                       |¦  «        S )z²Return True if the circuit has a calibration defined for the instruction context. In this
        case, the operation does not need to be translated to the device basis.
        )Ú_has_calibration_for©r“   rØ   s     rf   Úhas_calibration_forz"QuantumCircuit.has_calibration_forT  s   € ð ×(Ò(¨Ñ5Ô5Ð5rh   c                óÆ  ‡ — t          |t          ¦  «        r|j        }|j        }n|\  }}}‰ j        r|j        ‰ j        vrdS t          ˆ fd„|D ¦   «         ¦  «        }g }|j        D ]V}t          |t          ¦  «        r*|j	        s#| 
                    t          |¦  «        ¦  «         ŒA| 
                    |¦  «         ŒWt          |¦  «        }||f‰ j        |j                 v S )zjAn alternative private path to the `has_calibration_for` method for
        avoiding deprecation warnings.Fc              3  óL   •K  — | ]}‰j                              |¦  «        V — Œd S r`   )rÀ   rI   )rd   rÎ   r“   s     €rf   rg   z6QuantumCircuit._has_calibration_for.<locals>.<genexpr>f  s3   øè è € ÐDÐD°E�t”{×(Ò(¨Ñ/Ô/ÐDÐDÐDÐDÐDÐDrh   )ra   rB   Ú	operationrÀ   rì   rR   rv   Úparamsr3   Ú
parametersrã   Úfloat)r“   rØ   rú   rÀ   Ú_rû   Úps   `      rf   rõ   z#QuantumCircuit._has_calibration_for\  sÿ   ø€ õ �kÕ#5Ñ6Ô6ð 	/Ø#Ô-ˆIØ Ô'ˆFˆFà#.Ñ ˆI�v˜qØÔ&ð 	¨)¬.ÀÔ@WÐ*WÐ*WØ�5ÝÐDÐDÐDÐD¸VÐDÑDÔDÑDÔDˆØˆØÔ!ð 	!ð 	!ˆAÝ˜!Õ0Ñ1Ô1ð !¸!¼,ð !Ø—’�e A™hœhÑ'Ô'Ð'Ð'à—’˜aÑ Ô Ð Ð Ý�v‘”ˆØ˜Ð 4Ô#:¸9¼>Ô#JÐJÐJrh   c                ó   — | j         S )aß  The user provided metadata associated with the circuit.

        The metadata for the circuit is a user provided ``dict`` of metadata
        for the circuit. It will not be used to influence the execution or
        operation of the circuit, but it is expected to be passed between
        all transforms of the circuit (ie transpilation) and that providers will
        associate any circuit metadata with the results it returns from
        execution of that circuit.
        )Ú	_metadatarŸ   s    rf   rT   zQuantumCircuit.metadatap  s   € ð Œ~Ðrh   c                ó\   — t          |t          ¦  «        st          d¦  «        ‚|| _        dS )zUpdate the circuit metadataz2Only a dictionary is accepted for circuit metadataN)ra   r†   ru   r  )r“   rT   s     rf   rT   zQuantumCircuit.metadata}  s1   € õ ˜(¥DÑ)Ô)ð 	RÝÐPÑQÔQÐQØ!ˆŒˆˆrh   rz   c                óH   — t          |                      d¬¦  «        ¦  «        S )NÚtext)Úoutput)rz   ÚdrawrŸ   s    rf   Ú__str__zQuantumCircuit.__str__„  s   € Ý�4—9’9 F�9Ñ+Ô+Ñ,Ô,Ð,rh   c                ót   — t          |t          ¦  «        sdS ddlm}  || d¬¦  «         ||d¬¦  «        k    S )NFr   ©Úcircuit_to_dag©Úcopy_operations)ra   rO   Úqiskit.convertersr
  )r“   Úotherr
  s      rf   Ú__eq__zQuantumCircuit.__eq__‡  sa   € Ý˜%¥Ñ0Ô0ð 	Ø�5ð 	5Ð4Ð4Ð4Ð4Ð4àˆ~˜d°EÐ:Ñ:Ô:¸n¸nØ 5ð?
ñ ?
ô ?
ò 
ð 	
rh   c           	     óò  — | j         }|                     |¦  «        }| j                             ¦   «         ddhz
  D ]1}t	          ||t          j        | j        |         |¦  «        ¦  «         Œ2t          |¦  «        |_        | j	         
                    d¬¦  «        |_	        |j	                             t          j        | j	        j        |¦  «        t          j        | j	        j        |¦  «        ¬¦  «         |S )Nr„   r}   T)Údeepcopy©rÀ   rÃ   )Ú	__class__Ú__new__Ú__dict__ÚkeysÚsetattrÚ_copyr  r|   r}   r„   rá   Úreplace_bitsrÀ   rÃ   )r“   ÚmemorÄ   ÚresultÚks        rf   Ú__deepcopy__zQuantumCircuit.__deepcopy__’  sä   € ð ŒnˆØ—’˜SÑ!Ô!ˆØ”×#Ò#Ñ%Ô%¨°.Ð(AÑAð 	Gð 	GˆAÝ�F˜A�uœ~¨d¬m¸AÔ.>ÀÑEÔEÑFÔFÐFÐFå9¸&ÑAÔAˆÔð ”z—’°�Ñ5Ô5ˆŒØŒ×!Ò!Ý”> $¤*Ô"3°TÑ:Ô:Ý”> $¤*Ô"3°TÑ:Ô:ð 	"ñ 	
ô 	
ð 	
ð ˆrh   c                ó&   — | xj         dz  c_         d S ©Nr   ©Ú	instances©rÄ   s    rf   r{   z#QuantumCircuit._increment_instances©  s   € àˆŒ˜ÑˆŒˆˆrh   g333333ó?zin the 2.0 releasezWThis method is only used as an internal helper and will be removed with no replacement.)rš   r›   Úadditional_msgrk   c                ó   — | j         S ©zUReturn the current number of instances of this class,
        useful for auto naming.r   r"  s    rf   Úcls_instanceszQuantumCircuit.cls_instances­  s   € ð Œ}Ðrh   c                ó   — | j         S r%  r   r"  s    rf   Ú_cls_instanceszQuantumCircuit._cls_instances¹  s   € ð Œ}Ðrh   c                ó   — | j         S ©z)Return the prefix to use for auto naming.©Úprefixr"  s    rf   Ú
cls_prefixzQuantumCircuit.cls_prefix¿  s   € ð ŒzÐrh   c                ó   — | j         S r*  r+  r"  s    rf   rx   zQuantumCircuit._cls_prefixÊ  s   € ð ŒzÐrh   ÚNonec                ó¨   — t          ¦   «         sdt          j        ¦   «         j        › �}nd}| j        › d|                      ¦   «         › |› �| _        dS )z-update name of instance using instance numberú-Ú N)r   ÚmpÚcurrent_processÚpidrw   r(  rR   )r“   Úpid_names     rf   ry   zQuantumCircuit._name_updateÏ  s\   € åÑ Ô ð 	Ø5�2Ô-Ñ/Ô/Ô3Ð5Ð5ˆHˆHàˆHà”ÐJÐJ¨×)<Ò)<Ñ)>Ô)>ÐJÀÐJÐJˆŒ	ˆ	ˆ	rh   Úregisterr?   c                óŒ   — d}t          |t          ¦  «        r|| j        v rd}n t          |t          ¦  «        r|| j        v rd}|S )zâ
        Test if this circuit has the register r.

        Args:
            register (Register): a quantum or classical register.

        Returns:
            bool: True if the register is contained in this circuit.
        FT)ra   r5   r€   r9   r�   )r“   r7  Úhas_regs      rf   Úhas_registerzQuantumCircuit.has_registerØ  sW   € ð ˆÝ�h¥Ñ0Ô0ð 	°XÀÄÐ5KÐ5KØˆGˆGÝ˜Õ"3Ñ4Ô4ð 	¸ÀTÄZÐ9OÐ9OØˆGØˆrh   c                ó  — |                       | j        dz   ¦  «        }t          | j        ¦  «        D ]B}|                     |                     |j                             ¦   «         ¬¦  «        ¦  «         ŒC| j        |_        | j	        |_	        |S )uË  Reverse the circuit by reversing the order of instructions.

        This is done by recursively reversing all instructions.
        It does not invert (adjoint) any gate.

        Returns:
            QuantumCircuit: the reversed circuit.

        Examples:

            input:

            .. code-block:: text

                     â”Œâ”€â”€â”€â”�
                q_0: â”¤ H â”œâ”€â”€â”€â”€â”€â– â”€â”€â”€â”€â”€â”€
                     â””â”€â”€â”€â”˜â”Œâ”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”�
                q_1: â”€â”€â”€â”€â”€â”¤ RX(1.57) â”œ
                          â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜

            output:

            .. code-block:: text

                                 â”Œâ”€â”€â”€â”�
                q_0: â”€â”€â”€â”€â”€â– â”€â”€â”€â”€â”€â”€â”¤ H â”œ
                     â”Œâ”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”�â””â”€â”€â”€â”˜
                q_1: â”¤ RX(1.57) â”œâ”€â”€â”€â”€â”€
                     â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        Ú_reverse©rú   )
Úcopy_empty_likerR   Úreversedr©   r×   Úreplacerú   Úreverse_opsr    r§   )r“   Úreverse_circrØ   s      rf   rA  zQuantumCircuit.reverse_opsé  sŠ   € ð> ×+Ò+¨D¬I¸
Ñ,BÑCÔCˆå# D¤IÑ.Ô.ð 	eð 	eˆKØ× Ò  ×!4Ò!4¸{Ô?T×?`Ò?`Ñ?bÔ?bÐ!4Ñ!cÔ!cÑdÔdÐdÐdà $¤ˆÔØ œIˆÔØÐrh   c                ó*  ‡ ‡‡— t          t          t          ‰ j        ¦  «        ¦  «        t          t          ‰ j        ¦  «        ¦  «        ‰ j        ‰ j        ¬¦  «        }|j        ddd…         Š|j        ddd…         Št          ‰ j        ¦  «        D ]G}ˆˆ fd„t          |¦  «        D ¦   «         }|                     t          ||j        ¬¦  «        ¦  «         ŒHt          ‰ j
        ¦  «        D ]G}ˆˆ fd„t          |¦  «        D ¦   «         }|                     t          ||j        ¬¦  «        ¦  «         ŒH‰ j        D ]T}ˆˆ fd„|j        D ¦   «         }ˆˆ fd„|j        D ¦   «         }|                     |                     ||¬	¦  «        ¦  «         ŒU|S )
uˆ  Return a circuit with the opposite order of wires.

        The circuit is "vertically" flipped. If a circuit is
        defined over multiple registers, the resulting circuit will have
        the same registers but with their order flipped.

        This method is useful for converting a circuit written in little-endian
        convention to the big-endian equivalent, and vice versa.

        Returns:
            QuantumCircuit: the circuit with reversed bit order.

        Examples:

            input:

            .. code-block:: text

                     â”Œâ”€â”€â”€â”�
                a_0: â”¤ H â”œâ”€â”€â– â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€
                     â””â”€â”€â”€â”˜â”Œâ”€â”´â”€â”�
                a_1: â”€â”€â”€â”€â”€â”¤ X â”œâ”€â”€â– â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€
                          â””â”€â”€â”€â”˜â”Œâ”€â”´â”€â”�
                a_2: â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¤ X â”œâ”€â”€â– â”€â”€â”€â”€â”€â”€â”€
                               â””â”€â”€â”€â”˜â”Œâ”€â”´â”€â”�
                b_0: â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¤ X â”œâ”€â”€â– â”€â”€
                                    â””â”€â”€â”€â”˜â”Œâ”€â”´â”€â”�
                b_1: â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¤ X â”œ
                                         â””â”€â”€â”€â”˜

            output:

            .. code-block:: text

                                         â”Œâ”€â”€â”€â”�
                b_0: â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¤ X â”œ
                                    â”Œâ”€â”€â”€â”�â””â”€â”¬â”€â”˜
                b_1: â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¤ X â”œâ”€â”€â– â”€â”€
                               â”Œâ”€â”€â”€â”�â””â”€â”¬â”€â”˜
                a_0: â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”¤ X â”œâ”€â”€â– â”€â”€â”€â”€â”€â”€â”€
                          â”Œâ”€â”€â”€â”�â””â”€â”¬â”€â”˜
                a_1: â”€â”€â”€â”€â”€â”¤ X â”œâ”€â”€â– â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€
                     â”Œâ”€â”€â”€â”�â””â”€â”¬â”€â”˜
                a_2: â”¤ H â”œâ”€â”€â– â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€
                     â””â”€â”€â”€â”˜
        ©rR   rS   Néÿÿÿÿc                óP   •— g | ]"}‰‰                      |¦  «        j                 ‘Œ#S rQ   ©Úfind_bitrI   ©rd   rÎ   Únew_qubit_mapr“   s     €€rf   ro   z/QuantumCircuit.reverse_bits.<locals>.<listcomp>I  ó-   ø€ ÐYÐYÐYÀ%�M $§-¢-°Ñ"6Ô"6Ô"<Ô=ÐYÐYÐYrh   )r±   rR   c                óP   •— g | ]"}‰‰                      |¦  «        j                 ‘Œ#S rQ   rG  ©rd   rÒ   Únew_clbit_mapr“   s     €€rf   ro   z/QuantumCircuit.reverse_bits.<locals>.<listcomp>L  rK  rh   c                óP   •— g | ]"}‰‰                      |¦  «        j                 ‘Œ#S rQ   rG  rI  s     €€rf   ro   z/QuantumCircuit.reverse_bits.<locals>.<listcomp>P  ó-   ø€ Ð`Ð`Ð`ÀE�m D§M¢M°%Ñ$8Ô$8Ô$>Ô?Ð`Ð`Ð`rh   c                óP   •— g | ]"}‰‰                      |¦  «        j                 ‘Œ#S rQ   rG  rM  s     €€rf   ro   z/QuantumCircuit.reverse_bits.<locals>.<listcomp>Q  rP  rh   r  )rO   rb   r?  rÀ   rÃ   rR   rS   r€   rˆ   r5   r�   r9   r©   r×   r@  )	r“   Úcircre   r±   rØ   rÀ   rÃ   rN  rJ  s	   `      @@rf   Úreverse_bitszQuantumCircuit.reverse_bits  s¾  øøø€ õ^ Ý•˜$œ+Ñ&Ô&Ñ'Ô'Ý•˜$œ+Ñ&Ô&Ñ'Ô'Ø”ØÔ*ð	
ñ 
ô 
ˆð œ D D b DÔ)ˆØœ D D b DÔ)ˆÝ˜DœJÑ'Ô'ð 	Ið 	IˆCØYÐYÐYÐYÐYÍ8ÐTWÉ=Ì=ÐYÑYÔYˆDØ×Ò�o°4¸c¼hÐGÑGÔGÑHÔHÐHÐHÝ˜DœJÑ'Ô'ð 	Kð 	KˆCØYÐYÐYÐYÐYÍ8ÐTWÉ=Ì=ÐYÑYÔYˆDØ×ÒÕ/°TÀÄÐIÑIÔIÑJÔJÐJÐJàœ9ð 	Lð 	LˆKØ`Ð`Ð`Ð`Ð`È[ÔM_Ð`Ñ`Ô`ˆFØ`Ð`Ð`Ð`Ð`È[ÔM_Ð`Ñ`Ô`ˆFØ�LŠL˜×,Ò,°FÀ6Ð,ÑJÔJÑKÔKÐKÐKØˆrh   Ú	annotatedc                ó$  — t          | j        | j        g| j        ¢| j        ¢R | j        dz   | j         dœŽ}t          | j        ¦  «        D ]D}| 	                    | 
                    |j                             |¬¦  «        ¬¦  «        ¦  «         ŒE|S )uZ  Invert (take adjoint of) this circuit.

        This is done by recursively inverting all gates.

        Args:
            annotated: indicates whether the inverse gate can be implemented
                as an annotated gate.

        Returns:
            QuantumCircuit: the inverted circuit

        Raises:
            CircuitError: if the circuit cannot be inverted.

        Examples:

            input:

            .. code-block:: text

                     â”Œâ”€â”€â”€â”�
                q_0: â”¤ H â”œâ”€â”€â”€â”€â”€â– â”€â”€â”€â”€â”€â”€
                     â””â”€â”€â”€â”˜â”Œâ”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”�
                q_1: â”€â”€â”€â”€â”€â”¤ RX(1.57) â”œ
                          â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜

            output:

            .. code-block:: text

                                  â”Œâ”€â”€â”€â”�
                q_0: â”€â”€â”€â”€â”€â”€â– â”€â”€â”€â”€â”€â”€â”¤ H â”œ
                     â”Œâ”€â”€â”€â”€â”€â”´â”€â”€â”€â”€â”€â”�â””â”€â”€â”€â”˜
                q_1: â”¤ RX(-1.57) â”œâ”€â”€â”€â”€â”€
                     â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        Ú_dgrD  ©rT  r=  )rO   rÀ   rÃ   r€   r�   rR   rS   r?  r„   r×   r@  rú   Úinverse)r“   rT  Úinverse_circrØ   s       rf   rX  zQuantumCircuit.inverseU  sÃ   € õJ &ØŒKØŒKð
ð ŒZð
ð ŒZð	
ð 
ð
 ”˜UÑ"ØÔ+Ð+ð
ð 
ð 
ˆõ $ D¤JÑ/Ô/ð 	ð 	ˆKØ× Ò Ø×#Ò#¨kÔ.C×.KÒ.KÐV_Ð.KÑ.`Ô.`Ð#ÑaÔañô ð ð ð Ðrh   )Úinsert_barriersÚrepsrZ  c               óŽ  — t          | j        | j        g| j        ¢| j        ¢R d| j        d|› �z   iŽ}|dk    rŒ	 |                      ¦   «         }n$# t          $ r |                      ¦   «         }Y nw xY wt          |¦  «        D ]B}| 
                    || j        | j        ¦  «         |r||dz
  k    r|                     ¦   «          ŒC|S )aD  Repeat this circuit ``reps`` times.

        Args:
            reps (int): How often this circuit should be repeated.
            insert_barriers (bool): Whether to include barriers between circuit repetitions.

        Returns:
            QuantumCircuit: A circuit containing ``reps`` repetitions of this circuit.
        rR   z**r   r   )rO   rÀ   rÃ   r€   r�   rR   Úto_gater   Úto_instructionÚranger×   Úbarrier)r“   r[  rZ  Úrepeated_circÚinstÚis         rf   ÚrepeatzQuantumCircuit.repeat‰  s   € õ 'ØŒK˜œð
Ø'+¤zð
Ø48´Jð
ð 
ð 
ØEIÄYÐQ\ÐVZÐQ\ÐQ\ÑE\ð
ð 
ˆð �!Š8ˆ8ð-Ø$(§L¢L¡N¤N��øÝð -ð -ð -Ø×*Ò*Ñ,Ô,���ð-øøøå˜4‘[”[ð ,ð ,�Ø×%Ò% d¨D¬K¸¼ÑEÔEÐEØ"ð , q¨D°1©H¢} }Ø!×)Ò)Ñ+Ô+Ð+øàÐs   ºA ÁA0Á/A0Úpowerrý   Úmatrix_powerc                ó  — |dk    r:t          |t          t          j        f¦  «        r|s|s|                      |¦  «        S | j        dk    rt          d| j        › �¦  «        ‚	 |                      ¦   «         }n"# t          $ r}t          d¦  «        |‚d}~ww xY wt          | j        | j        g| j        ¢| j        ¢R Ž }|                     |                     ||¬¦  «        t#          t%          |j        ¦  «        ¦  «        ¦  «         |S )ah  Raise this circuit to the power of ``power``.

        If ``power`` is a positive integer and both ``matrix_power`` and ``annotated``
        are ``False``, this implementation defaults to calling ``repeat``. Otherwise,
        the circuit is converted into a gate, and a new circuit, containing this gate
        raised to the given power, is returned. The gate raised to the given power is
        implemented either as a unitary gate if ``annotated`` is ``False`` or as an
        annotated operation if ``annotated`` is ``True``.

        Args:
            power (float): The power to raise this circuit to.
            matrix_power (bool): indicates whether the inner power gate can be implemented
                as a unitary gate.
            annotated (bool): indicates whether the inner power gate can be implemented
                as an annotated operation.

        Raises:
            CircuitError: If the circuit needs to be converted to a unitary gate, but is
                not unitary.

        Returns:
            QuantumCircuit: A circuit implementing this circuit raised to the power of ``power``.
        r   zoCannot raise a parameterized circuit to a non-positive power or matrix-power, please bind the free parameters: z¦The circuit contains non-unitary operations and cannot be raised to a power. Note that no qiskit.circuit.Instruction objects may be in the circuit for this operation.NrW  )ra   rk   ÚnpÚintegerrd  Únum_parametersr   rü   r]  r   rO   rÀ   rÃ   r€   r�   rã   re  rb   r_  r¿   )r“   re  rf  rT  ÚgateÚexÚpower_circuits          rf   re  zQuantumCircuit.power¥  s8  € ð6 �QŠJˆJÝ˜5¥3­¬
Ð"3Ñ4Ô4ð à ð ð ð ð
 —;’;˜uÑ%Ô%Ð%ð Ô Ò"Ð"Ýð%à”?ð%ð %ñô ð ð	Ø—<’<‘>”>ˆDˆDøÝð 	ð 	ð 	ÝðDñô ð ð	øøøøð	øøøõ ' t¤{°D´KÐZÀ$Ä*ÐZÈtÌzÐZÐZÐZˆØ×Ò˜TŸZšZ¨¸˜ZÑCÔCÅTÍ%ÐPTÔP_ÑJ`ÔJ`ÑEaÔEaÑbÔbÐbØÐs   Á$A9 Á9
BÂBÂBr   Únum_ctrl_qubitsÚlabelÚ
ctrl_stateústr | int | Nonec                ó@  — 	 |                       ¦   «         }n"# t          $ r}t          d¦  «        |‚d}~ww xY w|                     ||||¦  «        }t	          |¦  «        }t          || j        g| j        ¢R dd| j        › �iŽ}	|	 	                    ||	j        ¦  «         |	S )aÊ  Control this circuit on ``num_ctrl_qubits`` qubits.

        Args:
            num_ctrl_qubits (int): The number of control qubits.
            label (str): An optional label to give the controlled operation for visualization.
            ctrl_state (str or int): The control state in decimal or as a bitstring
                (e.g. '111'). If None, use ``2**num_ctrl_qubits - 1``.
            annotated: indicates whether the controlled gate should be implemented
                as an annotated gate.

        Returns:
            QuantumCircuit: The controlled version of this circuit.

        Raises:
            CircuitError: If the circuit contains a non-unitary operation and cannot be controlled.
        zŸThe circuit contains non-unitary operations and cannot be controlled. Note that no qiskit.circuit.Instruction objects may be in the circuit for this operation.NrR   Úc_)
r]  r   r   Úcontrolr5   rO   rÀ   r€   rR   rã   )
r“   rn  ro  rp  rT  rk  rl  Úcontrolled_gateÚcontrol_qregÚcontrolled_circs
             rf   rt  zQuantumCircuit.controlÜ  sÔ   € ð.	Ø—<’<‘>”>ˆDˆDøÝð 	ð 	ð 	Ýð8ñô ð ð	øøøøð	øøøð Ÿ,š, ¸¸zÈ9ÑUÔUˆÝ& Ñ7Ô7ˆÝ(Ø˜$œ+ð
Ø(,¬
ð
ð 
ð 
Ø9I¸d¼iÐ9IÐ9Ið
ð 
ˆð 	×Ò˜°Ô0FÑGÔGÐGàÐs   ‚ —
6¡1±6)rá   Ú	var_remapÚinline_capturesr  ú$Union['QuantumCircuit', Instruction]ú0QubitSpecifier | Sequence[QubitSpecifier] | Noneú0ClbitSpecifier | Sequence[ClbitSpecifier] | NoneÚfrontÚinplaceÚwraprá   rx  ú.Mapping[str | expr.Var, str | expr.Var] | Nonery  úOptional['QuantumCircuit']c          	     ó
  ‡‡‡‡— |r|r| j         rt          d¦  «        ‚|s| j         rt          d¦  «        ‚|r| n|                      ¦   «         }
‰€i n‰Šdˆfd	„Št          |t          ¦  «        r]| j        sV|j        rO|
j         rt          d
¦  «        ‚|
                     |j        ¦  «         |j        D ]}|
                     |¦  «         Œ|r[t          |t          ¦  «        rFt          d„ |j
        D ¦   «         ¦  «        r|                     ¦   «         n|                     ¦   «         }t          |t          ¦  «        s°|€| j        d|j        …         }|€| j        d|j        …         }|rc|
j                             ‰¬¦  «        }|
                     ¦   «          |
                     |||‰¬¦  «         |D ]}|
                     |¦  «         Œn|
                     |||‰¬¦  «         |rdn|
S |j        |
j        k    s|j        |
j        k    rt          d¦  «        ‚i }|€5|
j        }|                     t+          |j        |
j        ¦  «        ¦  «         n½|
                     |¦  «        }t/          |¦  «        |j        k    r(t          dt/          |¦  «        › d|j        › d�¦  «        ‚t/          t1          |¦  «        ¦  «        t/          |¦  «        k    rt          d|› d�¦  «        ‚|                     t+          |j        |¦  «        ¦  «         |€5|
j        }|                     t+          |j        |
j        ¦  «        ¦  «         nÐ|
                     |¦  «        }t/          |¦  «        |j        k    r(t          dt/          |¦  «        › d|j        › d�¦  «        ‚t/          t1          |¦  «        ¦  «        t/          |¦  «        k    rt          d|› d�¦  «        ‚|                     t+          |j        |
                     |¦  «        ¦  «        ¦  «         |j                             ¦   «         D ]%\  }}|
j        |                              |¦  «         Œ&d|
_        d|
_        |
xj        |j        z  c_        |j
        }	 dˆˆˆfd„	Šd}|r/|
j                             ‰¬¦  «        }|
                     ¦   «           ‰||
|i |	||¬¦  «         |r'|
                      ¦   «          !                    |¦  «         |rdn|
S )u`  Apply the instructions from one circuit onto specified qubits and/or clbits on another.

        .. note::

            By default, this creates a new circuit object, leaving ``self`` untouched.  For most
            uses of this function, it is far more efficient to set ``inplace=True`` and modify the
            base circuit in-place.

        When dealing with realtime variables (:class:`.expr.Var` instances), there are two principal
        strategies for using :meth:`compose`:

        1. The ``other`` circuit is treated as entirely additive, including its variables.  The
           variables in ``other`` must be entirely distinct from those in ``self`` (use
           ``var_remap`` to help with this), and all variables in ``other`` will be declared anew in
           the output with matching input/capture/local scoping to how they are in ``other``.  This
           is generally what you want if you're joining two unrelated circuits.

        2. The ``other`` circuit was created as an exact extension to ``self`` to be inlined onto
           it, including acting on the existing variables in their states at the end of ``self``.
           In this case, ``other`` should be created with all these variables to be inlined declared
           as "captures", and then you can use ``inline_captures=True`` in this method to link them.
           This is generally what you want if you're building up a circuit by defining layers
           on-the-fly, or rebuilding a circuit using layers taken from itself.  You might find the
           ``vars_mode="captures"`` argument to :meth:`copy_empty_like` useful to create each
           layer's base, in this case.

        Args:
            other (qiskit.circuit.Instruction or QuantumCircuit):
                (sub)circuit or instruction to compose onto self.  If not a :obj:`.QuantumCircuit`,
                this can be anything that :obj:`.append` will accept.
            qubits (list[Qubit|int]): qubits of self to compose onto.
            clbits (list[Clbit|int]): clbits of self to compose onto.
            front (bool): If ``True``, front composition will be performed.  This is not possible within
                control-flow builder context managers.
            inplace (bool): If ``True``, modify the object. Otherwise, return composed circuit.
            copy (bool): If ``True`` (the default), then the input is treated as shared, and any
                contained instructions will be copied, if they might need to be mutated in the
                future.  You can set this to ``False`` if the input should be considered owned by
                the base circuit, in order to avoid unnecessary copies; in this case, it is not
                valid to use ``other`` afterward, and some instructions may have been mutated in
                place.
            var_remap (Mapping): mapping to use to rewrite :class:`.expr.Var` nodes in ``other`` as
                they are inlined into ``self``.  This can be used to avoid naming conflicts.

                Both keys and values can be given as strings or direct :class:`.expr.Var` instances.
                If a key is a string, it matches any :class:`~.expr.Var` with the same name.  If a
                value is a string, whenever a new key matches a it, a new :class:`~.expr.Var` is
                created with the correct type.  If a value is a :class:`~.expr.Var`, its
                :class:`~.expr.Expr.type` must exactly match that of the variable it is replacing.
            inline_captures (bool): if ``True``, then all "captured" :class:`~.expr.Var` nodes in
                the ``other`` :class:`.QuantumCircuit` are assumed to refer to variables already
                declared in ``self`` (as any input/capture/local type), and the uses in ``other``
                will apply to the existing variables.  If you want to build up a layer for an
                existing circuit to use with :meth:`compose`, you might find the
                ``vars_mode="captures"`` argument to :meth:`copy_empty_like` useful.  Any remapping
                in ``vars_remap`` occurs before evaluating this variable inlining.

                If this is ``False`` (the default), then all variables in ``other`` will be required
                to be distinct from those in ``self``, and new declarations will be made for them.
            wrap (bool): If True, wraps the other circuit into a gate (or instruction, depending on
                whether it contains only unitary instructions) before composing it onto self.
                Rather than using this option, it is almost always better to manually control this
                yourself by using :meth:`to_instruction` or :meth:`to_gate`, and then call
                :meth:`append`.

        Returns:
            QuantumCircuit: the composed circuit (returns None if inplace==True).

        Raises:
            CircuitError: if no correct wire mapping can be made between the two circuits, such as
                if ``other`` is wider than ``self``.
            CircuitError: if trying to emit a new circuit while ``self`` has a partially built
                control-flow context active, such as the context-manager forms of :meth:`if_test`,
                :meth:`for_loop` and :meth:`while_loop`.
            CircuitError: if trying to compose to the front of a circuit when a control-flow builder
                block is active; there is no clear meaning to this action.

        Examples:
            .. code-block:: python

                >>> lhs.compose(rhs, qubits=[3, 2], inplace=True)

            .. code-block:: text

                            â”Œâ”€â”€â”€â”�                   â”Œâ”€â”€â”€â”€â”€â”�                â”Œâ”€â”€â”€â”�
                lqr_1_0: â”€â”€â”€â”¤ H â”œâ”€â”€â”€    rqr_0: â”€â”€â– â”€â”€â”¤ Tdg â”œ    lqr_1_0: â”€â”€â”€â”¤ H â”œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€
                            â”œâ”€â”€â”€â”¤              â”Œâ”€â”´â”€â”�â””â”€â”€â”€â”€â”€â”˜                â”œâ”€â”€â”€â”¤
                lqr_1_1: â”€â”€â”€â”¤ X â”œâ”€â”€â”€    rqr_1: â”¤ X â”œâ”€â”€â”€â”€â”€â”€â”€    lqr_1_1: â”€â”€â”€â”¤ X â”œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€
                         â”Œâ”€â”€â”´â”€â”€â”€â”´â”€â”€â”�           â””â”€â”€â”€â”˜                    â”Œâ”€â”€â”´â”€â”€â”€â”´â”€â”€â”�â”Œâ”€â”€â”€â”�
                lqr_1_2: â”¤ U1(0.1) â”œ  +                     =  lqr_1_2: â”¤ U1(0.1) â”œâ”¤ X â”œâ”€â”€â”€â”€â”€â”€â”€
                         â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜                                    â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜â””â”€â”¬â”€â”˜â”Œâ”€â”€â”€â”€â”€â”�
                lqr_2_0: â”€â”€â”€â”€â”€â– â”€â”€â”€â”€â”€                           lqr_2_0: â”€â”€â”€â”€â”€â– â”€â”€â”€â”€â”€â”€â”€â– â”€â”€â”¤ Tdg â”œ
                            â”Œâ”€â”´â”€â”�                                          â”Œâ”€â”´â”€â”�        â””â”€â”€â”€â”€â”€â”˜
                lqr_2_1: â”€â”€â”€â”¤ X â”œâ”€â”€â”€                           lqr_2_1: â”€â”€â”€â”¤ X â”œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€
                            â””â”€â”€â”€â”˜                                          â””â”€â”€â”€â”˜
                lcr_0: 0 â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�                           lcr_0: 0 â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�

                lcr_1: 0 â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�                           lcr_1: 0 â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�â•�

        zPCannot compose to the front of a circuit while a control-flow context is active.zJCannot emit a new composed circuit while a control-flow context is active.Nr—   úexpr.VarÚcacheúMapping[expr.Var, expr.Var]r¬   c           	     ó”  •— |                      | ¦  «        x}r|S ‰                      | ¦  «        x}s‰                      | j        ¦  «        x}rst          |t          ¦  «        r%t          j                             || j        ¦  «        }|j        | j        k    r(t          d| j        › d| j        › d|j        › d�¦  «        ‚n| }||| <   |S )Nz%mismatched types in replacement for 'z': 'z' cannot become 'ú')	ÚgetrR   ra   rz   r1   ÚVarÚnewrm   r   )r—   r„  rÅ   Úreplacementrx  s       €rf   Úreplace_varz+QuantumCircuit.compose.<locals>.replace_var�  sü   ø€ ð —i’i ‘n”nÐ$ˆsð Ø�
Ø(Ÿ}š}¨SÑ1Ô1Ð1�ð 	"ÀiÇmÂmÐTWÔT\ÑF]ÔF]Ð7]°{ð 	"Ý˜k­3Ñ/Ô/ð FÝ"&¤(§,¢,¨{¸C¼HÑ"EÔ"E�KØÔ# s¤xÒ/Ð/Ý&ðLÀÄð Lð LØ œXðLð LØ8CÔ8HðLð Lð Lñô ð ð 0ð "�Ø$ˆE�#‰JØÐrh   z>cannot implicitly add clbits while within a control-flow scopec              3  óJ   K  — | ]}t          |j        t          ¦  «        V — Œd S r`   )ra   rú   r   )rd   Úinss     rf   rg   z)QuantumCircuit.compose.<locals>.<genexpr>²  s.   è è € ÐMÐM¸3•z #¤-µÑ6Ô6ÐMÐMÐMÐMÐMÐMrh   ©Úcopy_instructionsrà   )rä   rå   rá   zHTrying to compose with another QuantumCircuit which has more 'in' edges.z%Number of items in qubits parameter (z2) does not match number of qubits in the circuit (z).z4Duplicate qubits referenced in 'qubits' parameter: 'r‡  z%Number of items in clbits parameter (z2) does not match number of clbits in the circuit (z4Duplicate clbits referenced in 'clbits' parameter: 'rq   c                ót  •‡‡‡‡— |                       ¦   «         D ]!}|                      ‰|‰¦  «        ¦  «         Œ"|rp|                      ¦   «         D ]Z} ‰|‰¦  «        }|                      ‰|‰¦  «        ¦  «        s-||u rt	          d|› d�¦  «        ‚t	          d|› d|› d�¦  «        ‚Œ[n6|                      ¦   «         D ]!}|                      ‰|‰¦  «        ¦  «         Œ"|                      ¦   «         D ]!}|                      ‰|‰¦  «        ¦  «         Œ"ˆˆˆfd„Št          j	        |j
        ‰‰|j        ¬¦  «        Šˆˆˆfd„}	| j                             ‰¬	¦  «        }
|
                     ||¬
¦  «         |
                     |	¦  «         |                     ¦   «                              |
¦  «         d S )Nz
Variable 'zt' to be inlined is not in the base circuit. If you wanted it to be automatically added, use `inline_captures=False`.zReplacement 'z' for variable 'z:' is not in the base circuit.  Is the replacement correct?c                óz   •— |                       ¦   «         }i |_        i |_        i |_         ‰| |‰‰d¬¦  «         |S )NF)ry  )r>  rŠ   r‹   rŒ   )ÚblockÚ	new_blockÚbit_mapÚcopy_with_remappingÚvar_maps     €€€rf   Úrecurse_blockzJQuantumCircuit.compose.<locals>.copy_with_remapping.<locals>.recurse_block  sS   ø€ ð
 "×1Ò1Ñ3Ô3�	Ø(*�	Ô%Ø*,�	Ô'Ø(*�	Ô%ð $Ð# E¨9°g¸wÐX]Ð^Ñ^Ô^Ð^Ø Ð rh   )rˆ   c                óÞ  •— | }t          |t          ¦  «        }|sJt          |dd ¦  «        x}�7|| u r‰r|                     ¦   «         n|}‰                     |¦  «        |_        nî|r—|                     ˆfd„|j        D ¦   «         ¦  «        }t          |t          t          f¦  «        r ‰                     |j
        ¦  «        |_        nŠt          |t          ¦  «        r‰                     |j        ¦  «        |_        nUt          |t          ¦  «        r@t          ‰                     |j        ¦  «        ‰                     |j        ¦  «        ¦  «        }|| u r‰r|                     ¦   «         n|S )NÚ
_conditionc              3  ó.   •K  — | ]} ‰|¦  «        V — Œd S r`   rQ   )rd   r“  r˜  s     €rf   rg   zXQuantumCircuit.compose.<locals>.copy_with_remapping.<locals>.map_vars.<locals>.<genexpr>2  s-   øè è € Ð.]Ð.]È¨}¨}¸UÑ/CÔ/CÐ.]Ð.]Ð.]Ð.]Ð.]Ð.]rh   )ra   r!   Úgetattrrá   Úmap_conditionÚ	conditionÚreplace_blocksÚblocksr+   r/   rš  r-   Ú
map_targetÚtargetrD   Úmap_exprÚlvalueÚrvalue)ÚopÚn_opÚis_control_flowrž  rá   r˜  Úvariable_mappers       €€€rf   Úmap_varszEQuantumCircuit.compose.<locals>.copy_with_remapping.<locals>.map_vars(  sb  ø€ Ø�Ý",¨Tµ=Ñ"AÔ"A�à'ðå&-¨d°LÀ$Ñ&GÔ&GÐG˜ÐTà*.°"¨*¨*¸¨*˜4Ÿ9š9™;œ;˜;À4�DØ%4×%BÒ%BÀ9Ñ%MÔ%M�D”N�NØ$ð 	Ø×.Ò.Ð.]Ð.]Ð.]Ð.]ÐQUÔQ\Ð.]Ñ.]Ô.]Ñ]Ô]�DÝ! $­µ;Ð(?Ñ@Ô@ð NØ)8×)FÒ)FÀtÄÑ)WÔ)W˜œ˜Ý# D­,Ñ7Ô7ð NØ&5×&@Ò&@ÀÄÑ&MÔ&M˜œøÝ ¥eÑ,Ô,ð Ý Ø'×0Ò0°´Ñ=Ô=¸×?WÒ?WÐX\ÔXcÑ?dÔ?dñô �Dð '+¨b j j°T j�t—y’y‘{”{�{¸tÐCrh   r�  r  )Úiter_input_varsr�   Úiter_captured_varsÚhas_varr   rŽ   Úiter_declared_varsÚadd_uninitialized_varr    ÚVariableMapperr�   rˆ   r„   rá   r  Úmap_nonstandard_opsÚ_current_scopeÚextend)ÚsourceÚdestr•  r—  ry  Ú
new_qubitsÚ
new_clbitsr—   r‹  rª  rÇ   r˜  r©  rá   r–  rŒ  s     ``       @@€€€rf   r–  z3QuantumCircuit.compose.<locals>.copy_with_remappingú  sv  øøøøø€ ð ×-Ò-Ñ/Ô/ð :ð :�Ø—’˜{˜{¨3°Ñ8Ô8Ñ9Ô9Ð9Ð9Øð @Ø!×4Ò4Ñ6Ô6ð ð �CØ"- +¨c°7Ñ";Ô";�KØŸ<š<¨¨°C¸Ñ(AÔ(AÑBÔBð 
Ø +Ð-Ð-Ý".ð!<¨Sð !<ð !<ð !<ñ#ô #ð õ
 +ðJ¨Kð Jð JÈð Jð Jð Jñô ð ð
ðð "×4Ò4Ñ6Ô6ð @ð @�CØ×$Ò$ [ [°°gÑ%>Ô%>Ñ?Ô?Ð?Ð?Ø×0Ò0Ñ2Ô2ð Fð F�Ø×*Ò*¨;¨;°s¸GÑ+DÔ+DÑEÔEÐEÐEð!ð !ð !ð !ð !ð !ð !õ 6ÔDØ”
˜G W¸4Ô;Lðñ ô ˆOðDð Dð Dð Dð Dð Dð Dð* "œ<×,Ò,¸tÐ,ÑDÔDˆLØ×%Ò%¨ZÀ
Ð%ÑKÔKÐKØ×,Ò,¨XÑ6Ô6Ð6Ø×ÒÑ!Ô!×(Ò(¨Ñ6Ô6Ð6Ð6Ð6rh   )r•  r—  ry  r¶  r·  )r—   rƒ  r„  r…  r¬   rƒ  ©NN)"r   r   rá   ra   rO   rÃ   rÕ   r�   rˆ   rs   r©   r]  r^  rÀ   r¿   rÂ   r„   râ   rã   r×   rÖ   ÚzipÚ_qbit_argument_conversionÚlenrÔ   Ú_cbit_argument_conversionrì   r�   r‡   r    r§   rS   r²  r³  )r“   r  rÀ   rÃ   r}  r~  r  rá   rx  ry  rµ  re   Úold_datarØ   Úedge_mapÚmapped_qubitsÚmapped_clbitsrk  Úcalsrþ   Úappend_existingr–  rŒ  s          ``            @@rf   ÚcomposezQuantumCircuit.compose  sû  øøøø€ ðd ð 	�uð 	 Ô!:ð 	õ Øbñô ð ð ð 	˜4Ô4ð 	õ Ø\ñô ð ð Ð/ˆtˆt D§I¢I¡K¤Kˆà#Ð+�B�B°ˆ	ð	ð 	ð 	ð 	ð 	ð 	õ* �e�^Ñ,Ô,ð 	+Ø”;ð + 5¤<ð +ØÔ,ð Ý&ØXñô ð ð —’˜eœlÑ+Ô+Ð+Ø œ;ð +ð +�CØ×%Ò% cÑ*Ô*Ð*Ð*àð 	•J˜u¥nÑ5Ô5ð 	õ ÐMÐMÀ%Ä*ÐMÑMÔMÑMÔMð,�—’‘”�à×)Ò)Ñ+Ô+ð õ ˜%¥Ñ0Ô0ð 	-Øˆ~ØœÐ%7 uÔ'7Ð%7Ô8�Øˆ~ØœÐ%7 uÔ'7Ð%7Ô8�Øð Jàœ:Ÿ?š?¸T˜?ÑBÔB�Ø—
’
‘”�Ø—’˜E 6¨6¸�Ñ=Ô=Ð=Ø#+ð .ð .�KØ—L’L Ñ-Ô-Ð-Ð-ð.ð —’˜E¨°vÀD�ÑIÔIÐIØ"Ð,�4�4¨Ð,àÔ˜dœoÒ-Ð-°Ô1AÀDÄOÒ1SÐ1SÝØZñô ð ð 8:ˆØˆ>Ø œKˆMØ�OŠO�C ¤¨d¬kÑ:Ô:Ñ;Ô;Ð;Ð;à ×:Ò:¸6ÑBÔBˆMÝ�=Ñ!Ô! UÔ%5Ò5Ð5Ý"ðT½CÀÑ<NÔ<Nð Tð TØ?DÔ?OðTð Tð Tñô ð õ •3�}Ñ%Ô%Ñ&Ô&­#¨mÑ*<Ô*<Ò<Ð<Ý"Ø[È=Ð[Ð[Ð[ñô ð ð �OŠO�C ¤¨mÑ<Ô<Ñ=Ô=Ð=àˆ>Ø œKˆMØ�OŠO�C ¤¨d¬kÑ:Ô:Ñ;Ô;Ð;Ð;à ×:Ò:¸6ÑBÔBˆMÝ�=Ñ!Ô! UÔ%5Ò5Ð5Ý"ðT½CÀÑ<NÔ<Nð Tð TØ?DÔ?OðTð Tð Tñô ð õ •3�}Ñ%Ô%Ñ&Ô&­#¨mÑ*<Ô*<Ò<Ð<Ý"Ø[È=Ð[Ð[Ð[ñô ð ð �OŠO�C ¤¨d×.LÒ.LÈVÑ.TÔ.TÑUÔUÑVÔVÐVàÔ2×8Ò8Ñ:Ô:ð 	2ð 	2‰JˆD�$ØÔ˜tÔ$×+Ò+¨DÑ1Ô1Ð1Ð1àˆŒØˆŒ	ØÐÔ˜UÔ/Ñ/ÐÔð ŒJˆð Z^ðF	7ð F	7ð F	7ð F	7ð F	7ð F	7ð F	7ð F	7ðP ˆØð 	Ø"œjŸošoÀ˜oÑEÔEˆOØ�JŠJ‰LŒLˆLØÐØØØð Ø+Ø$Ø$ð	
ñ 	
ô 	
ð 	
ð ð 	:Ø×ÒÑ!Ô!×(Ò(¨Ñ9Ô9Ð9àÐ(ˆtˆt DÐ(rh   c                óJ  — | j         |j         z   }| j        |j        z   }t          | j        ¦  «        t          |j        ¦  «        cxk    rdk    rZn nW| j        d         j        |j        d         j        cxk    rdk    r*n n'|dk    rt          ||¦  «        }nêt          |¦  «        }nÚt          | j        ¦  «        t          |j        ¦  «        cxk    rdk    rkn nh| j        d         j        |j        d         j        cxk    rdk    r;n n8t          | j        |j        z   d¦  «        }t          g |j        ¢| j        ¢|‘R Ž }n>t          |j        | j        |j	        | j	        g|j        ¢| j        ¢|j        ¢| j        ¢R Ž }| 
                    |t          |j         ¦  «        t          |j        ¦  «        d¬¦  «         | 
                    | t          |j         |¦  «        t          |j        |¦  «        d¬¦  «         |r!| j                             |j        ¦  «         dS |S )uÉ  Tensor ``self`` with ``other``.

        Remember that in the little-endian convention the leftmost operation will be at the bottom
        of the circuit. See also
        `the docs <https://docs.quantum.ibm.com/guides/construct-circuits>`__
        for more information.

        .. code-block:: text

                 â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”�        â”Œâ”€â”€â”€â”€â”€â”�          â”Œâ”€â”€â”€â”€â”€â”�
            q_0: â”¤ bottom â”œ âŠ— q_0: â”¤ top â”œ  = q_0: â”€â”¤ top â”œâ”€â”€
                 â””â”€â”€â”€â”€â”€â”€â”€â”€â”˜        â””â”€â”€â”€â”€â”€â”˜         â”Œâ”´â”€â”€â”€â”€â”€â”´â”€â”�
                                              q_1: â”¤ bottom â”œ
                                                   â””â”€â”€â”€â”€â”€â”€â”€â”€â”˜

        Args:
            other (QuantumCircuit): The other circuit to tensor this circuit with.
            inplace (bool): If ``True``, modify the object. Otherwise return composed circuit.

        Examples:

            .. plot::
               :alt: Circuit diagram output by the previous code.
               :include-source:

               from qiskit import QuantumCircuit
               top = QuantumCircuit(1)
               top.x(0);
               bottom = QuantumCircuit(2)
               bottom.cry(0.2, 0, 1);
               tensored = bottom.tensor(top)
               tensored.draw('mpl')

        Returns:
            QuantumCircuit: The tensored circuit (returns ``None`` if ``inplace=True``).
        r   r   r°   ÚmeasT©r~  N)r¿   rÂ   r»  r€   rR   rO   r�   r9   rÀ   rÃ   rÃ  r_  r  rÖ   )r“   r  r~  r¿   rÂ   rµ  r½   s          rf   ÚtensorzQuantumCircuit.tensorW  sX  € ðJ ”_ uÔ'7Ñ7ˆ
Ø”_ uÔ'7Ñ7ˆ
õ �”
‰OŒO�s 5¤;Ñ/Ô/Ð4Ð4Ò4Ð4°1Ò4Ð4Ð4Ð4Ð4Ø”
˜1”Ô" e¤k°!¤nÔ&9Ð@Ð@Ò@Ð@¸SÒ@Ð@Ð@Ð@Ð@ð ˜AŠ~ˆ~Ý% j°*Ñ=Ô=��å% jÑ1Ô1��õ
 �”
‰OŒO�s 5¤;Ñ/Ô/Ð4Ð4Ò4Ð4°1Ò4Ð4Ð4Ð4Ð4Ø”
˜1”Ô" e¤k°!¤nÔ&9ÐCÐCÒCÐC¸VÒCÐCÐCÐCÐCå" 4¤?°UÔ5EÑ#EÀvÑNÔNˆBÝ!Ð@ 5¤;Ð@°´Ð@¸RÐ@Ð@Ð@ˆDˆDõ "Ø”Ø”Ø”Ø”ð		ð
 ”ð	ð ”ð	ð ”ð	ð ”ð	ð 	ð 	ˆDð 	�Š�U�E %Ô"2Ñ3Ô3µU¸5Ô;KÑ5LÔ5LÐVZˆÑ[Ô[Ð[Ø�ŠØÝ�%Ô" JÑ/Ô/Ý�%Ô" JÑ/Ô/Øð	 	ñ 	
ô 	
ð 	
ð ð 	ØŒM× Ò  ¤Ñ/Ô/Ð/Ø�4Øˆrh   úlist[Qubit]c                ó   — | j         j        S )zcA list of :class:`Qubit`\ s in the order that they were added.  You should not mutate
        this.)r„   rÀ   rŸ   s    rf   rÀ   zQuantumCircuit.qubits²  ó   € ð ŒzÔ Ð rh   úlist[Clbit]c                ó   — | j         j        S )zcA list of :class:`Clbit`\ s in the order that they were added.  You should not mutate
        this.)r„   rÃ   rŸ   s    rf   rÃ   zQuantumCircuit.clbits¸  rÊ  rh   úlist[AncillaQubit]c                ó   — | j         S )zjA list of :class:`AncillaQubit`\ s in the order that they were added.  You should not
        mutate this.)r…   rŸ   s    rf   ÚancillaszQuantumCircuit.ancillas¾  s   € ð Œ~Ðrh   c                ó0   — | j         | j        z   | j        z   S )zzThe number of real-time classical variables in the circuit.

        This is the length of the :meth:`iter_vars` iterable.)Únum_input_varsÚnum_captured_varsÚnum_declared_varsrŸ   s    rf   Únum_varszQuantumCircuit.num_varsÄ  s   € ð
 Ô" TÔ%;Ñ;¸dÔ>TÑTÐTrh   c                ó*   — t          | j        ¦  «        S )zßThe number of real-time classical variables in the circuit marked as circuit inputs.

        This is the length of the :meth:`iter_input_vars` iterable.  If this is non-zero,
        :attr:`num_captured_vars` must be zero.)r»  rŠ   rŸ   s    rf   rÑ  zQuantumCircuit.num_input_varsË  ó   € õ �4Ô#Ñ$Ô$Ð$rh   c                ó*   — t          | j        ¦  «        S )zùThe number of real-time classical variables in the circuit marked as captured from an
        enclosing scope.

        This is the length of the :meth:`iter_captured_vars` iterable.  If this is non-zero,
        :attr:`num_input_vars` must be zero.)r»  r‹   rŸ   s    rf   rÒ  z QuantumCircuit.num_captured_varsÓ  s   € õ �4Ô%Ñ&Ô&Ð&rh   c                ó*   — t          | j        ¦  «        S )zÑThe number of real-time classical variables in the circuit that are declared by this
        circuit scope, excluding inputs or captures.

        This is the length of the :meth:`iter_declared_vars` iterable.)r»  rŒ   rŸ   s    rf   rÓ  z QuantumCircuit.num_declared_varsÜ  rÖ  rh   útyping.Iterable[expr.Var]c                óR  — | j         rF| j         d         }t          j        |                     ¦   «         |                     ¦   «         ¦  «        S t          j        | j                             ¦   «         | j                             ¦   «         | j                             ¦   «         ¦  «        S )a  Get an iterable over all real-time classical variables in scope within this circuit.

        This method will iterate over all variables in scope.  For more fine-grained iterators, see
        :meth:`iter_declared_vars`, :meth:`iter_input_vars` and :meth:`iter_captured_vars`.rE  )	r   Ú	itertoolsÚchainr¬  Úiter_local_varsrŠ   Úvaluesr‹   rŒ   )r“   Úbuilders     rf   Ú	iter_varszQuantumCircuit.iter_varsä  s�   € ð
 Ô$ð 	\ØÔ/°Ô3ˆGÝ”? 7×#=Ò#=Ñ#?Ô#?À×AXÒAXÑAZÔAZÑ[Ô[Ð[ÝŒØÔ×#Ò#Ñ%Ô% tÔ'9×'@Ò'@Ñ'BÔ'BÀDÔDT×D[ÒD[ÑD]ÔD]ñ
ô 
ð 	
rh   c                ó€   — | j         r| j         d                              ¦   «         S | j                             ¦   «         S )zýGet an iterable over all real-time classical variables that are declared with automatic
        storage duration in this scope.  This excludes input variables (see :meth:`iter_input_vars`)
        and captured variables (see :meth:`iter_captured_vars`).rE  )r   rÝ  rŒ   rÞ  rŸ   s    rf   r®  z!QuantumCircuit.iter_declared_varsð  s?   € ð Ô$ð 	CØÔ,¨RÔ0×@Ò@ÑBÔBÐBØÔ×&Ò&Ñ(Ô(Ð(rh   c                óF   — | j         rdS | j                             ¦   «         S )zýGet an iterable over all real-time classical variables that are declared as inputs to
        this circuit scope.  This excludes locally declared variables (see
        :meth:`iter_declared_vars`) and captured variables (see :meth:`iter_captured_vars`).rQ   )r   rŠ   rÞ  rŸ   s    rf   r«  zQuantumCircuit.iter_input_varsø  s)   € ð Ô$ð 	Ø�2ØÔ×&Ò&Ñ(Ô(Ð(rh   c                ó€   — | j         r| j         d                              ¦   «         S | j                             ¦   «         S )a  Get an iterable over all real-time classical variables that are captured by this circuit
        scope from a containing scope.  This excludes input variables (see :meth:`iter_input_vars`)
        and locally declared variables (see :meth:`iter_declared_vars`).rE  )r   r¬  r‹   rÞ  rŸ   s    rf   r¬  z!QuantumCircuit.iter_captured_vars 	  s?   € ð Ô$ð 	FØÔ,¨RÔ0×CÒCÑEÔEÐEØÔ!×(Ò(Ñ*Ô*Ð*rh   Úrhsc                ó,   — |                       |¦  «        S )z%Overload & to implement self.compose.©rÃ  ©r“   rä  s     rf   Ú__and__zQuantumCircuit.__and__	  s   € à�|Š|˜CÑ Ô Ð rh   c                ó4   — |                       |d¬¦  «         | S )z/Overload &= to implement self.compose in place.TrÆ  ræ  rç  s     rf   Ú__iand__zQuantumCircuit.__iand__	  s   € à�Š�S $ˆÑ'Ô'Ð'Øˆrh   Útopc                ó,   — |                       |¦  «        S )z$Overload ^ to implement self.tensor.©rÇ  ©r“   rë  s     rf   Ú__xor__zQuantumCircuit.__xor__	  s   € à�{Š{˜3ÑÔÐrh   c                ó4   — |                       |d¬¦  «         | S )z.Overload ^= to implement self.tensor in place.TrÆ  rí  rî  s     rf   Ú__ixor__zQuantumCircuit.__ixor__	  s   € à�Š�C ˆÑ&Ô&Ð&Øˆrh   c                ó*   — t          | j        ¦  «        S )z'Return number of operations in circuit.)r»  r„   rŸ   s    rf   Ú__len__zQuantumCircuit.__len__	  s   € å�4”:‰ŒÐrh   ÚitemrB   c                ó   — d S r`   rQ   ©r“   rô  s     rf   Ú__getitem__zQuantumCircuit.__getitem__	  s   € Ø<?¸Crh   Úsliceúlist[CircuitInstruction]c                ó   — d S r`   rQ   rö  s     rf   r÷  zQuantumCircuit.__getitem__!	  ó   € ØDGÀCrh   c                ó   — | j         |         S )zReturn indexed operation.©r„   rö  s     rf   r÷  zQuantumCircuit.__getitem__$	  s   € àŒz˜$ÔÐrh   rK   Útype_úCallable[..., T]úUnion[S, T]c                óL   — 	  || ¦  «        S # t           t          f$ r | cY S w xY w©z@Best effort to cast value to type. Otherwise, returns the value.©rt   ru   ©r¡   rþ  s     rf   ÚcastzQuantumCircuit.cast(	  s>   € ð	Ø�5˜‘<”<ÐøÝ�IÐ&ð 	ð 	ð 	ØˆLˆLˆLð	øøøó   ‚
 �#¢#c                óL   — 	  || ¦  «        S # t           t          f$ r | cY S w xY wr  r  r  s     rf   Ú_castzQuantumCircuit._cast6	  s>   € ð	Ø�5˜‘<”<ÐøÝ�IÐ&ð 	ð 	ð 	ØˆLˆLˆLð	øøør  Úqubit_representationÚQubitSpecifierc                ó,   — |                       |¦  «        S ©a  
        Converts several qubit representations (such as indexes, range, etc.)
        into a list of qubits.

        Args:
            qubit_representation: Representation to expand.

        Returns:
            The resolved instances of the qubits.
        ©rº  ©r“   r	  s     rf   Úqbit_argument_conversionz'QuantumCircuit.qbit_argument_conversion>	  s   € ð$ ×-Ò-Ð.BÑCÔCÐCrh   c                óD   — t          || j        | j        t          ¦  «        S r  )Ú_bit_argument_conversionrÀ   r‚   r6   r  s     rf   rº  z(QuantumCircuit._qbit_argument_conversionR	  ó$   € õ (Ø  $¤+¨tÔ/BÅEñ
ô 
ð 	
rh   Úclbit_representationÚClbitSpecifierc                ó,   — |                       |¦  «        S )a&  
        Converts several classical bit representations (such as indexes, range, etc.)
        into a list of classical bits.

        Args:
            clbit_representation : Representation to expand.

        Returns:
            A list of tuples where each tuple is a classical bit.
        ©r¼  ©r“   r  s     rf   Úcbit_argument_conversionz'QuantumCircuit.cbit_argument_conversiona	  s   € ð" ×-Ò-Ð.BÑCÔCÐCrh   c                óD   — t          || j        | j        t          ¦  «        S )a%  
        Converts several classical bit representations (such as indexes, range, etc.)
        into a list of classical bits.

        Args:
            clbit_representation: Representation to expand.

        Returns:
            A list of tuples where each tuple is a classical bit.
        )r  rÃ   rƒ   r:   r  s     rf   r¼  z(QuantumCircuit._cbit_argument_conversiont	  r  rh   r¦  r   rä   úSequence[QubitSpecifier]rû   úSequence[ParameterValueType]r=   c                óÖ  ‡ — ‰                       ¦   «         }|€g }ˆ fd„|pg D ¦   «         }|D ]}t          j        ||¦  «         Œt          |j        ¬¦  «        }t          j        ||g ¦  «        D ]y\  }	}
‰                      |	¦  «         t          j        ||	||¬¦  «        }| 	                    |d¬¦  «         | 
                    |j        t          |j        ¦  «        dz
  ¦  «         Œz|S )zSAn internal method to bypass some checking when directly appending a standard gate.Nc                ó:   •— g | ]}‰                      |¦  «        ‘ŒS rQ   r  ©rd   Úqargr“   s     €rf   ro   z8QuantumCircuit._append_standard_gate.<locals>.<listcomp>�	  ó'   ø€ ÐWÐWÐWÀ4˜$×8Ò8¸Ñ>Ô>ÐWÐWÐWrh   ©Úresource_requester©ro  T©Ú_standard_gater   )r²  r   Úvalidate_parameterr=   Úresolve_classical_resourceÚbroadcast_argumentsÚ_check_dupsrB   Úfrom_standardrã   Ú_add_refrÇ   r»  )r“   r¦  rä   rû   ro  Úcircuit_scopeÚexpanded_qargsÚparamrÇ   r  rþ   rØ   s   `           rf   Ú_append_standard_gatez$QuantumCircuit._append_standard_gateƒ	  s  ø€ ð ×+Ò+Ñ-Ô-ˆàˆ>ØˆFàWÐWÐWÐWÈ5È;ÐTVÐWÑWÔWˆØð 	/ð 	/ˆEÝÔ# B¨Ñ.Ô.Ð.Ð.å%¸Ô9aÐbÑbÔbˆÝÔ/°°NÀBÑGÔGð 	cð 	c‰GˆD�!Ø×Ò˜TÑ"Ô"Ð"Ý,Ô:¸2¸tÀVÐSXÐYÑYÔYˆKØ× Ò  ¸TÐ ÑBÔBÐBØ×!Ò! -Ô"<½cÀ-ÔB\Ñ>]Ô>]Ð`aÑ>aÑbÔbÐbÐbØÐrh   rà   úOperation | CircuitInstructionúSequence[QubitSpecifier] | Nonerå   úSequence[ClbitSpecifier] | Nonec               óZ  ‡ — t          |t          ¦  «        r|j        }|j        }|j        }n|}t          |t
          ¦  «        s|t          |d¦  «        r9|                     ¦   «         }t          |t
          ¦  «        st          d¦  «        ‚n3t          |t
          ¦  «        rt          d¦  «        ‚t          d¦  «        ‚‰  
                    ¦   «         }t          |dd¦  «        x}r`d}|D ]C}	|pt          |	t          ¦  «        }t          |	t          j        ¦  «        rt          ||	¦  «        }	ŒD|r|rt!          j        |¦  «        }t          |t$          ¦  «        rOˆ fd„t&          j                             d	„ |j        D ¦   «         ¦  «        D ¦   «         x}
rt          d
|
› d�¦  «        ‚ˆ fd„|pg D ¦   «         }ˆ fd„|pg D ¦   «         }t/          |j        ¬¦  «        }t          |t2          ¦  «        r|                     ||¦  «        nt3          j        |||¦  «        }t          |dd¦  «        }|D ]v\  }}‰                      |¦  «         |                     ||¬¦  «        }|                     |¦  «         |                     |j        tA          |j        ¦  «        dz
  ¦  «         Œw|S )a‚  Append one or more instructions to the end of the circuit, modifying the circuit in
        place.

        The ``qargs`` and ``cargs`` will be expanded and broadcast according to the rules of the
        given :class:`~.circuit.Instruction`, and any non-:class:`.Bit` specifiers (such as
        integer indices) will be resolved into the relevant instances.

        If a :class:`.CircuitInstruction` is given, it will be unwrapped, verified in the context of
        this circuit, and a new object will be appended to the circuit.  In this case, you may not
        pass ``qargs`` or ``cargs`` separately.

        Args:
            instruction: :class:`~.circuit.Instruction` instance to append, or a
                :class:`.CircuitInstruction` with all its context.
            qargs: specifiers of the :class:`~.circuit.Qubit`\ s to attach instruction to.
            cargs: specifiers of the :class:`.Clbit`\ s to attach instruction to.
            copy: if ``True`` (the default), then the incoming ``instruction`` is copied before
                adding it to the circuit if it contains symbolic parameters, so it can be safely
                mutated without affecting other circuits the same instruction might be in.  If you
                are sure this instruction will not be in other circuits, you can set this ``False``
                for a small speedup.

        Returns:
            qiskit.circuit.InstructionSet: a handle to the :class:`.CircuitInstruction`\ s that
            were actually added to the circuit.

        Raises:
            CircuitError: if the operation passed is not an instance of :class:`~.circuit.Instruction` .
        r^  z/operation.to_instruction() is not an Operation.zTObject is a subclass of Operation, please add () to pass an instance of this object.zHObject to append must be an Operation or have a to_instruction() method.rû   rQ   Fc                ó>   •— h | ]}‰                      |¦  «        °|’ŒS rQ   )r­  )rd   r—   r“   s     €rf   ú	<setcomp>z(QuantumCircuit.append.<locals>.<setcomp>ç	  s=   ø€ ð  ð  ð  àð —|’| CÑ(Ô(ð Øð ð  ð  rh   c              3  ó>   K  — | ]}|                      ¦   «         V — Œd S r`   )r¬  )rd   r“  s     rf   rg   z(QuantumCircuit.append.<locals>.<genexpr>é	  s?   è è € ð 9ð 9Ø38�E×,Ò,Ñ.Ô.ð9ð 9ð 9ð 9ð 9ð 9rh   z%Control-flow op attempts to capture 'z' which are not in this circuitc                ó:   •— g | ]}‰                      |¦  «        ‘ŒS rQ   r  r  s     €rf   ro   z)QuantumCircuit.append.<locals>.<listcomp>ó	  r   rh   c                ó:   •— g | ]}‰                      |¦  «        ‘ŒS rQ   r  )rd   Úcargr“   s     €rf   ro   z)QuantumCircuit.append.<locals>.<listcomp>ô	  r   rh   r!  r  r   )!ra   rB   rú   rÀ   rÃ   r>   Úhasattrr^  r   Ú
issubclassr²  rœ  r3   r1   ÚExprÚ_validate_exprr  r  r!   rÛ  rÜ  Úfrom_iterabler   r=   r'  r   r(  r)  r@  rã   r+  rÇ   r»  )r“   rØ   rä   rå   rá   rú   r,  rû   Úis_parameterr.  Úbad_capturesr-  Úexpanded_cargsrÇ   Úbroadcast_iterÚbase_instructionr  r9  s   `                 rf   rã   zQuantumCircuit.appendœ	  sD  ø€ õJ �kÕ#5Ñ6Ô6ð 	$Ø#Ô-ˆIØÔ&ˆEØÔ&ˆEˆEà#ˆIõ ˜)¥YÑ/Ô/ð 	Ý�yÐ"2Ñ3Ô3ð Ø%×4Ò4Ñ6Ô6�	Ý! )­YÑ7Ô7ð ZÝ&Ð'XÑYÔYÐYðZõ ˜i­Ñ3Ô3ð Ý&ð;ñô ð õ
 #Ø^ñô ð ð ×+Ò+Ñ-Ô-ˆõ ˜Y¨°"Ñ5Ô5Ð5ˆ6ð 	6Ø ˆLØð Að A�Ø+ÐU­z¸%ÕATÑ/UÔ/U�Ý˜e¥T¤YÑ/Ô/ð AÝ*¨=¸%Ñ@Ô@�EøØð 6˜ð 6Ý!œN¨9Ñ5Ô5�	Ý�i¥Ñ/Ô/ð 	ð ð  ð  ð  å$œ?×8Ò8ð 9ð 9Ø<EÔ<Lð9ñ 9ô 9ñ ô ð ñ  ô  ð ˆ|ð 
õ #ð5¸Lð 5ð 5ð 5ñô ð ð
 XÐWÐWÐWÈ5È;ÐTVÐWÑWÔWˆØWÐWÐWÐWÈ5È;ÐTVÐWÑWÔWˆå%¸Ô9aÐbÑbÔbˆõ ˜)¥[Ñ1Ô1ð\ˆI×)Ò)¨.¸.ÑIÔIÐIåÔ0°¸NÈNÑ[Ô[ð 	õ
 .¨i¸¸RÑ@Ô@ÐØ(ð 	cð 	c‰JˆD�$Ø×Ò˜TÑ"Ô"Ð"Ø*×2Ò2¸$ÀtÐ2ÑLÔLˆKØ× Ò  Ñ-Ô-Ð-Ø×!Ò! -Ô"<½cÀ-ÔB\Ñ>]Ô>]Ð`aÑ>aÑbÔbÐbÐbØÐrh   r%  c               ó   — d S r`   rQ   ©r“   rØ   r%  s      rf   r×   zQuantumCircuit._append
  s	   € ð !˜Srh   r>   úSequence[Qubit]úSequence[Clbit]c                ó   — d S r`   rQ   )r“   rØ   rä   rå   s       rf   r×   zQuantumCircuit._append
  s	   € ð �Crh   r$  c               ó²  — |r*| j                              |¦  «         d| _        d| _        |S t	          |t
          ¦  «         }|rt          |||¦  «        }	 | j                              |¦  «         nN# t          $ rA d„ t          |j        j	        ¦  «        D ¦   «         }| j          
                    ||¦  «         Y nw xY wd| _        d| _        |r|j        n|S )ai  Append an instruction to the end of the circuit, modifying the circuit in place.

        .. warning::

            This is an internal fast-path function, and it is the responsibility of the caller to
            ensure that all the arguments are valid; there is no error checking here.  In
            particular:

            * all the qubits and clbits must already exist in the circuit and there can be no
              duplicates in the list.
            * any control-flow operations or classically conditioned instructions must act only on
              variables present in the circuit.
            * the circuit must not be within a control-flow builder context.

        .. note::

            This function may be used by callers other than :obj:`.QuantumCircuit` when the caller
            is sure that all error-checking, broadcasting and scoping has already been performed,
            and the only reference to the circuit the instructions are being appended to is within
            that same function.  In particular, it is not safe to call
            :meth:`QuantumCircuit._append` on a circuit that is received by a function argument.
            This is because :meth:`.QuantumCircuit._append` will not recognize the scoping
            constructs of the control-flow builder interface.

        Args:
            instruction: A complete well-formed :class:`.CircuitInstruction` of the operation and
                its context to be added.

                In the legacy compatibility form, this can be a bare :class:`.Operation`, in which
                case ``qargs`` and ``cargs`` must be explicitly given.
            qargs: Legacy argument for qubits to attach the bare :class:`.Operation` to.  Ignored if
                the first argument is in the preferential :class:`.CircuitInstruction` form.
            cargs: Legacy argument for clbits to attach the bare :class:`.Operation` to.  Ignored if
                the first argument is in the preferential :class:`.CircuitInstruction` form.

        Returns:
            CircuitInstruction: a handle to the instruction that was just added.

        :meta public:
        Nrq   c                ó^   — g | ]*\  }}t          |t          t          f¦  «        ¯!||j        f‘Œ+S rQ   )ra   r3   rO   rü   )rd   Úidxr.  s      rf   ro   z*QuantumCircuit._append.<locals>.<listcomp>N
  sJ   € ð ð ð á�C˜Ý˜eÕ&9½>Ð%JÑKÔKðØ�eÔ&Ð'ðð ð rh   )r„   rã   r    r§   ra   rB   ÚRuntimeErrorrÁ   rú   rû   Úappend_manual_params)r“   rØ   rä   rå   r%  Ú	old_stylerû   s          rf   r×   zQuantumCircuit._append
  s  € ðR ð 	ØŒJ×Ò˜kÑ*Ô*Ð*Ø ˆDŒMØˆDŒIØÐå" ;Õ0BÑCÔCÐCˆ	Øð 	HÝ,¨[¸%ÀÑGÔGˆKð	AØŒJ×Ò˜kÑ*Ô*Ð*Ð*øÝð 	Að 	Að 	Aðð å"+¨KÔ,AÔ,HÑ"IÔ"Iðñ ô ˆFð
 ŒJ×+Ò+¨K¸Ñ@Ô@Ð@Ð@Ð@ð	Aøøøð ˆŒØˆŒ	Ø(1ÐBˆ{Ô$Ð$°{ÐBs   ÁA2 Á2AB=Â<B=ÚdefaultrL   úUnion[Parameter, T]c                ó   — d S r`   rQ   ©r“   rR   rO  s      rf   Úget_parameterzQuantumCircuit.get_parameterZ
  s   € ØKNÈ3rh   .ú	type(...)r   c                ó   — d S r`   rQ   rR  s      rf   rS  zQuantumCircuit.get_parameter^
  s   € ØORÈsrh   ú
typing.Anyc                óz   — | j                              |¦  «        x}€|t          u rt          d|› d�¦  «        ‚|S |S )aí  Retrieve a compile-time parameter that is accessible in this circuit scope by name.

        Args:
            name: the name of the parameter to retrieve.
            default: if given, this value will be returned if the parameter is not present.  If it
                is not given, a :exc:`KeyError` is raised instead.

        Returns:
            The corresponding parameter.

        Raises:
            KeyError: if no default is given, but the parameter does not exist in the circuit.

        Examples:
            Retrieve a parameter by name from a circuit::

                from qiskit.circuit import QuantumCircuit, Parameter

                my_param = Parameter("my_param")

                # Create a parametrized circuit.
                qc = QuantumCircuit(1)
                qc.rx(my_param, 0)

                # We can use 'my_param' as a parameter, but let's say we've lost the Python object
                # and need to retrieve it.
                my_param_again = qc.get_parameter("my_param")

                assert my_param is my_param_again

            Get a variable from a circuit by name, returning some default if it is not present::

                assert qc.get_parameter("my_param", None) is my_param
                assert qc.get_parameter("unknown_param", None) is None

        See also:
            :meth:`get_var`
                A similar method, but for :class:`.expr.Var` run-time variables instead of
                :class:`.Parameter` compile-time parameters.
        Nzno parameter named 'ú' is present)r„   Úget_parameter_by_nameÚEllipsisÚKeyError)r“   rR   rO  Ú	parameters       rf   rS  zQuantumCircuit.get_parameterb
  sP   € ðR œ×9Ò9¸$Ñ?Ô?Ð?ˆIÐHØ�(Ð"Ð"ÝÐH°dÐHÐHÐHÑIÔIÐIØˆNØÐrh   Úname_or_paramústr | Parameterc               óÄ   — t          |t          ¦  «        r|                      |d¦  «        duS t          |t          ¦  «        o|                      |j        d¦  «        |k    S )aë  Check whether a parameter object exists in this circuit.

        Args:
            name_or_param: the parameter, or name of a parameter to check.  If this is a
                :class:`.Parameter` node, the parameter must be exactly the given one for this
                function to return ``True``.

        Returns:
            whether a matching parameter is assignable in this circuit.

        See also:
            :meth:`QuantumCircuit.get_parameter`
                Retrieve the :class:`.Parameter` instance from this circuit by name.
            :meth:`QuantumCircuit.has_var`
                A similar method to this, but for run-time :class:`.expr.Var` variables instead of
                compile-time :class:`.Parameter`\ s.
        N)ra   rz   rS  r   rR   )r“   r]  s     rf   Úhas_parameterzQuantumCircuit.has_parameter‘
  se   € õ$ �m¥SÑ)Ô)ð 	GØ×%Ò% m°TÑ:Ô:À$ÐFÐFå�}¥iÑ0Ô0ð NØ×"Ò" =Ô#5°tÑ<Ô<ÀÒMð	
rh   úUnion[expr.Var, T]c                ó   — d S r`   rQ   rR  s      rf   Úget_varzQuantumCircuit.get_varª
  rû  rh   rƒ  c                ó   — d S r`   rQ   rR  s      rf   rc  zQuantumCircuit.get_var®
  s   € ØHKÈrh   c                ó”   — |                       ¦   «                              |¦  «        x}�|S |t          u rt          d|› d�¦  «        ‚|S )a–  Retrieve a variable that is accessible in this circuit scope by name.

        Args:
            name: the name of the variable to retrieve.
            default: if given, this value will be returned if the variable is not present.  If it
                is not given, a :exc:`KeyError` is raised instead.

        Returns:
            The corresponding variable.

        Raises:
            KeyError: if no default is given, but the variable does not exist.

        Examples:
            Retrieve a variable by name from a circuit::

                from qiskit.circuit import QuantumCircuit

                # Create a circuit and create a variable in it.
                qc = QuantumCircuit()
                my_var = qc.add_var("my_var", False)

                # We can use 'my_var' as a variable, but let's say we've lost the Python object and
                # need to retrieve it.
                my_var_again = qc.get_var("my_var")

                assert my_var is my_var_again

            Get a variable from a circuit by name, returning some default if it is not present::

                assert qc.get_var("my_var", None) is my_var
                assert qc.get_var("unknown_variable", None) is None

        See also:
            :meth:`get_parameter`
                A similar method, but for :class:`.Parameter` compile-time parameters instead of
                :class:`.expr.Var` run-time variables.
        Nzno variable named 'rX  )r²  rc  rZ  r[  )r“   rR   rO  rÅ   s       rf   rc  zQuantumCircuit.get_var²
  sY   € ðN ×&Ò&Ñ(Ô(×0Ò0°Ñ6Ô6Ð6ˆCÐCØˆJØ•hÐÐÝÐC°ÐCÐCÐCÑDÔDÐDØˆrh   Úname_or_varústr | expr.Varc               óš   — t          |t          ¦  «        r|                      |d¦  «        duS |                      |j        d¦  «        |k    S )aÐ  Check whether a variable is accessible in this scope.

        Args:
            name_or_var: the variable, or name of a variable to check.  If this is a
                :class:`.expr.Var` node, the variable must be exactly the given one for this
                function to return ``True``.

        Returns:
            whether a matching variable is accessible.

        See also:
            :meth:`QuantumCircuit.get_var`
                Retrieve the :class:`.expr.Var` instance from this circuit by name.
            :meth:`QuantumCircuit.has_parameter`
                A similar method to this, but for compile-time :class:`.Parameter`\ s instead of
                run-time :class:`.expr.Var` variables.
        N)ra   rz   rc  rR   )r“   rf  s     rf   r­  zQuantumCircuit.has_varß
  sK   € õ$ �k¥3Ñ'Ô'ð 	?Ø—<’< ¨TÑ2Ô2¸$Ð>Ð>Ø�|Š|˜KÔ,¨dÑ3Ô3°{ÒBÐBrh   útypes.Type | Nonec               ó^  — t          |t          ¦  «        r2|€t          d¦  «        ‚t          j                             ||¦  «        }n|}|j        st          d¦  «        ‚|                      |j        d¬¦  «        x}�/||k    rt          d|› d�¦  «        ‚t          d|› d|› d�¦  «        ‚|S )	a²  The common logic for preparing and validating a new :class:`~.expr.Var` for the circuit.

        The given ``type_`` can be ``None`` if the variable specifier is already a :class:`.Var`,
        and must be a :class:`~.types.Type` if it is a string.  The argument is ignored if the given
        first argument is a :class:`.Var` already.

        Returns the validated variable, which is guaranteed to be safe to add to the circuit.Nz:the type must be known when creating a 'Var' from a stringzycannot add variables that wrap `Clbit` or `ClassicalRegister` instances. Use `add_bits` or `add_register` as appropriate.©rO  r‡  z#' is already present in the circuitzcannot add 'z$' as its name shadows the existing ')	ra   rz   r   r1   r‰  rŠ  Ú
standalonerc  rR   )r“   rf  rþ  r—   Úpreviouss        rf   Ú_prepare_new_varzQuantumCircuit._prepare_new_varõ
  sÒ   € õ �k¥3Ñ'Ô'ð 
	Øˆ}Ý"Ð#_Ñ`Ô`Ð`Ý”(—,’,˜{¨EÑ2Ô2ˆCˆCàˆCØ”>ð Ý"ðHñô ð ð Ÿš S¤X°t˜Ñ<Ô<Ð<ˆHÐIØ˜3ŠˆÝ"Ð#O sÐ#OÐ#OÐ#OÑPÔPÐPÝÐb¨cÐbÐbÐW_ÐbÐbÐbÑcÔcÐcØˆ
rh   r˜   c               óÄ  — |                       ¦   «         }t          |t          j        ¦  «        rJ|j        j        t          j        u r2t          |t          ¦  «        rt          |t          ¦  «        s|j        }nd}t          |t          j        ||¦  «        ¦  «        }t          |t          ¦  «        r&t          j                             ||j        ¦  «        }n|j        st          d¦  «        ‚|}|                     |¦  «         	 t#          ||¦  «        }n$# t          $ r |                     |¦  «         ‚ w xY w|                     t)          |dd¦  «        ¦  «         |S )a*  Add a classical variable with automatic storage and scope to this circuit.

        The variable is considered to have been "declared" at the beginning of the circuit, but it
        only becomes initialized at the point of the circuit that you call this method, so it can
        depend on variables defined before it.

        Args:
            name_or_var: either a string of the variable name, or an existing instance of
                :class:`~.expr.Var` to re-use.  Variables cannot shadow names that are already in
                use within the circuit.
            initial: the value to initialize this variable with.  If the first argument was given
                as a string name, the type of the resulting variable is inferred from the initial
                expression; to control this more manually, either use :meth:`.Var.new` to manually
                construct a new variable with the desired type, or use :func:`.expr.cast` to cast
                the initializer to the desired type.

                This must be either a :class:`~.expr.Expr` node, or a value that can be lifted to
                one using :class:`.expr.lift`.

        Returns:
            The created variable.  If a :class:`~.expr.Var` instance was given, the exact same
            object will be returned.

        Raises:
            CircuitError: if the variable cannot be created due to shadowing an existing variable.

        Examples:
            Define a new variable given just a name and an initializer expression::

                from qiskit.circuit import QuantumCircuit

                qc = QuantumCircuit(2)
                my_var = qc.add_var("my_var", False)

            Reuse a variable that may have been taken from a related circuit, or otherwise
            constructed manually, and initialize it to some more complicated expression::

                from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister
                from qiskit.circuit.classical import expr, types

                my_var = expr.Var.new("my_var", types.Uint(8))

                cr1 = ClassicalRegister(8, "cr1")
                cr2 = ClassicalRegister(8, "cr2")
                qc = QuantumCircuit(QuantumRegister(8), cr1, cr2)

                # Get some measurement results into each register.
                qc.h(0)
                for i in range(1, 8):
                    qc.cx(0, i)
                qc.measure(range(8), cr1)

                qc.reset(range(8))
                qc.h(0)
                for i in range(1, 8):
                    qc.cx(0, i)
                qc.measure(range(8), cr2)

                # Now when we add the variable, it is initialized using the real-time state of the
                # two classical registers we measured into above.
                qc.add_var(my_var, expr.bit_and(cr1, cr2))
        NzHcannot add variables that wrap `Clbit` or `ClassicalRegister` instances.rQ   )r²  ra   r1   r‰  rm   Úkindr2   ÚUintrk   r«   r=  Úliftrz   rŠ  rl  r   r¯  rD   Ú
remove_varrã   rB   )r“   rf  r˜   r,  Úcoerce_typer—   Ústores          rf   r�   zQuantumCircuit.add_var  se  € ðB ×+Ò+Ñ-Ô-ˆõ �{¥D¤HÑ-Ô-ð	àÔ Ô%­¬Ð3Ð3Ý˜7¥CÑ(Ô(ð 4å˜w­Ñ-Ô-ð 4ð &Ô*ˆKˆKàˆKÝ  µ´	¸'À;Ñ0OÔ0OÑPÔPˆÝ�k¥3Ñ'Ô'ð 	Ý”(—,’,˜{¨G¬LÑ9Ô9ˆCˆCØÔ'ð 	ÝØZñô ð ð ˆCØ×+Ò+¨CÑ0Ô0Ð0ð	å˜#˜wÑ'Ô'ˆEˆEøÝð 	ð 	ð 	Ø×$Ò$ SÑ)Ô)Ð)Øð	øøøð 	×ÒÕ/°°r¸2Ñ>Ô>Ñ?Ô?Ð?Øˆ
s   ÄD Ä!D9r—   c               ó’   — | j         rt          d¦  «        ‚|j        st          d¦  «        ‚| j                             |¦  «         dS )aÑ  Add a variable with no initializer.

        In most cases, you should use :meth:`add_var` to initialize the variable.  To use this
        function, you must already hold a :class:`~.expr.Var` instance, as the use of the function
        typically only makes sense in copying contexts.

        .. warning::

            Qiskit makes no assertions about what an uninitialized variable will evaluate to at
            runtime, and some hardware may reject this as an error.

            You should treat this function with caution, and as a low-level primitive that is useful
            only in special cases of programmatically rebuilding two like circuits.

        Args:
            var: the variable to add.
        z<cannot add an uninitialized variable in a control-flow scopez=cannot add a variable wrapping a bit or register to a circuitN)r   r   rl  r}   r¯  ©r“   r—   s     rf   r¯  z$QuantumCircuit.add_uninitialized_vars  sV   € ð6 Ô$ð 	_ÝÐ]Ñ^Ô^Ð^ØŒ~ð 	`ÝÐ^Ñ_Ô_Ð_ØÔ×/Ò/°Ñ4Ô4Ð4Ð4Ð4rh   c                óÊ   — | j         r"| j         d                              |¦  «         dS | j        rt          d¦  «        ‚|                      |d¦  «        | j        |j        <   dS )a  Add a variable to the circuit that it should capture from a scope it will be contained
        within.

        This method requires a :class:`~.expr.Var` node to enforce that you've got a handle to one,
        because you will need to declare the same variable using the same object into the outer
        circuit.

        This is a low-level method, which is only really useful if you are manually constructing
        control-flow operations. You typically will not need to call this method, assuming you
        are using the builder interface for control-flow scopes (``with`` context-manager statements
        for :meth:`if_test` and the other scoping constructs).  The builder interface will
        automatically make the inner scopes closures on your behalf by capturing any variables that
        are used within them.

        Args:
            var: the variable to capture from an enclosing scope.

        Raises:
            CircuitError: if the variable cannot be created due to shadowing an existing variable.
        rE  NzGcircuits with input variables cannot be enclosed, so cannot be closures)r   Úuse_varrŠ   r   rn  r‹   rR   rw  s     rf   rŽ   zQuantumCircuit.add_capture”  sy   € ð* Ô$ð 	ð Ô% bÔ)×1Ò1°#Ñ6Ô6Ð6ØˆFØÔð 	ÝØYñô ð ð (,×'<Ò'<¸SÀ$Ñ'GÔ'GˆÔ˜3œ8Ñ$Ð$Ð$rh   ú
types.Typec               ó   — d S r`   rQ   ©r“   rf  rþ  s      rf   r�   zQuantumCircuit.add_input´  s   € ØMPÈSrh   c               ó   — d S r`   rQ   r|  s      rf   r�   zQuantumCircuit.add_input·  s   € ØSVÐSVrh   c               óþ   — | j         rt          d¦  «        ‚| j        rt          d¦  «        ‚t          |t          j        ¦  «        r|�t          d¦  «        ‚|                      ||¦  «        }|| j        |j	        <   |S )a¿  Register a variable as an input to the circuit.

        Args:
            name_or_var: either a string name, or an existing :class:`~.expr.Var` node to use as the
                input variable.
            type_: if the name is given as a string, then this must be a :class:`~.types.Type` to
                use for the variable.  If the variable is given as an existing :class:`~.expr.Var`,
                then this must not be given, and will instead be read from the object itself.

        Returns:
            the variable created, or the same variable as was passed in.

        Raises:
            CircuitError: if the variable cannot be created due to shadowing an existing variable.
        z4cannot add an input variable in a control-flow scopezAcircuits to be enclosed with captures cannot have input variablesNz1cannot give an explicit type with an existing Var)
r   r   r‹   ra   r1   r‰  rt   rn  rŠ   rR   )r“   rf  rþ  r—   s       rf   r�   zQuantumCircuit.add_inputº  sŒ   € ð$ Ô$ð 	WÝÐUÑVÔVÐVØÔð 	dÝÐbÑcÔcÐcÝ�k¥4¤8Ñ,Ô,ð 	R°Ð1BÝÐPÑQÔQÐQØ×#Ò# K°Ñ7Ô7ˆØ%(ˆÔ˜œÑ"Øˆ
rh   c                ó|  ‡— |sdS t          d„ |D ¦   «         ¦  «        rçt          |¦  «        dk    rBt          |d         t          ¦  «        r'|d         dk    rd}nªt	          |d         d¦  «        f}n’t          |¦  «        dk    rkt          d„ |D ¦   «         ¦  «        rR|d         dk    rd}nt	          |d         d¦  «        f}|d         dk    rd}nt          |d         d	¦  «        f}||z   }nt          d
|f› d�¦  «        ‚|D �]²Št          ‰t          ¦  «        r@t          ˆfd„| j	        | j
        z   D ¦   «         ¦  «        rt          d‰j        › d�¦  «        ‚t          ‰t          ¦  «        r(‰D ]%}|| j        vr| j                             |¦  «         Œ&t          ‰t          ¦  «        r|                      ‰¦  «         ŒÀt          ‰t          ¦  «        r¤| j
                             ‰¦  «         t#          ‰¦  «        D ]x\  }}|| j        v r(| j        |         j                             ‰|f¦  «         Œ6| j                             |¦  «         t-          | j        j        dz
  ‰|fg¦  «        | j        |<   Œy�Œyt          ‰t0          ¦  «        r|                      ‰¦  «         �Œ¥t          d¦  «        ‚dS )zAdd registers.Nc              3  ó@   K  — | ]}t          |t          ¦  «        V — Œd S r`   ©ra   rk   rc   s     rf   rg   z.QuantumCircuit.add_register.<locals>.<genexpr>Û  s,   è è € Ð4Ð4¨�z˜#�sÑ#Ô#Ð4Ð4Ð4Ð4Ð4Ð4rh   r   r   rQ   r°   é   c              3  ó@   K  — | ]}t          |t          ¦  «        V — Œd S r`   r�  rc   s     rf   rg   z.QuantumCircuit.add_register.<locals>.<genexpr>ã  s,   è è € Ð'MÐ'MÀ­
°3½Ñ(<Ô(<Ð'MÐ'MÐ'MÐ'MÐ'MÐ'Mrh   r»   zwQuantumCircuit parameters can be Registers or Integers. If Integers, up to 2 arguments. QuantumCircuit was called with ú.c              3  ó8   •K  — | ]}‰j         |j         k    V — Œd S r`   r¯   )rd   re   r7  s     €rf   rg   z.QuantumCircuit.add_register.<locals>.<genexpr>ö  s=   øè è € ð 6ð 6Ø.1�” ¤Ò)ð6ð 6ð 6ð 6ð 6ð 6rh   zregister name "z" already existszexpected a register)rr   r»  ra   rk   r5   rs   r9   r   r?   r€   r�   rR   r7   r‚   r…   rã   Ú	_add_qregrÁ   rƒ   rJ   r„   Ú	add_clbitrH   rÂ   rb   rÕ   )r“   rX   r€   r�   r´   rK  r7  s         @rf   rˆ   zQuantumCircuit.add_registerÖ  s%  ø€ àð 	ØˆFåÐ4Ð4¨tÐ4Ñ4Ô4Ñ4Ô4ð 	å�4‰yŒy˜AŠ~ˆ~¥*¨T°!¬WµcÑ":Ô":ˆ~à˜”7˜a’<�<Ø�D�Då+¨D°¬G°SÑ9Ô9Ð;�D�DÝ�T‘”˜a’�¥CÐ'MÐ'MÈÐ'MÑ'MÔ'MÑ$MÔ$M�à˜”7˜a’<�<Ø9;�E�Eå,¨T°!¬W°cÑ:Ô:Ð<�EØ˜”7˜a’<�<Ø;=�E�Eå.¨t°A¬w¸Ñ<Ô<Ð>�EØ˜u‘}��å"ð(à"˜Wð(ð (ð (ñô ð ð ð 	:ñ 	:ˆHÝ˜(¥HÑ-Ô-ð Vµ#ð 6ð 6ð 6ð 6Ø59´ZÀ$Ä*Ñ5Lð6ñ 6ô 6ñ 3ô 3ð Võ #Ð#T°X´]Ð#TÐ#TÐ#TÑUÔUÐUå˜(¥OÑ4Ô4ð 3Ø#ð 3ð 3�CØ $Ô"5Ð5Ð5Øœ×-Ò-¨cÑ2Ô2Ð2øå˜(¥OÑ4Ô4ð :Ø—’˜xÑ(Ô(Ð(Ð(å˜HÕ&7Ñ8Ô8ð :Ø”
×!Ò! (Ñ+Ô+Ð+å )¨(Ñ 3Ô 3ð ð ‘H�C˜Ø˜dÔ1Ð1Ð1ØÔ+¨CÔ0Ô:×AÒAÀ8ÈSÀ/ÑRÔRÐRÐRàœ
×,Ò,¨SÑ1Ô1Ð1Ý3?Ø œJÔ1°AÑ5¸À3¸Ð7Hñ4ô 4˜Ô+¨CÑ0Ð0ñõ ˜H¥dÑ+Ô+ð :Ø—’˜hÑ'Ô'Ð'Ñ'å"Ð#8Ñ9Ô9Ð9ð;	:ð 	:rh   Úqregr5   c                óJ  — | j                              |¦  «         t          |¦  «        D ]x\  }}|| j        v r(| j        |         j                             ||f¦  «         Œ6| j                             |¦  «         t          | j        j        dz
  ||fg¦  «        | j        |<   Œyd S r  )	r€   rã   rÁ   r‚   rJ   r„   Ú	add_qubitrH   r¿   )r“   rˆ  rK  r´   s       rf   r†  zQuantumCircuit._add_qreg  s¸   € ØŒ
×Ò˜$ÑÔÐå! $™œð 	bð 	b‰HˆC�Ø�dÔ)Ð)Ð)ØÔ# CÔ(Ô2×9Ò9¸4À¸+ÑFÔFÐFÐFà”
×$Ò$ SÑ)Ô)Ð)Ý+7¸¼
Ô8MÐPQÑ8QÐUYÐ[^ÐT_ÐS`Ñ+aÔ+a�Ô# CÑ(Ð(ð	bð 	brh   r±   úIterable[Bit]c                ó*  ‡ — ˆ fd„|D ¦   «         }|rt          d|› �¦  «        ‚|D ]ì}t          |t          ¦  «        r‰ j                             |¦  «         t          |t
          ¦  «        r@‰ j                             |¦  «         t          ‰ j        j	        dz
  g ¦  «        ‰ j
        |<   Œ†t          |t          ¦  «        r@‰ j                             |¦  «         t          ‰ j        j        dz
  g ¦  «        ‰ j        |<   ŒÛt          d|› �¦  «        ‚dS )zAdd Bits to the circuit.c                ó8   •— h | ]}|‰j         v s	|‰j        v ¯|’ŒS rQ   )r‚   rƒ   )rd   r´   r“   s     €rf   r5  z*QuantumCircuit.add_bits.<locals>.<setcomp>   s:   ø€ ð 
ð 
ð 
Ø 3¨$Ô*=Ð#=Ð#=ÀÈÔH[ÐA[ÐA[ˆCÐA[ÐA[ÐA[rh   z0Attempted to add bits found already in circuit: r   zFExpected an instance of Qubit, Clbit, or AncillaQubit, but was passed N)r   ra   r8   r…   rã   r6   r„   rŠ  rH   r¿   r‚   r:   r‡  rÂ   rƒ   )r“   r±   Úduplicate_bitsr´   s   `   rf   rÕ   zQuantumCircuit.add_bits  sO  ø€ ð
ð 
ð 
ð 
Øð
ñ 
ô 
ˆð ð 	dÝÐbÐR`ÐbÐbÑcÔcÐcàð 	ð 	ˆCÝ˜#�|Ñ,Ô,ð +Ø”×%Ò% cÑ*Ô*Ð*Ý˜#�uÑ%Ô%ð 
Ø”
×$Ò$ SÑ)Ô)Ð)Ý+7¸¼
Ô8MÐPQÑ8QÐSUÑ+VÔ+V�Ô# CÑ(Ð(Ý˜C¥Ñ'Ô'ð Ø”
×$Ò$ SÑ)Ô)Ð)Ý+7¸¼
Ô8MÐPQÑ8QÐSUÑ+VÔ+V�Ô# CÑ(Ð(å"ð:Ø47ð:ð :ñô ð ð	ð 	rh   r´   r@   rH   c                ó  — 	 t          |t          ¦  «        r| j        |         S t          |t          ¦  «        r| j        |         S t          dt          |¦  «        › �¦  «        ‚# t          $ r}t          d|› d�¦  «        |‚d}~ww xY w)ag  Find locations in the circuit which can be used to reference a given :obj:`~Bit`.

        In particular, this function can find the integer index of a qubit, which corresponds to its
        hardware index for a transpiled circuit.

        .. note::
            The circuit index of a :class:`.AncillaQubit` will be its index in :attr:`qubits`, not
            :attr:`ancillas`.

        Args:
            bit (Bit): The bit to locate.

        Returns:
            namedtuple(int, List[Tuple(Register, int)]): A 2-tuple. The first element (``index``)
            contains the index at which the ``Bit`` can be found (in either
            :obj:`~QuantumCircuit.qubits`, :obj:`~QuantumCircuit.clbits`, depending on its
            type). The second element (``registers``) is a list of ``(register, index)``
            pairs with an entry for each :obj:`~Register` in the circuit which contains the
            :obj:`~Bit` (and the index in the :obj:`~Register` at which it can be found).

        Raises:
            CircuitError: If the supplied :obj:`~Bit` was of an unknown type.
            CircuitError: If the supplied :obj:`~Bit` could not be found on the circuit.

        Examples:
            Loop through a circuit, getting the qubit and clbit indices of each operation::

                from qiskit.circuit import QuantumCircuit, Qubit

                qc = QuantumCircuit(3, 3)
                qc.h(0)
                qc.cx(0, 1)
                qc.cx(1, 2)
                qc.measure([0, 1, 2], [0, 1, 2])

                # The `.qubits` and `.clbits` fields are not integers.
                assert isinstance(qc.data[0].qubits[0], Qubit)
                # ... but we can use `find_bit` to retrieve them.
                assert qc.find_bit(qc.data[0].qubits[0]).index == 0

                simple = [
                    (
                        instruction.operation.name,
                        [qc.find_bit(bit).index for bit in instruction.qubits],
                        [qc.find_bit(bit).index for bit in instruction.clbits],
                    )
                    for instruction in qc.data
                ]
        z&Could not locate bit of unknown type: zCould not locate provided bit: z*. Has it been added to the QuantumCircuit?N)ra   r6   r‚   r:   rƒ   r   rm   r[  )r“   r´   Úerrs      rf   rH  zQuantumCircuit.find_bit5  sª   € ðf
	Ý˜#�uÑ%Ô%ð YØÔ*¨3Ô/Ð/Ý˜C¥Ñ'Ô'ð YØÔ*¨3Ô/Ð/å"Ð#WÍDÐQTÉIÌIÐ#WÐ#WÑXÔXÐXøÝð 	ð 	ð 	ÝØa°#ÐaÐaÐañô àðøøøøð	øøøs"   ‚!A% ¤!A% ÁA% Á%
BÁ/BÂBc                ó‚   — t          |¦  «        }t          |¦  «        t          |¦  «        k    rt          d¦  «        ‚dS )z6Raise exception if list of qubits contains duplicates.zduplicate qubit argumentsN)rÔ   r»  r   )r“   rÀ   Úsqubitss      rf   r)  zQuantumCircuit._check_dupst  s;   € å�f‘+”+ˆÝˆw‰<Œ<�3˜v™;œ;Ò&Ð&ÝÐ:Ñ;Ô;Ð;ð 'Ð&rh   Úparameter_mapú*dict[Parameter, ParameterValueType] | Noner   c                ó*   — ddl m}  || ||¬¦  «        S )a’  Create an :class:`~.circuit.Instruction` out of this circuit.

        .. seealso::
            :func:`circuit_to_instruction`
                The underlying driver of this method.

        Args:
            parameter_map: For parameterized circuits, a mapping from
               parameters in the circuit to parameters to be used in the
               instruction. If None, existing circuit parameters will also
               parameterize the instruction.
            label: Optional gate label.

        Returns:
            qiskit.circuit.Instruction: a composite instruction encapsulating this circuit (can be
                decomposed back).
        r   )Úcircuit_to_instructionr#  )Ú(qiskit.converters.circuit_to_instructionr–  )r“   r“  ro  r–  s       rf   r^  zQuantumCircuit.to_instructionz  s/   € ð, 	TÐSÐSÐSÐSÐSà%Ð% d¨MÀÐGÑGÔGÐGrh   r   c                ó*   — ddl m}  || ||¬¦  «        S )a†  Create a :class:`.Gate` out of this circuit.  The circuit must act only qubits and
        contain only unitary operations.

        .. seealso::
            :func:`circuit_to_gate`
                The underlying driver of this method.

        Args:
            parameter_map: For parameterized circuits, a mapping from parameters in the circuit to
                parameters to be used in the gate. If ``None``, existing circuit parameters will
                also parameterize the gate.
            label : Optional gate label.

        Returns:
            Gate: a composite gate encapsulating this circuit (can be decomposed back).
        r   )Úcircuit_to_gater#  )Ú!qiskit.converters.circuit_to_gater™  )r“   r“  ro  r™  s       rf   r]  zQuantumCircuit.to_gate”  s.   € ð* 	FÐEÐEÐEÐEÐEàˆ˜t ]¸%Ð@Ñ@Ô@Ð@rh   Úgates_to_decomposeúBstr | Type[Instruction] | Sequence[str | Type[Instruction]] | Nonec                óÂ   — ddl m} ddlm} ddlm}  || d¬¦  «        } ||d¬¦  «        }t          |¦  «        D ]}|                     |¦  «        }Œ ||d¬¦  «        S )	a  Call a decomposition pass on this circuit, to decompose one level (shallow decompose).

        Args:
            gates_to_decompose: Optional subset of gates to decompose. Can be a gate type, such as
                ``HGate``, or a gate name, such as "h", or a gate label, such as "My H Gate", or a
                list of any combination of these. If a gate name is entered, it will decompose all
                gates with that name, whether the gates have labels or not. Defaults to all gates in
                the circuit.
            reps: Optional number of times the circuit should be decomposed.
                For instance, ``reps=2`` equals calling ``circuit.decompose().decompose()``.

        Returns:
            QuantumCircuit: a circuit one level decomposed
        r   )Ú	Decomposer	  )Údag_to_circuitTr  )Úapply_synthesisF)Ú(qiskit.transpiler.passes.basis.decomposerž  Ú qiskit.converters.circuit_to_dagr
  Ú qiskit.converters.dag_to_circuitrŸ  r_  Úrun)	r“   r›  r[  rž  r
  rŸ  ÚdagÚpass_rþ   s	            rf   Ú	decomposezQuantumCircuit.decompose­  s¡   € ð, 	GÐFÐFÐFÐFÐFØCÐCÐCÐCÐCÐCØCÐCÐCÐCÐCÐCàˆn˜T°4Ð8Ñ8Ô8ˆà�	Ð,¸dÐCÑCÔCˆÝ�t‘”ð 	!ð 	!ˆAØ—)’)˜C‘.”.ˆCˆCð ˆ~˜c°5Ð9Ñ9Ô9Ð9rh   Úmediumé   r  Úscaleúfloat | NoneÚfilenameÚstyleúdict | str | NoneÚinteractiveÚplot_barriersrS  úbool | NoneÚjustifyÚvertical_compressionÚ
idle_wiresÚwith_layoutÚfoldú
int | NoneÚaxú
Any | NoneÚinitial_stateÚ
cregbundleÚ
wire_orderúlist[int] | NoneÚexpr_lenc                ó‚   — ddl m}  || fi d|“d|“d|“d|“d|“d|“d	|“d
|“d|	“d|
“d|“d|“d|“d|“d|“d|“d|“ŽS )aì  Draw the quantum circuit. Use the output parameter to choose the drawing format:

        **text**: ASCII art TextDrawing that can be printed in the console.

        **mpl**: images with color rendered purely in Python using matplotlib.

        **latex**: high-quality images compiled via latex.

        **latex_source**: raw uncompiled latex output.

        .. warning::

            Support for :class:`~.expr.Expr` nodes in conditions and :attr:`.SwitchCaseOp.target`
            fields is preliminary and incomplete.  The ``text`` and ``mpl`` drawers will make a
            best-effort attempt to show data dependencies, but the LaTeX-based drawers will skip
            these completely.

        Args:
            output: Select the output method to use for drawing the circuit.
                Valid choices are ``text``, ``mpl``, ``latex``, ``latex_source``.
                By default, the ``text`` drawer is used unless the user config file
                (usually ``~/.qiskit/settings.conf``) has an alternative backend set
                as the default. For example, ``circuit_drawer = latex``. If the output
                kwarg is set, that backend will always be used over the default in
                the user config file.
            scale: Scale of image to draw (shrink if ``< 1.0``). Only used by
                the ``mpl``, ``latex`` and ``latex_source`` outputs. Defaults to ``1.0``.
            filename: File path to save image to. Defaults to ``None`` (result not saved in a file).
            style: Style name, file name of style JSON file, or a dictionary specifying the style.

                * The supported style names are ``"iqp"`` (default), ``"iqp-dark"``, ``"clifford"``,
                  ``"textbook"`` and ``"bw"``.
                * If given a JSON file, e.g. ``my_style.json`` or ``my_style`` (the ``.json``
                  extension may be omitted), this function attempts to load the style dictionary
                  from that location. Note, that the JSON file must completely specify the
                  visualization specifications. The file is searched for in
                  ``qiskit/visualization/circuit/styles``, the current working directory, and
                  the location specified in ``~/.qiskit/settings.conf``.
                * If a dictionary, every entry overrides the default configuration. If the
                  ``"name"`` key is given, the default configuration is given by that style.
                  For example, ``{"name": "textbook", "subfontsize": 5}`` loads the ``"texbook"``
                  style and sets the subfontsize (e.g. the gate angles) to ``5``.
                * If ``None`` the default style ``"iqp"`` is used or, if given, the default style
                  specified in ``~/.qiskit/settings.conf``.

            interactive: When set to ``True``, show the circuit in a new window
                (for ``mpl`` this depends on the matplotlib backend being used
                supporting this). Note when used with either the `text` or the
                ``latex_source`` output type this has no effect and will be silently
                ignored. Defaults to ``False``.
            reverse_bits: When set to ``True``, reverse the bit order inside
                registers for the output visualization. Defaults to ``False`` unless the
                user config file (usually ``~/.qiskit/settings.conf``) has an
                alternative value set. For example, ``circuit_reverse_bits = True``.
            plot_barriers: Enable/disable drawing barriers in the output
                circuit. Defaults to ``True``.
            justify: Options are ``"left"``, ``"right"`` or ``"none"`` (str).
                If anything else is supplied, left justified will be used instead.
                It refers to where gates should be placed in the output circuit if
                there is an option. ``none`` results in each gate being placed in
                its own column. Defaults to ``left``.
            vertical_compression: ``high``, ``medium`` or ``low``. It
                merges the lines generated by the `text` output so the drawing
                will take less vertical room.  Default is ``medium``. Only used by
                the ``text`` output, will be silently ignored otherwise.
            idle_wires: Include idle wires (wires with no circuit elements)
                in output visualization. Default is ``True`` unless the
                user config file (usually ``~/.qiskit/settings.conf``) has an
                alternative value set. For example, ``circuit_idle_wires = False``.
            with_layout: Include layout information, with labels on the
                physical layout. Default is ``True``.
            fold: Sets pagination. It can be disabled using -1. In ``text``,
                sets the length of the lines. This is useful when the drawing does
                not fit in the console. If None (default), it will try to guess the
                console width using ``shutil.get_terminal_size()``. However, if
                running in jupyter, the default line length is set to 80 characters.
                In ``mpl``, it is the number of (visual) layers before folding.
                Default is 25.
            ax: Only used by the `mpl` backend. An optional ``matplotlib.axes.Axes``
                object to be used for the visualization output. If none is
                specified, a new matplotlib Figure will be created and used.
                Additionally, if specified there will be no returned Figure since
                it is redundant.
            initial_state: Adds :math:`|0\rangle` in the beginning of the qubit wires and
                :math:`0` to classical wires. Default is ``False``.
            cregbundle: If set to ``True``, bundle classical registers.
                Default is ``True``, except for when ``output`` is set to  ``"text"``.
            wire_order: A list of integers used to reorder the display
                of the bits. The list must have an entry for every bit with the bits
                in the range 0 to (``num_qubits`` + ``num_clbits``).
            expr_len: The number of characters to display if an :class:`~.expr.Expr`
                is used for the condition in a :class:`.ControlFlowOp`. If this number is exceeded,
                the string will be truncated at that number and '...' added to the end.

        Returns:
            :class:`.TextDrawing` or :class:`matplotlib.figure` or :class:`PIL.Image` or
            :class:`str`:

            * ``TextDrawing`` (if ``output='text'``)
                A drawing that can be printed as ascii art.
            * ``matplotlib.figure.Figure`` (if ``output='mpl'``)
                A matplotlib figure object for the circuit diagram.
            * ``PIL.Image`` (if ``output='latex``')
                An in-memory representation of the image of the circuit diagram.
            * ``str`` (if ``output='latex_source'``)
                The LaTeX source code for visualizing the circuit diagram.

        Raises:
            VisualizationError: when an invalid output method is selected
            ImportError: when the output methods requires non-installed libraries.

        Example:
            .. plot::
               :alt: Circuit diagram output by the previous code.
               :include-source:

               from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
               qc = QuantumCircuit(1, 1)
               qc.h(0)
               qc.measure(0, 0)
               qc.draw(output='mpl', style={'backgroundcolor': '#EEEEEE'})
        r   )Úcircuit_drawerrª  r¬  r­  r  r¯  r°  rS  r²  r³  r´  rµ  r¶  r¸  rº  r»  r¼  r¾  )Úqiskit.visualizationrÀ  )r“   r  rª  r¬  r­  r¯  r°  rS  r²  r³  r´  rµ  r¶  r¸  rº  r»  r¼  r¾  rÀ  s                      rf   r  zQuantumCircuit.drawÐ  sþ   € ðd 	8Ð7Ð7Ð7Ð7Ð7àˆ~Øð
ð 
ð 
à�%ð
ð �Xð
ð �%ð	
ð
 �6ð
ð $˜ð
ð (˜-ð
ð &˜ð
ð �Gð
ð "6Ð!5ð
ð "�zð
ð $˜ð
ð �ð
ð ˆrð
ð (˜-ð
ð  "�zð!
ð" "�zð#
ð$ �Xð%
ð 	
rh   c                ó0   — t          | j        dd¦  «         S ©NÚ
_directiveF©rœ  rú   ©Úxs    rf   ú<lambda>zQuantumCircuit.<lambda>{  s   € ½GØŒK˜ uñ=
ô =
ð 9
€ rh   Úfilter_functionúCallable[..., int]c                óF   — t          t          || j        ¦  «        ¦  «        S )aŒ  Returns total number of instructions in circuit.

        Args:
            filter_function (callable): a function to filter out some instructions.
                Should take as input a tuple of (Instruction, list(Qubit), list(Clbit)).
                By default, filters out "directives", such as barrier or snapshot.

        Returns:
            int: Total number of gate operations.
        )ÚsumÚmapr„   )r“   rÉ  s     rf   ÚsizezQuantumCircuit.sizey  s   € õ  •3�¨¬
Ñ3Ô3Ñ4Ô4Ð4rh   c                ó0   — t          | j        dd¦  «         S rÃ  rÅ  rÆ  s    rf   rÈ  zQuantumCircuit.<lambda>�  s!   € ÍgØŒK˜ uñO
ô O
ð K
€ rh   ú$Callable[[CircuitInstruction], bool]c                óÆ  ‡— d„ | j         | j        |                      ¦   «         fD ¦   «         Šd„ }| j        D �]‡}t	          t          j        |j         |j        ¦  «        ¦  «        }t          |j        dd¦  «        x}�€| 	                    t          j        |¦  «        j        ¦  «         t          |t          j        ¦  «        r |||¦  «         n¶| 	                    t          j        |¦  «        j        ¦  «         n‰t          |j        t          ¦  «        r) ||t          j        |j        j        ¦  «        ¦  «         nFt          |j        t$          ¦  «        r, |||j        j        ¦  «          |||j        j        ¦  «         t+          ˆfd„|D ¦   «         d¬¦  «        } ||¦  «        r|dz  }|D ]}|‰|<   Œ�Œ‰t+          ‰                     ¦   «         d¬¦  «        S )	aï  Return circuit depth (i.e., length of critical path).

        The depth of a quantum circuit is a measure of how many
        "layers" of quantum gates, executed in parallel, it takes to
        complete the computation defined by the circuit.  Because
        quantum gates take time to implement, the depth of a circuit
        roughly corresponds to the amount of time it takes the quantum
        computer to execute the circuit.


        .. warning::
            This operation is not well defined if the circuit contains control-flow operations.

        Args:
            filter_function: A function to decide which instructions count to increase depth.
                Should take as a single positional input a :class:`CircuitInstruction`.
                Instructions for which the function returns ``False`` are ignored in the
                computation of the circuit depth.  By default, filters out "directives", such as
                :class:`.Barrier`.

        Returns:
            int: Depth of circuit.

        Examples:
            Simple calculation of total circuit depth::

                from qiskit.circuit import QuantumCircuit
                qc = QuantumCircuit(4)
                qc.h(0)
                qc.cx(0, 1)
                qc.h(2)
                qc.cx(2, 3)
                assert qc.depth() == 2

            Modifying the previous example to only calculate the depth of multi-qubit gates::

                assert qc.depth(lambda instr: len(instr.qubits) > 1) == 1
        c                ó   — i | ]
}|D ]}|d “ŒŒS ©r   rQ   )rd   ÚobjectsÚobjs      rf   r¶   z(QuantumCircuit.depth.<locals>.<dictcomp>·  s<   € ð 
ð 
ð 
ØÐZað
ð 
ØSVˆC�ð
ð 
ð 
ð 
rh   c                óÆ   — t          j        |¦  «        D ]K}|j        r|                      |¦  «         Œ|                      t          j        |¦  «        j        ¦  «         ŒLd S r`   )r1   rà  rl  ÚaddrÖ   r"   Únode_resourcesrÃ   )rÔ  Únoder—   s      rf   Úupdate_from_exprz.QuantumCircuit.depth.<locals>.update_from_expr»  sl   € Ý”~ dÑ+Ô+ð Nð N�Ø”>ð NØ—K’K Ñ$Ô$Ð$Ð$à—N’N¥>Ô#@ÀÑ#EÔ#EÔ#LÑMÔMÐMÐMð	Nð Nrh   rš  Nc              3  ó(   •K  — | ]}‰|         V — Œd S r`   rQ   )rd   rÕ  Ú
obj_depthss     €rf   rg   z'QuantumCircuit.depth.<locals>.<genexpr>Ó  s'   øè è € Ð@Ð@°˜Z¨œ_Ð@Ð@Ð@Ð@Ð@Ð@rh   r   rk  r   )rÀ   rÃ   rà  r„   rÔ   rÛ  rÜ  rœ  rú   rÖ   r"   Úcondition_resourcesra   r1   r<  r-   rr  r¢  rD   r¤  r¥  ÚmaxrÞ  )	r“   rÉ  rÚ  rØ   rÔ  rž  Ú	new_depthrÕ  rÜ  s	           @rf   ÚdepthzQuantumCircuit.depth‹  s	  ø€ ðX
ð 
Ø#'¤;°´¸T¿^º^Ñ=MÔ=MÐ"Nð
ñ 
ô 
ˆ
ð	Nð 	Nð 	Nð  œ:ð 	,ñ 	,ˆKÝ�)œ/¨+Ô*<¸kÔ>PÑQÔQÑRÔRˆGÝ$ [Ô%:¸LÈ$ÑOÔOÐO�	Ð\Ø—’�~ÔAÀ)ÑLÔLÔSÑTÔTÐTÝ˜i­¬Ñ3Ô3ð YØ$Ð$ W¨iÑ8Ô8Ð8Ð8à—N’N¥>Ô#EÀiÑ#PÔ#PÔ#WÑXÔXÐXÐXÝ˜KÔ1µ<Ñ@Ô@ð HØ Ð  ­$¬)°KÔ4IÔ4PÑ*QÔ*QÑRÔRÐRÐRÝ˜KÔ1µ5Ñ9Ô9ð HØ Ð  ¨+Ô*?Ô*FÑGÔGÐGØ Ð  ¨+Ô*?Ô*FÑGÔGÐGõ
 Ð@Ð@Ð@Ð@¸Ð@Ñ@Ô@È!ÐLÑLÔLˆIØˆ˜{Ñ+Ô+ð Ø˜Q‘�	Øð ,ð ,�Ø"+�
˜3‘�ñ,å�:×$Ò$Ñ&Ô&°Ð2Ñ2Ô2Ð2rh   c                ó4   — | j                              ¦   «         S )znReturn number of qubits plus clbits in circuit.

        Returns:
            int: Width of circuit.

        )r„   ÚwidthrŸ   s    rf   râ  zQuantumCircuit.widthÚ  s   € ð Œz×ÒÑ!Ô!Ð!rh   c                ó   — | j         j        S )zReturn number of qubits.)r„   r¿   rŸ   s    rf   r¿   zQuantumCircuit.num_qubitsã  ó   € ð ŒzÔ$Ð$rh   c                ó*   — t          | j        ¦  «        S )z$Return the number of ancilla qubits.)r»  rÏ  rŸ   s    rf   Únum_ancillaszQuantumCircuit.num_ancillasè  s   € õ �4”=Ñ!Ô!Ð!rh   c                ó   — | j         j        S )z Return number of classical bits.)r„   rÂ   rŸ   s    rf   rÂ   zQuantumCircuit.num_clbitsí  rä  rh   ú'OrderedDict[Instruction, int]'c                óR   — | j                              ¦   «         }t          |¦  «        S )z Count each operation kind in the circuit.

        Returns:
            OrderedDict: a breakdown of how many operations of each kind, sorted by amount.
        )r„   Ú	count_opsr   )r“   Úops_dicts     rf   rê  zQuantumCircuit.count_opsõ  s%   € ð ”:×'Ò'Ñ)Ô)ˆÝ˜8Ñ$Ô$Ð$rh   c                ó4   — | j                              ¦   «         S )z|Return number of non-local gates (i.e. involving 2+ qubits).

        Conditional nonlocal gates are also included.
        )r„   Únum_nonlocal_gatesrŸ   s    rf   rí  z!QuantumCircuit.num_nonlocal_gatesþ  s   € ð
 Œz×,Ò,Ñ.Ô.Ð.rh   c                ó*   ‡— ˆfd„| j         D ¦   «         S )z»Get instructions matching name.

        Args:
            name (str): The name of instruction to.

        Returns:
            list(tuple): list of (instruction, qargs, cargs).
        c                ó4   •— g | ]}|j         j        ‰k    ¯|‘ŒS rQ   )rú   rR   )rd   ÚmatchrR   s     €rf   ro   z3QuantumCircuit.get_instructions.<locals>.<listcomp>  s(   ø€ ÐNÐNÐN˜%°´Ô1EÈÒ1MÐ1M�Ð1MÐ1MÐ1Mrh   rý  )r“   rR   s    `rf   Úget_instructionszQuantumCircuit.get_instructions  s"   ø€ ð OÐNÐNÐN 4¤:ÐNÑNÔNÐNrh   Úunitary_onlyc                óL  — |r| j         n| j         | j        z   }d„ t          |¦  «        D ¦   «         }d„ t          t	          |¦  «        ¦  «        D ¦   «         }t	          |¦  «        }| j        D �]´}|r|j         }t	          |¦  «        }n9|j         |j        z   }t	          |¦  «        t          |j        dd¦  «        rdndz   }|dk    �rPt          |j        dd	¦  «        �s9g }	d}
|sJ|j        j        D ]=}||         }t          |¦  «        D ]#}|||         v r|	 	                    |¦  «          nŒ$Œ>|D ]A}||         }t          |¦  «        D ]'}|||         v r||	vr|	 	                    |¦  «          nŒ(ŒBt          t          |	¦  «        ¦  «        }	t	          |	¦  «        }
|
dk    rtg }|	D ]}|                     ||         ¦  «         Œg }t          |¦  «        D ]!}||	vr| 	                    ||         ¦  «         Œ"| 	                    |¦  «         |}||
dz
  z  }|dk    r n�Œ¶|S )
zíHow many non-entangled subcircuits can the circuit be factored to.

        Args:
            unitary_only (bool): Compute only unitary part of graph.

        Returns:
            int: Number of connected components in circuit.
        c                ó   — i | ]\  }}||“Œ	S rQ   rQ   )rd   rK  r´   s      rf   r¶   z;QuantumCircuit.num_connected_components.<locals>.<dictcomp>  s   € Ð0ZÐ0ZÐ0Z¹h¸cÀ3°°cÐ0ZÐ0ZÐ0Zrh   c                ó   — g | ]}|g‘ŒS rQ   rQ   )rd   r´   s     rf   ro   z;QuantumCircuit.num_connected_components.<locals>.<listcomp>  s   € Ð?Ð?Ð? �s�eÐ?Ð?Ð?rh   rš  Nr   r   r‚  rÄ  F)rÀ   rÃ   rÁ   r_  r»  r„   rœ  rú   Úcondition_bitsrã   rb   rÔ   r³  )r“   rò  r±   Úbit_indicesÚ
sub_graphsÚnum_sub_graphsrØ   ÚargsÚ	num_qargsÚgraphs_touchedÚnum_touchedr´   rK  r  rô  Úreg_intÚconnectionsÚ_sub_graphss                     rf   Únum_connected_componentsz'QuantumCircuit.num_connected_components  s²  € ð +ÐKˆtŒ{ˆ{°´¸t¼{Ñ1JˆØ0ZÐ0ZÍ)ÐTXÉ/Ì/Ð0ZÑ0ZÔ0Zˆð @Ð?¥u­S°Ñ-=Ô-=Ñ'>Ô'>Ð?Ñ?Ô?ˆ
å˜Z™œˆð  œ:ð 2	ñ 2	ˆKØð Ø"Ô)�Ý ™IœI�	�	à"Ô)¨KÔ,>Ñ>�Ý ™IœIÝ  Ô!6¸ÀdÑKÔKÐR�A�AÐQRñ�	ð ˜AŠ~‰~¥g¨kÔ.CÀ\ÐSXÑ&YÔ&Y‰~Ø!#�Ø�ð $ð &Ø*Ô4ÔCð &ð &˜Ø)¨#Ô.˜Ý!& ~Ñ!6Ô!6ð &ð &˜AØ" j°¤mÐ3Ð3Ø .× 5Ò 5°aÑ 8Ô 8Ð 8Ø % ð  4øð !ð &ð &�DØ)¨$Ô/�GÝ" >Ñ2Ô2ð &ð &˜Ø" j°¤mÐ3Ð3Ø ¨Ð6Ð6Ø .× 5Ò 5°aÑ 8Ô 8Ð 8Ø % øøå!%¥c¨.Ñ&9Ô&9Ñ!:Ô!:�Ý! .Ñ1Ô1�ð
  ’?�?Ø"$�KØ-ð <ð <˜Ø#×*Ò*¨:°c¬?Ñ;Ô;Ð;Ð;Ø"$�KÝ$ ^Ñ4Ô4ð @ð @˜Ø nÐ4Ð4Ø'×.Ò.¨z¸#¬Ñ?Ô?Ð?øØ×&Ò& {Ñ3Ô3Ð3Ø!,�JØ" k°A¡oÑ5�Nà Ò"Ð"Ø�ñ #àÐrh   c                ó.   — |                       d¬¦  «        S )ziComputes the number of tensor factors in the unitary
        (quantum) part of the circuit only.
        T)rò  )r  rŸ   s    rf   Únum_unitary_factorsz"QuantumCircuit.num_unitary_factorsY  s   € ð ×,Ò,¸$Ð,Ñ?Ô?Ð?rh   c                ó*   — |                       ¦   «         S )a)  Computes the number of tensor factors in the unitary
        (quantum) part of the circuit only.

        Notes:
            This is here for backwards compatibility, and will be
            removed in a future release of Qiskit. You should call
            `num_unitary_factors` instead.
        )r  rŸ   s    rf   Únum_tensor_factorsz!QuantumCircuit.num_tensor_factors_  s   € ð ×'Ò'Ñ)Ô)Ð)rh   c                ól   — |                       |¦  «        }| j                             ¦   «         |_        |S )zõCopy the circuit.

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

        Returns:
          QuantumCircuit: a deepcopy of the current circuit, with the specified name
        )r>  r„   rá   )r“   rR   Úcpys      rf   rá   zQuantumCircuit.copyj  s/   € ð ×"Ò" 4Ñ(Ô(ˆØ”J—O’OÑ%Ô%ˆŒ	Øˆ
rh   Úalike)Ú	vars_moder	  ú$Literal['alike', 'captures', 'drop']c               ó   — |�(t          |t          ¦  «        st          d|› d�¦  «        ‚t          j        | ¦  «        }t          | ||¦  «         t          | j        j        | j        j	        | j        j
        ¬¦  «        |_        |r||_        |S )aí  Return a copy of self with the same structure but empty.

        That structure includes:

        * name, calibrations and other metadata
        * global phase
        * all the qubits and clbits, including the registers
        * the realtime variables defined in the circuit, handled according to the ``vars`` keyword
          argument.

        .. warning::

            If the circuit contains any local variable declarations (those added by the
            ``declarations`` argument to the circuit constructor, or using :meth:`add_var`), they
            may be **uninitialized** in the output circuit.  You will need to manually add store
            instructions for them (see :class:`.Store` and :meth:`.QuantumCircuit.store`) to
            initialize them.

        Args:
            name: Name for the copied circuit. If None, then the name stays the same.
            vars_mode: The mode to handle realtime variables in.

                alike
                    The variables in the output circuit will have the same declaration semantics as
                    in the original circuit.  For example, ``input`` variables in the source will be
                    ``input`` variables in the output circuit.

                captures
                    All variables will be converted to captured variables.  This is useful when you
                    are building a new layer for an existing circuit that you will want to
                    :meth:`compose` onto the base, since :meth:`compose` can inline captures onto
                    the base circuit (but not other variables).

                drop
                    The output circuit will have no variables defined.

        Returns:
            QuantumCircuit: An empty copy of self.
        Nzinvalid name for a circuit: 'z''. The name must be a string or 'None'.)rS   )ra   rz   ru   r  rá   Ú_copy_metadatar   r„   rÀ   rÃ   rS   rR   )r“   rR   r	  r  s       rf   r>  zQuantumCircuit.copy_empty_likew  s�   € ðZ �¥
¨4µÑ 5Ô 5�ÝØ]°Ð]Ð]Ð]ñô ð õ Œj˜ÑÔˆå�t˜S )Ñ,Ô,Ð,åØŒJÔ˜tœzÔ0¸t¼zÔ?Vð
ñ 
ô 
ˆŒ	ð ð 	ØˆCŒHØˆ
rh   c                óP   — | j                              ¦   «          | j        | _        dS )ak  Clear all instructions in self.

        Clearing the circuits will keep the metadata and calibrations.

        .. seealso::
            :meth:`copy_empty_like`
                A method to produce a new circuit with no instructions and all the same tracking of
                quantum and classical typed data, but without mutating the original circuit.
        N)r„   râ   rS   rŸ   s    rf   râ   zQuantumCircuit.clear´  s)   € ð 	Œ
×ÒÑÔÐà Ô-ˆÔÐÐrh   Úlengthr9   c                ó´   — |d„ | j         D ¦   «         v r4t          j        }|t          _        t          |¦  «        }|t          _        nt          ||¦  «        }|S )zCCreates a creg, checking if ClassicalRegister with same name existsc                ó   — g | ]	}|j         ‘Œ
S rQ   r¯   )rd   Úcregs     rf   ro   z/QuantumCircuit._create_creg.<locals>.<listcomp>Ä  ó   € Ð5Ð5Ð5 $�D”IÐ5Ð5Ð5rh   )r�   r9   r,  )r“   r  rR   Úsave_prefixÚnew_cregs        rf   Ú_create_cregzQuantumCircuit._create_cregÂ  s\   € àÐ5Ð5¨$¬*Ð5Ñ5Ô5Ð5Ð5Ý+Ô2ˆKØ'+ÕÔ$Ý(¨Ñ0Ô0ˆHØ'2ÕÔ$Ð$å(¨°Ñ6Ô6ˆHØˆrh   c                ó´   — |d„ | j         D ¦   «         v r4t          j        }|t          _        t          |¦  «        }|t          _        nt          ||¦  «        }|S )zACreates a qreg, checking if QuantumRegister with same name existsc                ó   — g | ]	}|j         ‘Œ
S rQ   r¯   )rd   rˆ  s     rf   ro   z/QuantumCircuit._create_qreg.<locals>.<listcomp>Ï  r  rh   )r€   r5   r,  )r“   r  rR   r  Únew_qregs        rf   Ú_create_qregzQuantumCircuit._create_qregÍ  sZ   € àÐ5Ð5¨$¬*Ð5Ñ5Ô5Ð5Ð5Ý)Ô0ˆKØ%)�OÔ"Ý& vÑ.Ô.ˆHØ%0�OÔ"Ð"å& v¨tÑ4Ô4ˆHØˆrh   rÎ   c                óR   — ddl m} |                       |¦   «         |gg d¬¦  «        S )zÌReset the quantum bit(s) to their default state.

        Args:
            qubit: qubit(s) to reset.

        Returns:
            qiskit.circuit.InstructionSet: handle to the added instruction.
        r   )ÚResetFrà   )Úresetr  rã   )r“   rÎ   r  s      rf   r  zQuantumCircuit.resetØ  s8   € ð 	!Ð Ð Ð Ð Ð à�{Š{˜5˜5™7œ7 U G¨R°eˆ{Ñ<Ô<Ð<rh   r¤  r¥  c               ó  — t          j        |¦  «        }t          |t          ¦  «        rt          |t          ¦  «        s|j        nd}t          j        ||¦  «        }|                      t          ||¦  «        ddd¬¦  «        S )a±  Store the result of the given real-time classical expression ``rvalue`` in the memory
        location defined by ``lvalue``.

        Typically ``lvalue`` will be a :class:`~.expr.Var` node and ``rvalue`` will be some
        :class:`~.expr.Expr` to write into it, but anything that :func:`.expr.lift` can raise to an
        :class:`~.expr.Expr` is permissible in both places, and it will be called on them.

        Args:
            lvalue: a valid specifier for a memory location in the circuit.  This will typically be
                a :class:`~.expr.Var` node, but you can also write to :class:`.Clbit` or
                :class:`.ClassicalRegister` memory locations if your hardware supports it.  The
                memory location must already be present in the circuit.
            rvalue: a real-time classical expression whose result should be written into the given
                memory location.

        .. seealso::
            :class:`~.circuit.Store`
                The backing :class:`~.circuit.Instruction` class that represents this operation.

            :meth:`add_var`
                Create a new variable in the circuit that can be written to with this method.
        NrQ   Frà   )r1   rr  ra   rk   r«   rm   rã   rD   )r“   r¤  r¥  Úrvalue_types       rf   ru  zQuantumCircuit.storeå  sw   € õ0 ”˜6Ñ"Ô"ˆå% f­cÑ2Ô2Ð]½:ÀfÍdÑ;SÔ;SÐ]ˆFŒKˆKÐY]ð 	õ ”˜6 ;Ñ/Ô/ˆØ�{Š{�5 ¨Ñ0Ô0°"°b¸uˆ{ÑEÔEÐErh   Úcbitc                óT   — ddl m} |                       |¦   «         |g|gd¬¦  «        S )uâ	  Measure a quantum bit (``qubit``) in the Z basis into a classical bit (``cbit``).

        When a quantum state is measured, a qubit is projected in the computational (Pauli Z) basis
        to either :math:`\lvert 0 \rangle` or :math:`\lvert 1 \rangle`. The classical bit ``cbit``
        indicates the result
        of that projection as a ``0`` or a ``1`` respectively. This operation is non-reversible.

        Args:
            qubit: qubit(s) to measure.
            cbit: classical bit(s) to place the measurement result(s) in.

        Returns:
            qiskit.circuit.InstructionSet: handle to the added instructions.

        Raises:
            CircuitError: if arguments have bad format.

        Examples:
            In this example, a qubit is measured and the result of that measurement is stored in the
            classical bit (usually expressed in diagrams as a double line):

            .. code-block::

               from qiskit import QuantumCircuit
               circuit = QuantumCircuit(1, 1)
               circuit.h(0)
               circuit.measure(0, 0)
               circuit.draw()


            .. code-block:: text

                      â”Œâ”€â”€â”€â”�â”Œâ”€â”�
                   q: â”¤ H â”œâ”¤Mâ”œ
                      â””â”€â”€â”€â”˜â””â•¥â”˜
                 c: 1/â•�â•�â•�â•�â•�â•�â•©â•�
                            0

            It is possible to call ``measure`` with lists of ``qubits`` and ``cbits`` as a shortcut
            for one-to-one measurement. These two forms produce identical results:

            .. code-block::

               circuit = QuantumCircuit(2, 2)
               circuit.measure([0,1], [0,1])

            .. code-block::

               circuit = QuantumCircuit(2, 2)
               circuit.measure(0, 0)
               circuit.measure(1, 1)

            Instead of lists, you can use :class:`~qiskit.circuit.QuantumRegister` and
            :class:`~qiskit.circuit.ClassicalRegister` under the same logic.

            .. code-block::

                from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
                qreg = QuantumRegister(2, "qreg")
                creg = ClassicalRegister(2, "creg")
                circuit = QuantumCircuit(qreg, creg)
                circuit.measure(qreg, creg)

            This is equivalent to:

            .. code-block::

                circuit = QuantumCircuit(qreg, creg)
                circuit.measure(qreg[0], creg[0])
                circuit.measure(qreg[1], creg[1])

        r   )ÚMeasureFrà   )Úmeasurer!  rã   )r“   rÎ   r  r!  s       rf   r"  zQuantumCircuit.measure  s;   € ðR 	%Ð$Ð$Ð$Ð$Ð$à�{Š{˜7˜7™9œ9 u g°¨v¸Eˆ{ÑBÔBÐBrh   c                óN  ‡— ddl m} |r| }n|                      ¦   «         } ||¦  «        Šˆfd„|j        D ¦   «         }|                     t          |¦  «        d¦  «        }|                     |¦  «         |                     ¦   «          |                     ||¦  «         |s|S dS )a¦  Adds measurement to all non-idle qubits. Creates a new ClassicalRegister with
        a size equal to the number of non-idle qubits being measured.

        Returns a new circuit with measurements if `inplace=False`.

        Args:
            inplace (bool): All measurements inplace or return new circuit.

        Returns:
            QuantumCircuit: Returns circuit with measurements when ``inplace = False``.
        r   r	  c                ó@   •— g | ]}|‰                      ¦   «         v¯|‘ŒS rQ   )r´  )rd   rÎ   r¥  s     €rf   ro   z1QuantumCircuit.measure_active.<locals>.<listcomp>d  s-   ø€ Ð]Ð]Ð] u¸uÈCÏNÊNÑL\ÔL\Ð?\Ð?\˜UÐ?\Ð?\Ð?\rh   r"  N)	r¢  r
  rá   rÀ   r  r»  rˆ   r`  r"  )r“   r~  r
  rR  Úqubits_to_measurer  r¥  s         @rf   Úmeasure_activezQuantumCircuit.measure_activeQ  sÅ   ø€ ð 	DÐCÐCÐCÐCÐCàð 	ØˆDˆDà—9’9‘;”;ˆDØˆn˜TÑ"Ô"ˆØ]Ð]Ð]Ð]°´Ð]Ñ]Ô]ÐØ×$Ò$¥SÐ):Ñ%;Ô%;¸YÑGÔGˆØ×Ò˜(Ñ#Ô#Ð#Ø�Š‰ŒˆØ�ŠÐ&¨Ñ1Ô1Ð1àð 	ØˆKà�4rh   rÕ   c                óÄ  — |r| }n|                       ¦   «         }|r`|                     |j        d¦  «        }|                     |¦  «         |                     ¦   «          |                     |j        |¦  «         n`|j        |j        k     rt          d¦  «        ‚|                     ¦   «          |                     |j        |j	        d|j        …         ¦  «         |s|S dS )a  Adds measurement to all qubits.

        By default, adds new classical bits in a :obj:`.ClassicalRegister` to store these
        measurements.  If ``add_bits=False``, the results of the measurements will instead be stored
        in the already existing classical bits, with qubit ``n`` being measured into classical bit
        ``n``.

        Returns a new circuit with measurements if ``inplace=False``.

        Args:
            inplace (bool): All measurements inplace or return new circuit.
            add_bits (bool): Whether to add new bits to store the results.

        Returns:
            QuantumCircuit: Returns circuit with measurements when ``inplace=False``.

        Raises:
            CircuitError: if ``add_bits=False`` but there are not enough classical bits.
        rÅ  zPThe number of classical bits must be equal or greater than the number of qubits.r   N)
rá   r  r¿   rˆ   r`  r"  rÀ   rÂ   r   rÃ   )r“   r~  rÕ   rR  r  s        rf   Úmeasure_allzQuantumCircuit.measure_allo  så   € ð, ð 	ØˆDˆDà—9’9‘;”;ˆDØð 	HØ×(Ò(¨¬¸&ÑAÔAˆHØ×Ò˜hÑ'Ô'Ð'Ø�LŠL‰NŒNˆNØ�LŠL˜œ hÑ/Ô/Ð/Ð/àŒ ¤Ò0Ð0Ý"ð,ñô ð ð �LŠL‰NŒNˆNØ�LŠL˜œ d¤k°!°d´oÐ2EÔ&FÑGÔGÐGàð 	ØˆKà�4rh   c                ó  ‡‡— ddl m} ddlm} |r| }n|                      ¦   «         } ||¦  «        } |¦   «         }|                     |¦  «        }t          |j                             ¦   «         ¦  «        Št          |j	        ¦  «        Šˆfd„|j        D ¦   «         }ˆfd„|j
        j	        D ¦   «         }	g |_        i |_        t          |j
        j        t          |j
        ¦  «        |j        ¬¦  «        |_
        |                     |	¦  «         |D ]}
|                     |
¦  «         Œ|                     ¦   «         D ]<}|j                             ¦   «         }|                     ||j        |j        ¦  «         Œ=|s|S dS )aß  Removes final measurements and barriers on all qubits if they are present.
        Deletes the classical registers that were used to store the values from these measurements
        that become idle as a result of this operation, and deletes classical bits that are
        referenced only by removed registers, or that aren't referenced at all but have
        become idle as a result of this operation.

        Measurements and barriers are considered final if they are
        followed by no other operations (aside from other measurements or barriers.)

        .. note::
            This method has rather complex behavior, particularly around the removal of newly idle
            classical bits and registers.  It is much more efficient to avoid adding unnecessary
            classical data in the first place, rather than trying to remove it later.

        .. seealso::
            :class:`.RemoveFinalMeasurements`
                A transpiler pass that removes final measurements and barriers.  This does not
                remove the classical data.  If this is your goal, you can call that with::

                    from qiskit.circuit import QuantumCircuit
                    from qiskit.transpiler.passes import RemoveFinalMeasurements

                    qc = QuantumCircuit(2, 2)
                    qc.h(0)
                    qc.cx(0, 1)
                    qc.barrier()
                    qc.measure([0, 1], [0, 1])

                    pass_ = RemoveFinalMeasurements()
                    just_bell = pass_(qc)

        Args:
            inplace (bool): All measurements removed inplace or return new circuit.

        Returns:
            QuantumCircuit: Returns the resulting circuit when ``inplace=False``, else None.
        r   )ÚRemoveFinalMeasurementsr	  c                ó   •— g | ]}|‰v ¯|‘Œ	S rQ   rQ   )rd   r  Ú
kept_cregss     €rf   ro   z<QuantumCircuit.remove_final_measurements.<locals>.<listcomp>Ò  s#   ø€ ÐJÐJÐJ °t¸zÐ7IÐ7I˜Ð7IÐ7IÐ7Irh   c                ó   •— g | ]}|‰v ¯|‘Œ	S rQ   rQ   )rd   rÒ   Úkept_clbitss     €rf   ro   z<QuantumCircuit.remove_final_measurements.<locals>.<listcomp>Ó  s#   ø€ ÐVÐVÐV 5ÀÈ+ÐAUÐAU˜ÐAUÐAUÐAUrh   )rÀ   ÚreserverS   N)Úqiskit.transpiler.passesr*  r  r
  rá   r¤  rÔ   r�   rÞ  rÃ   r„   rƒ   r   rÀ   r»  rS   rÕ   rˆ   Útopological_op_nodesr¦  rã   rä   rå   )r“   r~  r*  r
  rR  r¥  Úremove_final_measÚnew_dagÚcregs_to_addÚclbits_to_addr  rÙ  rb  r.  r,  s                @@rf   Úremove_final_measurementsz(QuantumCircuit.remove_final_measurementsœ  s´  øø€ ðN 	EÐDÐDÐDÐDÐDØ4Ð4Ð4Ð4Ð4Ð4àð 	ØˆDˆDà—9’9‘;”;ˆDàˆn˜TÑ"Ô"ˆØ3Ð3Ñ5Ô5ÐØ#×'Ò'¨Ñ,Ô,ˆÝ˜œ×-Ò-Ñ/Ô/Ñ0Ô0ˆ
Ý˜'œ.Ñ)Ô)ˆð KÐJÐJÐJ¨¬ÐJÑJÔJˆØVÐVÐVÐV¨D¬JÔ,=ÐVÑVÔVˆð ˆŒ
Ø ˆÔõ !Ø”:Ô$­c°$´*©o¬oÈDÔL]ð
ñ 
ô 
ˆŒ
ð 	�Š�mÑ$Ô$Ð$Ø ð 	$ð 	$ˆDØ×Ò˜dÑ#Ô#Ð#Ð#ð ×0Ò0Ñ2Ô2ð 	6ð 	6ˆDà”7—<’<‘>”>ˆDØ�KŠK˜˜dœj¨$¬*Ñ5Ô5Ð5Ð5àð 	ØˆKà�4rh   Úpathc                ó`   — ddl m} |                     | |j        |j        |j        d¬¦  «        S )a‡  Read an OpenQASM 2.0 program from a file and convert to an instance of
        :class:`.QuantumCircuit`.

        Args:
          path (str): Path to the file for an OpenQASM 2 program

        Return:
          QuantumCircuit: The QuantumCircuit object for the input OpenQASM 2.

        See also:
            :func:`.qasm2.load`: the complete interface to the OpenQASM 2 importer.
        r   ©Úqasm2F©Úinclude_pathÚcustom_instructionsÚcustom_classicalÚstrict)Úqiskitr:  ÚloadÚLEGACY_INCLUDE_PATHÚLEGACY_CUSTOM_INSTRUCTIONSÚLEGACY_CUSTOM_CLASSICAL)r7  r:  s     rf   Úfrom_qasm_filezQuantumCircuit.from_qasm_fileð  sI   € ð 	!Ð Ð Ð Ð Ð à�zŠzØØÔ2Ø %Ô @Ø"Ô:Øð ñ 
ô 
ð 	
rh   Úqasm_strc                ó`   — ddl m} |                     | |j        |j        |j        d¬¦  «        S )av  Convert a string containing an OpenQASM 2.0 program to a :class:`.QuantumCircuit`.

        Args:
          qasm_str (str): A string containing an OpenQASM 2.0 program.
        Return:
          QuantumCircuit: The QuantumCircuit object for the input OpenQASM 2

        See also:
            :func:`.qasm2.loads`: the complete interface to the OpenQASM 2 importer.
        r   r9  Fr;  )r@  r:  ÚloadsrB  rC  rD  )rF  r:  s     rf   Úfrom_qasm_strzQuantumCircuit.from_qasm_str	  sI   € ð 	!Ð Ð Ð Ð Ð à�{Š{ØØÔ2Ø %Ô @Ø"Ô:Øð ñ 
ô 
ð 	
rh   c                óL   — | j         r| j         d         j        S | j        j        S )z9The global phase of the current circuit scope in radians.rE  ©r   rS   r„   rŸ   s    rf   rS   zQuantumCircuit.global_phase   s+   € ð Ô$ð 	>ØÔ,¨RÔ0Ô=Ð=ØŒzÔ&Ð&rh   Úanglec                óT   — | j         r|| j         d         _        dS || j        _        dS )z{Set the phase of the current circuit scope.

        Args:
            angle (float, ParameterExpression): radians
        rE  NrK  )r“   rL  s     rf   rS   zQuantumCircuit.global_phase'  s5   € ð Ô$ð 	,Ø9>ˆDÔ% bÔ)Ô6Ð6Ð6à&+ˆDŒJÔ#Ð#Ð#rh   r;   c                ó4   — t          | j        j        ¦  «        S )u
  The parameters defined in the circuit.

        This attribute returns the :class:`.Parameter` objects in the circuit sorted
        alphabetically. Note that parameters instantiated with a :class:`.ParameterVector`
        are still sorted numerically.

        Examples:

            The snippet below shows that insertion order of parameters does not matter.

            .. code-block:: python

                >>> from qiskit.circuit import QuantumCircuit, Parameter
                >>> a, b, elephant = Parameter("a"), Parameter("b"), Parameter("elephant")
                >>> circuit = QuantumCircuit(1)
                >>> circuit.rx(b, 0)
                >>> circuit.rz(elephant, 0)
                >>> circuit.ry(a, 0)
                >>> circuit.parameters  # sorted alphabetically!
                ParameterView([Parameter(a), Parameter(b), Parameter(elephant)])

            Bear in mind that alphabetical sorting might be unintuitive when it comes to numbers.
            The literal "10" comes before "2" in strict alphabetical sorting.

            .. code-block:: python

                >>> from qiskit.circuit import QuantumCircuit, Parameter
                >>> angles = [Parameter("angle_1"), Parameter("angle_2"), Parameter("angle_10")]
                >>> circuit = QuantumCircuit(1)
                >>> circuit.u(*angles, 0)
                >>> circuit.draw()
                   â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”�
                q: â”¤ U(angle_1,angle_2,angle_10) â”œ
                   â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
                >>> circuit.parameters
                ParameterView([Parameter(angle_1), Parameter(angle_10), Parameter(angle_2)])

            To respect numerical sorting, a :class:`.ParameterVector` can be used.

            .. code-block:: python

                >>> from qiskit.circuit import QuantumCircuit, Parameter, ParameterVector
                >>> x = ParameterVector("x", 12)
                >>> circuit = QuantumCircuit(1)
                >>> for x_i in x:
                ...     circuit.rx(x_i, 0)
                >>> circuit.parameters
                ParameterView([
                    ParameterVectorElement(x[0]), ParameterVectorElement(x[1]),
                    ParameterVectorElement(x[2]), ParameterVectorElement(x[3]),
                    ..., ParameterVectorElement(x[11])
                ])


        Returns:
            The sorted :class:`.Parameter` objects in the circuit.
        )r;   r„   rü   rŸ   s    rf   rü   zQuantumCircuit.parameters3  s   € õx ˜TœZÔ2Ñ3Ô3Ð3rh   c                ó4   — | j                              ¦   «         S )z/The number of parameter objects in the circuit.)r„   rj  rŸ   s    rf   rj  zQuantumCircuit.num_parametersq  s   € ð Œz×(Ò(Ñ*Ô*Ð*rh   úset[Parameter]c                ó4   — | j                              ¦   «         S )a^  Efficiently get all parameters in the circuit, without any sorting overhead.

        .. warning::

            The returned object may directly view onto the ``ParameterTable`` internals, and so
            should not be mutated.  This is an internal performance detail.  Code outside of this
            package should not use this method.
        )r„   Úunsorted_parametersrŸ   s    rf   Ú_unsorted_parametersz#QuantumCircuit._unsorted_parametersv  s   € ð Œz×-Ò-Ñ/Ô/Ð/rh   )Ú
flat_inputr?  rü   úKUnion[Mapping[Parameter, ParameterValueType], Iterable[ParameterValueType]]úLiteral[False]rT  r?  c               ó   — d S r`   rQ   ©r“   rü   r~  rT  r?  s        rf   Úassign_parametersz QuantumCircuit.assign_parametersƒ  s	   € ð ˜3rh   úLiteral[True]c               ó   — d S r`   rQ   rX  s        rf   rY  z QuantumCircuit.assign_parameters�  s	   € ð ˆsrh   c               óö  ‡ ‡‡‡	‡
‡‡— |r‰ }n]t          ‰t          ¦  «        s‰ j        j        }‰                      ¦   «         }|                     ¦   «          |                     ¦   «          t          ‰t          j        j	        ¦  «        r{|r‰n‰  
                    ‰¦  «        Š|r@ˆ fd„‰D ¦   «         x}r0t          dd                     d„ |D ¦   «         ¦  «        › d�¦  «        ‚ˆfd„Š|j                             ‰¦  «         n,|j        j        Š	ˆ	ˆfd„Š|j                             ‰¦  «         dŠˆˆfd	„Š
t          t          ˆ
fd
„|j                             ¦   «         D ¦   «         ¦  «        |_        |rdn|S )a7  Assign parameters to new parameters or values.

        If ``parameters`` is passed as a dictionary, the keys should be :class:`.Parameter`
        instances in the current circuit. The values of the dictionary can either be numeric values
        or new parameter objects.

        If ``parameters`` is passed as a list or array, the elements are assigned to the
        current parameters in the order of :attr:`parameters` which is sorted
        alphabetically (while respecting the ordering in :class:`.ParameterVector` objects).

        The values can be assigned to the current circuit object or to a copy of it.

        .. note::
            When ``parameters`` is given as a mapping, it is permissible to have keys that are
            strings of the parameter names; these will be looked up using :meth:`get_parameter`.
            You can also have keys that are :class:`.ParameterVector` instances, and in this case,
            the dictionary value should be a sequence of values of the same length as the vector.

            If you use either of these cases, you must leave the setting ``flat_input=False``;
            changing this to ``True`` enables the fast path, where all keys must be
            :class:`.Parameter` instances.

        Args:
            parameters: Either a dictionary or iterable specifying the new parameter values.
            inplace: If False, a copy of the circuit with the bound parameters is returned.
                If True the circuit instance itself is modified.
            flat_input: If ``True`` and ``parameters`` is a mapping type, it is assumed to be
                exactly a mapping of ``{parameter: value}``.  By default (``False``), the mapping
                may also contain :class:`.ParameterVector` keys that point to a corresponding
                sequence of values, and these will be unrolled during the mapping, or string keys,
                which will be converted to :class:`.Parameter` instances using
                :meth:`get_parameter`.
            strict: If ``False``, any parameters given in the mapping that are not used in the
                circuit will be ignored.  If ``True`` (the default), an error will be raised
                indicating a logic error.

        Raises:
            CircuitError: If parameters is a dict and contains parameters not present in the
                circuit.
            ValueError: If parameters is a list/array and the length mismatches the number of free
                parameters in the circuit.

        Returns:
            A copy of the circuit with bound parameters if ``inplace`` is False, otherwise None.

        Examples:

            Create a parameterized circuit and assign the parameters in-place.

            .. plot::
               :alt: Circuit diagram output by the previous code.
               :include-source:

               from qiskit.circuit import QuantumCircuit, Parameter

               circuit = QuantumCircuit(2)
               params = [Parameter('A'), Parameter('B'), Parameter('C')]
               circuit.ry(params[0], 0)
               circuit.crx(params[1], 0, 1)
               circuit.draw('mpl')
               circuit.assign_parameters({params[0]: params[2]}, inplace=True)
               circuit.draw('mpl')

            Bind the values out-of-place by list and get a copy of the original circuit.

            .. plot::
               :alt: Circuit diagram output by the previous code.
               :include-source:

               from qiskit.circuit import QuantumCircuit, ParameterVector

               circuit = QuantumCircuit(2)
               params = ParameterVector('P', 2)
               circuit.ry(params[0], 0)
               circuit.crx(params[1], 0, 1)

               bound_circuit = circuit.assign_parameters([1, 2])
               bound_circuit.draw('mpl')

               circuit.draw('mpl')

        c                ó>   •— g | ]}‰                      |¦  «        °|‘ŒS rQ   )r`  )rd   r\  r“   s     €rf   ro   z4QuantumCircuit.assign_parameters.<locals>.<listcomp>   s=   ø€ ð ð ð Ø"+À$×BTÒBTÐU^ÑB_ÔB_ðØðð ð rh   zCannot bind parameters (z, c              3  ó4   K  — | ]}t          |¦  «        V — Œd S r`   )rz   )rd   rÇ  s     rf   rg   z3QuantumCircuit.assign_parameters.<locals>.<genexpr>  s(   è è € Ð8PÐ8PÀA½¸Q¹¼Ð8PÐ8PÐ8PÐ8PÐ8PÐ8Prh   z) not present in the circuit.c                 ó   •— ‰ S r`   rQ   )Úraw_mappings   €rf   Úcreate_mapping_viewz=QuantumCircuit.assign_parameters.<locals>.create_mapping_view	  s	   ø€ Ø"Ð"rh   c                 ó>   •— t          t          ‰ ‰¦  «        ¦  «        S r`   )r†   r¹  )Úinitial_parametersrü   s   €€rf   ra  z=QuantumCircuit.assign_parameters.<locals>.create_mapping_view  s   ø€ Ý�CÐ 2°JÑ?Ô?Ñ@Ô@Ð@rh   Nc                óü  •— ‰
€
 ‰	¦   «         Š
d}t          |¦  «        }t          |¦  «        D ]¥\  }}t          |t          ¦  «        sŒ|j        ‰
                     ¦   «         z  x}sŒ:|D ]}|                     |‰
|         ¦  «        }Œ|j        s<|                     ¦   «         }t          |t          ¦  «        rt          d|› d�¦  «        ‚|||<   d}Œ¦|r| 
                    ‰
¦  «         | t          |¦  «        f|fS )NFz(Calibration cannot use complex number: 'r‡  T)rb   rÁ   ra   r3   rü   r  ÚassignÚnumericÚcomplexru   rY  rv   )rÀ   rü   ÚscheduleÚmodifiedÚnew_parametersrc  r\  Ú	containedÚto_bindra  Úmapping_views            €€rf   Úmap_calibrationz9QuantumCircuit.assign_parameters.<locals>.map_calibration"  s=  ø€ ð Ð#Ø2Ð2Ñ4Ô4�àˆHÝ! *Ñ-Ô-ˆNÝ )¨.Ñ 9Ô 9ð  ð  ‘��9Ý! )Õ-@ÑAÔAð ØØ%.Ô%9¸L×<MÒ<MÑ<OÔ<OÑ%OÐO˜	ð ØØ(ð Qð Q�GØ )× 0Ò 0°¸,ÀwÔ:OÑ PÔ P�I�IØ Ô+ð aØ )× 1Ò 1Ñ 3Ô 3�IÝ! )­WÑ5Ô5ð aÝ'Ð(_ÐS\Ð(_Ð(_Ð(_Ñ`Ô`Ð`Ø$-�˜qÑ!Ø��Øð 9Ø×*Ò*¨<Ñ8Ô8Ð8Ø�E .Ñ1Ô1Ð2°HÐ<Ð<rh   c              3  ó|   •K  — | ]6\  }}|t          ˆfd „|                     ¦   «         D ¦   «         ¦  «        fV — Œ7dS )c              3  ó>   •K  — | ]\  \  }}} ‰|||¦  «        V — Œd S r`   rQ   )rd   rÀ   rü   rh  rn  s       €rf   rg   z=QuantumCircuit.assign_parameters.<locals>.<genexpr>.<genexpr>A  sN   øè è € ð ð á:Ñ0˜V Z°(ð (˜¨°
¸HÑEÔEðð ð ð ð ð rh   N)r†   r�   )rd   rk  rí   rn  s      €rf   rg   z3QuantumCircuit.assign_parameters.<locals>.<genexpr>>  s�   øè è € ð 	ð 	ñ '�D˜,ð Ýð ð ð ð à>J×>PÒ>PÑ>RÔ>Rðñ ô ñ ô ðð	ð 	ð 	ð 	ð 	ð 	rh   )ra   r†   r„   rü   rá   r{   ry   ÚcollectionsÚabcr   Ú_unroll_param_dictr   ÚjoinÚassign_parameters_mappingÚassign_parameters_iterabler   r‡   r�   )r“   rü   r~  rT  r?  r¢  rþ   Úextrasra  rc  rn  rm  r`  s   ``      @@@@@rf   rY  z QuantumCircuit.assign_parameters—  s  øøøøøøø€ ðt ð 
	"ØˆFˆFå˜j­$Ñ/Ô/ð *ð ”JÔ)�Ø—Y’Y‘[”[ˆFØ×'Ò'Ñ)Ô)Ð)Ø×ÒÑ!Ô!Ð!å�j¥+¤/Ô"9Ñ:Ô:ð 	@Ø(2Ð[˜*˜*¸×8OÒ8OÐPZÑ8[Ô8[ˆKØð ðð ð ð Ø/:ðñ ô ð �ðõ
 #ð$¨t¯yªyÐ8PÐ8PÈÐ8PÑ8PÔ8PÑ/PÔ/Pð $ð $ð $ñô ð ð
#ð #ð #ð #ð #ð ŒL×2Ò2°;Ñ?Ô?Ð?Ð?ð "(¤Ô!8ÐðAð Að Að Að Að Að ŒL×3Ò3°JÑ?Ô?Ð?ð ˆð	=ð 	=ð 	=ð 	=ð 	=ð 	=õ4  +Ýð	ð 	ð 	ð 	ð +1Ô*>×*DÒ*DÑ*FÔ*Fð	ñ 	ô 	ñ 
ô  
ˆÔð Ð*ˆtˆt FÐ*rh   Úparameter_bindsú&Mapping[Parameter, ParameterValueType]c                óÆ  — i }|                      ¦   «         D ]É\  }}t          |t          ¦  «        r|t          |¦  «        t          |¦  «        k    r8t	          d|j        › dt          |¦  «        › dt          |¦  «        › d�¦  «        ‚|                     t          ||¦  «        ¦  «         Œ–t          |t          ¦  «        r|||  	                    |¦  «        <   ŒÄ|||<   ŒÊ|S )NzParameter vector 'z' has length z, but was assigned to z values.)
r�   ra   r<   r»  r   rR   rÖ   r¹  rz   rS  )r“   rx  rÅ   r\  r¡   s        rf   rs  z!QuantumCircuit._unroll_param_dictK  s  € ð ˆØ /× 5Ò 5Ñ 7Ô 7ð 	'ð 	'ÑˆI�uÝ˜)¥_Ñ5Ô5ð 
'Ý�y‘>”>¥S¨¡Z¤ZÒ/Ð/Ý&ðE¨Y¬^ð Eð EÍ#ÈiÉ.Ì.ð Eð EÝ03°E±
´
ðEð Eð Eñô ð ð —
’
�3˜y¨%Ñ0Ô0Ñ1Ô1Ð1Ð1Ý˜I¥sÑ+Ô+ð 'Ø5:��D×&Ò& yÑ1Ô1Ñ2Ð2à!&��I‘�Øˆ
rh   r#  c          	     ó”  ‡ — ddl m} |rYt          ˆ fd„|D ¦   «         ¦  «        }‰                      t	           |t          |¦  «        |¬¦  «        |d¦  «        d¬¦  «        S ‰ j                             ¦   «         }‰                      ¦   «                              t	           |t          |¦  «        |¬¦  «        |d¦  «        ¦  «        S )aj  Apply :class:`~.library.Barrier`. If ``qargs`` is empty, applies to all qubits
        in the circuit.

        Args:
            qargs (QubitSpecifier): Specification for one or more qubit arguments.
            label (str): The string label of the barrier.

        Returns:
            qiskit.circuit.InstructionSet: handle to the added instructions.
        r   )ÚBarrierc                óF   •— i | ]}‰                      |¦  «        D ]}|d “ŒŒS r`   r  )rd   r  r°   r“   s      €rf   r¶   z*QuantumCircuit.barrier.<locals>.<dictcomp>m  s7   ø€ ÐYÐYÐY˜T°D×4RÒ4RÐSWÑ4XÔ4XÐYÐY¨q��DÐYÐYÐYÐYrh   r#  rQ   Frà   )	r`  r|  rv   rã   rB   r»  rÀ   rá   r²  )r“   ro  rä   r|  rÀ   s   `    rf   r`  zQuantumCircuit.barrier]  sæ   ø€ ð 	%Ð$Ð$Ð$Ð$Ð$àð 	åØYÐYÐYÐY UÐYÑYÔYñô ˆFð —;’;Ý" 7 7­3¨v©;¬;¸eÐ#DÑ#DÔ#DÀfÈbÑQÔQÐX]ð ñ ô ð ð ”[×%Ò%Ñ'Ô'ˆFØ×&Ò&Ñ(Ô(×/Ò/Ý" 7 7­3¨v©;¬;¸eÐ#DÑ#DÔ#DÀfÈbÑQÔQñô ð rh   rq   r    r  úQubitSpecifier | Noner§   c                óf   — |€| j         }|                      t          ||¬¦  «        |gg d¬¦  «        S )aá  Apply :class:`~.circuit.Delay`. If qarg is ``None``, applies to all qubits.
        When applying to multiple qubits, delays with the same duration will be created.

        Args:
            duration (int or float or ParameterExpression): duration of the delay.
            qarg (Object): qubit argument to apply this delay.
            unit (str): unit of the duration. Supported units: ``'s'``, ``'ms'``, ``'us'``,
                ``'ns'``, ``'ps'``, and ``'dt'``. Default is ``'dt'``, i.e. integer time unit
                depending on the target backend.

        Returns:
            qiskit.circuit.InstructionSet: handle to the added instructions.

        Raises:
            CircuitError: if arguments have bad format.
        N)r§   Frà   )rÀ   rã   rC   )r“   r    r  r§   s       rf   ÚdelayzQuantumCircuit.delayx  s9   € ð, ˆ<Ø”;ˆDØ�{Š{�5 °Ð5Ñ5Ô5¸°v¸rÈˆ{ÑNÔNÐNrh   c                óF   — |                       t          j        |gd¦  «        S )a  Apply :class:`~qiskit.circuit.library.HGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            qubit: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        rQ   )r/  r   ÚHGate©r“   rÎ   s     rf   ÚhzQuantumCircuit.h’  ó!   € ð ×)Ò)­,Ô*<¸u¸gÀrÑJÔJÐJrh   Úcontrol_qubitÚtarget_qubitc                ó°   — |�|dv r%|                       t          j        ||gd|¬¦  «        S ddlm} |                       |||¬¦  «        ||gg d¬	¦  «        S )
a:  Apply :class:`~qiskit.circuit.library.CHGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            control_qubit: The qubit(s) used as the control.
            target_qubit: The qubit(s) targeted by the gate.
            label: The string label of the gate in the circuit.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. '1').  Defaults to controlling
                on the '1' state.

        Returns:
            A handle to the instructions created.
        N©Ú1r   rQ   r#  r   )ÚCHGate©ro  rp  Frà   )r/  r   r‹  Úlibrary.standard_gates.hrã   )r“   r†  r‡  ro  rp  r‹  s         rf   ÚchzQuantumCircuit.chŸ  ó‘   € ð. Ð ¨xÐ!7Ð!7Ø×-Ò-ÝÔ# m°\Ð%BÀBÈeð .ñ ô ð ð 	5Ð4Ð4Ð4Ð4Ð4à�{Š{ØˆF˜¨:Ð6Ñ6Ô6Ø˜LÐ)ØØð	 ñ 
ô 
ð 	
rh   c                óF   — |                       t          j        |gd¦  «        S )a  Apply :class:`~qiskit.circuit.library.IGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            qubit: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        rQ   )r/  r   ÚIGaterƒ  s     rf   ÚidzQuantumCircuit.idÄ  r…  rh   Úthetac                ól   — ddl m} |                       |t          |¦  «        |¦  «        |d¬¦  «        S )aD  Apply :class:`~qiskit.circuit.library.MSGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            theta: The angle of the rotation.
            qubits: The qubits to apply the gate to.

        Returns:
            A handle to the instructions created.
        r   )ÚMSGateFrà   )Úlibrary.generalized_gates.gmsr•  rã   r»  )r“   r“  rÀ   r•  s       rf   ÚmszQuantumCircuit.msÑ  s@   € ð 	:Ð9Ð9Ð9Ð9Ð9à�{Š{˜6˜6¥# f¡+¤+¨uÑ5Ô5°vÀEˆ{ÑJÔJÐJrh   c                óH   — |                       t          j        |g|f¦  «        S )aH  Apply :class:`~qiskit.circuit.library.PhaseGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            theta: THe angle of the rotation.
            qubit: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        )r/  r   Ú	PhaseGate)r“   r“  rÎ   s      rf   rÿ   zQuantumCircuit.pâ  s#   € ð ×)Ò)­,Ô*@À5À'ÈEÈ8ÑTÔTÐTrh   c                ó´   — |�|dv r&|                       t          j        ||g|f|¬¦  «        S ddlm} |                       ||||¬¦  «        ||gg d¬¦  «        S )	al  Apply :class:`~qiskit.circuit.library.CPhaseGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            theta: The angle of the rotation.
            control_qubit: The qubit(s) used as the control.
            target_qubit: The qubit(s) targeted by the gate.
            label: The string label of the gate in the circuit.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. '1').  Defaults to controlling
                on the '1' state.

        Returns:
            A handle to the instructions created.
        Nr‰  r#  r   )Ú
CPhaseGaterŒ  Frà   )r/  r   r›  Úlibrary.standard_gates.prã   )r“   r“  r†  r‡  ro  rp  r›  s          rf   ÚcpzQuantumCircuit.cpð  s–   € ð2 Ð ¨xÐ!7Ð!7Ø×-Ò-ÝÔ'¨-¸Ð)FÈÈÐX]ð .ñ ô ð ð 	9Ð8Ð8Ð8Ð8Ð8à�{Š{ØˆJ�u E°jÐAÑAÔAØ˜LÐ)ØØð	 ñ 
ô 
ð 	
rh   ÚlamÚcontrol_qubitsc                óŽ   — ddl m} t          |¦  «        }|                       ||||¬¦  «        |dd…         |gz   g d¬¦  «        S )a+  Apply :class:`~qiskit.circuit.library.MCPhaseGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            lam: The angle of the rotation.
            control_qubits: The qubits used as the controls.
            target_qubit: The qubit(s) targeted by the gate.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. '1').  Defaults to controlling
                on the '1' state.

        Returns:
            A handle to the instructions created.
        r   )ÚMCPhaseGate©rp  NFrà   )rœ  r¡  r»  rã   )r“   rž  rŸ  r‡  rp  r¡  rn  s          rf   ÚmcpzQuantumCircuit.mcp  sk   € ð, 	:Ð9Ð9Ð9Ð9Ð9å˜nÑ-Ô-ˆØ�{Š{ØˆK˜˜_¸ÐDÑDÔDØ˜1˜1˜1Ô  Ñ.ØØð	 ñ 
ô 
ð 	
rh   Úphic                óJ   — |                       t          j        |g||g¦  «        S )a‰  Apply :class:`~qiskit.circuit.library.RGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            theta: The angle of the rotation.
            phi: The angle of the axis of rotation in the x-y plane.
            qubit: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        )r/  r   ÚRGate)r“   r“  r¤  rÎ   s       rf   ÚrzQuantumCircuit.r7  s%   € ð ×)Ò)­,Ô*<¸u¸gÈÈsÀ|ÑTÔTÐTrh   ÚvxÚvyÚvzc                óX   — ddl m} |                       ||||¦  «        |gg d¬¦  «        S )a+  Apply :class:`~qiskit.circuit.library.RVGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Rotation around an arbitrary rotation axis :math:`v`, where :math:`|v|` is the angle of
        rotation in radians.

        Args:
            vx: x-component of the rotation axis.
            vy: y-component of the rotation axis.
            vz: z-component of the rotation axis.
            qubit: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        r   )ÚRVGateFrà   )Úlibrary.generalized_gates.rvr¬  rã   )r“   r¨  r©  rª  rÎ   r¬  s         rf   ÚrvzQuantumCircuit.rvH  s@   € ð. 	9Ð8Ð8Ð8Ð8Ð8à�{Š{˜6˜6 " b¨"Ñ-Ô-°¨w¸Àˆ{ÑGÔGÐGrh   Úcontrol_qubit1Úcontrol_qubit2c                óJ   — |                       t          j        |||gd¦  «        S )a©  Apply :class:`~qiskit.circuit.library.RCCXGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            control_qubit1: The qubit(s) used as the first control.
            control_qubit2: The qubit(s) used as the second control.
            target_qubit: The qubit(s) targeted by the gate.

        Returns:
            A handle to the instructions created.
        rQ   )r/  r   ÚRCCXGate)r“   r¯  r°  r‡  s       rf   ÚrccxzQuantumCircuit.rccxc  s.   € ð$ ×)Ò)ÝÔ! N°NÀLÐ#QÐSUñ
ô 
ð 	
rh   Úcontrol_qubit3c                óL   — |                       t          j        ||||gd¦  «        S )aí  Apply :class:`~qiskit.circuit.library.RC3XGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            control_qubit1: The qubit(s) used as the first control.
            control_qubit2: The qubit(s) used as the second control.
            control_qubit3: The qubit(s) used as the third control.
            target_qubit: The qubit(s) targeted by the gate.

        Returns:
            A handle to the instructions created.
        rQ   )r/  r   ÚRC3XGate)r“   r¯  r°  r´  r‡  s        rf   ÚrcccxzQuantumCircuit.rcccxy  s1   € ð( ×)Ò)ÝÔ!Ø˜^¨^¸\ÐJØñ
ô 
ð 	
rh   c                óL   — |                       t          j        |g|g|¬¦  «        S )aŠ  Apply :class:`~qiskit.circuit.library.RXGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            theta: The rotation angle of the gate.
            qubit: The qubit(s) to apply the gate to.
            label: The string label of the gate in the circuit.

        Returns:
            A handle to the instructions created.
        r#  )r/  r   ÚRXGate©r“   r“  rÎ   ro  s       rf   ÚrxzQuantumCircuit.rx“  ó)   € ð ×)Ò)­,Ô*=À¸wÈÈÐW\Ð)Ñ]Ô]Ð]rh   c                ó´   — |�|dv r&|                       t          j        ||g|g|¬¦  «        S ddlm} |                       ||||¬¦  «        ||gg d¬¦  «        S )	ai  Apply :class:`~qiskit.circuit.library.CRXGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            theta: The angle of the rotation.
            control_qubit: The qubit(s) used as the control.
            target_qubit: The qubit(s) targeted by the gate.
            label: The string label of the gate in the circuit.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. '1').  Defaults to controlling
                on the '1' state.

        Returns:
            A handle to the instructions created.
        Nr‰  r#  r   )ÚCRXGaterŒ  Frà   )r/  r   r¾  Úlibrary.standard_gates.rxrã   )r“   r“  r†  r‡  ro  rp  r¾  s          rf   ÚcrxzQuantumCircuit.crx¤  ó–   € ð2 Ð ¨xÐ!7Ð!7Ø×-Ò-ÝÔ$ }°lÐ&CÀeÀWÐTYð .ñ ô ð ð 	7Ð6Ð6Ð6Ð6Ð6à�{Š{ØˆG�E °:Ð>Ñ>Ô>Ø˜LÐ)ØØð	 ñ 
ô 
ð 	
rh   Úqubit1Úqubit2c                óJ   — |                       t          j        ||g|g¦  «        S )a~  Apply :class:`~qiskit.circuit.library.RXXGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            theta: The angle of the rotation.
            qubit1: The qubit(s) to apply the gate to.
            qubit2: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        )r/  r   ÚRXXGate©r“   r“  rÂ  rÃ  s       rf   ÚrxxzQuantumCircuit.rxxË  ó(   € ð ×)Ò)­,Ô*>ÀÈÐ@PÐSXÐRYÑZÔZÐZrh   c                óL   — |                       t          j        |g|g|¬¦  «        S )aŠ  Apply :class:`~qiskit.circuit.library.RYGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            theta: The rotation angle of the gate.
            qubit: The qubit(s) to apply the gate to.
            label: The string label of the gate in the circuit.

        Returns:
            A handle to the instructions created.
        r#  )r/  r   ÚRYGaterº  s       rf   ÚryzQuantumCircuit.ryÜ  r¼  rh   c                ó´   — |�|dv r&|                       t          j        ||g|g|¬¦  «        S ddlm} |                       ||||¬¦  «        ||gg d¬¦  «        S )	ai  Apply :class:`~qiskit.circuit.library.CRYGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            theta: The angle of the rotation.
            control_qubit: The qubit(s) used as the control.
            target_qubit: The qubit(s) targeted by the gate.
            label: The string label of the gate in the circuit.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. '1').  Defaults to controlling
                on the '1' state.

        Returns:
            A handle to the instructions created.
        Nr‰  r#  r   )ÚCRYGaterŒ  Frà   )r/  r   rÍ  Úlibrary.standard_gates.ryrã   )r“   r“  r†  r‡  ro  rp  rÍ  s          rf   ÚcryzQuantumCircuit.cryí  rÁ  rh   c                óJ   — |                       t          j        ||g|g¦  «        S )aƒ  Apply :class:`~qiskit.circuit.library.RYYGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            theta: The rotation angle of the gate.
            qubit1: The qubit(s) to apply the gate to.
            qubit2: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        )r/  r   ÚRYYGaterÆ  s       rf   ÚryyzQuantumCircuit.ryy  rÈ  rh   c                óH   — |                       t          j        |g|g¦  «        S )aH  Apply :class:`~qiskit.circuit.library.RZGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            phi: The rotation angle of the gate.
            qubit: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        )r/  r   ÚRZGate)r“   r¤  rÎ   s      rf   ÚrzzQuantumCircuit.rz%  s#   € ð ×)Ò)­,Ô*=À¸wÈÈÑNÔNÐNrh   c                ó´   — |�|dv r&|                       t          j        ||g|g|¬¦  «        S ddlm} |                       ||||¬¦  «        ||gg d¬¦  «        S )	ai  Apply :class:`~qiskit.circuit.library.CRZGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            theta: The angle of the rotation.
            control_qubit: The qubit(s) used as the control.
            target_qubit: The qubit(s) targeted by the gate.
            label: The string label of the gate in the circuit.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. '1').  Defaults to controlling
                on the '1' state.

        Returns:
            A handle to the instructions created.
        Nr‰  r#  r   )ÚCRZGaterŒ  Frà   )r/  r   r×  Úlibrary.standard_gates.rzrã   )r“   r“  r†  r‡  ro  rp  r×  s          rf   ÚcrzzQuantumCircuit.crz3  rÁ  rh   c                óJ   — |                       t          j        ||g|g¦  «        S )aƒ  Apply :class:`~qiskit.circuit.library.RZXGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            theta: The rotation angle of the gate.
            qubit1: The qubit(s) to apply the gate to.
            qubit2: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        )r/  r   ÚRZXGaterÆ  s       rf   ÚrzxzQuantumCircuit.rzxZ  rÈ  rh   c                óJ   — |                       t          j        ||g|g¦  «        S )aƒ  Apply :class:`~qiskit.circuit.library.RZZGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            theta: The rotation angle of the gate.
            qubit1: The qubit(s) to apply the gate to.
            qubit2: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        )r/  r   ÚRZZGaterÆ  s       rf   ÚrzzzQuantumCircuit.rzzk  rÈ  rh   c                óH   — |                       t          j        ||gd¦  «        S )a  Apply :class:`~qiskit.circuit.library.ECRGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            qubit1, qubit2: The qubits to apply the gate to.

        Returns:
            A handle to the instructions created.
        rQ   )r/  r   ÚECRGate©r“   rÂ  rÃ  s      rf   ÚecrzQuantumCircuit.ecr|  s%   € ð ×)Ò)­,Ô*>ÀÈÐ@PÐRTÑUÔUÐUrh   c                óF   — |                       t          j        |gd¦  «        S )a  Apply :class:`~qiskit.circuit.library.SGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            qubit: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        rQ   )r/  r   ÚSGaterƒ  s     rf   ÚszQuantumCircuit.s‰  r…  rh   c                óF   — |                       t          j        |gd¦  «        S )a  Apply :class:`~qiskit.circuit.library.SdgGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            qubit: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        rQ   )r/  r   ÚSdgGaterƒ  s     rf   ÚsdgzQuantumCircuit.sdg–  ó!   € ð ×)Ò)­,Ô*>ÀÀÈÑLÔLÐLrh   c                ó°   — |�|dv r%|                       t          j        ||gd|¬¦  «        S ddlm} |                       |||¬¦  «        ||gg d¬	¦  «        S )
a:  Apply :class:`~qiskit.circuit.library.CSGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            control_qubit: The qubit(s) used as the control.
            target_qubit: The qubit(s) targeted by the gate.
            label: The string label of the gate in the circuit.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. '1').  Defaults to controlling
                on the '1' state.

        Returns:
            A handle to the instructions created.
        Nr‰  rQ   r#  r   )ÚCSGaterŒ  Frà   )r/  r   rì  Úlibrary.standard_gates.srã   )r“   r†  r‡  ro  rp  rì  s         rf   ÚcszQuantumCircuit.cs£  r�  rh   c                ó°   — |�|dv r%|                       t          j        ||gd|¬¦  «        S ddlm} |                       |||¬¦  «        ||gg d¬	¦  «        S )
a<  Apply :class:`~qiskit.circuit.library.CSdgGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            control_qubit: The qubit(s) used as the control.
            target_qubit: The qubit(s) targeted by the gate.
            label: The string label of the gate in the circuit.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. '1').  Defaults to controlling
                on the '1' state.

        Returns:
            A handle to the instructions created.
        Nr‰  rQ   r#  r   )ÚCSdgGaterŒ  Frà   )r/  r   rð  rí  rã   )r“   r†  r‡  ro  rp  rð  s         rf   ÚcsdgzQuantumCircuit.csdgÈ  s’   € ð. Ð ¨xÐ!7Ð!7Ø×-Ò-ÝÔ%¨°|Ð'DÀbÐPUð .ñ ô ð ð 	7Ð6Ð6Ð6Ð6Ð6à�{Š{ØˆH˜5¨ZÐ8Ñ8Ô8Ø˜LÐ)ØØð	 ñ 
ô 
ð 	
rh   c                óH   — |                       t          j        ||gd¦  «        S )a   Apply :class:`~qiskit.circuit.library.SwapGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            qubit1, qubit2: The qubits to apply the gate to.

        Returns:
            A handle to the instructions created.
        rQ   )r/  r   ÚSwapGaterâ  s      rf   ÚswapzQuantumCircuit.swapí  s-   € ð ×)Ò)ÝÔ!Ø�VÐØñ
ô 
ð 	
rh   c                óH   — |                       t          j        ||gd¦  «        S )a!  Apply :class:`~qiskit.circuit.library.iSwapGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            qubit1, qubit2: The qubits to apply the gate to.

        Returns:
            A handle to the instructions created.
        rQ   )r/  r   Ú	ISwapGaterâ  s      rf   ÚiswapzQuantumCircuit.iswapþ  s%   € ð ×)Ò)­,Ô*@À6È6ÐBRÐTVÑWÔWÐWrh   Útarget_qubit1Útarget_qubit2c                ó´   — |�|dv r&|                       t          j        |||gd|¬¦  «        S ddlm} |                       |||¬¦  «        |||gg d¬	¦  «        S )
a„  Apply :class:`~qiskit.circuit.library.CSwapGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            control_qubit: The qubit(s) used as the control.
            target_qubit1: The qubit(s) targeted by the gate.
            target_qubit2: The qubit(s) targeted by the gate.
            label: The string label of the gate in the circuit.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. ``'1'``).  Defaults to controlling
                on the ``'1'`` state.

        Returns:
            A handle to the instructions created.
        Nr‰  rQ   r#  r   )Ú	CSwapGaterŒ  Frà   )r/  r   rû  Úlibrary.standard_gates.swaprã   )r“   r†  rø  rù  ro  rp  rû  s          rf   ÚcswapzQuantumCircuit.cswap  s˜   € ð2 Ð ¨xÐ!7Ð!7Ø×-Ò-ÝÔ&Ø ¨}Ð=ØØð	 .ñ ô ð ð 	;Ð:Ð:Ð:Ð:Ð:à�{Š{ØˆI˜E¨jÐ9Ñ9Ô9Ø˜M¨=Ð9ØØð	 ñ 
ô 
ð 	
rh   c                óF   — |                       t          j        |gd¦  «        S )a  Apply :class:`~qiskit.circuit.library.SXGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            qubit: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        rQ   )r/  r   ÚSXGaterƒ  s     rf   ÚsxzQuantumCircuit.sx5  s!   € ð ×)Ò)­,Ô*=À¸wÈÑKÔKÐKrh   c                óF   — |                       t          j        |gd¦  «        S )a  Apply :class:`~qiskit.circuit.library.SXdgGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            qubit: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        rQ   )r/  r   ÚSXdgGaterƒ  s     rf   ÚsxdgzQuantumCircuit.sxdgB  s!   € ð ×)Ò)­,Ô*?À%ÀÈ"ÑMÔMÐMrh   c                ó°   — |�|dv r%|                       t          j        ||gd|¬¦  «        S ddlm} |                       |||¬¦  «        ||gg d¬	¦  «        S )
a;  Apply :class:`~qiskit.circuit.library.CSXGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            control_qubit: The qubit(s) used as the control.
            target_qubit: The qubit(s) targeted by the gate.
            label: The string label of the gate in the circuit.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. '1').  Defaults to controlling
                on the '1' state.

        Returns:
            A handle to the instructions created.
        Nr‰  rQ   r#  r   )ÚCSXGaterŒ  Frà   )r/  r   r  Úlibrary.standard_gates.sxrã   )r“   r†  r‡  ro  rp  r  s         rf   ÚcsxzQuantumCircuit.csxO  s‘   € ð. Ð ¨xÐ!7Ð!7Ø×-Ò-ÝÔ$ }°lÐ&CÀRÈuð .ñ ô ð ð 	7Ð6Ð6Ð6Ð6Ð6à�{Š{ØˆG˜%¨JÐ7Ñ7Ô7Ø˜LÐ)ØØð	 ñ 
ô 
ð 	
rh   c                óF   — |                       t          j        |gd¦  «        S )a  Apply :class:`~qiskit.circuit.library.TGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            qubit: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        rQ   )r/  r   ÚTGaterƒ  s     rf   ÚtzQuantumCircuit.tt  r…  rh   c                óF   — |                       t          j        |gd¦  «        S )a  Apply :class:`~qiskit.circuit.library.TdgGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            qubit: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        rQ   )r/  r   ÚTdgGaterƒ  s     rf   ÚtdgzQuantumCircuit.tdg�  rê  rh   c                óL   — |                       t          j        |g|||g¦  «        S )a×  Apply :class:`~qiskit.circuit.library.UGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            theta: The :math:`\theta` rotation angle of the gate.
            phi: The :math:`\phi` rotation angle of the gate.
            lam: The :math:`\lambda` rotation angle of the gate.
            qubit: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        )r/  r   ÚUGate)r“   r“  r¤  rž  rÎ   s        rf   ÚuzQuantumCircuit.uŽ  s)   € ð( ×)Ò)­,Ô*<¸u¸gÈÈsÐTWÐGXÑYÔYÐYrh   Úgammac	           
     óÀ   — |�|dv r)|                       t          j        ||g||||g|¬¦  «        S ddlm}	 |                       |	||||||¬¦  «        ||gg d¬¦  «        S )	aB  Apply :class:`~qiskit.circuit.library.CUGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            theta: The :math:`\theta` rotation angle of the gate.
            phi: The :math:`\phi` rotation angle of the gate.
            lam: The :math:`\lambda` rotation angle of the gate.
            gamma: The global phase applied of the U gate, if applied.
            control_qubit: The qubit(s) used as the control.
            target_qubit: The qubit(s) targeted by the gate.
            label: The string label of the gate in the circuit.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. '1').  Defaults to controlling
                on the '1' state.

        Returns:
            A handle to the instructions created.
        Nr‰  r#  r   )ÚCUGaterŒ  Frà   )r/  r   r  Úlibrary.standard_gates.urã   )
r“   r“  r¤  rž  r  r†  r‡  ro  rp  r  s
             rf   ÚcuzQuantumCircuit.cu¤  s¥   € ð> Ð ¨xÐ!7Ð!7Ø×-Ò-ÝÔ#Ø Ð-Ø˜˜S %Ð(Øð	 .ñ ô ð ð 	5Ð4Ð4Ð4Ð4Ð4à�{Š{ØˆF�5˜#˜s E°À:ÐNÑNÔNØ˜LÐ)ØØð	 ñ 
ô 
ð 	
rh   c                óJ   — |                       t          j        |gd|¬¦  «        S )aV  Apply :class:`~qiskit.circuit.library.XGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            qubit: The qubit(s) to apply the gate to.
            label: The string label of the gate in the circuit.

        Returns:
            A handle to the instructions created.
        rQ   r#  )r/  r   ÚXGate)r“   rÎ   ro  s      rf   rÇ  zQuantumCircuit.xÔ  s'   € ð ×)Ò)­,Ô*<¸u¸gÀrÐQVÐ)ÑWÔWÐWrh   c                ó°   — |�|dv r%|                       t          j        ||gd|¬¦  «        S ddlm} |                       |||¬¦  «        ||gg d¬	¦  «        S )
a:  Apply :class:`~qiskit.circuit.library.CXGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            control_qubit: The qubit(s) used as the control.
            target_qubit: The qubit(s) targeted by the gate.
            label: The string label of the gate in the circuit.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. '1').  Defaults to controlling
                on the '1' state.

        Returns:
            A handle to the instructions created.
        Nr‰  rQ   r#  r   )ÚCXGaterŒ  Frà   )r/  r   r  Úlibrary.standard_gates.xrã   )r“   r†  r‡  ro  rp  r  s         rf   ÚcxzQuantumCircuit.cxâ  ó”   € ð. Ð ¨xÐ!7Ð!7Ø×-Ò-ÝÔ#Ø Ð-ØØð	 .ñ ô ð ð 	5Ð4Ð4Ð4Ð4Ð4à�{Š{ØˆF˜¨:Ð6Ñ6Ô6Ø˜LÐ)ØØð	 ñ 
ô 
ð 	
rh   c                óH   — |                       t          j        ||gd¦  «        S )aP  Apply :class:`~qiskit.circuit.library.DCXGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            qubit1: The qubit(s) to apply the gate to.
            qubit2: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        rQ   )r/  r   ÚDCXGaterâ  s      rf   ÚdcxzQuantumCircuit.dcx
  s%   € ð ×)Ò)­,Ô*>ÀÈÐ@PÐRTÑUÔUÐUrh   c                ó®   — |�|dv r$|                       t          j        |||gd¦  «        S ddlm} |                       ||¬¦  «        |||gg d¬¦  «        S )	aG  Apply :class:`~qiskit.circuit.library.CCXGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            control_qubit1: The qubit(s) used as the first control.
            control_qubit2: The qubit(s) used as the second control.
            target_qubit: The qubit(s) targeted by the gate.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. '1').  Defaults to controlling
                on the '1' state.

        Returns:
            A handle to the instructions created.
        N©Ú11é   rQ   r   )ÚCCXGater¢  Frà   )r/  r   r$  r  rã   )r“   r¯  r°  r‡  rp  r$  s         rf   ÚccxzQuantumCircuit.ccx  sŽ   € ð. Ð ¨yÐ!8Ð!8Ø×-Ò-ÝÔ$Ø °Ð>Øñô ð ð 	6Ð5Ð5Ð5Ð5Ð5à�{Š{ØˆG˜zÐ*Ñ*Ô*Ø˜^¨\Ð:ØØð	 ñ 
ô 
ð 	
rh   Ú	noancillaÚancilla_qubitsÚmodec                ó8  — ddl m}m}m} t	          |¦  «        }	 ||	|¬¦  «         ||	|¬¦  «         ||	d|¬¦  «         ||	d|¬¦  «         ||	|¬¦  «         ||	d|¬¦  «         ||	d|¬¦  «        dœ}
|r|                      |¦  «        }	 |
|         }nI# t          $ r<}t          |
                     ¦   «         ¦  «        }t          d|› d	|› �¦  «        |‚d
}~ww xY wt          |d¦  «        r}|j        dk    rr|j        }|€t          d|› d�¦  «        ‚t          |d¦  «        s|g}t	          |¦  «        |k     r%t	          |¦  «        }t          d|› d|› d�¦  «        ‚|d
|…         }ng }|                      ||d
d
…         |gz   |d
d
…         z   g ¦  «        S )aV  Apply :class:`~qiskit.circuit.library.MCXGate`.

        The multi-cX gate can be implemented using different techniques, which use different numbers
        of ancilla qubits and have varying circuit depth. These modes are:

        - ``'noancilla'``: Requires 0 ancilla qubits.
        - ``'recursion'``: Requires 1 ancilla qubit if more than 4 controls are used, otherwise 0.
        - ``'v-chain'``: Requires 2 less ancillas than the number of control qubits.
        - ``'v-chain-dirty'``: Same as for the clean ancillas (but the circuit will be longer).

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            control_qubits: The qubits used as the controls.
            target_qubit: The qubit(s) targeted by the gate.
            ancilla_qubits: The qubits used as the ancillae, if the mode requires them.
            mode: The choice of mode, explained further above.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. '1').  Defaults to controlling
                on the '1' state.

        Returns:
            A handle to the instructions created.

        Raises:
            ValueError: if the given mode is not known, or if too few ancilla qubits are passed.
            AttributeError: if no ancilla qubits are passed, but some are needed.
        r   )ÚMCXGateÚMCXRecursiveÚ	MCXVChainr¢  FT)Údirty_ancillasrp  )r&  Ú	recursionzv-chainzv-chain-dirtyÚadvancedÚbasiczbasic-dirty-ancillazUnsupported mode (z) selected, choose one of NÚnum_ancilla_qubitsr   zNo ancillas provided, but z are needed!ró  z	At least z ancillas required, but z given.)r  r*  r+  r,  r»  rº  r[  rb   r  rt   r:  r1  rè   rã   )r“   rŸ  r‡  r'  r(  rp  r*  r+  r,  rn  Úavailable_implementationsrþ   rk  rl  Ú	all_modesÚrequiredÚactuallys                    rf   ÚmcxzQuantumCircuit.mcx?  sS  € ðH 	OÐNÐNÐNÐNÐNÐNÐNÐNÐNå˜nÑ-Ô-ˆð !˜ ¸ZÐHÑHÔHØ%˜ oÀ*ÐMÑMÔMØ �y °%ÀJÐOÑOÔOØ&˜Y ÀtÐXbÐcÑcÔcà$˜ _ÀÐLÑLÔLØ�Y˜¸uÐQ[Ð\Ñ\Ô\Ø#, 9Ø°Àð$ñ $ô $ð%
ð %
Ð!ð ð 	?Ø×.Ò.¨~Ñ>Ô>ˆAð	Ø,¨TÔ2ˆDˆDøÝð 	ð 	ð 	ÝÐ6×;Ò;Ñ=Ô=Ñ>Ô>ˆIÝØP TÐPÐPÀYÐPÐPñô àðøøøøð	øøøõ �4Ð-Ñ.Ô.ð 	 °4Ô3JÈQÒ3NÐ3NØÔ.ˆHØÐ%Ý$Ð%XÀ(Ð%XÐ%XÐ%XÑYÔYÐYõ ˜>¨9Ñ5Ô5ð 2Ø"0Ð!1�å�>Ñ"Ô" XÒ-Ð-Ý˜~Ñ.Ô.�Ý Ð!`¨XÐ!`Ð!`ÈxÐ!`Ð!`Ð!`ÑaÔaÐaà+¨I¨X¨IÔ6ˆNˆNàˆNà�{Š{˜4 °°°Ô!2°l°^Ñ!CÀnÐUVÐUVÐUVÔFWÑ!WÐY[Ñ\Ô\Ð\s   ÂB Â
CÂ 7CÃCc                óF   — |                       t          j        |gd¦  «        S )a  Apply :class:`~qiskit.circuit.library.YGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            qubit: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        rQ   )r/  r   ÚYGaterƒ  s     rf   ÚyzQuantumCircuit.y“  r…  rh   c                ó°   — |�|dv r%|                       t          j        ||gd|¬¦  «        S ddlm} |                       |||¬¦  «        ||gg d¬	¦  «        S )
a;  Apply :class:`~qiskit.circuit.library.CYGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            control_qubit: The qubit(s) used as the controls.
            target_qubit: The qubit(s) targeted by the gate.
            label: The string label of the gate in the circuit.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. '1').  Defaults to controlling
                on the '1' state.

        Returns:
            A handle to the instructions created.
        Nr‰  rQ   r#  r   )ÚCYGaterŒ  Frà   )r/  r   r;  Úlibrary.standard_gates.yrã   )r“   r†  r‡  ro  rp  r;  s         rf   ÚcyzQuantumCircuit.cy   r  rh   c                óF   — |                       t          j        |gd¦  «        S )a  Apply :class:`~qiskit.circuit.library.ZGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            qubit: The qubit(s) to apply the gate to.

        Returns:
            A handle to the instructions created.
        rQ   )r/  r   ÚZGaterƒ  s     rf   ÚzzQuantumCircuit.zÈ  r…  rh   c                ó°   — |�|dv r%|                       t          j        ||gd|¬¦  «        S ddlm} |                       |||¬¦  «        ||gg d¬	¦  «        S )
a;  Apply :class:`~qiskit.circuit.library.CZGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            control_qubit: The qubit(s) used as the controls.
            target_qubit: The qubit(s) targeted by the gate.
            label: The string label of the gate in the circuit.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. '1').  Defaults to controlling
                on the '1' state.

        Returns:
            A handle to the instructions created.
        Nr‰  rQ   r#  r   )ÚCZGaterŒ  Frà   )r/  r   rB  Úlibrary.standard_gates.zrã   )r“   r†  r‡  ro  rp  rB  s         rf   ÚczzQuantumCircuit.czÕ  r�  rh   c                ó´   — |�|dv r&|                       t          j        |||gd|¬¦  «        S ddlm} |                       |||¬¦  «        |||gg d¬	¦  «        S )
a‰  Apply :class:`~qiskit.circuit.library.CCZGate`.

        For the full matrix form of this gate, see the underlying gate documentation.

        Args:
            control_qubit1: The qubit(s) used as the first control.
            control_qubit2: The qubit(s) used as the second control.
            target_qubit: The qubit(s) targeted by the gate.
            label: The string label of the gate in the circuit.
            ctrl_state:
                The control state in decimal, or as a bitstring (e.g. '10').  Defaults to controlling
                on the '11' state.

        Returns:
            A handle to the instructions created.
        Nr!  rQ   r#  r   )ÚCCZGaterŒ  Frà   )r/  r   rF  rC  rã   )r“   r¯  r°  r‡  ro  rp  rF  s          rf   ÚcczzQuantumCircuit.cczú  s˜   € ð2 Ð ¨yÐ!8Ð!8Ø×-Ò-ÝÔ$Ø °Ð>ØØð	 .ñ ô ð ð 	6Ð5Ð5Ð5Ð5Ð5à�{Š{ØˆG˜%¨JÐ7Ñ7Ô7Ø˜^¨\Ð:ØØð	 ñ 
ô 
ð 	
rh   Úpauli_stringc                óR   — ddl m} |                       ||¦  «        |g d¬¦  «        S )a  Apply :class:`~qiskit.circuit.library.PauliGate`.

        Args:
            pauli_string: A string representing the Pauli operator to apply, e.g. 'XX'.
            qubits: The qubits to apply this gate to.

        Returns:
            A handle to the instructions created.
        r   )Ú	PauliGateFrà   )Ú.qiskit.circuit.library.generalized_gates.paulirJ  rã   )r“   rH  rÀ   rJ  s       rf   ÚpaulizQuantumCircuit.pauli$  s;   € ð 	MÐLÐLÐLÐLÐLà�{Š{˜9˜9 \Ñ2Ô2°F¸BÀUˆ{ÑKÔKÐKrh   Ústateú+Statevector | Sequence[complex] | str | intÚ	normalizec                ó  — ddl m} |€| j        }n0t          |t          t
          j        t          t          f¦  «        r|g}t          |t          ¦  «        rt          |¦  «        nd}|  
                     |||||¬¦  «        |d¬¦  «        S )uƒ  Prepare qubits in a specific state.

        This class implements a state preparing unitary. Unlike
        :meth:`.initialize` it does not reset the qubits first.

        Args:
            state: The state to initialize to, can be either of the following.

                * Statevector or vector of complex amplitudes to initialize to.
                * Labels of basis states of the Pauli eigenstates Z, X, Y. See
                  :meth:`.Statevector.from_label`. Notice the order of the labels is reversed with
                  respect to the qubit index to be applied to. Example label '01' initializes the
                  qubit zero to :math:`|1\rangle` and the qubit one to :math:`|0\rangle`.
                * An integer that is used as a bitmap indicating which qubits to initialize to
                  :math:`|1\rangle`. Example: setting params to 5 would initialize qubit 0 and qubit
                  2 to :math:`|1\rangle` and qubit 1 to :math:`|0\rangle`.

            qubits: Qubits to initialize. If ``None`` the initialization is applied to all qubits in
                the circuit.
            label: An optional label for the gate
            normalize: Whether to normalize an input array to a unit vector.

        Returns:
            A handle to the instruction that was just initialized

        Examples:
            Prepare a qubit in the state :math:`(|0\rangle - |1\rangle) / \sqrt{2}`.

            .. code-block::

                import numpy as np
                from qiskit import QuantumCircuit

                circuit = QuantumCircuit(1)
                circuit.prepare_state([1/np.sqrt(2), -1/np.sqrt(2)], 0)
                circuit.draw()

            output:

            .. code-block:: text

                     â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”�
                q_0: â”¤ State Preparation(0.70711,-0.70711) â”œ
                     â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜


            Prepare from a string two qubits in the state :math:`|10\rangle`.
            The order of the labels is reversed with respect to qubit index.
            More information about labels for basis states are in
            :meth:`.Statevector.from_label`.

            .. code-block::

                import numpy as np
                from qiskit import QuantumCircuit

                circuit = QuantumCircuit(2)
                circuit.prepare_state('01', circuit.qubits)
                circuit.draw()

            output:

            .. code-block:: text

                     â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”�
                q_0: â”¤0                        â”œ
                     â”‚  State Preparation(0,1) â”‚
                q_1: â”¤1                        â”œ
                     â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜


            Initialize two qubits from an array of complex amplitudes
            .. code-block::

                import numpy as np
                from qiskit import QuantumCircuit

                circuit = QuantumCircuit(2)
                circuit.prepare_state([0, 1/np.sqrt(2), -1.j/np.sqrt(2), 0], circuit.qubits)
                circuit.draw()

            output:

            .. code-block:: text

                     â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”�
                q_0: â”¤0                                          â”œ
                     â”‚  State Preparation(0,0.70711,-0.70711j,0) â”‚
                q_1: â”¤1                                          â”œ
                     â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        r   )ÚStatePreparationN)ro  rO  Frà   )Ú'qiskit.circuit.library.data_preparationrQ  rÀ   ra   rk   rh  ri  rø  r6   r»  rã   )r“   rM  rÀ   ro  rO  rQ  r¿   s          rf   Úprepare_statezQuantumCircuit.prepare_state6  s    € ðF 	MÐLÐLÐLÐLÐLàˆ>Ø”[ˆFˆFÝ˜¥¥b¤jµ%½Ð ?Ñ@Ô@ð 	Ø�XˆFå$.¨uµcÑ$:Ô$:ÐD•S˜‘[”[�[Àˆ
à�{Š{ØÐ˜U J°eÀyÐQÑQÔQØØð ñ 
ô 
ð 	
rh   c                ó  — ddl m} |€| j        }n0t          |t          t
          j        t          t          f¦  «        r|g}t          |t          ¦  «        rt          |¦  «        nd}|  
                     ||||¦  «        |d¬¦  «        S )uc  Initialize qubits in a specific state.

        Qubit initialization is done by first resetting the qubits to :math:`|0\rangle`
        followed by calling :class:`~qiskit.circuit.library.StatePreparation`
        class to prepare the qubits in a specified state.
        Both these steps are included in the
        :class:`~qiskit.circuit.library.Initialize` instruction.

        Args:
            params: The state to initialize to, can be either of the following.

                * Statevector or vector of complex amplitudes to initialize to.
                * Labels of basis states of the Pauli eigenstates Z, X, Y. See
                  :meth:`.Statevector.from_label`. Notice the order of the labels is reversed with
                  respect to the qubit index to be applied to. Example label ``'01'`` initializes the
                  qubit zero to :math:`|1\rangle` and the qubit one to :math:`|0\rangle`.
                * An integer that is used as a bitmap indicating which qubits to initialize to
                  :math:`|1\rangle`. Example: setting params to 5 would initialize qubit 0 and qubit
                  2 to :math:`|1\rangle` and qubit 1 to :math:`|0\rangle`.

            qubits: Qubits to initialize. If ``None`` the initialization is applied to all qubits in
                the circuit.
            normalize: Whether to normalize an input array to a unit vector.

        Returns:
            A handle to the instructions created.

        Examples:
            Prepare a qubit in the state :math:`(|0\rangle - |1\rangle) / \sqrt{2}`.

            .. code-block::

                import numpy as np
                from qiskit import QuantumCircuit

                circuit = QuantumCircuit(1)
                circuit.initialize([1/np.sqrt(2), -1/np.sqrt(2)], 0)
                circuit.draw()

            output:

            .. code-block:: text

                     â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”�
                q_0: â”¤ Initialize(0.70711,-0.70711) â”œ
                     â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜


            Initialize from a string two qubits in the state :math:`|10\rangle`.
            The order of the labels is reversed with respect to qubit index.
            More information about labels for basis states are in
            :meth:`.Statevector.from_label`.

            .. code-block::

                import numpy as np
                from qiskit import QuantumCircuit

                circuit = QuantumCircuit(2)
                circuit.initialize('01', circuit.qubits)
                circuit.draw()

            output:

            .. code-block:: text

                     â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”�
                q_0: â”¤0                 â”œ
                     â”‚  Initialize(0,1) â”‚
                q_1: â”¤1                 â”œ
                     â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜

            Initialize two qubits from an array of complex amplitudes.

            .. code-block::

                import numpy as np
                from qiskit import QuantumCircuit

                circuit = QuantumCircuit(2)
                circuit.initialize([0, 1/np.sqrt(2), -1.j/np.sqrt(2), 0], circuit.qubits)
                circuit.draw()

            output:

            .. code-block:: text

                     â”Œâ”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”�
                q_0: â”¤0                                   â”œ
                     â”‚  Initialize(0,0.70711,-0.70711j,0) â”‚
                q_1: â”¤1                                   â”œ
                     â””â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”˜
        r   )Ú
InitializeNFrà   )Ú$library.data_preparation.initializerrU  rÀ   ra   rk   rh  ri  rø  r6   r»  rã   )r“   rû   rÀ   rO  rU  r¿   s         rf   Ú
initializezQuantumCircuit.initialize¨  s�   € ðH 	EÐDÐDÐDÐDÐDàˆ>Ø”[ˆFˆFÝ˜¥¥b¤jµ%½Ð ?Ñ@Ô@ð 	Ø�XˆFå$.¨vµsÑ$;Ô$;ÐE•S˜‘[”[�[Àˆ
à�{Š{˜:˜: f¨j¸)ÑDÔDÀfÐSXˆ{ÑYÔYÐYrh   rÕ  ú np.ndarray | Gate | BaseOperatorc                óÔ   — ddl m}  |||¬¦  «        }|j        dk    r2t          |t          t
          f¦  «        st          |¦  «        dk    r|g}|                      ||g d¬¦  «        S )aä  Apply unitary gate specified by ``obj`` to ``qubits``.

        Args:
            obj: Unitary operator.
            qubits: The circuit qubits to apply the transformation to.
            label: Unitary name for backend [Default: None].

        Returns:
            QuantumCircuit: The quantum circuit.

        Example:

            Apply a gate specified by a unitary matrix to a quantum circuit

            .. code-block:: python

                from qiskit import QuantumCircuit
                matrix = [[0, 0, 0, 1],
                        [0, 0, 1, 0],
                        [1, 0, 0, 0],
                        [0, 1, 0, 0]]
                circuit = QuantumCircuit(2)
                circuit.unitary(matrix, [0, 1])
        r   )ÚUnitaryGater#  Frà   )Ú!library.generalized_gates.unitaryrZ  r¿   ra   rk   r6   r»  rã   )r“   rÕ  rÀ   ro  rZ  rk  s         rf   ÚunitaryzQuantumCircuit.unitary  s   € ð> 	CÐBÐBÐBÐBÐBàˆ{˜3 eÐ,Ñ,Ô,ˆð Œ?˜aÒÐÝ˜&¥3­ ,Ñ/Ô/ð "µ3°v±;´;À²?°?Ø ˜�à�{Š{˜4 ¨°%ˆ{Ñ8Ô8Ð8rh   r#   c                ó8   — | j         r| j         d         S | j        S )NrE  )r   r}   rŸ   s    rf   r²  zQuantumCircuit._current_scopeB  s$   € ØÔ$ð 	1ØÔ,¨RÔ0Ð0ØÔ Ð rh   rJ   úIterable[Register]Úallow_jumpsÚforbidden_messageúOptional[str]c           
     ó„   — | j                              t          |||                      ¦   «         |||¬¦  «        ¦  «         dS )ac  Add a scope for collecting instructions into this circuit.

        This should only be done by the control-flow context managers, which will handle cleaning up
        after themselves at the end as well.

        Args:
            qubits: Any qubits that this scope should automatically use.
            clbits: Any clbits that this scope should automatically use.
            allow_jumps: Whether this scope allows jumps to be used within it.
            forbidden_message: If given, all attempts to add instructions to this scope will raise a
                :exc:`.CircuitError` with this message.
        )ÚparentrJ   r_  r`  N)r   rã   r$   r²  )r“   rÀ   rÃ   rJ   r_  r`  s         rf   Ú_push_scopezQuantumCircuit._push_scopeG  sY   € ð( 	Ô!×(Ò(Ý#ØØØ×*Ò*Ñ,Ô,Ø#Ø'Ø"3ðñ ô ñ		
ô 		
ð 		
ð 		
ð 		
rh   r$   c                ó4   — | j                              ¦   «         S )zõFinish a scope used in the control-flow builder interface, and return it to the caller.

        This should only be done by the control-flow context managers, since they naturally
        synchronize the creation and deletion of stack elements.)r   ÚpoprŸ   s    rf   Ú
_pop_scopezQuantumCircuit._pop_scopef  s   € ð
 Ô(×,Ò,Ñ.Ô.Ð.rh   c                ó”   — | j         r| j         d                              ¦   «         S | j        st          d¦  «        ‚| j        d         S )a'  Return the instruction 3-tuple of the most recent instruction in the current scope, even
        if that scope is currently under construction.

        This function is only intended for use by the control-flow ``if``-statement builders, which
        may need to modify a previous instruction.rE  ú&This circuit contains no instructions.)r   Úpeekr„   r   rŸ   s    rf   Ú#_peek_previous_instruction_in_scopez2QuantumCircuit._peek_previous_instruction_in_scopem  sO   € ð Ô$ð 	8ØÔ,¨RÔ0×5Ò5Ñ7Ô7Ð7ØŒzð 	IÝÐGÑHÔHÐHØŒz˜"Œ~Ðrh   c                ó°   — | j         r| j         d                              ¦   «         S | j        st          d¦  «        ‚| j                             ¦   «         }|S )a]  Return the instruction 3-tuple of the most recent instruction in the current scope, even
        if that scope is currently under construction, and remove it from that scope.

        This function is only intended for use by the control-flow ``if``-statement builders, which
        may need to replace a previous instruction with another.
        rE  ri  )r   rf  r„   r   rö   s     rf   Ú"_pop_previous_instruction_in_scopez1QuantumCircuit._pop_previous_instruction_in_scopey  sZ   € ð Ô$ð 	7ØÔ,¨RÔ0×4Ò4Ñ6Ô6Ð6ØŒzð 	IÝÐGÑHÔHÐHØ”j—n’nÑ&Ô&ˆØÐrh   rž  ú1tuple[ClassicalRegister | Clbit, int] | expr.ExprÚbodyr0   c               ó   — d S r`   rQ   ©r“   rž  ro  rÀ   rÃ   ro  s         rf   Ú
while_loopzQuantumCircuit.while_loop‡  s	   € ð ˜3rh   úSequence[ClbitSpecifier]c               ó   — d S r`   rQ   rq  s         rf   rr  zQuantumCircuit.while_loop’  ó	   € ð ˜rh   c               óŠ  — |                       ¦   «         }t          |t          j        ¦  «        rt	          ||¦  «        }n#|                     |d         ¦  «        |d         f}|€%|€|�t          d¦  «        ‚t          | ||¬¦  «        S |�|€t          d¦  «        ‚|                      t          |||¦  «        ||d¬¦  «        S )	aß  Create a ``while`` loop on this circuit.

        There are two forms for calling this function.  If called with all its arguments (with the
        possible exception of ``label``), it will create a
        :obj:`~qiskit.circuit.controlflow.WhileLoopOp` with the given ``body``.  If ``body`` (and
        ``qubits`` and ``clbits``) are *not* passed, then this acts as a context manager, which
        will automatically build a :obj:`~qiskit.circuit.controlflow.WhileLoopOp` when the scope
        finishes.  In this form, you do not need to keep track of the qubits or clbits you are
        using, because the scope will handle it for you.

        Example usage::

            from qiskit.circuit import QuantumCircuit, Clbit, Qubit
            bits = [Qubit(), Qubit(), Clbit()]
            qc = QuantumCircuit(bits)

            with qc.while_loop((bits[2], 0)):
                qc.h(0)
                qc.cx(0, 1)
                qc.measure(0, 0)

        Args:
            condition (Tuple[Union[ClassicalRegister, Clbit], int]): An equality condition to be
                checked prior to executing ``body``. The left-hand side of the condition must be a
                :obj:`~ClassicalRegister` or a :obj:`~Clbit`, and the right-hand side must be an
                integer or boolean.
            body (Optional[QuantumCircuit]): The loop body to be repeatedly executed.  Omit this to
                use the context-manager mode.
            qubits (Optional[Sequence[Qubit]]): The circuit qubits over which the loop body should
                be run.  Omit this to use the context-manager mode.
            clbits (Optional[Sequence[Clbit]]): The circuit clbits over which the loop body should
                be run.  Omit this to use the context-manager mode.
            label (Optional[str]): The string label of the instruction in the circuit.

        Returns:
            InstructionSet or WhileLoopContext: If used in context-manager mode, then this should be
            used as a ``with`` resource, which will infer the block content and operands on exit.
            If the full form is used, then this returns a handle to the instructions created.

        Raises:
            CircuitError: if an incorrect calling convention is used.
        r   r   NzOWhen using 'while_loop' as a context manager, you cannot pass qubits or clbits.r#  zEWhen using 'while_loop' with a body, you must pass qubits and clbits.Frà   )
r²  ra   r1   r<  r=  r'  r   r0   rã   r/   )r“   rž  ro  rÀ   rÃ   ro  r,  s          rf   rr  zQuantumCircuit.while_loop�  sä   € ðV ×+Ò+Ñ-Ô-ˆÝ�i¥¤Ñ+Ô+ð 	_Ý& }°iÑ@Ô@ˆIˆIà&×AÒAÀ)ÈAÄ,ÑOÔOÐQZÐ[\ÔQ]Ð^ˆIàˆ<ØÐ! VÐ%7Ý"ð9ñô ð õ $ D¨)¸5ÐAÑAÔAÐAØˆ^˜v˜~ÝØWñô ð ð �{Š{�; y°$¸Ñ>Ô>ÀÈÐUZˆ{Ñ[Ô[Ð[rh   ÚindexsetúIterable[int]Úloop_parameterúParameter | Noner*   c               ó   — d S r`   rQ   ©r“   rw  ry  ro  rÀ   rÃ   ro  s          rf   Úfor_loopzQuantumCircuit.for_loopÜ  ó	   € ð ˜rh   úUnion[Parameter, None]c               ó   — d S r`   rQ   r|  s          rf   r}  zQuantumCircuit.for_loopè  r~  rh   c               óÊ   — |€&|€|�t          d¦  «        ‚t          | |||¬¦  «        S |�|€t          d¦  «        ‚|                      t          ||||¦  «        ||d¬¦  «        S )aÔ
  Create a ``for`` loop on this circuit.

        There are two forms for calling this function.  If called with all its arguments (with the
        possible exception of ``label``), it will create a
        :class:`~qiskit.circuit.ForLoopOp` with the given ``body``.  If ``body`` (and
        ``qubits`` and ``clbits``) are *not* passed, then this acts as a context manager, which,
        when entered, provides a loop variable (unless one is given, in which case it will be
        reused) and will automatically build a :class:`~qiskit.circuit.ForLoopOp` when the
        scope finishes.  In this form, you do not need to keep track of the qubits or clbits you are
        using, because the scope will handle it for you.

        For example::

            from qiskit import QuantumCircuit
            qc = QuantumCircuit(2, 1)

            with qc.for_loop(range(5)) as i:
                qc.h(0)
                qc.cx(0, 1)
                qc.measure(0, 0)
                qc.break_loop().c_if(0, True)

        Args:
            indexset (Iterable[int]): A collection of integers to loop over.  Always necessary.
            loop_parameter (Optional[Parameter]): The parameter used within ``body`` to which
                the values from ``indexset`` will be assigned.  In the context-manager form, if this
                argument is not supplied, then a loop parameter will be allocated for you and
                returned as the value of the ``with`` statement.  This will only be bound into the
                circuit if it is used within the body.

                If this argument is ``None`` in the manual form of this method, ``body`` will be
                repeated once for each of the items in ``indexset`` but their values will be
                ignored.
            body (Optional[QuantumCircuit]): The loop body to be repeatedly executed.  Omit this to
                use the context-manager mode.
            qubits (Optional[Sequence[QubitSpecifier]]): The circuit qubits over which the loop body
                should be run.  Omit this to use the context-manager mode.
            clbits (Optional[Sequence[ClbitSpecifier]]): The circuit clbits over which the loop body
                should be run.  Omit this to use the context-manager mode.
            label (Optional[str]): The string label of the instruction in the circuit.

        Returns:
            InstructionSet or ForLoopContext: depending on the call signature, either a context
            manager for creating the for loop (it will automatically be added to the circuit at the
            end of the block), or an :obj:`~InstructionSet` handle to the appended loop operation.

        Raises:
            CircuitError: if an incorrect calling convention is used.
        NzMWhen using 'for_loop' as a context manager, you cannot pass qubits or clbits.r#  zCWhen using 'for_loop' with a body, you must pass qubits and clbits.Frà   )r   r*   rã   r)   r|  s          rf   r}  zQuantumCircuit.for_loopô  s–   € ðh ˆ<ØÐ! VÐ%7Ý"Øcñô ð õ " $¨°.ÈÐNÑNÔNÐNØˆ^˜v˜~ÝØUñô ð ð �{Š{Ý�h °°eÑ<Ô<¸fÀfÐSXð ñ 
ô 
ð 	
rh   ú%tuple[ClassicalRegister | Clbit, int]r,   c                ó   — d S r`   rQ   )r“   rž  s     rf   Úif_testzQuantumCircuit.if_test7  s   € ØVYÐVYrh   Ú	true_bodyc               ó   — d S r`   rQ   )r“   rž  r…  rÀ   rÃ   ro  s         rf   r„  zQuantumCircuit.if_test:  ru  rh   c               óÚ  — |                       ¦   «         }t          |t          j        ¦  «        rt	          ||¦  «        }n#|                     |d         ¦  «        |d         f}|€L|€|�t          d¦  «        ‚t          | j        o| j        d         j	        ¦  «        }t          | |||¬¦  «        S |�|€t          d¦  «        ‚|                      t          ||d|¦  «        ||d¬	¦  «        S )
a5  Create an ``if`` statement on this circuit.

        There are two forms for calling this function.  If called with all its arguments (with the
        possible exception of ``label``), it will create a
        :obj:`~qiskit.circuit.IfElseOp` with the given ``true_body``, and there will be
        no branch for the ``false`` condition (see also the :meth:`.if_else` method).  However, if
        ``true_body`` (and ``qubits`` and ``clbits``) are *not* passed, then this acts as a context
        manager, which can be used to build ``if`` statements.  The return value of the ``with``
        statement is a chainable context manager, which can be used to create subsequent ``else``
        blocks.  In this form, you do not need to keep track of the qubits or clbits you are using,
        because the scope will handle it for you.

        For example::

            from qiskit.circuit import QuantumCircuit, Qubit, Clbit
            bits = [Qubit(), Qubit(), Qubit(), Clbit(), Clbit()]
            qc = QuantumCircuit(bits)

            qc.h(0)
            qc.cx(0, 1)
            qc.measure(0, 0)
            qc.h(0)
            qc.cx(0, 1)
            qc.measure(0, 1)

            with qc.if_test((bits[3], 0)) as else_:
                qc.x(2)
            with else_:
                qc.h(2)
                qc.z(2)

        Args:
            condition (Tuple[Union[ClassicalRegister, Clbit], int]): A condition to be evaluated in
                real time during circuit execution, which, if true, will trigger the evaluation of
                ``true_body``. Can be specified as either a tuple of a ``ClassicalRegister`` to be
                tested for equality with a given ``int``, or as a tuple of a ``Clbit`` to be
                compared to either a ``bool`` or an ``int``.
            true_body (Optional[QuantumCircuit]): The circuit body to be run if ``condition`` is
                true.
            qubits (Optional[Sequence[QubitSpecifier]]): The circuit qubits over which the if/else
                should be run.
            clbits (Optional[Sequence[ClbitSpecifier]]): The circuit clbits over which the if/else
                should be run.
            label (Optional[str]): The string label of the instruction in the circuit.

        Returns:
            InstructionSet or IfContext: depending on the call signature, either a context
            manager for creating the ``if`` block (it will automatically be added to the circuit at
            the end of the block), or an :obj:`~InstructionSet` handle to the appended conditional
            operation.

        Raises:
            CircuitError: If the provided condition references Clbits outside the
                enclosing circuit.
            CircuitError: if an incorrect calling convention is used.

        Returns:
            A handle to the instruction created.
        r   r   NzLWhen using 'if_test' as a context manager, you cannot pass qubits or clbits.rE  ©Úin_loopro  zBWhen using 'if_test' with a body, you must pass qubits and clbits.Frà   )r²  ra   r1   r<  r=  r'  r   r«   r   r_  r,   rã   r+   )r“   rž  r…  rÀ   rÃ   ro  r,  r‰  s           rf   r„  zQuantumCircuit.if_testE  s  € ðH ×+Ò+Ñ-Ô-ˆÝ�i¥¤Ñ+Ô+ð 	_Ý& }°iÑ@Ô@ˆIˆIà&×AÒAÀ)ÈAÄ,ÑOÔOÐQZÐ[\ÔQ]Ð^ˆIàÐØÐ! VÐ%7Ý"Øbñô ð õ
 ˜4Ô4Ðb¸Ô9RÐSUÔ9VÔ9bÑcÔcˆGÝ˜T 9°gÀUÐKÑKÔKÐKØˆ^˜v˜~ÝÐcÑdÔdÐdà�{Š{�8 I¨y¸$ÀÑFÔFÈÐPVÐ]bˆ{ÑcÔcÐcrh   úFtuple[ClassicalRegister, int] | tuple[Clbit, int] | tuple[Clbit, bool]Ú
false_bodyc                ó  — |                       ¦   «         }t          |t          j        ¦  «        rt	          ||¦  «        }n#|                     |d         ¦  «        |d         f}|                      t          ||||¦  «        ||d¬¦  «        S )aŒ  Apply :class:`~qiskit.circuit.IfElseOp`.

        .. note::

            This method does not have an associated context-manager form, because it is already
            handled by the :meth:`.if_test` method.  You can use the ``else`` part of that with
            something such as::

                from qiskit.circuit import QuantumCircuit, Qubit, Clbit
                bits = [Qubit(), Qubit(), Clbit()]
                qc = QuantumCircuit(bits)
                qc.h(0)
                qc.cx(0, 1)
                qc.measure(0, 0)
                with qc.if_test((bits[2], 0)) as else_:
                    qc.h(0)
                with else_:
                    qc.x(0)

        Args:
            condition: A condition to be evaluated in real time at circuit execution, which,
                if true, will trigger the evaluation of ``true_body``. Can be
                specified as either a tuple of a ``ClassicalRegister`` to be
                tested for equality with a given ``int``, or as a tuple of a
                ``Clbit`` to be compared to either a ``bool`` or an ``int``.
            true_body: The circuit body to be run if ``condition`` is true.
            false_body: The circuit to be run if ``condition`` is false.
            qubits: The circuit qubits over which the if/else should be run.
            clbits: The circuit clbits over which the if/else should be run.
            label: The string label of the instruction in the circuit.

        Raises:
            CircuitError: If the provided condition references Clbits outside the
                enclosing circuit.

        Returns:
            A handle to the instruction created.
        r   r   Frà   )r²  ra   r1   r<  r=  r'  rã   r+   )r“   rž  r…  r‹  rÀ   rÃ   ro  r,  s           rf   Úif_elsezQuantumCircuit.if_else�  s’   € ð^ ×+Ò+Ñ-Ô-ˆÝ�i¥¤Ñ+Ô+ð 	_Ý& }°iÑ@Ô@ˆIˆIà&×AÒAÀ)ÈAÄ,ÑOÔOÐQZÐ[\ÔQ]Ð^ˆIà�{Š{Ý�Y 	¨:°uÑ=Ô=¸vÀvÐTYð ñ 
ô 
ð 	
rh   r¢  ú(Union[ClbitSpecifier, ClassicalRegister]Úcasesr.   c               ó   — d S r`   rQ   ©r“   r¢  r�  rÀ   rÃ   ro  s         rf   ÚswitchzQuantumCircuit.switchÖ  s	   € ð ˜rh   ú+Iterable[Tuple[typing.Any, QuantumCircuit]]c               ó   — d S r`   rQ   r‘  s         rf   r’  zQuantumCircuit.switchá  ru  rh   c               ó¾  — |                       ¦   «         }t          |t          j        ¦  «        rt	          ||¦  «        }n|                     |¦  «        }|€L|€|�t          d¦  «        ‚t          | j        o| j        d         j	        ¦  «        }t          | |||¬¦  «        S |�|€t          d¦  «        ‚|                      t          |||¬¦  «        ||d¬¦  «        S )	a•
  Create a ``switch``/``case`` structure on this circuit.

        There are two forms for calling this function.  If called with all its arguments (with the
        possible exception of ``label``), it will create a :class:`.SwitchCaseOp` with the given
        case structure.  If ``cases`` (and ``qubits`` and ``clbits``) are *not* passed, then this
        acts as a context manager, which will automatically build a :class:`.SwitchCaseOp` when the
        scope finishes.  In this form, you do not need to keep track of the qubits or clbits you are
        using, because the scope will handle it for you.

        Example usage::

            from qiskit.circuit import QuantumCircuit, ClassicalRegister, QuantumRegister
            qreg = QuantumRegister(3)
            creg = ClassicalRegister(3)
            qc = QuantumCircuit(qreg, creg)
            qc.h([0, 1, 2])
            qc.measure([0, 1, 2], [0, 1, 2])

            with qc.switch(creg) as case:
                with case(0):
                    qc.x(0)
                with case(1, 2):
                    qc.z(1)
                with case(case.DEFAULT):
                    qc.cx(0, 1)

        Args:
            target (Union[ClassicalRegister, Clbit]): The classical value to switch one.  This must
                be integer-like.
            cases (Iterable[Tuple[typing.Any, QuantumCircuit]]): A sequence of case specifiers.
                Each tuple defines one case body (the second item).  The first item of the tuple can
                be either a single integer value, the special value :data:`.CASE_DEFAULT`, or a
                tuple of several integer values.  Each of the integer values will be tried in turn;
                control will then pass to the body corresponding to the first match.
                :data:`.CASE_DEFAULT` matches all possible values.  Omit in context-manager form.
            qubits (Sequence[Qubit]): The circuit qubits over which all case bodies execute. Omit in
                context-manager form.
            clbits (Sequence[Clbit]): The circuit clbits over which all case bodies execute. Omit in
                context-manager form.
            label (Optional[str]): The string label of the instruction in the circuit.

        Returns:
            InstructionSet or SwitchCaseContext: If used in context-manager mode, then this should
            be used as a ``with`` resource, which will return an object that can be repeatedly
            entered to produce cases for the switch statement.  If the full form is used, then this
            returns a handle to the instructions created.

        Raises:
            CircuitError: if an incorrect calling convention is used.
        NzKWhen using 'switch' as a context manager, you cannot pass qubits or clbits.rE  rˆ  z@When using 'switch' with cases, you must pass qubits and clbits.r#  Frà   )r²  ra   r1   r<  r=  r'  r   r«   r   r_  r.   rã   r-   )r“   r¢  r�  rÀ   rÃ   ro  r,  r‰  s           rf   r’  zQuantumCircuit.switchì  sð   € ðh ×+Ò+Ñ-Ô-ˆÝ�f�dœiÑ(Ô(ð 	FÝ# M°6Ñ:Ô:ˆFˆFà"×=Ò=¸fÑEÔEˆFØˆ=ØÐ! VÐ%7Ý"Øañô ð õ ˜4Ô4Ðb¸Ô9RÐSUÔ9VÔ9bÑcÔcˆGÝ   v°wÀeÐLÑLÔLÐLàˆ>˜V˜^ÝÐaÑbÔbÐbØ�{Š{�<¨°¸UÐCÑCÔCÀVÈVÐZ_ˆ{Ñ`Ô`Ð`rh   c                ó  — | j         rEt          ¦   «         }|                     ¦   «         }|                      ||j        |j        d¬¦  «        S |                      t          | j        | j        ¦  «        | j        | j        d¬¦  «        S )aè  Apply :class:`~qiskit.circuit.BreakLoopOp`.

        .. warning::

            If you are using the context-manager "builder" forms of :meth:`.if_test`,
            :meth:`.for_loop` or :meth:`.while_loop`, you can only call this method if you are
            within a loop context, because otherwise the "resource width" of the operation cannot be
            determined.  This would quickly lead to invalid circuits, and so if you are trying to
            construct a reusable loop body (without the context managers), you must also use the
            non-context-manager form of :meth:`.if_test` and :meth:`.if_else`.  Take care that the
            :obj:`.BreakLoopOp` instruction must span all the resources of its containing loop, not
            just the immediate scope.

        Returns:
            A handle to the instruction created.

        Raises:
            CircuitError: if this method was called within a builder context, but not contained
                within a loop.
        Frà   )	r   r&   Úplaceholder_resourcesrã   rÀ   rÃ   r%   r¿   rÂ   ©r“   rú   Ú	resourcess      rf   Ú
break_loopzQuantumCircuit.break_loop1  s„   € ð* Ô$ð 	ZÝ,Ñ.Ô.ˆIØ!×7Ò7Ñ9Ô9ˆIØ—;’;˜y¨)Ô*:¸IÔ<LÐSX�;ÑYÔYÐYØ�{Š{Ý˜œ¨¬Ñ9Ô9¸4¼;ÈÌÐZ_ð ñ 
ô 
ð 	
rh   c                ó  — | j         rEt          ¦   «         }|                     ¦   «         }|                      ||j        |j        d¬¦  «        S |                      t          | j        | j        ¦  «        | j        | j        d¬¦  «        S )aÿ  Apply :class:`~qiskit.circuit.ContinueLoopOp`.

        .. warning::

            If you are using the context-manager "builder" forms of :meth:`.if_test`,
            :meth:`.for_loop` or :meth:`.while_loop`, you can only call this method if you are
            within a loop context, because otherwise the "resource width" of the operation cannot be
            determined.  This would quickly lead to invalid circuits, and so if you are trying to
            construct a reusable loop body (without the context managers), you must also use the
            non-context-manager form of :meth:`.if_test` and :meth:`.if_else`.  Take care that the
            :class:`~qiskit.circuit.ContinueLoopOp` instruction must span all the resources of its
            containing loop, not just the immediate scope.

        Returns:
            A handle to the instruction created.

        Raises:
            CircuitError: if this method was called within a builder context, but not contained
                within a loop.
        Frà   )	r   r(   r—  rã   rÀ   rÃ   r'   r¿   rÂ   r˜  s      rf   Úcontinue_loopzQuantumCircuit.continue_loopN  s„   € ð* Ô$ð 	ZÝ/Ñ1Ô1ˆIØ!×7Ò7Ñ9Ô9ˆIØ—;’;˜y¨)Ô*:¸IÔ<LÐSX�;ÑYÔYÐYØ�{Š{Ý˜4œ?¨D¬OÑ<Ô<¸d¼kÈ4Ì;Ð]bð ñ 
ô 
ð 	
rh   rk  úUnion[Gate, str]úSequence[int]ú#Sequence[ParameterValueType] | Nonec                óÔ   — d„ }t          |t          ¦  «        r|j        }|j        }|�t	          t          ||¦  «        ¦  «        }nd}|| j        |         t	          |¦  «        |f<   dS )aÁ  Register a low-level, custom pulse definition for the given gate.

        Args:
            gate (Union[Gate, str]): Gate information.
            qubits (Union[int, Tuple[int]]): List of qubits to be measured.
            schedule (Schedule): Schedule information.
            params (Optional[List[Union[float, Parameter]]]): A list of parameters.

        Raises:
            Exception: if the gate is of type string and params is None.
        c                óà   — 	 t          | ¦  «        }t          j        |¦  «        r7t          |j        ¦  «        }|                     ¦   «         rt          |¦  «        }|S # t          $ r | cY S w xY wr`   )rg  rh  Úisrealrý   ÚrealÚ
is_integerrk   ru   )ÚoperandÚ	evaluateds     rf   Ú_formatz/QuantumCircuit.add_calibration.<locals>._formatƒ  s€   € ðõ $ GÑ,Ô,�	Ý”9˜YÑ'Ô'ð 3Ý % i¤nÑ 5Ô 5�IØ ×+Ò+Ñ-Ô-ð 3Ý$'¨	¡N¤N˜	Ø Ð øÝð ð ð à���ðøøøs   ‚AA ÁA-Á,A-NrQ   )ra   r   rû   rR   rv   rÍ  r‡   )r“   rk  rÀ   rh  rû   r§  s         rf   Úadd_calibrationzQuantumCircuit.add_calibrationk  sz   € ð0	ð 	ð 	õ" �d�DÑ!Ô!ð 	Ø”[ˆFØ”9ˆDØÐÝ�3˜w¨Ñ/Ô/Ñ0Ô0ˆFˆFàˆFà<DˆÔ˜4Ô ¥%¨¡-¤-°Ð!8Ñ9Ð9Ð9rh   úUnion[Qubit, int]c                ó,   —  | j         |Ž  | j        |Ž z
  S )ar  Return the duration between the start and stop time of the first and last instructions,
        excluding delays, over the supplied qubits. Its time unit is ``self.unit``.

        Args:
            *qubits: Qubits within ``self`` to include.

        Returns:
            Return the duration between the first start and last stop time of non-delay instructions
        )Úqubit_stop_timeÚqubit_start_time)r“   rÀ   s     rf   Úqubit_durationzQuantumCircuit.qubit_durationŸ  s$   € ð $ˆtÔ# VÐ,Ð/D¨tÔ/DÀfÐ/MÑMÐMrh   c                óR  ‡ — ‰ j         €5‰ j        D ]+}t          |j        t          ¦  «        st          d¦  «        ‚Œ,dS ˆ fd„|D ¦   «         }d„ |D ¦   «         }d„ |D ¦   «         }‰ j        D ]»}|D ]M}||j        v rBt          |j        t          ¦  «        r#||         s||xx         |j        j         z  cc<   ŒHd||<   ŒNt          |¦  «        t          d„ |                     ¦   «         D ¦   «         ¦  «        k    r-t          d	„ |                     ¦   «         D ¦   «         ¦  «        c S Œ¼dS )
a)  Return the start time of the first instruction, excluding delays,
        over the supplied qubits. Its time unit is ``self.unit``.

        Return 0 if there are no instructions over qubits

        Args:
            *qubits: Qubits within ``self`` to include. Integers are allowed for qubits, indicating
            indices of ``self.qubits``.

        Returns:
            Return the start time of the first instruction, excluding delays, over the qubits

        Raises:
            CircuitError: if ``self`` is a not-yet scheduled circuit.
        Nz<qubit_start_time undefined. Circuit must be scheduled first.r   c                óX   •— g | ]&}t          |t          ¦  «        r‰j        |         n|‘Œ'S rQ   ©ra   rk   rÀ   ©rd   r°   r“   s     €rf   ro   z3QuantumCircuit.qubit_start_time.<locals>.<listcomp>Ä  ó2   ø€ ÐNÐNÐNÀ!¥J¨qµ#Ñ$6Ô$6Ð=�$”+˜a”.�.¸AÐNÐNÐNrh   c                ó   — i | ]}|d “ŒS rÓ  rQ   ©rd   r°   s     rf   r¶   z3QuantumCircuit.qubit_start_time.<locals>.<dictcomp>Æ  s   € Ð'Ð'Ð'˜1�!�QÐ'Ð'Ð'rh   c                ó   — i | ]}|d “ŒS ©FrQ   r´  s     rf   r¶   z3QuantumCircuit.qubit_start_time.<locals>.<dictcomp>Ç  ó   € Ð*Ð*Ð*˜a��EÐ*Ð*Ð*rh   Tc                ó   — g | ]}|¯|‘ŒS rQ   rQ   ©rd   Údones     rf   ro   z3QuantumCircuit.qubit_start_time.<locals>.<listcomp>Ð  ó   € Ð"KÐ"KÐ"K¨DÀdÐ"K 4Ð"KÐ"KÐ"Krh   c              3  ó   K  — | ]}|V — Œd S r`   rQ   )rd   Ústarts     rf   rg   z2QuantumCircuit.qubit_start_time.<locals>.<genexpr>Ñ  s"   è è € Ð>Ð> U˜5Ð>Ð>Ð>Ð>Ð>Ð>rh   )
r    r„   ra   rú   rC   r   rÀ   r»  rÞ  Úmin)r“   rÀ   rØ   ÚstartsÚdonesr°   s   `     rf   r¬  zQuantumCircuit.qubit_start_time«  sr  ø€ ð  Œ=Ð à#œzð ð �Ý! +Ô"7½Ñ?Ô?ð Ý&ØVñô ð ðð �1àNÐNÐNÐNÀvÐNÑNÔNˆà'Ð' Ð'Ñ'Ô'ˆØ*Ð* 6Ð*Ñ*Ô*ˆØœ:ð 		?ð 		?ˆKØð (ð (�Ø˜Ô*Ð*Ð*Ý! +Ô"7½Ñ?Ô?ð (Ø$ Qœxð HØ" 1˜I˜IœI¨Ô)>Ô)GÑG˜I˜I™Iøà#'˜˜a™øÝ�6‰{Œ{�cÐ"KÐ"K°E·L²L±N´NÐ"KÑ"KÔ"KÑLÔLÒLÐLÝÐ>Ð>¨f¯mªm©o¬oÐ>Ñ>Ô>Ñ>Ô>Ð>Ð>Ð>ð Mð ˆqrh   c                óØ  ‡ — ‰ j         €5‰ j        D ]+}t          |j        t          ¦  «        st          d¦  «        ‚Œ,dS ˆ fd„|D ¦   «         }ˆ fd„|D ¦   «         }d„ |D ¦   «         }t          ‰ j        ¦  «        D ]»}|D ]M}||j        v rBt          |j        t          ¦  «        r#||         s||xx         |j        j         z  cc<   ŒHd||<   ŒNt          |¦  «        t          d„ | 	                    ¦   «         D ¦   «         ¦  «        k    r-t          d	„ | 	                    ¦   «         D ¦   «         ¦  «        c S Œ¼t          |¦  «        dk    r!t          | 	                    ¦   «         ¦  «        S dS )
a%  Return the stop time of the last instruction, excluding delays, over the supplied qubits.
        Its time unit is ``self.unit``.

        Return 0 if there are no instructions over qubits

        Args:
            *qubits: Qubits within ``self`` to include. Integers are allowed for qubits, indicating
            indices of ``self.qubits``.

        Returns:
            Return the stop time of the last instruction, excluding delays, over the qubits

        Raises:
            CircuitError: if ``self`` is a not-yet scheduled circuit.
        Nz;qubit_stop_time undefined. Circuit must be scheduled first.r   c                óX   •— g | ]&}t          |t          ¦  «        r‰j        |         n|‘Œ'S rQ   r°  r±  s     €rf   ro   z2QuantumCircuit.qubit_stop_time.<locals>.<listcomp>î  r²  rh   c                ó    •— i | ]
}|‰j         “ŒS rQ   )r    r±  s     €rf   r¶   z2QuantumCircuit.qubit_stop_time.<locals>.<dictcomp>ð  s   ø€ Ð2Ð2Ð2 a��D”MÐ2Ð2Ð2rh   c                ó   — i | ]}|d “ŒS r¶  rQ   r´  s     rf   r¶   z2QuantumCircuit.qubit_stop_time.<locals>.<dictcomp>ñ  r·  rh   Tc                ó   — g | ]}|¯|‘ŒS rQ   rQ   r¹  s     rf   ro   z2QuantumCircuit.qubit_stop_time.<locals>.<listcomp>ú  r»  rh   c              3  ó   K  — | ]}|V — Œd S r`   rQ   )rd   Ústops     rf   rg   z1QuantumCircuit.qubit_stop_time.<locals>.<genexpr>û  s"   è è € Ð;Ð; D˜4Ð;Ð;Ð;Ð;Ð;Ð;rh   )r    r„   ra   rú   rC   r   r?  rÀ   r»  rÞ  rÞ  )r“   rÀ   rØ   ÚstopsrÀ  r°   s   `     rf   r«  zQuantumCircuit.qubit_stop_timeÕ  s¥  ø€ ð  Œ=Ð à#œzð ð �Ý! +Ô"7½Ñ?Ô?ð Ý&ØUñô ð ðð �1àNÐNÐNÐNÀvÐNÑNÔNˆà2Ð2Ð2Ð2¨6Ð2Ñ2Ô2ˆØ*Ð* 6Ð*Ñ*Ô*ˆÝ# D¤JÑ/Ô/ð 		<ð 		<ˆKØð (ð (�Ø˜Ô*Ð*Ð*Ý! +Ô"7½Ñ?Ô?ð (Ø$ Qœxð GØ! !˜H˜HœH¨Ô(=Ô(FÑF˜H˜H™Høà#'˜˜a™øÝ�6‰{Œ{�cÐ"KÐ"K°E·L²L±N´NÐ"KÑ"KÔ"KÑLÔLÒLÐLÝÐ;Ð;¨E¯LªL©N¬NÐ;Ñ;Ô;Ñ;Ô;Ð;Ð;Ð;ð Mõ ˆu‰:Œ:˜Š>ˆ>Ý�u—|’|‘~”~Ñ&Ô&Ð&à�1rh   ræ  úint | floatc                óê   — ddl m} t           || ¦  «        |¦  «        }|dk    r|S |dk    rddlm}  |||j        ¦  «        S dddd	d	d
ddddddœ}||vrt          d|› d�¦  «        ‚|||         z  S )u^  Estimate the duration of a scheduled circuit

        This method computes the estimate of the circuit duration by finding
        the longest duration path in the circuit based on the durations
        provided by a given target. This method only works for simple circuits
        that have no control flow or other classical feed-forward operations.

        Args:
            target (Target): The :class:`.Target` instance that contains durations for
                the instructions if the target is missing duration data for any of the
                instructions in the circuit an :class:`.QiskitError` will be raised. This
                should be the same target object used as the target for transpilation.
            unit: The unit to return the duration in. This defaults to "s" for seconds
                but this can be a supported SI prefix for seconds returns. For example
                setting this to "n" will return in unit of nanoseconds. Supported values
                of this type are "f", "p", "n", "u", "Âµ", "m", "k", "M", "G", "T", and
                "P". Additionally, a value of "dt" is also accepted to output an integer
                in units of "dt". For this to function "dt" must be specified in the
                ``target``.

        Returns:
            The estimated duration for the execution of a single shot of the circuit in
            the specified unit.

        Raises:
            QiskitError: If the circuit is not scheduled or contains other
                details that prevent computing an estimated duration from
                (such as parameterized delay).
        r   r	  ræ  rq   )Úduration_in_dtgVçž¯Ò<gê-�™—q=g•Ö&è.>g�íµ ÷Æ°>gü©ñÒMbP?g     @�@g    €„.Ag    eÍÍAg   ¢”mBg  4&õkC)Úfrÿ   Únr  õ   ÂµÚmr  ÚMÚGrL   ÚPzSpecified unit: z1 is not a valid/supported SI prefix, 's', or 'dt')r  r
  r   Úqiskit.circuit.durationrË  rq   r   )r“   r¢  r§   r
  ÚdurrË  Úprefix_dicts          rf   Úestimate_durationz QuantumCircuit.estimate_duration  sÚ   € ð< 	5Ð4Ð4Ð4Ð4Ð4å(¨¨¸Ñ)=Ô)=¸vÑFÔFˆØ�3Š;ˆ;ØˆJØ�4Š<ˆ<Ø>Ð>Ð>Ð>Ð>Ð>à!�> # v¤yÑ1Ô1Ð1ð ØØØØØØØØØØð
ð 
ˆð �{Ð"Ð"ÝØZ 4ÐZÐZÐZñô ð ð �[ Ô&Ñ&Ð&rh   )rX   rY   rR   rZ   rS   r4   rT   r[   rU   r\   rV   r\   rW   r]   )r¡   r¢   )FN)r©   r   rª   r«   rR   rZ   r¬   r­   )rÇ   rÈ   rÀ   rÉ   rÃ   rÊ   rR   rZ   rS   r4   rT   r[   r¬   rË   )r¬   rÚ   )r¬   rA   )rÞ   r   )r¬   ræ   )r¬   r†   )rí   r†   )rØ   ró   )rT   r†   )r¬   rz   )r¬   r«   r`   )r¬   rk   )r¬   r/  )r7  r?   r¬   r«   )r¬   rË   r¶  )rT  r«   r¬   rË   )r[  rk   rZ  r«   r¬   rË   )FF)re  rý   rf  r«   rT  r«   r¬   rË   )r   NNF)
rn  rk   ro  rZ   rp  rq  rT  r«   r¬   rË   )NNFFF)r  rz  rÀ   r{  rÃ   r|  r}  r«   r~  r«   r  r«   rá   r«   rx  r€  ry  r«   r¬   r�  )r  rË   r~  r«   r¬   r�  )r¬   rÈ  )r¬   rË  )r¬   rÍ  )r¬   rÙ  )rä  rË   r¬   rË   )rë  rË   r¬   rË   )rô  rk   r¬   rB   )rô  rø  r¬   rù  )r¡   rK   rþ  rÿ  r¬   r   )r	  r
  r¬   rÈ  )r  r  r¬   rË  )rQ   rQ   N)
r¦  r   rä   r  rû   r  ro  rZ   r¬   r=   r¸  )
rØ   r0  rä   r1  rå   r2  rá   r«   r¬   r=   )rØ   rB   r%  r«   r¬   rB   )rØ   r>   rä   rF  rå   rG  r¬   r>   )rQ   rQ   ©r%  r«   )rR   rz   rO  rL   r¬   rP  ).)rR   rz   rO  rT  r¬   r   )rR   rz   rO  rV  r¬   r   )r]  r^  r¬   r«   )rR   rz   rO  rL   r¬   ra  )rR   rz   rO  rT  r¬   rƒ  )rR   rz   rO  rV  )rf  rg  r¬   r«   )rf  rg  rþ  ri  r¬   rƒ  )r˜   rV  rf  rg  r¬   rƒ  )r—   rƒ  )rf  rz   rþ  rz  r¬   rƒ  )rf  rƒ  rþ  r/  r¬   rƒ  )rX   rY   r¬   r/  )rˆ  r5   r¬   r/  )r±   r‹  r¬   r/  )r´   r@   r¬   rH   )rÀ   rF  r¬   r/  )r“  r”  ro  rZ   r¬   r   )r“  r”  ro  rZ   r¬   r   r  )r›  rœ  r[  rk   r¬   r­   )NNNNFTNNr¨  NTNNFNNr©  )"r  rZ   rª  r«  r¬  rZ   r­  r®  r¯  r«   r°  r«   rS  r±  r²  rZ   r³  rZ   r´  r±  rµ  r«   r¶  r·  r¸  r¹  rº  r«   r»  r±  r¼  r½  r¾  rk   )rÉ  rÊ  r¬   rk   )rÉ  rÐ  r¬   rk   )r¬   rè  )rR   rz   r¬   rù  )rò  r«   r¬   rk   )rR   rZ   r¬   r­   )rR   rZ   r	  r
  r¬   r­   )r  rk   rR   rz   r¬   r9   )r  rk   rR   rz   r¬   r5   )rÎ   r
  r¬   r=   )r¤  rV  r¥  rV  r¬   r=   )rÎ   r
  r  r  r¬   r=   )T)r~  r«   r¬   r�  )TT)r~  r«   rÕ   r«   r¬   r�  )r7  rz   r¬   rË   )rF  rz   r¬   rË   )r¬   r4   )rL  r4   )r¬   r;   )r¬   rP  )
rü   rU  r~  rV  rT  r«   r?  r«   r¬   rË   )
rü   rU  r~  rZ  rT  r«   r?  r«   r¬   r/  )
rü   rU  r~  r«   rT  r«   r?  r«   r¬   r�  )rx  ry  r¬   ry  )rä   r
  r¬   r=   ©Nrq   )r    r4   r  r~  r§   rz   r¬   r=   )
r†  r
  r‡  r
  ro  rZ   rp  rq  r¬   r=   )r“  r4   rÀ   r  r¬   r=   )r“  r4   rÎ   r
  r¬   r=   )r“  r4   r†  r
  r‡  r
  ro  rZ   rp  rq  r¬   r=   )
rž  r4   rŸ  r  r‡  r
  rp  rq  r¬   r=   )r“  r4   r¤  r4   rÎ   r
  r¬   r=   )
r¨  r4   r©  r4   rª  r4   rÎ   r
  r¬   r=   )r¯  r
  r°  r
  r‡  r
  r¬   r=   )
r¯  r
  r°  r
  r´  r
  r‡  r
  r¬   r=   )r“  r4   rÎ   r
  ro  rZ   r¬   r=   )r“  r4   rÂ  r
  rÃ  r
  r¬   r=   )r¤  r4   rÎ   r
  r¬   r=   )rÂ  r
  rÃ  r
  r¬   r=   )r†  r
  rø  r
  rù  r
  ro  rZ   rp  rq  r¬   r=   )
r“  r4   r¤  r4   rž  r4   rÎ   r
  r¬   r=   )r“  r4   r¤  r4   rž  r4   r  r4   r†  r
  r‡  r
  ro  rZ   rp  rq  r¬   r=   )rÎ   r
  ro  rZ   r¬   r=   )
r¯  r
  r°  r
  r‡  r
  rp  rq  r¬   r=   )Nr&  N)rŸ  r  r‡  r
  r'  r{  r(  rz   rp  rq  r¬   r=   )r¯  r
  r°  r
  r‡  r
  ro  rZ   rp  rq  r¬   r=   )rH  rz   rÀ   r  r¬   r=   )NNF)
rM  rN  rÀ   r1  ro  rZ   rO  r«   r¬   r=   )NF)rû   rN  rÀ   r1  rO  r«   )rÕ  rX  rÀ   r  ro  rZ   )r¬   r#   )rQ   rQ   rQ   TN)
rÀ   rÉ   rÃ   rÊ   rJ   r^  r_  r«   r`  ra  )r¬   r$   )r¬   rB   )rž  rn  ro  r/  rÀ   r/  rÃ   r/  ro  rZ   r¬   r0   )rž  rn  ro  rË   rÀ   r  rÃ   rs  ro  rZ   r¬   r=   )NNN)rw  rx  ry  rz  ro  r/  rÀ   r/  rÃ   r/  ro  rZ   r¬   r*   )rw  rx  ry  r  ro  rË   rÀ   r  rÃ   rs  ro  rZ   r¬   r=   )NNNN)rž  r‚  r¬   r,   )rž  r‚  r…  rË   rÀ   r  rÃ   rs  ro  rZ   r¬   r=   )rž  rŠ  r…  rË   r‹  rË   rÀ   r  rÃ   rs  ro  rZ   r¬   r=   )r¢  rŽ  r�  r/  rÀ   r/  rÃ   r/  ro  ra  r¬   r.   )r¢  rŽ  r�  r“  rÀ   r  rÃ   rs  ro  ra  r¬   r=   )r¬   r=   )rk  r�  rÀ   rž  rû   rŸ  r¬   r/  )rÀ   r©  r¬   rý   )ræ  )r§   rz   r¬   rÉ  )½rn   Ú
__module__Ú__qualname__Ú__doc__r!  r,  r™   Úpropertyr   r    Úsetterr§   ÚclassmethodrÆ   ÚstaticmethodrÙ   rÜ   r©   ré   r   rí   rì   r÷   rõ   rT   r  r  r  r{   r&  r(  r-  rx   ry   r:  rA  rS  rX  rd  re  rt  rÃ  rÇ  rÀ   rÃ   rÏ  rÔ  rÑ  rÒ  rÓ  rà  r®  r«  r¬  rè  rê  rï  rñ  ró  Útypingr   r÷  r  r  r  rº  r  r¼  r/  rã   r×   rS  r`  rc  r­  rn  r�   r¯  rŽ   r�   rˆ   r†  rÕ   rH  r)  r^  r]  r§  r  rÎ  rà  râ  r¿   ræ  rÂ   rê  rí  rñ  r  r  r  rá   r>  râ   r  r  r  ru  r"  r&  r(  r6  rE  rI  rS   rü   rj  rS  rY  rs  r`  r€  r„  rŽ  r’  r—  rÿ   r�  r£  r§  r®  r³  r·  r»  rÀ  rÇ  rË  rÏ  rÒ  rÕ  rÙ  rÜ  rß  rã  ræ  ré  rî  rñ  rô  r÷  rý  r   r  r  r
  r  r  r  rÇ  r  r  r%  r6  r9  r=  r@  rD  rG  rL  rS  rW  r\  r²  rd  rg  rk  rm  rr  r}  r„  r�  r’  rš  rœ  r¨  r­  r¬  r«  rÖ  rQ   rh   rf   rO   rO   z   sB  € € € € € ðQð Qðf €IØ€Fð
  Ø+,Ø $Ø%'Ø')Ø\^ðeYð eYñ eYð eYð eYð eYðN Ø€^˜'Ð4EÐSWÐXÑXÔXðð ñ YÔXñ „Xðð
 „_ñð ð ñ „_ðð Ø€^˜'Ð4EÐSWÐXÑXÔXðð ñ YÔXñ „Xðð 
„[ðð ñ „[ðð àKOñ ñ  ð  ð  ñ „[ð ðD ð #%Ø"$ØØ+,Ø $ð2ð 2ñ 2ð 2ð 2ñ „\ð2ðh ñð ð ñ „Xðð  ñ(ð (ð (ñ „Xð(ð 
„[ñCð Cð Cñ „[ðCð: ñ$ð $ð $ñ „Xð$ð( ØÐ¨DÐ1Ñ1Ô1ñ'ð 'ð 'ñ 2Ô1ñ „Xð'ð ÔØÐ¨DÐ1Ñ1Ô1ñ/ð /ð /ñ 2Ô1ñ Ôð/ð ñ(ð (ð (ñ „Xð(ð
 Ôñ=ð =ð =ñ Ôð=ð
  ñ6ð 6ð 6ñ  Ôð6ñKð Kð Kð Kð( ñ
ð 
ð 
ñ „Xð
ð „_ñ"ð "ð "ñ „_ð"ñ-ð -ð -ð -ñ	
ð 	
ð 	
ð 	
ñð ð ð ð. ðð ñ „[ðð Ø€^ØØ-ð3ðñ ô ñð ð ñô ñ „[ðð
 ñð ð ñ „[ðð
 Ø€^ØØ-ð3ðñ ô ñð ð ñô ñ „[ðð ñð ð ñ „[ðñKð Kð Kð Kñð ð ð ñ"&ð &ð &ð &ñPBð Bð Bð BñH2ñ 2ð 2ð 2ð 2ðh <Að ð ñ ð ð ð ð: KPñ5ñ 5ð 5ð 5ð 5ðr  !Ø Ø'+Øñ'ñ 'ð 'ð 'ð 'ðX DHØCGØØØñP)ð ØDHØ %ðP)ð P)ñ P)ð P)ð P)ð P)ñd
Yñ Yð Yð Yð Yðv ñ!ð !ð !ñ „Xð!ð
 ñ!ð !ð !ñ „Xð!ð
 ñð ð ñ „Xðð
 ñUð Uð Uñ „XðUð ñ%ð %ð %ñ „Xð%ð ñ'ð 'ð 'ñ „Xð'ð ñ%ð %ð %ñ „Xð%ñ

ð 

ð 

ð 

ñ)ð )ð )ð )ñ)ð )ð )ð )ñ+ð +ð +ð +ñ!ð !ð !ð !ñð ð ð ñ
 ð  ð  ð  ñð ð ð ñ
ð ð ð ð „_Ù?Ð?Ð?ñ „_Ø?à„_ÙGÐGÐGñ „_ØGð ð  ð  ð Ø€^ØØ-ð3ðñ ô ñð ð ñô ñ „\ðð ñð ð ñ „\ðð €^ØØ-ð3ðñ ô ñDð Dð Dñô ðDñ
ð 
ð 
ð 
ð €^ØØ-ð3ðñ ô ñDð Dð Dñô ðDñ
ð 
ð 
ð 
ð$ +-Ø/1Ø ññ ð ð ð ð8 26Ø15ñ	gð ðgð gñ gð gð gð gðT „_ñ!ð !ð !ñ „_ð!ð
 „_ñð ð ñ „_ðñDCÐQVð DCð DCñ DCð DCð DCð DCðL „_ÙNÐNÐNñ „_ØNð „_ÙRÑRÐRÐRñ „_ØRñ-ñ -ð -ð -ð -ñ^
ð 
ð 
ð 
ð2 „_ÙGÐGÐGñ „_ØGð „_ÙKÑKÐKÐKñ „_ØKñ+ñ +ð +ð +ð +ñZCð Cð Cð Cñ,ð ð ð ñ<^ð ^ð ^ð ^ñ@5ð 5ð 5ð 5ñBHð Hð Hð Hð@ „_ÙPÐPÐPñ „_ØPà„_ÙVÑVÐVÐVñ „_ØVð GKññ ð ð ð ñ8<:ð <:ð <:ð <:ñ|bð bð bð bñð ð ð ñ.=ð =ð =ð =ñ~<ð <ð <ð <ð EIØ ñHñ Hð Hð Hð Hð8 EIØ ñAñ Að Að Að Að: Øñ!:ñ !:ð !:ð !:ð !:ðJ "Ø"Ø#Ø#'Ø!Ø"Ø$(Ø"Ø+3Ø"&Ø Øð Ø#Ø"&Ø'+Øñ)g
ñ g
ñ g
ð g
ð g
ñV/
ð /
ð5ñ 5ñ 5ð 5ð 5ñ(A
ð A
ðM3ñ M3ñ M3ð M3ð M3ñ^"ñ "ð "ð "ð ñ%ñ %ð %ñ „Xð%ð ñ"ñ "ð "ñ „Xð"ð ñ%ñ %ð %ñ „Xð%ñ%ñ %ð %ð %ñ/ñ /ð /ð /ñ	Oñ 	Oð 	Oð 	OñGñ Gñ Gð Gð GñR@ñ @ð @ð @ñ	*ñ 	*ð 	*ð 	*ññ ñ ð ð ð  ñ;ñ ;Bñ	;ð ;ñ ;ñ ;ð ;ð ;ñz.ñ .ð .ð .ñ	ñ 	ð 	ð 	ñ	ñ 	ð 	ð 	ñ=ñ =ð =ð =ñFñ Fð Fð Fñ>KCñ KCð KCð KCñZñ ñ ð ð ð> 6:ñ+ñ +ñ +ð +ð +ñZRñ Rñ Rð Rð Rðh ñ
ñ 
ð 
ñ „\ð
ð0 ñ
ñ 
ð 
ñ „\ð
ð, ñ'ñ 'ð 'ñ „Xð'ð Ôñ	,ñ 	,ð 	,ñ Ôð	,ð ñ;4ñ ;4ð ;4ñ „Xð;4ðz ñ+ñ +ð +ñ „Xð+ñ0ñ 0ð 0ð 0ð ð #&ñð
 Øñð ñ ñ ð ñ „Xðð ð "%ñð
 Øñð ñ ñ ð ñ „Xðð ñr+ð
 !Øñr+ð r+ñ r+ñ r+ð r+ð r+ñhñ ð ð ð$ 59ñ ð ñ ñ ð ð ð< '+Øñ	Oñ Oñ Oð Oð Oñ4Kñ Kð Kð Kð" !Ø'+ñ#
ñ #
ñ #
ð #
ð #
ñJKñ Kð Kð KñKñ Kð Kð Kñ"Uñ Uð Uð Uð& !Ø'+ñ%
ñ %
ñ %
ð %
ð %
ðX (,ñ
ñ 
ñ 
ð 
ð 
ñ@Uñ Uð Uð Uñ"Hñ Hð Hð Hñ6
ñ 
ð 
ð 
ñ,
ñ 
ð 
ð 
ð6 UYñ^ñ ^ñ ^ð ^ð ^ð, !Ø'+ñ%
ñ %
ñ %
ð %
ð %
ñN[ñ [ð [ð [ð$ UYñ^ñ ^ñ ^ð ^ð ^ð, !Ø'+ñ%
ñ %
ñ %
ð %
ð %
ñN[ñ [ð [ð [ñ"Oñ Oð Oð Oð& !Ø'+ñ%
ñ %
ñ %
ð %
ð %
ñN[ñ [ð [ð [ñ"[ñ [ð [ð [ñ"Vñ Vð Vð VñKñ Kð Kð KñMñ Mð Mð Mð" !Ø'+ñ#
ñ #
ñ #
ð #
ð #
ðR !Ø'+ñ#
ñ #
ñ #
ð #
ð #
ñJ
ñ 
ð 
ð 
ñ"Xñ Xð Xð Xð$ !Ø'+ñ(
ñ (
ñ (
ð (
ð (
ñTLñ Lð Lð LñNñ Nð Nð Nð" !Ø'+ñ#
ñ #
ñ #
ð #
ð #
ñJKñ Kð Kð KñMñ Mð Mð MñZñ Zð Zð Zð< !Ø'+ñ.
ñ .
ñ .
ð .
ð .
ñ`Xñ Xñ Xð Xð Xð$ !Ø'+ñ&
ñ &
ñ &
ð &
ð &
ñPVñ Vð Vð Vð& (,ñ%
ñ %
ñ %
ð %
ð %
ðV LPØØ'+ñR]ñ R]ñ R]ð R]ð R]ñhKñ Kð Kð Kð" !Ø'+ñ&
ñ &
ñ &
ð &
ð &
ñPKñ Kð Kð Kð" !Ø'+ñ#
ñ #
ñ #
ð #
ð #
ðT !Ø'+ñ(
ñ (
ñ (
ð (
ð (
ñTLñ Lð Lð Lð* 37Ø Øñp
ñ p
ñ p
ð p
ð p
ðj 37Øñ	mZñ mZñ mZð mZð mZðf !ñ	)9ñ )9ñ )9ð )9ð )9ñV!ñ !ð !ð !ð #%Ø"$Ø(*Ø Ø+/ñ
ñ 
ñ 
ð 
ð 
ñ>/ñ /ð /ð /ñ
ñ 
ð 
ð 
ññ ð ð ð „_ññ ð ñ „_ðð „_ññ ð ñ „_ðñ=\ÐRVñ =\ð =\ñ =\ð =\ð =\ð~ „_ñ	ñ 	ð 	ñ „_ð	ð „_ñ	ñ 	ð 	ñ „_ð	ð MQñA
Ø[_ñA
ð A
ñ A
ð A
ð A
ðF „_ÙYÑYÐYñ „_ØYà„_ð !ñð ñ ñ ð ñ „_ðð ØØñVdð ñVdð Vdñ Vdð Vdð Vdð~ !ñ7
ñ 7
ñ 7
ð 7
ð 7
ðr „_ññ ð ñ „_ðð „_ññ ð ñ „_ðñCaÈDñ Cað Cañ Cað Cað CañJ
ñ 
ð 
ð 
ñ:
ñ 
ð 
ð 
ð:  ð 7;ñ0Eñ 0Eñ 0Eð 0Eñ  Ôð0Eñf
Nñ 
Nð 
Nð 
Nñ(ñ (ð (ð (ñT+ñ +ð +ð +ñZ9'ñ 9'ñ 9'ð 9'ð 9'ð 9'ð 9'rh   rO   c                  ód   — e Zd ZdZdd„Zed„ ¦   «         Zddœdd
„Zdd„Zd„ Z	d„ Z
d„ Zd„ Zd„ ZdS )r|   ©rP   rP   rO   c                ó   — || _         d S r`   râ  )r“   rP   s     rf   r™   z$_OuterCircuitScopeInterface.__init__D  s   € ØˆŒˆˆrh   c                ó   — | j         j        S r`   )rP   r„   rŸ   s    rf   rÇ   z(_OuterCircuitScopeInterface.instructionsG  s   € àŒ|Ô!Ð!rh   Fr$  r%  r«   c               ó:   — | j                              ||¬¦  «        S )Nr$  )rP   r×   rE  s      rf   rã   z"_OuterCircuitScopeInterface.appendK  s   € àŒ|×#Ò# KÀÐ#ÑOÔOÐOrh   r©   r   c                ót   — | j         j                             |¦  «         d | j         _        d| j         _        d S rØ  )rP   r„   r³  r    r§   )r“   r©   s     rf   r³  z"_OuterCircuitScopeInterface.extendO  s5   € ØŒÔ×!Ò! $Ñ'Ô'Ð'Ø $ˆŒÔØ ˆŒÔÐÐrh   c                ó¦  — t          |t          ¦  «        r#|| j        j        vrt	          d|› d�¦  «        ‚|S t          |t
          ¦  «        r#|| j        j        vrt	          d|› d�¦  «        ‚|S t          |t          ¦  «        r:	 | j        j        j	        |         S # t          $ r t	          d|› d�¦  «        d ‚w xY wt	          d|› d�¦  «        ‚)NzClbit z  is not present in this circuit.z	Register zClassical bit index z is out-of-range.z'Unknown classical resource specifier: 'z'.)ra   r:   rP   rƒ   r   r9   r�   rk   r„   rÃ   Ú
IndexError)r“   Ú	specifiers     rf   r'  z6_OuterCircuitScopeInterface.resolve_classical_resourceT  s  € õ
 �i¥Ñ'Ô'ð 	Ø ¤Ô ;Ð;Ð;Ý"Ð#W¨IÐ#WÐ#WÐ#WÑXÔXÐXØÐÝ�iÕ!2Ñ3Ô3ð 	ð
  ¤Ô 2Ð2Ð2Ý"Ð#Z¨yÐ#ZÐ#ZÐ#ZÑ[Ô[Ð[ØÐÝ�i¥Ñ%Ô%ð 	bðbØ”|Ô)Ô0°Ô;Ð;øÝð bð bð bÝ"Ð#V¸)Ð#VÐ#VÐ#VÑWÔWÐ]aÐaðbøøøåÐRÀYÐRÐRÐRÑSÔSÐSs   ÂB ÂB=c                ód   — | j                              |d ¦  «        }|| j         j        |j        <   d S r`   )rP   rn  rŒ   rR   rw  s     rf   r¯  z1_OuterCircuitScopeInterface.add_uninitialized_varl  s0   € ØŒl×+Ò+¨C°Ñ6Ô6ˆØ-0ˆŒÔ  ¤Ñ*Ð*Ð*rh   c                óN   — | j         j                             |j        ¦  «         d S r`   )rP   rŒ   rf  rR   rw  s     rf   rs  z&_OuterCircuitScopeInterface.remove_varp  s#   € ØŒÔ ×$Ò$ S¤XÑ.Ô.Ð.Ð.Ð.rh   c                óÌ   — | j         j                             |¦  «        x}�|S | j         j                             |¦  «        x}�|S | j         j                             |¦  «        S r`   )rP   rŒ   rˆ  r‹   rŠ   )r“   rR   rÅ   s      rf   rc  z#_OuterCircuitScopeInterface.get_vars  sa   € Ø”<Ô+×/Ò/°Ñ5Ô5Ð5ˆCÐBØˆJØ”<Ô-×1Ò1°$Ñ7Ô7Ð7ˆCÐDØˆJØŒ|Ô'×+Ò+¨DÑ1Ô1Ð1rh   c                óh   — |                       |j        ¦  «        |k    rt          d|› d�¦  «        ‚d S )Nr‡  z ' is not present in this circuit)rc  rR   r   rw  s     rf   ry  z#_OuterCircuitScopeInterface.use_varz  s=   € Ø�<Š<˜œÑ!Ô! SÒ(Ð(ÝÐH 3ÐHÐHÐHÑIÔIÐIð )Ð(rh   N)rP   rO   r×  )r©   r   )rn   rÙ  rÚ  Ú	__slots__r™   rÜ  rÇ   rã   r³  r'  r¯  rs  rc  ry  rQ   rh   rf   r|   r|   >  sÛ   € € € € € ð €Iðð ð ð ð ð"ð "ñ „Xð"ð =Bð Pð Pð Pð Pð Pð Pð!ð !ð !ð !ð
Tð Tð Tð01ð 1ð 1ð/ð /ð /ð2ð 2ð 2ðJð Jð Jð Jð Jrh   r|   r,  r#   rÙ  ú	expr.Exprr¬   c                ó¼   — t          t          j        |¦  «        ¦  «        D ]9}|j        r|                      |¦  «         Œ|                      |j        ¦  «         Œ:|S r`   )rÔ   r1   rà  rl  ry  r'  r—   )r,  rÙ  r—   s      rf   r=  r=    sd   € õ •4”> $Ñ'Ô'Ñ(Ô(ð >ð >ˆØŒ>ð 	>Ø×!Ò! #Ñ&Ô&Ð&Ð&à×4Ò4°S´WÑ=Ô=Ð=Ð=Ø€Krh   ú	list[Bit]c           	     óT  ‡‡‡— t          | ‰¦  «        r| ‰v r| gS t          d| › d�¦  «        ‚t          | t          t          j        f¦  «        r@	 ‰|          gS # t
          $ r)}t          d| › dt          ‰¦  «        › d�¦  «        |‚d}~ww xY wt          | t          ¦  «        r‰|          S 	 ˆˆˆfd„| D ¦   «         S # t          $ r`}t          | t          ¦  «        r d‰j
        › d	t          | ¦  «        j
        › d
�nd| › dt          | ¦  «        › d
�}t          |¦  «        |‚d}~ww xY w)aÉ  Get the list of bits referred to by the specifier ``specifier``.

    Valid types for ``specifier`` are integers, bits of the correct type (as given in ``type_``), or
    iterables of one of those two scalar types.  Integers are interpreted as indices into the
    sequence ``bit_sequence``.  All allowed bits must be in ``bit_set`` (which should implement
    fast lookup), which is assumed to contain the same bits as ``bit_sequence``.

    Returns:
        List[Bit]: a list of the specified bits from ``bits``.

    Raises:
        CircuitError: if an incorrect type or index is encountered, if the same bit is specified
            more than once, or if the specifier is to a bit not in the ``bit_set``.
    úBit 'ú' is not in the circuit.úIndex ú out of range for size r„  Nc                ó4   •— g | ]}t          |‰‰‰¦  «        ‘ŒS rQ   )Ú_bit_argument_conversion_scalar)rd   rI   Úbit_sequenceÚbit_setrþ  s     €€€rf   ro   z,_bit_argument_conversion.<locals>.<listcomp>¬  s7   ø€ ð 
ð 
ð 
àõ ,¨E°<ÀÈ%ÑPÔPð
ð 
ð 
rh   úIncorrect bit type: expected 'ú' but got 'r‡  úInvalid bit index: 'ú' of type ')ra   r   rk   rh  ri  rè  r»  rø  ru   r@   rn   rm   ©ré  rù  rú  rþ  rl  Úmessages    ```  rf   r  r  ‹  s«  øøø€ õ$ �)˜UÑ#Ô#ð HØ˜ÐÐØ�;ÐÝÐF 9ÐFÐFÐFÑGÔGÐGÝ�)�c¥2¤:Ð.Ñ/Ô/ð ð	Ø  Ô+Ð,Ð,øÝð 	ð 	ð 	ÝØO˜ÐOÐO½3¸|Ñ;LÔ;LÐOÐOÐOñô àðøøøøð	øøøõ
 �)�UÑ#Ô#ð 'Ø˜IÔ&Ð&ð,ð
ð 
ð 
ð 
ð 
ð 
à"ð
ñ 
ô 
ð 	
øõ ð ,ð ,ð ,õ ˜)¥SÑ)Ô)ðQÐc¨U¬^ÐcÐcÍÈYÉÌÔH`ÐcÐcÐcÐcàP¨	ÐPÐP½dÀ9¹o¼oÐPÐPÐPð 	õ
 ˜7Ñ#Ô#¨Ð+øøøøð,øøøs1   ÁA Á
BÁ#$BÂBÂ-B= Â=
D'ÃAD"Ä"D'c           	     óÈ  — t          | |¦  «        r| |v r| S t          d| › d�¦  «        ‚t          | t          t          j        f¦  «        r?	 ||          S # t
          $ r)}t          d| › dt          |¦  «        › d�¦  «        |‚d }~ww xY wt          | t          ¦  «        r d|j        › dt          | ¦  «        j        › d�nd	| › d
t          | ¦  «        › d�}t          |¦  «        ‚)Nró  rô  rõ  rö  r„  rû  rü  r‡  rý  rþ  )
ra   r   rk   rh  ri  rè  r»  r@   rn   rm   rÿ  s         rf   rø  rø  ¹  s%  € Ý�)˜UÑ#Ô#ð HØ˜ÐÐØÐÝÐF 9ÐFÐFÐFÑGÔGÐGÝ�)�c¥2¤:Ð.Ñ/Ô/ð ð	Ø 	Ô*Ð*øÝð 	ð 	ð 	ÝØO˜ÐOÐO½3¸|Ñ;LÔ;LÐOÐOÐOñô àðøøøøð	øøøõ �i¥Ñ%Ô%ð	MÐ_¨¬Ð_Ð_ÅDÈÁOÄOÔD\Ð_Ð_Ð_Ð_àL IÐLÐL½$¸y¹/¼/ÐLÐLÐLð õ
 �wÑ
Ô
Ðs   ÁA Á
BÁ$BÂBc                ób  — | j                              ¦   «         |_         | j                             ¦   «         |_        t          |¦  «        |_        | j                             ¦   «         |_        | j                             ¦   «         |_        | j                             ¦   «         |_        |dk    r[| j                             ¦   «         |_        | j	                             ¦   «         |_	        | j
                             ¦   «         |_
        ng|dk    r2i |_        i |_	        d„ |                      ¦   «         D ¦   «         |_
        n/|dk    ri |_        i |_	        i |_
        nt          d|› d�¦  «        ‚t          j        | j        ¦  «        |_        t          j        | j        ¦  «        |_        d S )Nr  rV   c                ó   — i | ]
}|j         |“ŒS rQ   r¯   )rd   r—   s     rf   r¶   z"_copy_metadata.<locals>.<dictcomp>à  s   € ÐKÐKÐK¨s˜SœX sÐKÐKÐKrh   Údropzunknown vars_mode: 'r‡  )r€   rá   r�   r|   r}   r…   r‚   rƒ   rŒ   rŠ   r‹   rà  rt   r  r  r‡   r  )Úoriginalr  r	  s      rf   r  r  Í  s|  € à”×#Ò#Ñ%Ô%€C„IØ”×#Ò#Ñ%Ô%€C„IÝ2°3Ñ7Ô7€CÔØÔ&×+Ò+Ñ-Ô-€C„MØ!Ô0×5Ò5Ñ7Ô7€CÔØ!Ô0×5Ò5Ñ7Ô7€CÔà�GÒÐð #Ô.×3Ò3Ñ5Ô5ˆŒØ"Ô.×3Ò3Ñ5Ô5ˆŒØ$Ô2×7Ò7Ñ9Ô9ˆÔÐØ	�jÒ	 Ð	 ØˆŒØˆŒØKÐK°h×6HÒ6HÑ6JÔ6JÐKÑKÔKˆÔÐØ	�fÒ	Ð	ØˆŒØˆŒØˆÔÐåÐ<°	Ð<Ð<Ð<Ñ=Ô=Ð=åœ xÔ'=Ñ>Ô>€CÔÝ”N 8Ô#5Ñ6Ô6€C„M€M€Mrh   )r,  r#   rÙ  rï  r¬   rï  )r¬   rñ  )ƒrÛ  Ú
__future__r   Úcollections.abcrq  rá   r  rÛ  Úmultiprocessingr3  rà  r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   Únumpyrh  Úqiskit._accelerate.circuitr   r   Ú#qiskit._accelerate.circuit_durationr   Úqiskit.exceptionsr   Úqiskit.utils.multiprocessingr   Úqiskit.circuit.instructionr   Úqiskit.circuit.gater   Úqiskit.circuit.parameterr   Úqiskit.circuit.exceptionsr   Úqiskit.utilsr   Úqiskit.utils.deprecate_pulser   r2  r    Úcontrolflowr!   r"   Úcontrolflow.builderr#   r$   Úcontrolflow.break_loopr%   r&   Úcontrolflow.continue_loopr'   r(   Úcontrolflow.for_loopr)   r*   Úcontrolflow.if_elser+   r,   Úcontrolflow.switch_caser-   r.   Úcontrolflow.while_loopr/   r0   Ú	classicalr1   r2   Úparameterexpressionr3   r4   Úquantumregisterr5   r6   r7   r8   Úclassicalregisterr9   r:   Úparametertabler;   Úparametervectorr<   Úinstructionsetr=   rú   r>   r7  r?   r´   r@   ÚquantumcircuitdatarA   rB   r€  rC   ru  rD   ÚTYPE_CHECKINGr@  Úqiskit.transpiler.layoutrE   Ú+qiskit.quantum_info.operators.base_operatorrF   Ú&qiskit.quantum_info.states.statevectorrG   rH   rK   rL   rk   rø  r
  r  rM   rO   r|   r=  r  rø  r  rQ   rh   rf   ú<module>r(     sq  ðð Ð à "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø Ð Ð Ð Ø Ð Ð Ð Ø Ð Ð Ð Ø €€€Ø <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð Ð Ð Ð Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø JÐ JÐ JÐ JÐ JÐ JØ )Ð )Ð )Ð )Ð )Ð )Ø 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø $Ð $Ð $Ð $Ð $Ð $Ø .Ð .Ð .Ð .Ð .Ð .Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø CÐ CÐ CÐ CÐ CÐ CØ %Ð %Ð %Ð %Ð %Ð %Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø OÐ OÐ OÐ OÐ OÐ OÐ OÐ OØ EÐ EÐ EÐ EÐ EÐ EÐ EÐ EØ NÐ NÐ NÐ NÐ NÐ NÐ NÐ NØ ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ø AÐ AÐ AÐ AÐ AÐ AÐ AÐ AØ "Ð "Ð "Ð "Ð "Ð "Ð "Ð "Ø HÐ HÐ HÐ HÐ HÐ HÐ HÐ HØ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RØ 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø )Ð )Ð )Ð )Ð )Ð )Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø *Ð *Ð *Ð *Ð *Ð *Ø  Ð  Ð  Ð  Ð  Ð  Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø FÐ FÐ FÐ FÐ FÐ FÐ FÐ FØ Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð ð 
Ôð CØ€M€M€MØ8Ð8Ð8Ð8Ð8Ð8ØHÐHÐHÐHÐHÐHØBÐBÐBÐBÐBÐBàˆz˜.Ð*@ÑAÔA€ð €GˆC�L„L€Ø€GˆC�L„L€ð Ø	ØØØ	ØˆU�5˜#�:ÔÔð	!ô€ð Ø	ØØØ	ØˆU�5˜#�:ÔÔð	!ô€ð ˆ'�)˜U EÑ
*Ô
*€ðAg'ð Ag'ð Ag'ð Ag'ð Ag'ñ Ag'ô Ag'ð Ag'ðHN>Jð >Jð >Jð >Jð >JÐ"7ñ >Jô >Jð >JðB	ð 	ð 	ð 	ð+,ð +,ð +,ð +,ð\ ð  ð  ð(7ð 7ð 7ð 7ð 7rh   