§
    ¹³Ùge  ã                  ó    — d Z ddlmZ ddl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 ej        rddlmZ dZ G d„ de¦  «        ZdS )z8
Initialize qubit registers to desired arbitrary state.
é    )Úannotations)ÚSequenceN)ÚQuantumCircuit)ÚQuantumRegister)ÚInstruction)ÚIsometryé   )ÚStatePreparation)ÚStatevectorg»½×Ùß|Û=c                  óv   ‡ — e Zd ZdZ	 	 ddˆ fd„Zd„ Zdd„Zed„ ¦   «         Zej	        dd„¦   «         Zd„ Z
ˆ xZS )Ú
Initializea…  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>`__.

    NFÚparamsú+Statevector | Sequence[complex] | str | intÚ
num_qubitsú
int | NoneÚ	normalizeÚboolÚreturnÚNonec                ó¦   •— t          |||¬¦  «        | _        t          ¦   «                              d| j        j        d| j        j        ¦  «         dS )a÷  
        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.
        )r   Ú
initializer   N)r
   Ú
_stateprepÚsuperÚ__init__r   r   )Úselfr   r   r   Ú	__class__s       €úi/granary/edev/quantum/lib/python3.11/site-packages/qiskit/circuit/library/data_preparation/initializer.pyr   zInitialize.__init__2   sI   ø€ õ2 +¨6°:ÈÐSÑSÔSˆŒå‰Œ×Ò˜ t¤Ô'AÀ1ÀdÄoÔF\Ñ]Ô]Ð]Ð]Ð]ó    c                óÀ   — t          | j        d¦  «        }t          |d¬¦  «        }|                     |¦  «         |                     | j        |¦  «         || _        d S )NÚqÚinit_def)Úname)r   r   r   ÚresetÚappendr   Ú
definition)r   r    Úinitialize_circuits      r   Ú_definezInitialize._defineO   s]   € Ý˜DœO¨SÑ1Ô1ˆÝ+¨A°JÐ?Ñ?Ô?ÐØ× Ò  Ñ#Ô#Ð#Ø×!Ò! $¤/°1Ñ5Ô5Ð5Ø,ˆŒˆˆr   r   c                óV   — t          | j        dd¦  «        }|                     ¦   «         S )zÆCall 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_uncomputezInitialize.gates_to_uncomputeV   s)   € õ ˜œ Q¨Ñ*Ô*ˆØ×'Ò'Ñ)Ô)Ð)r   c                ó   — | j         j        S )zReturn initialize params.©r   r   )r   s    r   r   zInitialize.params`   s   € ð ŒÔ%Ð%r   Ú
parametersc                ó   — || j         _        dS )zSet initialize params.Nr-   )r   r.   s     r   r   zInitialize.paramse   s   € ð ",ˆŒÔÐÐr   c                ó8   — | j                              ||¦  «        S )N)r   Úbroadcast_arguments)r   ÚqargsÚcargss      r   r1   zInitialize.broadcast_argumentsj   s   € ØŒ×2Ò2°5¸%Ñ@Ô@Ð@r   )NF)r   r   r   r   r   r   r   r   )r   r   )r.   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r'   r+   Úpropertyr   Úsetterr1   Ú__classcell__)r   s   @r   r   r   !   sÑ   ø€ € € € € ðð ð& "&Øð	^ð ^ð ^ð ^ð ^ð ^ð ^ð:-ð -ð -ð*ð *ð *ð *ð ð&ð &ñ „Xð&ð „]ð,ð ,ð ,ñ „]ð,ðAð Að Að Að Að Að Ar   r   )r7   Ú
__future__r   Úcollections.abcr   ÚtypingÚqiskit.circuit.quantumcircuitr   Úqiskit.circuit.quantumregisterr   Úqiskit.circuit.instructionr   Ú(qiskit.circuit.library.generalized_gatesr   Ústate_preparationr
   ÚTYPE_CHECKINGÚ&qiskit.quantum_info.states.statevectorr   Ú_EPSr   © r   r   ú<module>rG      s  ððð ð #Ð "Ð "Ð "Ð "Ð "Ø $Ð $Ð $Ð $Ð $Ð $Ø €€€à 8Ð 8Ð 8Ð 8Ð 8Ð 8Ø :Ð :Ð :Ð :Ð :Ð :Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø =Ð =Ð =Ð =Ð =Ð =Ø /Ð /Ð /Ð /Ð /Ð /à	Ôð CØBÐBÐBÐBÐBÐBà€ðJAð JAð JAð JAð JA�ñ JAô JAð JAð JAð JAr   