
    z	i                       S r SSKJr  SSKJrJr  SSKrSSKJ	s  J
s  Jr  SSKJr  0 S\R                  _S\R                  _S\R                   _S	\R"                  _S
\R$                  _S\R&                  _S\R(                  _S\R*                  _S\R,                  _S\R.                  _S\R0                  _S\R2                  _S\R4                  _S\R6                  _S\R8                  _S\R:                  _S\R<                  _\R<                  \R>                  \R@                  \RB                  \RD                  S.Er#SS S jjr$\RJ                  " 5       RM                  5       \RJ                  " 5       RM                  5       \RN                  " 5       RM                  5       \RP                  " 5       RM                  5       \RR                  " 5       RM                  5       \RT                  " 5       RM                  5       \RV                  " 5       RM                  5       \RX                  " 5       RM                  5       \RZ                  " 5       RM                  5       \R\                  " 5       RM                  5       \R^                  " 5       RM                  5       \R`                  " 5       RM                  5       S.r1\Rd                  \Rf                  \Rh                  \Rj                  \Rl                  \Rn                  \Rp                  \Rr                  \Rt                  \Rv                  \Rx                  \Rz                  \R|                  S.r?\R                  " 5       RM                  5       \R                  " 5       RM                  5       \R                  " 5       RM                  5       \R                  " 5       RM                  5       S.rDS!S jrES!S jrF      S"S jrGg)#z;Contains functions used by the basic provider simulators.

    )annotations)ascii_uppercaseascii_lowercaseN)QiskitErrorUuu1u2u3hpssdgsxsxdgttdgxyzid)irrxryrzc                v    Uc  / nU [         ;   a
  [         U    nO[        SU  35      eU" U6 R                  5       $ )a(  Get the matrix for a single qubit.

Args:
    gate: the single qubit gate name
    params: the operation parameters op['params']
Returns:
    array: A numpy array representing the matrix
Raises:
    QiskitError: If a gate outside the supported set is passed in for the
        ``Gate`` argument.
z3Gate is not a valid basis gate for this simulator: )SINGLE_QUBIT_GATESr   	to_matrix)gateparamsgcs      n/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/providers/basic_provider/basic_provider_tools.pysingle_gate_matrixr$   4   sH     ~!!%OPTvVWWv;  ""    )CXcxecrcyczswapiswapchcscsdgcsxdcx)cpcrxcrycrzcucu1cu3rxxryyrzzrzxxx_minus_yy
xx_plus_yy)ccxcczrccxcswapc                P    [        X5      u  p#pE[        SU nU U SU U SU U 3$ )aO  Return the index string for Numpy.einsum matrix-matrix multiplication.

The returned indices are to perform a matrix multiplication A.B where
the matrix A is an M-qubit matrix, matrix B is an N-qubit matrix, and
M <= N, and identity matrices are implied on the subsystems where A has no
support on B.

Args:
    gate_indices (list[int]): the indices of the right matrix subsystems
                               to contract with the left matrix.
    number_of_qubits (int): the total number of qubits for the right matrix.

Returns:
    str: An indices string for the Numpy.einsum function.
N, ->)_einsum_matmul_index_helperr   )gate_indicesnumber_of_qubitsmat_lmat_rtens_lin	tens_louttens_rs          r#   einsum_matmul_indexrN   u   sI    " )DL(c%E( ../F WUG2hZxr)VHEEr%   c                6    [        X5      u  p#pEU U SU SU 3$ )aN  Return the index string for Numpy.einsum matrix-vector multiplication.

The returned indices are to perform a matrix multiplication A.v where
the matrix A is an M-qubit matrix, vector v is an N-qubit vector, and
M <= N, and identity matrices are implied on the subsystems where A has no
support on v.

Args:
    gate_indices (list[int]): the indices of the right matrix subsystems
                              to contract with the left matrix.
    number_of_qubits (int): the total number of qubits for the right matrix.

Returns:
    str: An indices string for the Numpy.einsum function.
rD   rE   )rF   )rG   rH   rI   rJ   rK   rL   s         r#   einsum_vecmul_indexrP      s1    " )DL(c%E( WUG2hZr)55r%   c                &   [        U 5      U-   S:  a  [        S5      e[        SU n[        U5      nSnSn[	        [        U 5      5       H0  u  pgU[        SU-
     -  nXRSU-
     -  n[        SU-
     USU-
  '   M2     SR                  U5      nXEX#4$ )a  Return the index string for Numpy.einsum matrix multiplication.

The returned indices are to perform a matrix multiplication A.v where
the matrix A is an M-qubit matrix, matrix v is an N-qubit vector, and
M <= N, and identity matrices are implied on the subsystems where A has no
support on v.

Args:
    gate_indices (list[int]): the indices of the right matrix subsystems
                               to contract with the left matrix.
    number_of_qubits (int): the total number of qubits for the right matrix.

Returns:
    tuple: (mat_left, mat_right, tens_in, tens_out) of index strings for
    that may be combined into a Numpy.einsum function string.

Raises:
    QiskitError: if the total number of qubits plus the number of
    contracted indices is greater than 26.
   z*Total number of free indexes limited to 26N )lenr   r   list	enumeratereversedjoin)rG   rH   tens_intens_outmat_left	mat_rightposidxs           r#   rF   rF      s    8 <++b0FGG //0G G}H HI h|45OBH--R#X&&	,R#X6c 6 wwx H 11r%   )N)r    strr!   zlist[float] | Nonereturnz
np.ndarray)rG   	list[int]rH   intra   r`   )rG   rb   rH   rc   ra   ztuple[str, str, str, str])H__doc__
__future__r   stringr   r   numpynp%qiskit.circuit.library.standard_gatescircuitlibrarystandard_gatesgatesqiskit.exceptionsr   UGateU1GateU2GateU3GateHGate	PhaseGateSGateSdgGateSXGateSXdgGateTGateTdgGateXGateYGateZGateIGateRGateRXGateRYGateRZGater   r$   CXGater   ECRGateCYGateCZGateSwapGate	iSwapGateCHGateCSGateCSdgGateCSXGateDCXGateTWO_QUBIT_GATES
CPhaseGateCRXGateCRYGateCRZGateCUGateCU1GateCU3GateRXXGateRYYGateRZZGateRZXGateXXMinusYYGateXXPlusYYGateTWO_QUBIT_GATES_WITH_PARAMETERSCCXGateCCZGateRCCXGate	CSwapGateTHREE_QUBIT_GATESrN   rP   rF    r%   r#   <module>r      s,   # 3  5 5 ) 	%,, 	%,,	
 	%,,    
5== 	%,, ENN  
5==    !" 	%++#$ 
	
,,
,,
,,- 4#0 ,,.
"
"
$
,,.
"
"
$==?$$&
,,.
"
"
$
,,.
"
"
$NN&&(__((*
,,.
"
"
$
,,.
"
"
$NN&&(==?$$&==?$$&" 

======
,,============&&$$# & ==?$$&==?$$&NN&&(__((*	 F6602222/22222r%   