
    {	i	                     Z    S r SSKJrJr  SSKJr  SSKJr   " S S\5      rS r\\l        g	)
z;
Instruction to set the state simulator state to a matrix.
    )QuantumCircuitInstruction)Operator   )default_qubitsc                   0   ^  \ rS rSrSrSrU 4S jrSrU =r$ )
SetUnitary   z"Set unitary state of the simulatorTc                    > [        U[        5      (       d  [        U5      nUR                  (       a  UR                  5       (       d  [	        S5      e[
        TU ]  SUR                  SUR                  /5        g)aN  Create new instruction to set the unitary simulator state.

Args:
    state (Operator): A unitary matrix.

Raises:
    ValueError: if the input matrix is not state.

.. note::

    This set instruction must always be performed on the full width of
    qubits in a circuit, otherwise an exception will be raised during
    simulation.
zThe input matrix is not unitaryset_unitaryr   N)
isinstancer   
num_qubits
is_unitary
ValueErrorsuper__init__data)selfstate	__class__s     i/home/james-whalen/.local/lib/python3.13/site-packages/qiskit_aer/library/set_instructions/set_unitary.pyr   SetUnitary.__init__   s]     %**UOEu'7'7'9'9>??(8(8!ejj\J     )	__name__
__module____qualname____firstlineno____doc__
_directiver   __static_attributes____classcell__)r   s   @r   r	   r	      s    ,JK Kr   r	   c                 .   [        U 5      n[        U[        5      (       d  [        U5      nUR                  (       a  UR                  [	        U5      :w  a&  [        SUR                   SU R                   S35      eU R                  [        U5      U5      $ )aa  Set the state of the simulator.

Args:
    state (Operator): A state matrix.

Returns:
    QuantumCircuit: with attached instruction.

Raises:
    ValueError: If the state is the incorrect size for the current circuit.
    ValueError: if the input matrix is not unitary.

.. note:

    This instruction is always defined across all qubits in a circuit.
zThe size of the unitary matrix for the set_unitary instruction must be equal to the number of qubits in the circuit (state.num_qubits (z ) != QuantumCircuit.num_qubits (z)).)r   r   r   r   lenr   appendr	   )r   r   qubitss      r   r   r   0   s    " D!FeX&&u//3v;>2272B2B1C D..2oo->cC
 	
 ;;z%(&11r   N)	r   qiskit.circuitr   r   qiskit.quantum_infor   r   r	   r   r   r   r   <module>r)      s2    7 ( +K K62< ) r   