+
    /åûjâB  ã                   ó–   € R t ^ RIHt ^RIHt ^RIHtHt ^ RIH	t	 ^ RI
HtHt R tR tR tR	 tR
 tR tR tR tR tRRRR/R ltR# )z,Functions returning normal forms of matrices)Údefaultdict)ÚDomainMatrix)ÚDMDomainErrorÚDMShapeError)Úsymmetric_residue)ÚQQÚZZc                ór   € \        V 4      p\        P                  ! WP                  V P                  4      pV# )a  
Return the Smith Normal Form of a matrix `m` over the ring `domain`.
This will only work if the ring is a principal ideal domain.

Examples
========

>>> from sympy import ZZ
>>> from sympy.polys.matrices import DomainMatrix
>>> from sympy.polys.matrices.normalforms import smith_normal_form
>>> m = DomainMatrix([[ZZ(12), ZZ(6), ZZ(4)],
...                   [ZZ(3), ZZ(9), ZZ(6)],
...                   [ZZ(2), ZZ(16), ZZ(14)]], (3, 3), ZZ)
>>> print(smith_normal_form(m).to_Matrix())
Matrix([[1, 0, 0], [0, 10, 0], [0, 0, 30]])

)Úinvariant_factorsr   ÚdiagÚdomainÚshape)ÚmÚinvsÚsmfs   &  Ú\C:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\sympy\polys\matrices\normalforms.pyÚsmith_normal_formr      s-   € ô$ ˜QÓ€DÜ
×
Ò
˜D§(¡(¨A¯G©GÓ
4€CØ€Jó    c                óv  € V P                   pV P                  pVP                  pV P                  4       p \	        V^ ,          4       F<  p\	        V^,          4       F#  pWE8X  d   K  W,          V,          V8X  d   K!    R# 	  K>  	  \        V^ ,          V^,          4      p\	        ^V4       Fˆ  pW^,
          ,          V^,
          ,          V8X  d   W,          V,          V8w  d    R# K>  VP                  W,          V,          W^,
          ,          V^,
          ,          4      ^,          pWs8w  g   K‡   R# 	  R# )z0
Checks that the matrix is in Smith Normal Form
FT)r   r   ÚzeroÚto_listÚrangeÚminÚdiv)r   r   r   r   ÚiÚjÚupperÚrs   &       r   Úis_smith_normal_formr   (   sï   € ð �X‰X€FØ�G‰G€EØ�;‰;€DØ	�	‰	‹€Aä�5˜•8Ž_ˆÜ�u˜Q•x–ˆAØŒvÙØ•4˜•7˜d–?Ûó	 !ñ ô ��a•˜% �(Ó#€EÜ�1�eŽ_ˆØˆq�S�6�!�A•#�;˜$ÔØ�t�A�w˜$ŒÚñ ð —
‘
˜1�4 �7 A¨¥c¥F¨1¨Q­3¥KÓ0°Õ3ˆAØŽyÚñ ñ r   c                 ó
  € \        \        V 4      4       Fj  pW,          V,          pW8,          W@V,          V,          ,          ,           W,          V&   WX,          W`V,          V,          ,          ,           W,          V&   Kl  	  R # ©N©r   Úlen©	r   r   r   ÚaÚbÚcÚdÚkÚes	   &&&&&&&  r   Úadd_columnsr*   E   sW   € ô ”3�q“6Ž]ˆØ�D��GˆØ•#˜˜A�$˜q�'�	•/ˆ�ˆQ‰Ø•#˜˜A�$˜q�'�	•/ˆ�ˆQ‹ó r   c                ón   € V P                   pV P                  pV P                  4       p \        WVRR7      # )a  
Return the tuple of abelian invariants for a matrix `m`
(as in the Smith-Normal form)

References
==========

[1] https://en.wikipedia.org/wiki/Smith_normal_form#Algorithm
[2] https://web.archive.org/web/20200331143852/https://sierra.nmsu.edu/morandi/notes/SmithNormalForm.pdf

F©r   Úfull)r   r   r   Ú_smith_normal_decomp)r   r   r   s   &  r   r
   r
   N   s0   € ð �X‰X€FØ�G‰G€EØ	�	‰	‹€AÜ °¸UÔCÐCr   c                ó  € V P                   pV P                  ;w  r#pV P                  4       p \        WVRR7      w  rVp\        P
                  ! WQV4      P                  4       p\	        WaW"3R7      p\	        WqW33R7      pW†V3# )aµ  
Return the Smith-Normal form decomposition of matrix `m`.

Examples
========

>>> from sympy import ZZ
>>> from sympy.polys.matrices import DomainMatrix
>>> from sympy.polys.matrices.normalforms import smith_normal_decomp
>>> m = DomainMatrix([[ZZ(12), ZZ(6), ZZ(4)],
...                   [ZZ(3), ZZ(9), ZZ(6)],
...                   [ZZ(2), ZZ(16), ZZ(14)]], (3, 3), ZZ)
>>> a, s, t = smith_normal_decomp(m)
>>> assert a == s * m * t
Tr,   )r   r   )r   r   r   r.   r   r   Úto_dense)	r   r   ÚrowsÚcolsr   r   ÚsÚtr   s	   &        r   Úsmith_normal_decompr5   `   s{   € ð  �X‰X€FØŸ™Ð �J€D�Ø	�	‰	‹€Aä% a°uÀ4ÔH�J€DˆQÜ
×
Ò
˜D¨%Ó
0×
9Ñ
9Ó
;€Cä�Q¨d¨\Ô:€AÜ�Q¨d¨\Ô:€AØ�1ˆ9Ðr   c           
     ó€  a aaaa a!a"a#a$a%€ SP                   '       g   RS 2p\        V4      hVw  o"o SP                  o%SP                  o!V!V%3R lp^ V9   d   S'       d   RV! S"4      V! S 4      3# R# S'       d   V! S"4      o#V! S 4      o$R oVVVV V"V#V%3R lpV VVV V$V%3R lp\	        S"4       Uu. uF  pS V,          ^ ,          S%8w  g   K  VNK  	  p	pV	'       df   V	^ ,          S%8w  dX   S V	^ ,          ,          S ^ ,          uS ^ &   S V	^ ,          &   S'       d(   S#V	^ ,          ,          S#^ ,          uS#^ &   S#V	^ ,          &   M«\	        S 4       U
u. uF  p
S ^ ,          V
,          S%8w  g   K  V
NK  	  p	p
V	'       ds   V	^ ,          S%8w  de   S  F(  pW¹^ ,          ,          V^ ,          uV^ &   W¹^ ,          &   K*  	  S'       d/   S$ F(  pW¹^ ,          ,          V^ ,          uV^ &   W¹^ ,          &   K*  	  \
        ;QJ d*    V V%3R l\	        ^S 4       4       F  '       g   K   RM	  RM! V V%3R l\	        ^S 4       4       4      '       gW   \
        ;QJ d*    V V%3R	 l\	        ^S"4       4       F  '       g   K   RM	  RM! V V%3R	 l\	        ^S"4       4       4      '       d   V! 4        V! 4        K¼  V3R
 lpS ^ ,          ^ ,          ^ 8w  d    SP                  S ^ ,          ^ ,          4      pSP                  '       d   ^S ^ ,          ^ ,          ,          pVSP                  8w  dG   S ^ ,          ^ ;;,          V,          uu&   S'       d#   S#^ ,           Uu. uF  qîV,          NK  	  upS#^ &   ^V9   d   RpEMS R,           Uu. uF  pVR,          NK  	  pp\        VSS"^,
          S ^,
          3SR7      pS'       dÊ   Vw  ppp^.^ .S"^,
          ,          ,           .V Uu. uF  p^ .V,           NK  	  up,           p^.^ .S ^,
          ,          ,           .V Uu. uF  p^ .V,           NK  	  up,           p\        \        VS#VS$V.4      4      w  o#po$pVS#,          o#S$V,          o$S#P                  4       o#S$P                  4       o$MTpS ^ ,          ^ ,          '       Edy   S ^ ,          ^ ,          .pVP                  V4       \	        \        V4      ^,
          4       EF5  pVV,          VV^,           ,          ppV'       Ed   SP                  VV4      ^,          S%8w  dó   S'       d   SP                  VV4      w  pppMSP!                  VV4      pSP                  VV4      ^ ,          pS'       d†   SP                  VV4      ^ ,          pS! S#Wˆ^,           ^^ X^4       \#        S$Wˆ^,           ^X^ ^4       S! S#Wˆ^,           ^V) ^ ^4       \#        S$Wˆ^,           ^^ V) ^4       S! S#Wˆ^,           ^ ^R^ 4       VV,          VV^,           &   VVV&   EK6   Mp	  MmS'       dN   S"^8”  d   S#R,          S#^ ,          .,           o#S ^8”  d(   S$ Uu. uF  q»R,          V^ ,          .,           NK  	  upo$VS ^ ,          ^ ,          3,           pS'       d   \%        V4      S#S$3# \%        V4      # u upi u up
i u upi u upi u upi u upi u upi )z×
Return the tuple of abelian invariants for a matrix `m`
(as in the Smith-Normal form). If `full=True` then invertible matrices
``s, t`` such that the product ``s, m, t`` is the Smith Normal Form
are also returned.
zBThe matrix entries must be over a principal ideal domain, but got c           	      ó–   <€ \        V 4       UUu. uF&  p\        V 4       Uu. uF  q"V8X  d   SMSNK  	  upNK(  	  upp# u upi u uppi r    )r   )Únr   r   Úoner   s   &  €€r   ÚeyeÚ!_smith_normal_decomp.<locals>.eye‹   s>   ø€ ÜEJÈ1ÄXÔNÁXÀ´%¸´(Ó;±(¨Q˜Qœ‘ DÒ(±(Ô;ÁXÒNÐNùÒ;ùÓNs   �A¢A µAÁ Ac                 ó  € \        \        V ^ ,          4      4       Fj  pW,          V,          pW8,          W@V,          V,          ,          ,           W,          V&   WX,          W`V,          V,          ,          ,           W,          V&   Kl  	  R# ©é    Nr!   r#   s	   &&&&&&&  r   Úadd_rowsÚ&_smith_normal_decomp.<locals>.add_rows˜   s\   € ô ”s˜1˜Q�4“yÖ!ˆAØ•�Q•ˆAØ•c˜A �d 1�g�I•oˆA�D�‰GØ•c˜A �d 1�g�I•oˆA�D�‹Gó "r   c            
      ó  <€ S^ ,          ^ ,          p \        ^S4       Få  pSV,          ^ ,          S8X  d   K  S
P                  SV,          ^ ,          V 4      w  r#VS8X  d+   S	! S^ V^^ V) ^4       S'       d   S	! S^ V^^ V) ^4       Kk  Km  S
P                  V SV,          ^ ,          4      w  rEpS
P                  SV,          ^ ,          V4      pS
P                  W4      pS	! S^ WWWV) 4       S'       d   S	! S^ WWWV) 4       Tp Kç  	  R# r=   )r   r   ÚgcdexÚexquo)Úpivotr   r'   r   r$   r%   ÚgÚd_0Úd_jr?   r   r-   r   r1   r3   r   s            €€€€€€€r   Úclear_columnÚ*_smith_normal_decomp.<locals>.clear_column    s÷   ø€ à�!•�Q•ˆÜ�q˜$–ˆAØ��t�A�w˜$ŒÙØ—:‘:˜a �d 1�g uÓ-‰DˆAØ�DŒyÙ˜˜A˜q ! Q¨¨¨AÔ.ßÙ˜Q  1 a¨¨Q¨B°Ö2ñ ð !Ÿ,™, u¨a°­d°1­gÓ6‘��aØ—l‘l 1 Q¥4¨¥7¨AÓ.�Ø—l‘l 5Ó,�Ù˜˜A˜q Q¨c¨TÔ2ßÙ˜Q  1¨°#°Ô6Ø’ó  r   c            
      ó*  <€ S^ ,          ^ ,          p \        ^S	4       Fñ  pS^ ,          V,          S8X  d   K  S
P                  S^ ,          V,          V 4      w  r#VS8X  d1   \        S^ V^^ V) ^4       S'       d   \        S^ V^^ V) ^4       Kq  Ks  S
P                  V S^ ,          V,          4      w  rEpS
P	                  S^ ,          V,          V4      pS
P	                  W4      p\        S^ WWWV) 4       S'       d   \        S^ WWWV) 4       Tp Kó  	  R# r=   )r   r   r*   rB   rC   )rD   r   r'   r   r$   r%   rE   rF   rG   r2   r   r-   r   r4   r   s            €€€€€€r   Ú	clear_rowÚ'_smith_normal_decomp.<locals>.clear_row´   s÷   ø€ à�!•�Q•ˆÜ�q˜$–ˆAØ��t�A�w˜$ŒÙØ—:‘:˜a �d 1�g uÓ-‰DˆAØ�DŒyÜ˜A˜q ! Q¨¨A¨2¨qÔ1ßÜ  1 a¨¨A°¨r°1Ö5ñ ð !Ÿ,™, u¨a°­d°1­gÓ6‘��aØ—l‘l 1 Q¥4¨¥7¨AÓ.�Ø—l‘l 5Ó,�Ü˜A˜q !¨°°Ô5ßÜ  1 a¨A°S°DÔ9Ø’ó  r   c              3   óJ   <"  € T F  pS^ ,          V,          S8g  x € K  	  R# 5ir=   © ©Ú.0r   r   r   s   & €€r   Ú	<genexpr>Ú'_smith_normal_decomp.<locals>.<genexpr>Ø   ó   øé € Ð6© 1ˆq��t�A�w˜$Ž«ùó   ƒ #TFc              3   óJ   <"  € T F  pSV,          ^ ,          S8g  x € K  	  R# 5ir=   rN   rO   s   & €€r   rQ   rR   Ù   rS   rT   c                 óV   <€ \        V \        V 4      \        V ^ ,          4      3SR7      # )r>   )r   r   )r   r"   )r   r   s   &€r   Úto_domain_matrixÚ._smith_normal_decomp.<locals>.to_domain_matrixÝ   s#   ø€ Ü˜A¤c¨!£f¬c°!°Aµ$«iÐ%8ÀÔHÐHr   :é   NNr,   rN   éÿÿÿÿ)Úis_PIDÚ
ValueErrorr   r9   r   ÚanyÚcanonical_unitÚis_Fieldr.   ÚlistÚmapr   Úextendr"   r   rB   Úgcdr*   Útuple)&r   r   r   r-   Úmsgr:   rH   rK   r   Úindr   ÚrowrW   r&   Úelemr   r   Úlower_rightÚretÚs_smallÚt_smallÚs2Út2Úresultr$   r%   ÚxÚyr'   ÚalphaÚbetar?   r2   r9   r1   r3   r4   r   s&   ff&f                           @@@@@@@r   r.   r.   |   sž  ÿù€ ð �=�=ˆ=ØRÐSYÐRZÐ[ˆÜ˜‹oÐà�J€Dˆ$Ø�;‰;€DØ
�*‰*€CöOð 	ˆE„zßØ‘s˜4“y¡# d£)Ð+Ð+àˆIçÙ�‹IˆÙ�‹Iˆò&÷ó ÷(ò ô* ˜D”kÓ
5‘k� Q q¥T¨!¥W°¡_�1ˆ1‘k€CÐ
5ß
ˆs�1�v˜Œ~Ø˜C �F�) Q q¥Tˆˆˆ!‰ˆa��A•‰ißØ  A¥�i¨¨1­ˆOˆAˆa‰D�!�C˜•F‘)øä œ+Ó9™+�Q¨¨1­¨a­°D©�qˆq™+ˆÐ9ß�3�q•6˜T”>Û�Ø&)¨a­&¥k°3°qµ6Ð#��A‘˜ �F›ñ çÛ�CØ*-°!­f­+°s¸1µvÐ'�C˜‘F˜C A¥›Kñ ÷ ‹3Õ6¬¨a°¬Ó6�3�3Š3Õ6¬¨a°¬Ó6×6Ò6ß‹3Õ6¬¨a°¬Ó6�3�3Š3Õ6¬¨a°¬Ó6×6Ò6ÙŒÙŽõIð 	ˆ…tˆA…w�!„|Ø×!Ñ! ! A¥$ q¥'Ó*ˆØ�?�?ˆ?Ø�A�a•D˜•G•ˆAØ�—
‘
Œ?Øˆa�D��G�q�L‹GßØ-.¨q®TÓ2©T T˜qŸ˜©TÑ2��!‘àˆE„zØŠà&'¨¦eÓ,¡e �q˜—u�u¡eˆÐ,Ü" ;°Ø˜a•x ¨¥Ð*°ô7ˆçØ%(Ñ"ˆD�'˜7Ø�#˜˜˜T !�V�Õ$Ð%¹gÓ(F¹g°s¨!¨¨s¯¨¹gÑ(FÕFˆBØ�#˜˜˜T !�V�Õ$Ð%¹gÓ(F¹g°s¨!¨¨s¯¨¹gÑ(FÕFˆBÜ¤Ð$4°q¸"¸aÀ°nÓ EÓF‰LˆAˆr�1�bØ�Q•ˆAØ�B•ˆAØ—	‘	“ˆAØ—	‘	“‰AàˆDàˆ…tˆA‡w…wØ�A•$�q•'�ˆØ�‰�dÔä”s˜6“{ 1•}×%ˆAØ˜!•9˜f Q q¥S�kˆqˆAßˆq�V—Z‘Z  1Ó% aÕ(¨DÔ0ßØ$Ÿl™l¨1¨aÓ0‘G�A�q™!àŸ
™
 1 aÓ(�AàŸ
™
 1 aÓ(¨Õ+�ßØ!Ÿ:™: a¨Ó+¨AÕ.�DÙ˜Q  q¥5¨!¨Q°°1Ô5Ü  1¨!¥e¨Q°°1°aÔ8Ù˜Q  q¥5¨!¨e¨V°Q¸Ô:Ü  1¨!¥e¨Q°°D°5¸!Ô<Ù˜Q  q¥5¨!¨Q°°AÔ6à %�i��q˜•s‘Ø��q”	áò) &÷, Ø�aŒxØ�b•E˜Q˜q�T˜F•N�Ø�aŒxÙ34Ó5±1¨C˜•W  A¥˜x×'Ð'±1Ñ5�Ø˜˜1�˜a�˜
Õ"ˆçÜ�V‹}˜a Ð"Ð"ä�V‹}Ðùòm 6ùò :ùò0 3ùò
 -ùò
 )GùÚ(FùòN 6s6   Â2ZÃZÅZ"Å,Z"ÍZ'Í:Z,ÏZ1ÐZ6Ù Z;c                ó~   € \         P                  ! W4      w  r#pV ^ 8w  d   W,          ^ 8X  d   ^ pV ^ 8  d   RM^pW#V3# )aƒ  
This supports the functions that compute Hermite Normal Form.

Explanation
===========

Let x, y be the coefficients returned by the extended Euclidean
Algorithm, so that x*a + y*b = g. In the algorithms for computing HNF,
it is critical that x, y not only satisfy the condition of being small
in magnitude -- namely that |x| <= |b|/g, |y| <- |a|/g -- but also that
y == 0 when a | b.

rZ   )r   rB   )r$   r%   rp   rq   rE   s   &&   r   Ú_gcdexru   "  s?   € ô �hŠh�q‹n�G€Aˆ!ØˆA„v�!•%˜1”*ØˆØ�a”%‰B˜QˆØ�ˆ7€Nr   c                óŠ  € V P                   P                  '       g   \        R4      hV P                  w  rV P	                  4       P                  4       p Tp\        V^,
          RR4       EF'  pV^ 8X  d    EMV^,          p\        V^,
          RR4       F|  pW,          V,          ^ 8w  g   K  \        W,          V,          W,          V,          4      w  rgpW,          V,          V,          W,          V,          V,          r©\        WWVWz) V	4       K~  	  W,          V,          pV^ 8  d   \        WVR^ R^ 4       V) pV^ 8X  d   V^,          pKæ  \        V^,           V4       F*  pW,          V,          V,          p\        WV^V) ^ ^4       K,  	  EK*  	  \        P                  ! V P                  4       4      RVR13,          # )a¤  
Compute the Hermite Normal Form of DomainMatrix *A* over :ref:`ZZ`.

Parameters
==========

A : :py:class:`~.DomainMatrix` over domain :ref:`ZZ`.

Returns
=======

:py:class:`~.DomainMatrix`
    The HNF of matrix *A*.

Raises
======

DMDomainError
    If the domain of the matrix is not :ref:`ZZ`.

References
==========

.. [1] Cohen, H. *A Course in Computational Algebraic Number Theory.*
   (See Algorithm 2.4.5.)

úMatrix must be over domain ZZ.:NNNNrZ   )r   Úis_ZZr   r   Úto_ddmÚcopyr   ru   r*   r   Úfrom_repÚto_dfm_or_ddm)ÚAr   r8   r(   r   r   ÚuÚvr'   r   r3   r%   Úqs   &            r   Ú_hermite_normal_formr�   7  s|  € ð8 �8‰8�>�>ˆ>ÜÐ<Ó=Ð=ð �7‰7�D€AØ	�‰‹
�‰Ó€Að 	
€AÜ�1�q•5˜"˜b×!ˆØ�Œ6ò Ø	ˆQ�ˆô �q˜1•u˜b "Ö%ˆAØ�t�A�w˜!Ž|ô ! ¥ a¥¨!­$¨q­'Ó2‘��aØ•t˜A•w !•| Q¥T¨!¥W°¥\�1Ü˜A !¨¨2¨qÖ1ñ &ð �D��GˆàˆqŒ5Ü˜˜a  Q¨¨AÔ.Ø�ˆAð �Œ6Ø��FŠAô
 ˜1˜q�5 !–_�Ø•D˜•G˜q•L�Ü˜A ! Q¨¨¨A¨qÖ1ô %ñ? "ôH × Ò  §¡Ó!2Ó3°A°q±r°EÕ:Ð:r   c                ó¤  € V P                   P                  '       g   \        R4      h\        P                  ! V4      '       d   V^8  d   \        R4      hR p\        \        4      pV P                  w  rEWT8  d   \        R4      hV P                  4       p TpTp\        V^,
          RR4       EF~  pV^,          p\        V^,
          RR4       Fz  p	W,          V	,          ^ 8w  g   K  \        W,          V,          W,          V	,          4      w  r«pW,          V,          V,          W,          V	,          V,          ríV! WWiW«V) V4       K|  	  W,          V,          pV^ 8X  d   T;W,          V&   p\        W÷4      w  r«p\        V4       F*  pW V,          V,          ,          V,          VV,          V&   K,  	  W8,          V,          ^ 8X  d   WsV,          V&   \        V^,           V4       F7  p	W8,          V	,          W8,          V,          ,          p\        W9V^V) ^ ^4       K9  	  W|,          pEK�  	  \        W4V3\        4      P                  4       # )aß  
Perform the mod *D* Hermite Normal Form reduction algorithm on
:py:class:`~.DomainMatrix` *A*.

Explanation
===========

If *A* is an $m \times n$ matrix of rank $m$, having Hermite Normal Form
$W$, and if *D* is any positive integer known in advance to be a multiple
of $\det(W)$, then the HNF of *A* can be computed by an algorithm that
works mod *D* in order to prevent coefficient explosion.

Parameters
==========

A : :py:class:`~.DomainMatrix` over :ref:`ZZ`
    $m \times n$ matrix, having rank $m$.
D : :ref:`ZZ`
    Positive integer, known to be a multiple of the determinant of the
    HNF of *A*.

Returns
=======

:py:class:`~.DomainMatrix`
    The HNF of matrix *A*.

Raises
======

DMDomainError
    If the domain of the matrix is not :ref:`ZZ`, or
    if *D* is given but is not in :ref:`ZZ`.

DMShapeError
    If the matrix has more rows than columns.

References
==========

.. [1] Cohen, H. *A Course in Computational Algebraic Number Theory.*
   (See Algorithm 2.4.8.)

rw   z0Modulus D must be positive element of domain ZZ.c                 óN  € \        \        V 4      4       FŒ  pW,          V,          p	\        WI,          WPV,          V,          ,          ,           V,          V4      W,          V&   \        Wi,          WpV,          V,          ,          ,           V,          V4      W,          V&   KŽ  	  R # r    )r   r"   r   )
r   ÚRr   r   r$   r%   r&   r'   r(   r)   s
   &&&&&&&&  r   Úadd_columns_mod_RÚ8_hermite_normal_form_modulo_D.<locals>.add_columns_mod_R¶  sq   € ô ”s˜1“v–ˆAØ•�Q•ˆAÜ'¨­°°qµT¸!µWµÕ)<ÀÕ(AÀ1ÓEˆA�D�‰GÜ'¨­°°qµT¸!µWµÕ)<ÀÕ(AÀ1ÓEˆA�D�‹Gó r   z2Matrix must have at least as many columns as rows.rZ   )r   rx   r   r   Úof_typer   Údictr   r   r   r   ru   r*   r   r0   )r}   ÚDr…   ÚWr   r8   r(   r„   r   r   r~   r   r'   r   r3   r%   Úiir€   s   &&                r   Ú_hermite_normal_form_modulo_DrŒ   „  sá  € ðZ �8‰8�>�>ˆ>ÜÐ<Ó=Ð=Ü�:Š:�a�=Š=˜A œEÜÐNÓOÐOòFô 	”DÓ€Aà�7‰7�D€AØ„uÜÐOÓPÐPØ	�	‰	‹€AØ	€AØ	€AÜ�1�q•5˜"˜b×!ˆØ	ˆQ�ˆÜ�q˜1•u˜b "Ö%ˆAØ�t�A�w˜!Ž|Ü  ¥ a¥¨!­$¨q­'Ó2‘��aØ•t˜A•w !•| Q¥T¨!¥W°¥\�1Ù! !¨¨a°Q°B¸Ö:ñ	 &ð
 �D��GˆØ�Œ6ØˆOˆA�D�‰G�aÜ˜“,‰ˆˆaÜ˜–(ˆBØ˜2�˜q�•z A•~ˆAˆb�E�!‹Hñ à�4��7�aŒ<Øˆa�D�‰GÜ�q˜1•u˜a–ˆAØ•�Q•˜1�4 �7Õ"ˆAÜ˜˜a  Q B¨¨1Ö-ñ !ð 	
�‹ñ% "ô& ˜˜q˜6¤2Ó&×/Ñ/Ó1Ð1r   r‰   NÚ
check_rankFc               ó  € V P                   P                  '       g   \        R4      hVeM   V'       d:   V P                  \        4      P                  4       V P                  ^ ,          8X  d   \        W4      # \        V 4      # )a}  
Compute the Hermite Normal Form of :py:class:`~.DomainMatrix` *A* over
:ref:`ZZ`.

Examples
========

>>> from sympy import ZZ
>>> from sympy.polys.matrices import DomainMatrix
>>> from sympy.polys.matrices.normalforms import hermite_normal_form
>>> m = DomainMatrix([[ZZ(12), ZZ(6), ZZ(4)],
...                   [ZZ(3), ZZ(9), ZZ(6)],
...                   [ZZ(2), ZZ(16), ZZ(14)]], (3, 3), ZZ)
>>> print(hermite_normal_form(m).to_Matrix())
Matrix([[10, 0, 2], [0, 15, 3], [0, 0, 2]])

Parameters
==========

A : $m \times n$ ``DomainMatrix`` over :ref:`ZZ`.

D : :ref:`ZZ`, optional
    Let $W$ be the HNF of *A*. If known in advance, a positive integer *D*
    being any multiple of $\det(W)$ may be provided. In this case, if *A*
    also has rank $m$, then we may use an alternative algorithm that works
    mod *D* in order to prevent coefficient explosion.

check_rank : boolean, optional (default=False)
    The basic assumption is that, if you pass a value for *D*, then
    you already believe that *A* has rank $m$, so we do not waste time
    checking it for you. If you do want this to be checked (and the
    ordinary, non-modulo *D* algorithm to be used if the check fails), then
    set *check_rank* to ``True``.

Returns
=======

:py:class:`~.DomainMatrix`
    The HNF of matrix *A*.

Raises
======

DMDomainError
    If the domain of the matrix is not :ref:`ZZ`, or
    if *D* is given but is not in :ref:`ZZ`.

DMShapeError
    If the mod *D* algorithm is used but the matrix has more rows than
    columns.

References
==========

.. [1] Cohen, H. *A Course in Computational Algebraic Number Theory.*
   (See Algorithms 2.4.5 and 2.4.8.)

rw   )	r   rx   r   Ú
convert_tor   Úrankr   rŒ   r�   )r}   r‰   r�   s   &$$r   Úhermite_normal_formr‘   Ü  s\   € ðv �8‰8�>�>ˆ>ÜÐ<Ó=Ð=Ø‚}Ÿj¨A¯L©L¼Ó,<×,AÑ,AÓ,CÀqÇwÁwÈqÅzÔ,QÜ,¨QÓ2Ð2ä# AÓ&Ð&r   )Ú__doc__Úcollectionsr   Údomainmatrixr   Ú
exceptionsr   r   Úsympy.ntheory.modularr   Úsympy.polys.domainsr   r   r   r   r*   r
   r5   r.   ru   r�   rŒ   r‘   rN   r   r   Ú<module>r˜      sa   ðÙ 2å #å &ß 3Ý 3ß &òò.ò:"òDò$ò8còLò*J;òZU2ðp@' ð @'°ö @'r   