+
    åûjr  ã                   óv   € ^ RI Ht ^ RIHt ^ RIHt ^RIHt ^RIH	t	H
t
Ht  ! R R]4      t ! R R	]4      tR
# )é    )ÚS)Ú_sympify)ÚKroneckerDelta)Ú
MatrixExpr)Ú
ZeroMatrixÚIdentityÚ	OneMatrixc                   ó‚   a a€ ] tR t^	t oRtV 3R lt]R 4       t]R 4       tR t	R t
R tR t];ttR	 tR
 tRtVtV ;t# )ÚPermutationMatrixa)  A Permutation Matrix

Parameters
==========

perm : Permutation
    The permutation the matrix uses.

    The size of the permutation determines the matrix size.

    See the documentation of
    :class:`sympy.combinatorics.permutations.Permutation` for
    the further information of how to create a permutation object.

Examples
========

>>> from sympy import Matrix, PermutationMatrix
>>> from sympy.combinatorics import Permutation

Creating a permutation matrix:

>>> p = Permutation(1, 2, 0)
>>> P = PermutationMatrix(p)
>>> P = P.as_explicit()
>>> P
Matrix([
[0, 1, 0],
[0, 0, 1],
[1, 0, 0]])

Permuting a matrix row and column:

>>> M = Matrix([0, 1, 2])
>>> Matrix(P*M)
Matrix([
[1],
[2],
[0]])

>>> Matrix(M.T*P)
Matrix([[2, 0, 1]])

See Also
========

sympy.combinatorics.permutations.Permutation
c                óš   <€ ^ RI Hp \        V4      p\        W4      '       g   \	        RP                  V4      4      h\        SV `  W4      # )r   ©ÚPermutationz({} must be a SymPy Permutation instance.)Ú sympy.combinatorics.permutationsr   r   Ú
isinstanceÚ
ValueErrorÚformatÚsuperÚ__new__)ÚclsÚpermr   Ú	__class__s   && €ÚbC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\sympy\matrices\expressions\permutation.pyr   ÚPermutationMatrix.__new__;   sH   ø€ Ý@ä˜‹~ˆÜ˜$×,Ò,ÜØ:×AÑAÀ$ÓGóIð Iô ‰w‰˜sÓ)Ð)ó    c                óB   € V P                   ^ ,          P                  pW3# ©r   )ÚargsÚsize)Úselfr   s   & r   ÚshapeÚPermutationMatrix.shapeE   s   € à�y‰y˜�|× Ñ ˆØˆ|Ðr   c                ó<   € V P                   ^ ,          P                  # r   )r   Úis_Identity©r   s   &r   r#   ÚPermutationMatrix.is_IdentityJ   s   € à�y‰y˜�|×'Ñ'Ð'r   c                óT   € V P                   '       d   \        V P                  4      # V # )N)r#   r   Úrows)r   Úhintss   &,r   ÚdoitÚPermutationMatrix.doitN   s"   € Ø××ÐÜ˜DŸI™IÓ&Ð&Øˆr   c                ó^   € V P                   ^ ,          p\        VP                  V4      V4      # r   )r   r   Úapply)r   ÚiÚjÚkwargsr   s   &&&, r   Ú_entryÚPermutationMatrix._entryS   s$   € Ø�y‰y˜�|ˆÜ˜dŸj™j¨›m¨QÓ/Ð/r   c                ód   € \        V P                  ^ ,          V,          4      P                  4       # r   )r   r   r)   )r   Úexps   &&r   Ú_eval_powerÚPermutationMatrix._eval_powerW   s#   € Ü  §¡¨1¥°Õ!4Ó5×:Ñ:Ó<Ð<r   c                óH   € \        V P                  ^ ,          R,          4      # ©r   éÿÿÿÿ)r   r   r$   s   &r   Ú_eval_inverseÚPermutationMatrix._eval_inverseZ   s   € Ü  §¡¨1¥°Õ!3Ó4Ð4r   c                ó¬   € V P                   ^ ,          P                  4       pV^8X  d   \        P                  # VR8X  d   \        P                  # \
        hr7   )r   Ú	signaturer   ÚOneÚNegativeOneÚNotImplementedError)r   Úsigns   & r   Ú_eval_determinantÚ#PermutationMatrix._eval_determinant_   s?   € Ø�y‰y˜�|×%Ñ%Ó'ˆØ�1Œ9Ü—5‘5ˆLØ�RŒZÜ—=‘=Ð Ü!Ð!r   c                óî  € ^ RI Hp ^RIHp V P                  ^ ,          pVP
                  p. p^ ^ ^ r©pRpV EF.  p\        V4      p\        V4      pV'       g<   V^,           W�,           8”  d   RpV.pTp	Tp
KA  VP                  V.4       W�,          pK]  Wé8”  dh   V^,           WŠ,           V,           8X  d0   XP                  V4       VP                  V4       RpV^,           pK­  Tp	XP                  V4       W­,          p
KÊ  V	^,           WŠ,           V,           8X  d1   XP                  V4       VP                  V4       RpV	^,           pEK  XP                  V4       W­,          p
EK1  	  ^ p. pV Fx  p. p^ pV F>  pV Uu. uF  pVV,
          NK  	  ppVP                  V4       V\        V4      ,          pK@  	  VV,          pV! V4      p\        V4      pVP                  V4       Kz  	  V! V!  # u upi )r   r   )ÚBlockDiagMatrixFT)
r   r   ÚblockmatrixrD   r   Úfull_cyclic_formÚlenÚmaxÚappendr   )r   r   r/   r   rD   r   rF   Úcycles_picksÚaÚbÚcÚflagÚcycleÚlÚmÚtempÚpÚpickÚ
new_cyclesr-   Ú	new_cycleÚmats   &*,                   r   Ú _eval_rewrite_as_BlockDiagMatrixÚ2PermutationMatrix._eval_rewrite_as_BlockDiagMatrixg   sÕ  € Ý@Ý0à�y‰y˜�|ˆØ×0Ñ0Ðàˆð �Q˜ˆaˆØˆÜ%ˆEÜ�E“
ˆAÜ�E“
ˆAçØ�q•5˜1�5”=Ø�DØ!˜7�DØ�AØ’Aà ×'Ñ'¨¨Ô0Ø•F’Að ”5Ø˜1•u ¥¨¥	Ô)ØŸ™ EÔ*Ø$×+Ñ+¨DÔ1Ø$˜Ø˜a�Cšà˜ØŸ™ EÔ*Ø�šà˜1•u ¥¨¥	Ô)ØŸ™ EÔ*Ø$×+Ñ+¨DÔ1Ø$˜Ø˜a�C›àŸ™ EÔ*Ø�›ñC &ðH ˆØˆÛ ˆDØˆJØˆAÛ�Ù,1Ó2©E q˜Q ŸU˜U©E�	Ð2Ø×!Ñ! )Ô,Ø”S˜“Z•’ñ ð ��FˆAÙ˜zÓ*ˆDÜ# DÓ)ˆCØ�K‰K˜Öñ !ñ  Ñ%Ð%ùò 3s   Æ G2© )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Úpropertyr    r#   r)   r0   r4   r9   Ú_eval_transposeÚ_eval_adjointrA   rX   Ú__static_attributes__Ú__classdictcell__Ú__classcell__©r   Ú__classdict__s   @@r   r   r   	   sg   ù‡ € ñ/õb*ð ñó ðð ñ(ó ð(òò
0ò=ò5ð '4Ð3€O�mò"÷>&ò >&r   r   c                   óv   a a€ ] tR t^¨t oRt]P                  3V 3R lltRR lt]	R 4       t
R tR tRtVtV ;t# )	ÚMatrixPermuteaæ  Symbolic representation for permuting matrix rows or columns.

Parameters
==========

perm : Permutation, PermutationMatrix
    The permutation to use for permuting the matrix.
    The permutation can be resized to the suitable one,

axis : 0 or 1
    The axis to permute alongside.
    If `0`, it will permute the matrix rows.
    If `1`, it will permute the matrix columns.

Notes
=====

This follows the same notation used in
:meth:`sympy.matrices.matrixbase.MatrixBase.permute`.

Examples
========

>>> from sympy import Matrix, MatrixPermute
>>> from sympy.combinatorics import Permutation

Permuting the matrix rows:

>>> p = Permutation(1, 2, 0)
>>> A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
>>> B = MatrixPermute(A, p, axis=0)
>>> B.as_explicit()
Matrix([
[4, 5, 6],
[7, 8, 9],
[1, 2, 3]])

Permuting the matrix columns:

>>> B = MatrixPermute(A, p, axis=1)
>>> B.as_explicit()
Matrix([
[2, 3, 1],
[5, 6, 4],
[8, 9, 7]])

See Also
========

sympy.matrices.matrixbase.MatrixBase.permute
c                óT  <€ ^ RI Hp \        V4      pVP                  '       g   \	        RP                  V4      4      h\        V4      p\        V\        4      '       d   VP                  ^ ,          p\        W$4      '       g   \	        RP                  V4      4      h\        V4      pVR9  d   \	        R4      hVP                  V,          pWRP                  8w  d    VP                  V4      p\        SV `5  WW#4      #   \         d    \	        RP                  Y!T4      4      hi ; i)r   r   z#{} must be a SymPy matrix instance.z>{} must be a SymPy Permutation or a PermutationMatrix instancezThe axis must be 0 or 1.zsSize does not match between the permutation {} and the matrix {} threaded over the axis {} and cannot be converted.)r   é   )r   r   r   Ú	is_Matrixr   r   r   r   r   r    r   Úresizer   r   )r   rW   r   Úaxisr   Úmat_sizer   s   &&&&  €r   r   ÚMatrixPermute.__new__Ü   s  ø€ Ý@ä�s‹mˆØ�}�}ˆ}ÜØ5×<Ñ<¸TÓBóDð Dô ˜‹~ˆÜ�dÔ-×.Ò.Ø—9‘9˜Q•<ˆDä˜$×,Ò,Üðß!™6 $›<ó)ð )ô ˜‹~ˆØ�vÔÜÐ7Ó8Ð8à—9‘9˜T•?ˆØ—y‘yÔ ð.Ø—{‘{ 8Ó,�ô ‰w‰˜s¨Ó4Ð4øô ô .Ü ð/÷ ‘V˜D tÓ,ó	.ð .ð.ús   ÃD  Ä 'D'c                ó\  € V P                   w  r4pV'       d)   VP                  ! RR V/VB pVP                  ! RR V/VB pVP                  '       d   V# VP                  '       dF   V\        P                  J d   \        V4      # V\        P                  J d   \        VR,          4      # \        V\        \        34      '       d   V# \        V\        4      '       dN   VP                   ^,          V8X  d6   \        VP                   ^ ,          WCP                   ^,          ,          V4      # V # )ÚdeeprZ   r8   )r   r)   r#   r   ÚZeror   r=   r   r   r	   ri   )r   rr   r(   rW   r   rn   s   &&,   r   r)   ÚMatrixPermute.doitþ   sâ   € ØŸ)™)‰ˆ�4çØ—(’(Ñ. Ð.¨Ñ.ˆCØ—9’9Ñ0 $Ð0¨%Ñ0ˆDà××ÐØˆJà�?�?ˆ?Ø”q—v‘v‹~Ü(¨Ó.Ð.ØœŸ™“Ü(¨¨r­Ó2Ð2ä�cœJ¬	Ð2×3Ò3ØˆJä�cœ=×)Ò)¨c¯h©h°q­k¸TÔ.AÜ  §¡¨!¥¨d·X±X¸aµ[Õ.@À$ÓGÐGàˆr   c                ó<   € V P                   ^ ,          P                  # r   )r   r    r$   s   &r   r    ÚMatrixPermute.shape  s   € à�y‰y˜�|×!Ñ!Ð!r   c                ó¤   € V P                   w  rEpV^ 8X  d   WEP                  V4      V3,          # V^8X  d   WAVP                  V4      3,          # R# )r   N)r   r,   )r   r-   r.   r/   rW   r   rn   s   &&&,   r   r0   ÚMatrixPermute._entry  sN   € ØŸ)™)‰ˆ�4à�1Œ9Ø—z‘z !“} aÐ'Õ(Ð(Ø�QŒYØ˜$Ÿ*™* Q›-Ð'Õ(Ð(ñ r   c                óø   € ^RI Hp V P                  w  rEpVP                  RR4      pV'       d   VP	                  V4      pV^ 8X  d   V! \        V4      V4      # V^8X  d   V! V\        VR,          4      4      # R# )rk   )ÚMatMulrr   TNr8   )Úmatmulrz   r   ÚgetÚrewriter   )r   r   r/   rz   rW   r   rn   rr   s   &*,     r   Ú_eval_rewrite_as_MatMulÚ%MatrixPermute._eval_rewrite_as_MatMul"  sp   € Ý"àŸ)™)‰ˆ�4à�z‰z˜& $Ó'ˆçØ—+‘+˜fÓ%ˆCà�1Œ9ÙÔ+¨DÓ1°3Ó7Ð7Ø�QŒYÙ˜#Ô0°°rµÓ:Ó;Ð;ñ r   rZ   )T)r[   r\   r]   r^   r_   r   rs   r   r)   r`   r    r0   r~   rc   rd   re   rf   s   @@r   ri   ri   ¨   sB   ù‡ € ñ2ðf &'§V¡V÷  5ôDð0 ñ"ó ð"ò)÷<ò <r   ri   N)Ú
sympy.corer   Úsympy.core.sympifyr   Úsympy.functionsr   Úmatexprr   Úspecialr   r   r	   r   ri   rZ   r   r   Ú<module>r…      s4   ðÝ Ý 'Ý *å ß 4Ñ 4ô\&˜
ô \&ô~G<�Jö G<r   