
    z	iE                        S r SSKJr  SSKJr  SSKrSSKJr  SSKJ	r	  SSK
Jr  SSKJr  S	S
KJr  \R                   (       a  SSKJr  Sr " S S\5      rg)z8
Initialize qubit registers to desired arbitrary state.
    )annotations)SequenceN)QuantumCircuit)QuantumRegister)Instruction)Isometry   )StatePreparation)Statevectorg|=c                     ^  \ rS rSrSr  S
       SU 4S jjjrS rSS jr\S 5       r	\	R                  SS j5       r	S rS	rU =r$ )
Initialize!   aM  Complex amplitude initialization.

Class that initializes some flexible collection of qubit registers, implemented by calling
the :class:`~.library.StatePreparation` class.
Note that ``Initialize`` is an :class:`~.circuit.Instruction` and not a :class:`.Gate` since it
contains a reset instruction, which is not unitary.

The initial state is prepared based on the :class:`~.library.Isometry` synthesis described in [1].

References:

[1] Iten et al., Quantum circuits for isometries (2016).
`Phys. Rev. A 93, 032318
<https://journals.aps.org/pra/abstract/10.1103/PhysRevA.93.032318>`__.

c                   > [        XUS9U l        [        TU ]  SU R                  R                  SU R                  R
                  5        g)aw  
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`.

    num_qubits: This parameter is only used if params is an int. Indicates the total
        number of qubits in the `initialize` call. Example: `initialize` covers 5 qubits
        and params is 3. This allows qubits 0 and 1 to be initialized to :math:`|1\rangle`
        and the remaining 3 qubits to be initialized to :math:`|0\rangle`.
    normalize: Whether to normalize an input array to a unit vector.
)	normalize
initializer   N)r
   
_stateprepsuper__init__
num_qubitsparams)selfr   r   r   	__class__s       m/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/circuit/library/data_preparation/initializer.pyr   Initialize.__init__3   s:    2 +6St'A'A1dooF\F\]    c                    [        U R                  S5      n[        USS9nUR                  U5        UR	                  U R
                  U5        X l        g )Nqinit_def)name)r   r   r   resetappendr   
definition)r   r   initialize_circuits      r   _defineInitialize._defineP   sF    DOOS1+AJ?  #!!$//15,r   c                P    [        U R                  SS5      nUR                  5       $ )zCall to create a circuit with gates that take the desired vector to zero.

Returns:
    QuantumCircuit: circuit to take ``self.params`` vector to :math:`|{00\ldots0}\rangle`
r   )r   r   _gates_to_uncompute)r   isoms     r   gates_to_uncomputeInitialize.gates_to_uncomputeW   s%     Q*''))r   c                .    U R                   R                  $ )zReturn initialize params.r   r   )r   s    r   r   Initialize.paramsa   s     %%%r   c                $    XR                   l        g)zSet initialize params.Nr,   )r   
parameterss     r   r   r-   f   s     ",r   c                8    U R                   R                  X5      $ )N)r   broadcast_arguments)r   qargscargss      r   r1   Initialize.broadcast_argumentsk   s    225@@r   )r   r"   )NF)r   +Statevector | Sequence[complex] | str | intr   z
int | Noner   boolreturnNone)r7   r   )r/   r5   r7   r8   )__name__
__module____qualname____firstlineno____doc__r   r$   r)   propertyr   setterr1   __static_attributes____classcell__)r   s   @r   r   r   !   s    ( "&	^;^ ^ 	^
 
^ ^:-* & & ]], ,A Ar   r   )r=   
__future__r   collections.abcr   typingqiskit.circuit.quantumcircuitr   qiskit.circuitr   qiskit.circuit.instructionr   (qiskit.circuit.library.generalized_gatesr   state_preparationr
   TYPE_CHECKING&qiskit.quantum_info.states.statevectorr   _EPSr    r   r   <module>rN      sE    # $  8 * 2 = /	BKA KAr   