+
    åûj\4  ã            	       ód  € R t ^ RIHt ^ RIHt ^ RIHtHt ^ RIH	t	 ^ RI
Ht ^ RIHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHtHtHtHtHtHtHtHt ^ RIHt ^ RIH t  ^RI!H"t" ^RI#H$t$ ^RI%H&t& R t' ! R R]4      t(R t)R t*R t+R t,]],]]*3t-]! ]! R ]! ]-!  4      4      t.R t/R t0R t1R t2R t3R# )z'Implementation of the Kronecker product)Úreduce)Úprod)ÚMulÚsympify)Úadjoint)Ú
ShapeError)Ú
MatrixExpr)Ú	transpose)ÚIdentity)Ú
MatrixBase)ÚcanonÚ	conditionÚ
distributeÚdo_oneÚexhaustÚflattenÚtypedÚunpack)Ú	bottom_up)Úsift)ÚMatAdd)ÚMatMul)ÚMatPowc                 óˆ   € V '       g   \        R4      h\        V 4      ^8X  d
   V ^ ,          # \        V !  P                  4       # )a   
The Kronecker product of two or more arguments.

This computes the explicit Kronecker product for subclasses of
``MatrixBase`` i.e. explicit matrices. Otherwise, a symbolic
``KroneckerProduct`` object is returned.


Examples
========

For ``MatrixSymbol`` arguments a ``KroneckerProduct`` object is returned.
Elements of this matrix can be obtained by indexing, or for MatrixSymbols
with known dimension the explicit matrix can be obtained with
``.as_explicit()``

>>> from sympy import kronecker_product, MatrixSymbol
>>> A = MatrixSymbol('A', 2, 2)
>>> B = MatrixSymbol('B', 2, 2)
>>> kronecker_product(A)
A
>>> kronecker_product(A, B)
KroneckerProduct(A, B)
>>> kronecker_product(A, B)[0, 1]
A[0, 0]*B[0, 1]
>>> kronecker_product(A, B).as_explicit()
Matrix([
    [A[0, 0]*B[0, 0], A[0, 0]*B[0, 1], A[0, 1]*B[0, 0], A[0, 1]*B[0, 1]],
    [A[0, 0]*B[1, 0], A[0, 0]*B[1, 1], A[0, 1]*B[1, 0], A[0, 1]*B[1, 1]],
    [A[1, 0]*B[0, 0], A[1, 0]*B[0, 1], A[1, 1]*B[0, 0], A[1, 1]*B[0, 1]],
    [A[1, 0]*B[1, 0], A[1, 0]*B[1, 1], A[1, 1]*B[1, 0], A[1, 1]*B[1, 1]]])

For explicit matrices the Kronecker product is returned as a Matrix

>>> from sympy import Matrix, kronecker_product
>>> sigma_x = Matrix([
... [0, 1],
... [1, 0]])
...
>>> Isigma_y = Matrix([
... [0, 1],
... [-1, 0]])
...
>>> kronecker_product(sigma_x, Isigma_y)
Matrix([
[ 0, 0,  0, 1],
[ 0, 0, -1, 0],
[ 0, 1,  0, 0],
[-1, 0,  0, 0]])

See Also
========
    KroneckerProduct

z$Empty Kronecker product is undefined)Ú	TypeErrorÚlenÚKroneckerProductÚdoit)Úmatricess   *Ú`C:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\sympy\matrices\expressions\kronecker.pyÚkronecker_productr       s>   € ÷p ÜÐ>Ó?Ð?Ü
ˆ8ƒ}˜ÔØ˜�{Ðä Ñ*×/Ñ/Ó1Ð1ó    c                   ó    a a€ ] tR t^Vt oRtRtRR/V 3R llt]R 4       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VtV ;t# )r   aZ  
The Kronecker product of two or more arguments.

The Kronecker product is a non-commutative product of matrices.
Given two matrices of dimension (m, n) and (s, t) it produces a matrix
of dimension (m s, n t).

This is a symbolic object that simply stores its argument without
evaluating it. To actually compute the product, use the function
``kronecker_product()`` or call the ``.doit()`` or  ``.as_explicit()``
methods.

>>> from sympy import KroneckerProduct, MatrixSymbol
>>> A = MatrixSymbol('A', 5, 5)
>>> B = MatrixSymbol('B', 5, 5)
>>> isinstance(KroneckerProduct(A, B), KroneckerProduct)
True
TÚcheckc               ó¾  <€ \        \        \        V4      4      p\        ;QJ d    R  V 4       F  '       d   K   RM	  RM! R  V 4       4      '       dh   \	        \        R V 4       4      4      p\        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       d   VP                  4       # V# V'       d
   \        V!   \        SV `$  ! V .VO5!  # )c              3   ó8   "  € T F  qP                   x € K  	  R # 5i©N)Úis_Identity©Ú.0Úas   & r   Ú	<genexpr>Ú+KroneckerProduct.__new__.<locals>.<genexpr>m   s   é € Ð+¡d �}Ž}£dùó   ‚FTc              3   ó8   "  € T F  qP                   x € K  	  R # 5ir&   )Úrowsr(   s   & r   r+   r,   n   s   é € Ð5±¨1§¦³ùr-   c              3   óB   "  € T F  p\        V\        4      x € K  	  R # 5ir&   ©Ú
isinstancer   r(   s   & r   r+   r,   o   s   é € Ð;±d°”:˜a¤×,Ð,³dùó   ‚)
ÚlistÚmapr   Úallr
   r   Úas_explicitÚvalidateÚsuperÚ__new__)Úclsr#   ÚargsÚretÚ	__class__s   &$* €r   r:   ÚKroneckerProduct.__new__k   s›   ø€ Ü”Cœ Ó&Ó'ˆß‹3Ñ+¡dÓ+�3�3Š3Ñ+¡dÓ+×+Ò+Üœ4Ñ5±Ó5Ó5Ó6ˆCß‹sÑ;±dÓ;�s�sŠsÑ;±dÓ;×;Ò;Ø—‘Ó(Ð(à�
çÜ�dŠOÜ‰wŠ˜sÐ* TÓ*Ð*r!   c                óÂ   € V P                   ^ ,          P                  w  rV P                   R,           F'  pWP                  ,          pW#P                  ,          pK)  	  W3# )é    :é   NN)r<   Úshaper/   Úcols)Úselfr/   rD   Úmats   &   r   rC   ÚKroneckerProduct.shapex   sM   € à—Y‘Y˜q•\×'Ñ'‰
ˆØ—9‘9˜R—=�=ˆCØ—H‘HÕˆDØ—H‘HÕŠDñ !ð ˆ|Ðr!   c                ó¾   € ^p\        V P                  4       FA  p\        WP                  4      w  r\        W%P                  4      w  r'WEWg3,          ,          pKC  	  V# ©rB   )Úreversedr<   Údivmodr/   rD   )rE   ÚiÚjÚkwargsÚresultrF   ÚmÚns   &&&,    r   Ú_entryÚKroneckerProduct._entry€   sO   € ØˆÜ˜DŸI™IÖ&ˆCÜ˜!ŸX™XÓ&‰DˆAÜ˜!ŸX™XÓ&‰DˆAØ˜!˜$•iÕŠFñ 'ð ˆr!   c                ór   € \        \        \        \        V P                  4      4      !  P                  4       # r&   )r   r4   r5   r   r<   r   ©rE   s   &r   Ú_eval_adjointÚKroneckerProduct._eval_adjointˆ   s&   € Ü¤¤c¬'°4·9±9Ó&=Ó!>Ñ?×DÑDÓFÐFr!   c                óˆ   € \        V P                   Uu. uF  qP                  4       NK  	  up!  P                  4       # u upi r&   )r   r<   Ú	conjugater   )rE   r*   s   & r   Ú_eval_conjugateÚ KroneckerProduct._eval_conjugate‹   s0   € Ü¸¿ºÓ!C¹°A§+¡+¦-¹Ñ!CÑD×IÑIÓKÐKùÒ!Cs   ”?c                ór   € \        \        \        \        V P                  4      4      !  P                  4       # r&   )r   r4   r5   r	   r<   r   rU   s   &r   Ú_eval_transposeÚ KroneckerProduct._eval_transposeŽ   s&   € Ü¤¤c¬)°T·Y±YÓ&?Ó!@ÑA×FÑFÓHÐHr!   c                óh   € ^RI H p \        V P                   Uu. uF
  q!! V4      NK  	  up!  # u upi )rB   )Útrace)r`   r   r<   )rE   r`   r*   s   &  r   Ú_eval_traceÚKroneckerProduct._eval_trace‘   s*   € Ý Ü t§y¢yÓ1¡y !�U˜1–X¡yÑ1Ñ2Ð2ùÒ1s   š/c                ó^  € ^RI HpHp \        ;QJ d&    R V P                   4       F  '       d   K   RM	  RM! R V P                   4       4      '       g	   V! V 4      # V P
                  p\        V P                   Uu. uF!  qA! V4      W4P
                  ,          ,          NK#  	  up!  # u upi )rB   )ÚdetÚDeterminantc              3   ó8   "  € T F  qP                   x € K  	  R # 5ir&   ©Ú	is_squarer(   s   & r   r+   Ú5KroneckerProduct._eval_determinant.<locals>.<genexpr>—   s   é € Ð2©	 1—;–;«	ùr-   FT)Údeterminantrd   re   r6   r<   r/   r   )rE   rd   re   rP   r*   s   &    r   Ú_eval_determinantÚ"KroneckerProduct._eval_determinant•   su   € ß1ß‹sÑ2¨¯	ª	Ó2�s�sŠsÑ2¨¯	ª	Ó2×2Ò2Ù˜tÓ$Ð$à�I‰IˆÜ°·²Ó;±¨A�S˜“V˜a§¡�h×'Ð'±Ñ;Ñ<Ð<ùÒ;s   Á>'B*c                ó¬   €  \        V P                   Uu. uF  qP                  4       NK  	  up!  # u upi   \         d    ^ RIHp T! T 4      u # i ; i)rA   )ÚInverse)r   r<   Úinverser   Ú"sympy.matrices.expressions.inversern   )rE   r*   rn   s   &  r   Ú_eval_inverseÚKroneckerProduct._eval_inverse�   sH   € ð	!Ü#¸4¿9º9Ó%E¹9°a§i¡i¦k¹9Ñ%EÑFÐFùÒ%EøÜô 	!ÝBÙ˜4“=Ò ð	!ús   ‚7 •2­7 ²7 ·AÁAc                óº  € \        V\        4      ;'       dÅ    V P                  VP                  8H  ;'       d¤    \        V P                  4      \        VP                  4      8H  ;'       dq    \
        ;QJ d:    R \        V P                  VP                  4       4       F  '       d   K   R# 	  R# ! R \        V P                  VP                  4       4       4      # )a  Determine whether two matrices have the same Kronecker product structure

Examples
========

>>> from sympy import KroneckerProduct, MatrixSymbol, symbols
>>> m, n = symbols(r'm, n', integer=True)
>>> A = MatrixSymbol('A', m, m)
>>> B = MatrixSymbol('B', n, n)
>>> C = MatrixSymbol('C', m, m)
>>> D = MatrixSymbol('D', n, n)
>>> KroneckerProduct(A, B).structurally_equal(KroneckerProduct(C, D))
True
>>> KroneckerProduct(A, B).structurally_equal(KroneckerProduct(D, C))
False
>>> KroneckerProduct(A, B).structurally_equal(C)
False
c              3   óX   "  € T F   w  rVP                   VP                   8H  x € K"  	  R # 5ir&   ©rC   ©r)   r*   Úbs   &  r   r+   Ú6KroneckerProduct.structurally_equal.<locals>.<genexpr>»   s!   é € ÐTÑ9S©v°˜Ÿ™ 1§7¡7Ö*Ó9Sùó   ‚(*FT)r2   r   rC   r   r<   r6   Úzip©rE   Úothers   &&r   Ústructurally_equalÚ#KroneckerProduct.structurally_equal¤   s³   € ô( ˜5Ô"2Ó3÷ Uð UØ—J‘J %§+¡+Ñ-÷Uð Uä˜Ÿ	™	“N¤c¨%¯*©*£oÑ5÷Uð U÷ “CÑT¼¸T¿Y¹YÈÏ
É
Ô9SÓT—C”Cð	Vò ð	Vð ÑT¼¸T¿Y¹YÈÏ
É
Ô9SÓTÓTð	Vr!   c                óº  € \        V\        4      ;'       dÅ    V P                  VP                  8H  ;'       d¤    \	        V P
                  4      \	        VP
                  4      8H  ;'       dq    \        ;QJ d:    R \        V P
                  VP
                  4       4       F  '       d   K   R# 	  R# ! R \        V P
                  VP
                  4       4       4      # )a  Determine whether two matrices have the appropriate structure to bring matrix
multiplication inside the KroneckerProdut

Examples
========
>>> from sympy import KroneckerProduct, MatrixSymbol, symbols
>>> m, n = symbols(r'm, n', integer=True)
>>> A = MatrixSymbol('A', m, n)
>>> B = MatrixSymbol('B', n, m)
>>> KroneckerProduct(A, B).has_matching_shape(KroneckerProduct(B, A))
True
>>> KroneckerProduct(A, B).has_matching_shape(KroneckerProduct(A, B))
False
>>> KroneckerProduct(A, B).has_matching_shape(A)
False
c              3   óX   "  € T F   w  rVP                   VP                  8H  x € K"  	  R # 5ir&   )rD   r/   rv   s   &  r   r+   Ú6KroneckerProduct.has_matching_shape.<locals>.<genexpr>Ñ   s!   é € ÐRÑ7Q©V¨a˜Ÿ™ !§&¡&Ö(Ó7Qùry   FT)r2   r   rD   r/   r   r<   r6   rz   r{   s   &&r   Úhas_matching_shapeÚ#KroneckerProduct.has_matching_shape½   s³   € ô" ˜5Ô"2Ó3÷ Sð SØ—I‘I §¡Ñ+÷Sð Sä˜Ÿ	™	“N¤c¨%¯*©*£oÑ5÷Sð S÷ “CÑR´s¸4¿9¹9ÀeÇjÁjÔ7QÓR—C”Cð	Tò ð	Tð ÑR´s¸4¿9¹9ÀeÇjÁjÔ7QÓRÓRð	Tr!   c                óx   € \        \        \        \        \	        \        \
        4      /4      4      ! V 4      4      # r&   )r   r   r   r   r   r   )rE   Úhintss   &,r   Ú_eval_expand_kroneckerproductÚ.KroneckerProduct._eval_expand_kroneckerproductÓ   s,   € Ü”uœUÔ$4´jÔAQÔSYÓ6ZÐ#[Ó\Ô]Ð^bÓcÓdÐdr!   c                óÜ   € V P                  V4      '       dI   V P                  ! \        V P                  VP                  4       UUu. uF  w  r#W#,           NK  	  upp!  # W,           # u uppi r&   )r}   r>   rz   r<   ©rE   r|   r*   rw   s   &&  r   Ú_kronecker_addÚKroneckerProduct._kronecker_addÖ   sV   € Ø×"Ñ" 5×)Ò)Ø—>’>¼¸D¿I¹IÀuÇzÁzÔ8RÔ#SÑ8R©f¨q A§E EÑ8RÒ#SÑTÐTà•<Ðùó $Tó   ÁA(
c                óÜ   € V P                  V4      '       dI   V P                  ! \        V P                  VP                  4       UUu. uF  w  r#W#,          NK  	  upp!  # W,          # u uppi r&   )r‚   r>   rz   r<   r‰   s   &&  r   Ú_kronecker_mulÚKroneckerProduct._kronecker_mulÜ   sV   € Ø×"Ñ" 5×)Ò)Ø—>’>´c¸$¿)¹)ÀUÇZÁZÔ6PÔ#QÑ6P©F¨Q A§C CÑ6PÒ#QÑRÐRà•<Ðùó $RrŒ   c                óÒ   € VP                  R R4      pV'       d,   V P                   Uu. uF  q3P                  ! R/ VB NK  	  ppMV P                  p\        \	        V!  4      # u upi )ÚdeepT© )Úgetr<   r   Úcanonicalizer   )rE   r…   r‘   Úargr<   s   &,   r   r   ÚKroneckerProduct.doitâ   sX   € Ø�y‰y˜ Ó&ˆßØ15·²Ó;±¨#—H’HÑ%˜uÔ%±ˆDÐ;ˆDà—9‘9ˆDÜÔ,¨dÑ3Ó4Ð4ùò <s   ©A$r’   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úis_KroneckerProductr:   ÚpropertyrC   rR   rV   rZ   r]   ra   rk   rq   r}   r‚   r†   rŠ   rŽ   r   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r>   Ú__classdict__s   @@r   r   r   V   s~   ù‡ € ñð$ Ðð+ $÷ +ð ñó ðòòGòLòIò3ò=ò!òVò2Tò,eò ò ÷5ò 5r!   r   c                  ó�   € \         ;QJ d    R  V  4       F  '       d   K   RM	  RM! R  V  4       4      '       g   \        R4      hR# )c              3   ó8   "  € T F  qP                   x € K  	  R # 5ir&   )Ú	is_Matrix)r)   r•   s   & r   r+   Úvalidate.<locals>.<genexpr>ì   s   é € Ð-© �}Ž}«ùr-   FTz Mix of Matrix and Scalar symbolsN)r6   r   )r<   s   *r   r8   r8   ë   s4   € ß‹3Ñ-©Ó-�3�3Š3Ñ-©Ó-×-Ò-ÜÐ:Ó;Ð;ñ .r!   c                 ó  € . p. pV P                    FK  pVP                  4       w  rEVP                  V4       VP                  \        P
                  ! V4      4       KM  	  \	        V!  pV^8w  d   V\        V!  ,          # V # rI   )r<   Úargs_cncÚextendÚappendr   Ú
_from_argsr   )ÚkronÚc_partÚnc_partr•   ÚcÚncs   &     r   Úextract_commutativer°   ò   sp   € Ø€FØ€GØ�yŒyˆØ—‘“‰ˆØ�‰�aÔØ�‰”s—~’~ bÓ)Ö*ñ ô
 �&‰\€FØ�„{ØÔ&¨Ñ0Õ0Ð0Ø€Kr!   c            	     óž  € \         ;QJ d    R V  4       F  '       d   K   RM	  RM! R V  4       4      '       g   \        R\        V 4      ,          4      hV R,          p\        V RR 4       F«  pVP                  pVP
                  p\        V4       F  pWWT,          ,          ,          p\        V^,
          4       F5  pVP                  WWT,          V,           ^,           ,          ,          4      pK7  	  V^ 8X  d   TpKn  XP                  V4      pK�  	  XpK­  	  \        V R R7      P                  p	\        W4      '       d   V# V	! V4      # )	a  Compute the Kronecker product of a sequence of SymPy Matrices.

This is the standard Kronecker product of matrices [1].

Parameters
==========

matrices : tuple of MatrixBase instances
    The matrices to take the Kronecker product of.

Returns
=======

matrix : MatrixBase
    The Kronecker product matrix.

Examples
========

>>> from sympy import Matrix
>>> from sympy.matrices.expressions.kronecker import (
... matrix_kronecker_product)

>>> m1 = Matrix([[1,2],[3,4]])
>>> m2 = Matrix([[1,0],[0,1]])
>>> matrix_kronecker_product(m1, m2)
Matrix([
[1, 0, 2, 0],
[0, 1, 0, 2],
[3, 0, 4, 0],
[0, 3, 0, 4]])
>>> matrix_kronecker_product(m2, m1)
Matrix([
[1, 2, 0, 0],
[3, 4, 0, 0],
[0, 0, 1, 2],
[0, 0, 3, 4]])

References
==========

.. [1] https://en.wikipedia.org/wiki/Kronecker_product
c              3   óB   "  € T F  p\        V\        4      x € K  	  R # 5ir&   r1   ©r)   rP   s   & r   r+   Ú+matrix_kronecker_product.<locals>.<genexpr>-  s   é € Ð;±(¨QŒz˜!œZ×(Ð(³(ùr3   FTz&Sequence of Matrices expected, got: %sNc                 ó   € V P                   # r&   )Ú_class_priority)ÚMs   &r   Ú<lambda>Ú*matrix_kronecker_product.<locals>.<lambda>I  s
   € ¨a×.?Ò.?r!   )Úkeyéÿÿÿÿ)r6   r   ÚreprrJ   r/   rD   ÚrangeÚrow_joinÚcol_joinÚmaxr>   r2   )
r   Úmatrix_expansionrF   r/   rD   rL   ÚstartrM   ÚnextÚMatrixClasss
   *         r   Úmatrix_kronecker_productrÅ      s  € ÷Z ‹3Ñ;±(Ó;�3�3Š3Ñ;±(Ó;×;Ò;ÜØ4´t¸H³~ÕEó
ð 	
ð
   •|Ðä˜  "˜Ö&ˆØ�x‰xˆØ�x‰xˆô �t–ˆAØ$¨­¥[Õ0ˆEä˜4 !�8–_�ØŸ™Ø$¨­°!­°a­Õ%8Õ8ó’ñ %ð �AŒvØ’à—}‘} UÓ+’ñ ð  Òñ% 'ô( �hÑ$?Ô@×JÑJ€KÜÐ"×0Ò0ØÐáÐ+Ó,Ð,r!   c                 óÈ   € \         ;QJ d&    R  V P                   4       F  '       d   K   RM	  RM! R  V P                   4       4      '       g   V # \        V P                  !  # )c              3   óB   "  € T F  p\        V\        4      x € K  	  R # 5ir&   r1   r³   s   & r   r+   Ú-explicit_kronecker_product.<locals>.<genexpr>R  s   é € Ð<±)¨QŒz˜!œZ×(Ð(³)ùr3   FT)r6   r<   rÅ   )r«   s   &r   Úexplicit_kronecker_productrÉ   P  s?   € ç‹3Ñ<°$·)²)Ó<�3�3Š3Ñ<°$·)²)Ó<×<Ò<Øˆä# T§Y¡YÑ/Ð/r!   c                 ó"   € \        V \        4      # r&   )r2   r   )Úxs   &r   r¸   r¸   ]  s   € ¬:°aÔ9IÔ+Jr!   c                 ó²   € \        V \        4      '       dA   \        ;QJ d    . R  V P                   4       F  NK  	  5# ! R  V P                   4       4      # R# )c              3   ó8   "  € T F  qP                   x € K  	  R # 5ir&   ru   r(   s   & r   r+   Ú&_kronecker_dims_key.<locals>.<genexpr>c  s   é € Ð0¡i —W–W£iùr-   ©rA   )r2   r   Útupler<   ©Úexprs   &r   Ú_kronecker_dims_keyrÓ   a  s?   € Ü�$Ô(×)Ò)ßŒuÑ0 d§i¢iÓ0�uÐ0ˆuÑ0 d§i¢iÓ0Ó0Ð0àˆr!   c                 ó  € \        V P                  \        4      pVP                  RR4      pV'       g   V # VP	                  4        Uu. uF  p\        R V4      NK  	  ppV'       g
   \        V!  # \        V!  V,           # u upi )rA   Nc                 ó$   € V P                  V4      # r&   )rŠ   )rË   Úys   &&r   r¸   Ú#kronecker_mat_add.<locals>.<lambda>n  s   €  ×!1Ñ!1°!Ô!4r!   rÏ   )r   r<   rÓ   ÚpopÚvaluesr   r   )rÒ   r<   ÚnonkronsÚgroupÚkronss   &    r   Úkronecker_mat_addrÝ   h  s~   € Ü�—	‘	Ô.Ó/€DØ�x‰x˜˜dÓ#€HßØˆð Ÿ+™+œ-ó)Ù'�ô Ñ4°eÖ<Ù'ð 
ð )÷ Ü�u‰~Ðä�u‰~ Õ(Ð(ùò)s   Á	Bc                 óZ  € V P                  4       w  r^ pV\        V4      ^,
          8  dr   W#V^,            w  rE\        V\        4      '       dD   \        V\        4      '       d.   VP	                  V4      W#&   VP                  V^,           4       K}  V^,          pKˆ  V\        V!  ,          # rÏ   )Úas_coeff_matricesr   r2   r   rŽ   rØ   r   )rÒ   Úfactorr   rL   ÚAÚBs   &     r   Úkronecker_mat_mulrã   w  sŽ   € à×-Ñ-Ó/Ñ€Fà	€AØ
Œc�(‹m˜aÕÔ
Ø˜!˜A�#ˆ‰ˆÜ�aÔ)×*Ò*¬z¸!Ô=M×/NÒ/NØ×*Ñ*¨1Ó-ˆH‰KØ�L‰L˜˜1�Öà��FŠAà”&˜(Ñ#Õ#Ð#r!   c           	      ó”  € \        V P                  \        4      '       d£   \        ;QJ d0    R  V P                  P                   4       F  '       d   K   RM%	  RM!! R  V P                  P                   4       4      '       dA   \        V P                  P                   Uu. uF  p\        WP                  4      NK  	  up!  # V # u upi )c              3   ó8   "  € T F  qP                   x € K  	  R # 5ir&   rg   r(   s   & r   r+   Ú$kronecker_mat_pow.<locals>.<genexpr>ˆ  s   é € Ð6[ÉNÀq·{¶{ËNùr-   FT)r2   Úbaser   r6   r<   r   Úexp)rÒ   r*   s   & r   Úkronecker_mat_powré   ‡  sz   € Ü�$—)‘)Ô-×.Ò.·3³3Ñ6[ÈDÏIÉIÏNÊNÓ6[·3·3²3Ñ6[ÈDÏIÉIÏNÊNÓ6[×3[Ò3[Ü¸t¿y¹y¿~º~Ó!N¹~¸!¤&¨¯H©HÖ"5¹~Ñ!NÑOÐOàˆùò "Os   Â Cc                óè   € R p\        \        \        \        V\        \        \
        \        \        \        \        /4      4      4      4      4      pV! V 4      p\        VRR4      pVe   V! 4       # V# )aå  Combine KronekeckerProduct with expression.

If possible write operations on KroneckerProducts of compatible shapes
as a single KroneckerProduct.

Examples
========

>>> from sympy.matrices.expressions import combine_kronecker
>>> from sympy import MatrixSymbol, KroneckerProduct, symbols
>>> m, n = symbols(r'm, n', integer=True)
>>> A = MatrixSymbol('A', m, n)
>>> B = MatrixSymbol('B', n, m)
>>> combine_kronecker(KroneckerProduct(A, B)*KroneckerProduct(B, A))
KroneckerProduct(A*B, B*A)
>>> combine_kronecker(KroneckerProduct(A, B)+KroneckerProduct(B.T, A.T))
KroneckerProduct(A + B.T, B + A.T)
>>> C = MatrixSymbol('C', n, n)
>>> D = MatrixSymbol('D', m, m)
>>> combine_kronecker(KroneckerProduct(C, D)**m)
KroneckerProduct(C**m, D**m)
c                 ó\   € \        V \        4      ;'       d    V P                  \        4      # r&   )r2   r   Úhasr   rÑ   s   &r   ÚhaskronÚ"combine_kronecker.<locals>.haskron¥  s!   € Ü˜$¤
Ó+×JÐJ°·±Ô9IÓ0JÐJr!   r   N)r   r   r   r   r   rÝ   r   rã   r   ré   Úgetattr)rÒ   rí   ÚrulerO   r   s   &    r   Úcombine_kroneckerrñ   Ž  su   € ò.Kô Ü”'œ) G¬UÜÔ&ÜÔ&ÜÔ&ð(ó.)ó *ó +ó 	,ó-€Dñ
 �$‹Z€FÜ�6˜6 4Ó(€DØÒÙ‹vˆàˆr!   N)4r›   Ú	functoolsr   Úmathr   Ú
sympy.corer   r   Úsympy.functionsr   Úsympy.matrices.exceptionsr   Ú"sympy.matrices.expressions.matexprr   Ú$sympy.matrices.expressions.transposer	   Ú"sympy.matrices.expressions.specialr
   Úsympy.matrices.matrixbaser   Úsympy.strategiesr   r   r   r   r   r   r   r   Úsympy.strategies.traverser   Úsympy.utilitiesr   Úmataddr   Úmatmulr   Úmatpowr   r    r   r8   r°   rÅ   rÉ   Úrulesr”   rÓ   rÝ   rã   ré   rñ   r’   r!   r   Ú<module>r     sº   ðÙ -Ý Ý ç #Ý #Ý 0Ý 9Ý :Ý 7Ý 0÷K÷ Kó Kå /Ý  å Ý Ý ò=2ô@R5�zô R5òj<òòM-ò`0ð 
Ø	#Ø	Ø	ð	€ñ
 ‘yÑ!JÙ!'¨¡ó1ó 2€òò)ò$ò ô$r!   