+
    
þÎj   ã                   ó¤  € R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
Ht ^ RIHt . R'Ot]! R	4      t]'       g    ! R
 R4      tM]P"                  t]! RRR./R7      t]'       g    ! R R4      tRtM]P(                  t]P*                  tR tR tR tR tR tR tR tR tR tR tR t R t!R t"R t#R t$R  t%R! t&R" t'R# t(R$ t)R% t*R& t+R# )(z<Utilities to deal with sympy.Matrix, numpy and scipy.sparse.)ÚExpr)ÚI)ÚS©Ú
MatrixBase)ÚeyeÚzeros)Úimport_moduleÚnumpy_ndarrayÚscipy_sparse_matrixÚnumpyc                   ó   € ] tR t^tRtR# )r
   © N©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    ÚW/opt/data/home/.local/lib/python3.14/site-packages/sympy/physics/quantum/matrixutils.pyr
   r
      ó   † Ûr   ÚscipyÚfromlistÚsparse)Úimport_kwargsc                   ó   € ] tR t^&tRtR# )r   r   Nr   r   r   r   r   r   &   r   r   Nc                ó„  € \         '       g   \        hVP                  RR4      p\        V \        4      '       d&   \         P                  V P                  4       VR7      # \        V \        4      '       d;   V P                  '       g   V P                  '       g   V \        8X  d   \        V 4      # \        RV ,          4      h©zBConvert a SymPy Matrix/complex number to a numpy matrix or scalar.ÚdtypeÚcomplex©r   z.Expected MatrixBase or complex scalar, got: %r)ÚnpÚImportErrorÚgetÚ
isinstancer   ÚarrayÚtolistr   Ú	is_NumberÚis_NumberSymbolr   r    Ú	TypeError©ÚmÚoptionsr   s   &, r   Úsympy_to_numpyr.   .   s…   € ç‹2ÜÐØ�K‰K˜ Ó+€EÜ�!”Z× Ò Ü�x‰x˜Ÿ™›
¨%ˆxÓ0Ð0Ü	�A”t×	Ò	Ø�;�;ˆ;˜!×+×+Ð+¨q´A¬vÜ˜1“:ÐÜ
ÐDÀqÕHÓ
IÐIr   c                óÂ  € \         '       d   \        '       g   \        hVP                  RR4      p\	        V \
        4      '       d9   \        P                  \         P                  V P                  4       VR7      4      # \	        V \        4      '       d;   V P                  '       g   V P                  '       g   V \        8X  d   \        V 4      # \        RV ,          4      hr   )r"   r   r#   r$   r%   r   Ú
csr_matrixr&   r'   r   r(   r)   r   r    r*   r+   s   &, r   Úsympy_to_scipy_sparser1   ;   s”   € ç‹2—V“VÜÐØ�K‰K˜ Ó+€EÜ�!”Z× Ò Ü× Ñ ¤§¡¨!¯(©(«*¸E Ó!BÓCÐCÜ	�A”t×	Ò	Ø�;�;ˆ;˜!×+×+Ð+¨q´A¬vÜ˜1“:ÐÜ
ÐDÀqÕHÓ
IÐIr   c                ó4   € \        V P                  4       4      # )z0Convert a scipy.sparse matrix to a SymPy matrix.)r   Útodense©r,   r-   s   &,r   Úscipy_sparse_to_sympyr5   H   s   € ä�a—i‘i“kÓ"Ð"r   c                ó   € \        V 4      # )z)Convert a numpy matrix to a SymPy matrix.r   r4   s   &,r   Únumpy_to_sympyr7   M   s   € ä�a‹=Ðr   c                ó
  € \        V \        4      '       d   V # \        V \        4      '       d   \        V 4      # \        V \        4      '       d   \        V 4      # \        V \        4      '       d   V # \        RV ,          4      h)z6Convert a numpy/scipy.sparse matrix to a SymPy matrix.ú1Expected sympy/numpy/scipy.sparse matrix, got: %r)r%   r   r
   r7   r   r5   r   r*   r4   s   &,r   Úto_sympyr:   R   sh   € ä�!”Z× Ò ØˆÜ	�A”}×	%Ò	%Ü˜aÓ Ð Ü	�AÔ*×	+Ò	+Ü$ QÓ'Ð'Ü	�A”t×	Ò	ØˆÜ
ÐGÈ!ÕKÓ
LÐLr   c                ó  € VP                  RR4      p\        V \        \        34      '       d   \	        WR7      # \        V \
        4      '       d   V # \        V \        4      '       d   V P                  4       # \        RV ,          4      h)z6Convert a sympy/scipy.sparse matrix to a numpy matrix.r   r    r!   r9   )	r$   r%   r   r   r.   r
   r   r3   r*   r+   s   &, r   Úto_numpyr<   _   sl   € à�K‰K˜ Ó+€EÜ�!”j¤$Ð'×(Ò(Ü˜aÔ-Ð-Ü	�A”}×	%Ò	%ØˆÜ	�AÔ*×	+Ò	+Ø�y‰y‹{ÐÜ
ÐGÈ!ÕKÓ
LÐLr   c                óD  € VP                  RR4      p\        V \        \        34      '       d   \	        WR7      # \        V \
        4      '       d(   \        '       g   \        h\        P                  V 4      # \        V \        4      '       d   V # \        RV ,          4      h)z6Convert a sympy/numpy matrix to a scipy.sparse matrix.r   r    r!   r9   )r$   r%   r   r   r1   r
   r   r#   r0   r   r*   r+   s   &, r   Úto_scipy_sparser>   k   s|   € à�K‰K˜ Ó+€EÜ�!”j¤$Ð'×(Ò(Ü$ QÔ4Ð4Ü	�A”}×	%Ò	%ß‹vÜÐÜ× Ñ  Ó#Ð#Ü	�AÔ*×	+Ò	+ØˆÜ
ÐGÈ!ÕKÓ
LÐLr   c                óä   € \        V \        4      '       d   V P                  R8X  d
   V ^ ,          p \        V \        \        34      '       d$   V P                  R8X  d   \        V R,          4      p V # )zCFlatten a 1x1 matrix to a scalar, return larger matrices unchanged.)é   r@   )é    rA   )r%   r   Úshaper
   r   r    ©Úes   &r   Úflatten_scalarrE   y   sV   € ä�!”Z× Ò Ø�7‰7�fÔØ�!•ˆAÜ�!”mÔ%8Ð9×:Ò:Ø�7‰7�fÔÜ˜˜$�Ó ˆAØ€Hr   c                óÞ   € \        V \        4      '       d   V P                  # \        V \        \        34      '       d   V P                  4       P                  4       # \        RV ,          4      h)z7Return the dagger of a sympy/numpy/scipy.sparse matrix.r9   )r%   r   ÚHr
   r   Ú	conjugateÚ	transposer*   rC   s   &r   Úmatrix_daggerrJ   „   sQ   € ä�!”Z× Ò Ø�s‰sˆ
Ü	�AœÔ':Ð;×	<Ò	<Ø�{‰{‹}×&Ñ&Ó(Ð(Ü
ÐGÈ!ÕKÓ
LÐLr   c                 ó   € ^ RI Hp V! V !  # )zCCompute the kronecker product of a sequence of SymPy Matrices.
    )Úmatrix_kronecker_product)Ú$sympy.matrices.expressions.kroneckerrL   )ÚmatricesrL   s   * r   Ú_sympy_tensor_productrO   Ž   s   € õ Ná# XÑ.Ð.r   c                 ó†   € \         '       g   \        hV ^ ,          pV R,           F  p\         P                  W4      pK  	  V# )z6numpy version of tensor product of multiple arguments.ºr@   NN)r"   r#   Úkron©ÚproductÚanswerÚitems   *  r   Ú_numpy_tensor_productrW   –   s9   € ç‹2ÜÐØ�Q�Z€FØ˜—�ˆÜ—‘˜Ó&Šñ à€Mr   c                 ó¬   € \         '       g   \        hV ^ ,          pV R,           F  p\         P                  W4      pK  	  \         P                  V4      # )z=scipy.sparse version of tensor product of multiple arguments.rQ   )r   r#   rR   r0   rS   s   *  r   Ú_scipy_sparse_tensor_productrY       sG   € ç‹6ÜÐØ�Q�Z€FØ˜—�ˆÜ—‘˜VÓ*Šñ ô ×Ñ˜VÓ$Ð$r   c                 óê   € \        V ^ ,          \        4      '       d
   \        V !  # \        V ^ ,          \        4      '       d
   \	        V !  # \        V ^ ,          \
        4      '       d
   \        V !  # R# )zGCompute the matrix tensor product of sympy/numpy/scipy.sparse matrices.N)r%   r   rO   r
   rW   r   rY   )rT   s   *r   Úmatrix_tensor_productr[   ¬   s\   € ä�'˜!•*œj×)Ò)Ü$ gÑ.Ð.Ü	�G˜A•J¤×	.Ò	.Ü$ gÑ.Ð.Ü	�G˜A•JÔ 3×	4Ò	4Ü+¨WÑ5Ð5ñ 
5r   c                óz   € \         '       g   \        h\         P                  \         P                  V RR7      4      # )znumpy version of complex eye.r    r!   )r"   r#   r&   r   ©Úns   &r   Ú
_numpy_eyer_   ¶   s)   € ç‹2ÜÐÜ�8‰8”B—F‘F˜1 I�FÓ.Ó/Ð/r   c                óT   € \         '       g   \        h\         P                  W RR7      # )z$scipy.sparse version of complex eye.r    r!   )r   r#   r   r]   s   &r   Ú_scipy_sparse_eyera   ½   s    € ç‹6ÜÐÜ�:‰:�a )ˆ:Ó,Ð,r   c                ó¶   € VP                  RR4      pVR8X  d   \        V 4      # VR8X  d   \        V 4      # VR8X  d   \        V 4      # \	        RV,          4      h)z=Get the version of eye and tensor_product for a given format.ÚformatÚsympyr   úscipy.sparsezInvalid format: %r)r$   r   r_   ra   ÚNotImplementedError)r^   r-   rc   s   &, r   Ú
matrix_eyerg   Ä   sY   € à�[‰[˜ 7Ó+€FØ�ÔÜ�1‹vˆØ	�7Ô	Ü˜!‹}ÐØ	�>Ô	!Ü  Ó#Ð#Ü
Ð2°VÕ;Ó
<Ð<r   c                óz   € VP                  RR4      p\        '       g   \        h\        P                  W3VR7      # )znumpy version of zeros.r   Úfloat64r!   )r$   r"   r#   r   )r,   r^   r-   r   s   &&, r   Ú_numpy_zerosrj   Ð   s2   € à�K‰K˜ Ó+€Eß‹2ÜÐÜ�8‰8�Q�F %ˆ8Ó(Ð(r   c                óî   € VP                  RR4      pVP                  RR4      p\        '       g   \        hVR8X  d   \        P                  W3VR7      # VR8X  d   \        P	                  W3VR7      # R# )zscipy.sparse version of zeros.ÚspmatrixÚcsrr   ri   Úlilr!   N)r$   r   r#   Ú
lil_matrixr0   )r,   r^   r-   rl   r   s   &&,  r   Ú_scipy_sparse_zerosrp   Ø   sr   € à�{‰{˜: uÓ-€HØ�K‰K˜ Ó+€Eß‹6ÜÐØ�5ÔÜ× Ñ  ! ¨uÐ Ó5Ð5Ø	�UÔ	Ü× Ñ  ! ¨uÐ Ó5Ð5ñ 
r   c                óº   € VP                  RR4      pVR8X  d   \        W4      # VR8X  d   \        W3/ VB # VR8X  d   \        W3/ VB # \	        RV,          4      h)z'"Get a zeros matrix for a given format.rc   rd   r   re   zInvaild format: %r)r$   r   rj   rp   rf   )r,   r^   r-   rc   s   &&, r   Úmatrix_zerosrr   ä   se   € à�[‰[˜ 7Ó+€FØ�ÔÜ�Q‹{ÐØ	�7Ô	Ü˜AÑ, GÑ,Ð,Ø	�>Ô	!Ü" 1Ñ3¨7Ñ3Ð3Ü
Ð2°VÕ;Ó
<Ð<r   c                óŽ   € \         '       g   \        h\         P                  V 4      p\         P                  W4      '       d   R# V # )z/Convert a numpy zero matrix to the zero scalar.ç        )r"   r#   Ú
zeros_likeÚallclose)rD   Útests   & r   Ú_numpy_matrix_to_zerorx   ð   s2   € ç‹2ÜÐÜ�=‰=˜Ó€DÜ	‡{�{�1×ÒÙàˆr   c                ó®   € \         '       g   \        hV P                  4       p\         P                  V4      p\         P	                  W4      '       d   R# V # )z6Convert a scipy.sparse zero matrix to the zero scalar.rt   )r"   r#   r3   ru   rv   )rD   Úedenserw   s   &  r   Ú_scipy_sparse_matrix_to_zeror{   û   s=   € ç‹2ÜÐØ�Y‰Y‹[€FÜ�=‰=˜Ó €DÜ	‡{�{�6× Ò Ùàˆr   c                ó  € \        V \        4      '       d+   \        V P                  !  V 8X  d   \        P
                  p V # \        V \        4      '       d   \        V 4      p V # \        V \        4      '       d   \        V 4      p V # )z)Convert a zero matrix to the scalar zero.)
r%   r   r   rB   r   ÚZeror
   rx   r   r{   rC   s   &r   Úmatrix_to_zeror~     sn   € ä�!”Z× Ò Ü�!—'‘'‰?˜aÔÜ—‘ˆAð
 €Hô	 
�A”}×	%Ò	%Ü! !Ó$ˆð €Hô 
�AÔ*×	+Ò	+Ü(¨Ó+ˆØ€Hr   )r
   r   r.   r1   r7   r5   rE   rJ   r:   r<   r>   r[   rr   ),Ú__doc__Úsympy.core.exprr   Úsympy.core.numbersr   Úsympy.core.singletonr   Úsympy.matrices.matrixbaser   Úsympy.matricesr   r   Úsympy.externalr	   Ú__all__r"   r
   Úndarrayr   r   r   rl   r.   r1   r5   r7   r:   r<   r>   rE   rJ   rO   rW   rY   r[   r_   ra   rg   rj   rp   rr   rx   r{   r~   r   r   r   Ú<module>rˆ      sñ   ðÙ Bå  Ý  Ý "Ý 0ß %Ý (ò€ñ& �7Ó€ß	÷ò ð —J‘J€Má�g¨j¸8¸*Ð-EÔF€ß÷ñ à�Fà�\‰\€FØ Ÿ/™/Ðò
Jò
Jò#ò
ò

Mò	MòMòòMò/òò	%ò6ò0ò-ò	=ò)ò	6ò	=òò	ô	r   