
    {	iw                         S r SSKJr  SSKJrJr  SSKJr   " S S\5      r " S	 S
\5      rSS jr	 SS jr
SS jr\	\l	        \
\l
        g)zN
Simulator instruction to save statevector amplitudes and amplitudes squared.
    )QuantumCircuit   )SaveSingleDataSaveAverageData   )default_qubitsc                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )SaveAmplitudes   z$Save complex statevector amplitudes.c           	      @   > [        X!5      n[        TU ]	  SUUUUUS9  g)a  Instruction to save complex statevector amplitudes.

Args:
    num_qubits (int): the number of qubits for the snapshot type.
    params (list): list of entries to vale.
    label (str): the key for retrieving saved data from results.
    pershot (bool): if True save a list of amplitudes vectors for each
                    shot of the simulation rather than the a single
                    amplitude vector [Default: False].
    conditional (bool): if True save the amplitudes vector conditional
                        on the current classical register values
                        [Default: False].

Raises:
    ValueError: if params is invalid for the specified number of qubits.
save_amplitudes)pershotconditionalparamsN_format_amplitude_paramssuper__init__)self
num_qubitsr   labelr   r   	__class__s         n/home/james-whalen/.local/lib/python3.13/site-packages/qiskit_aer/library/save_instructions/save_amplitudes.pyr   SaveAmplitudes.__init__   s3    " *&=# 	 	
     
amplitudesFF__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classcell__r   s   @r   r
   r
      s    .
 
r   r
   c                   8   ^  \ rS rSrSr    SU 4S jjrSrU =r$ )SaveAmplitudesSquared4   z4Save squared statevector amplitudes (probabilities).c           
      B   > [        X!5      n[        TU ]	  SUUUUUUS9  g)aT  Instruction to save squared statevector amplitudes (probabilities).

Args:
    num_qubits (int): the number of qubits for the snapshot type.
    params (list): list of entries to vale.
    label (str): the key for retrieving saved data from results.
    unnormalized (bool): If True return save the unnormalized accumulated
                         probabilities over all shots [Default: False].
    pershot (bool): if True save a list of probability vectors for each
                    shot of the simulation rather than the a single
                    amplitude vector [Default: False].
    conditional (bool): if True save the probability vector conditional
                        on the current classical register values
                        [Default: False].

Raises:
    ValueError: if params is invalid for the specified number of qubits.
save_amplitudes_sq)unnormalizedr   r   r   Nr   )r   r   r   r   r-   r   r   r   s          r   r   SaveAmplitudesSquared.__init__7   s6    6 *&= %# 	 	
r   r   amplitudes_squaredFFFr   r'   s   @r   r)   r)   4   s    > #$
 $
r   r)   c                 b    [        U 5      n[        [        U5      XX4S9nU R                  Xe5      $ )a  Save complex statevector amplitudes.

Args:
    params (List[int] or List[str]): the basis states to return amplitudes for.
    label (str): the key for retrieving saved data from results.
    pershot (bool): if True save a list of amplitudes vectors for each
                    shot of the simulation rather than the a single
                    amplitude vector [Default: False].
    conditional (bool): if True save the amplitudes vector conditional
                        on the current classical register values
                        [Default: False].

Returns:
    QuantumCircuit: with attached instruction.

Raises:
    ValueError: if params is invalid for the specified number of qubits.
)r   r   r   )r   r
   lenappend)r   r   r   r   r   qubitsinstrs          r   r   r   ^   s4    & D!FFV'E ;;u%%r   c           	      h    [        U 5      n[        [        U5      UUUUUS9nU R                  Xv5      $ )a`  Save squared statevector amplitudes (probabilities).

Args:
    params (List[int] or List[str]): the basis states to return amplitudes for.
    label (str): the key for retrieving saved data from results.
    unnormalized (bool): If True return save the unnormalized accumulated
                         probabilities over all shots [Default: False].
    pershot (bool): if True save a list of probability vectors for each
                    shot of the simulation rather than the a single
                    amplitude vector [Default: False].
    conditional (bool): if True save the probability vector conditional
                        on the current classical register values
                        [Default: False].

Returns:
    QuantumCircuit: with attached instruction.

Raises:
    ValueError: if params is invalid for the specified number of qubits.
)r   r-   r   r   )r   r)   r2   r3   )r   r   r   r-   r   r   r4   r5   s           r   save_amplitudes_squaredr7   x   s?    . D!F!F!E ;;u%%r   Nc                 4   [        U S   [        5      (       aQ  U S   R                  S5      S:X  a  U  Vs/ s H  n[        US5      PM     n nOU  Vs/ s H  n[        US5      PM     n nU(       a  [	        U 5      SU-  :  a  [        S5      eU $ s  snf s  snf )z+Format amplitude params as a interger list.r   0x   r   z=Param values contain a state larger than the number of qubits)
isinstancestrfindintmax
ValueError)r   r   is      r   r   r      s    &)S!!!9>>$1$*01&Qc!Rj&F1F)/0Ac!QiF0c&kQ
]2XYYM 20s   BBr   r/   )N)r$   qiskit.circuitr   	save_datar   r   r   r
   r)   r   r7   r   r   r   r   <module>rD      sW    * 6 +
^ 
>'
O '
T&6 ^c &F	 "1 )@ &r   