+
    ‹°³j  ã                   óŽ   € R 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 RR ltRR ltRR lt
RR	 ltRR
 ltRRRR/R ltR# )z,Functions returning normal forms of matrices)ÚZZ)ÚPoly)ÚDomainMatrix)Úsmith_normal_formÚis_smith_normal_formÚsmith_normal_decompÚinvariant_factorsÚhermite_normal_formNc                ó²   € \        V RR4      pV P                  R 4      p \        P                  ! V 4      pT;'       g    TpVe   VP	                  V4      pV# )zConvert Matrix to DomainMatrixÚringNc                 óR   € \        V \        4      '       d   V P                  4       # T # ©N)Ú
isinstancer   Úas_expr)Úes   &Ú[/home/luca/screen-checking/.venv/lib/python3.14/site-packages/sympy/matrices/normalforms.pyÚ<lambda>Ú_to_domain.<locals>.<lambda>   s   € ¬Z¸¼4×-@Ò-@˜aŸi™i›kÐGÀaÐGó    )ÚgetattrÚ	applyfuncr   Úfrom_MatrixÚ
convert_to)ÚmÚdomainr   ÚdMs   &&  r   Ú
_to_domainr      sU   € ô �1�f˜dÓ#€DØ	�‰ÑGÓH€Aä	×	!Ò	! !Ó	$€Bà�^ˆ^�t€FØÒØ�]‰]˜6Ó"ˆØ€Ir   c                óJ   € \        W4      p\        V4      P                  4       # )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 Matrix, ZZ
>>> from sympy.matrices.normalforms import smith_normal_form
>>> m = Matrix([[12, 6, 4], [3, 9, 6], [2, 16, 14]])
>>> print(smith_normal_form(m, domain=ZZ))
Matrix([[1, 0, 0], [0, 10, 0], [0, 0, 30]])

)r   Ú_snfÚ	to_Matrix©r   r   r   s   && r   r   r      s!   € ô 
�AÓ	€BÜ�‹8×ÑÓÐr   c                ó.   € \        W4      p\        V4      # )z0
Checks that the matrix is in Smith Normal Form
)r   Ú_is_snfr    s   && r   r   r   0   s   € ô 
�AÓ	€BÜ�2‹;Ðr   c                ó’   € \        W4      p\        V4      w  r4pVP                  4       VP                  4       VP                  4       3# )a  
Return the Smith Normal Decomposition of a matrix `m` over the ring
`domain`. This will only work if the ring is a principal ideal domain.

Examples
========

>>> from sympy import Matrix, ZZ
>>> from sympy.matrices.normalforms import smith_normal_decomp
>>> m = Matrix([[12, 6, 4], [3, 9, 6], [2, 16, 14]])
>>> a, s, t = smith_normal_decomp(m, domain=ZZ)
>>> assert a == s * m * t
)r   Ú_sndr   )r   r   r   ÚaÚsÚts   &&    r   r   r   8   s:   € ô 
�AÓ	€BÜ�2‹h�G€Aˆ!Ø�;‰;‹=˜!Ÿ+™+›-¨¯©«Ð6Ð6r   c                ó€  aaa€ \        W4      o\        S4      p\        ;QJ d    . V3R lV 4       F  NK  	  5M! V3R lV 4       4      p\        V R4      '       da   V P                  P
                  '       dE   V P                  oV3R lo\        ;QJ d    . V3R lV 4       F  NK  	  5M! V3R lV 4       4      pV# )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

c              3   óZ   <"  € T F   pSP                   P                  V4      x € K"  	  R # 5ir   )r   Úto_sympy)Ú.0Úfr   s   & €r   Ú	<genexpr>Ú$invariant_factors.<locals>.<genexpr>Y   s#   øé € Ð;±7¨a�B—I‘I×&Ñ& q×)Ð)³7ùs   ƒ(+r   c                 óH   <€ \        V SP                  SP                  R 7      # ))r   )r   Úsymbolsr   )r,   ÚKs   &€r   r   Ú#invariant_factors.<locals>.<lambda>^   s   ø€ ¤ Q¨¯	©	¸!¿(¹(Õ Cr   c              3   ó4   <"  € T F  pS! V4      x € K  	  R # 5ir   © )r+   r,   Úto_polys   & €r   r-   r.   _   s   øé € Ð8±¨1™G AŸJ˜J³ùs   ƒ)r   Ú_invfÚtupleÚhasattrr   Úis_PolynomialRing)r   r   Úfactorsr1   r   r5   s   && @@@r   r   r   K   s„   ú€ ô 
�AÓ	€BÜ�B‹i€GßŒeÔ;±7Ó;�e‰eÔ;±7Ó;Ó;€Gäˆq�&×ÒØ�6‰6×#×#Ð#Ø—‘ˆAÜCˆGß”eÔ8±Ó8—e‘eÔ8±Ó8Ó8ˆGØ€Nr   ÚDÚ
check_rankFc               ó´   € Ve1   \         P                  ! V4      '       g   \        \        V4      4      p\        V P                  WR7      P                  4       # )aw  
Compute the Hermite Normal Form of a Matrix *A* of integers.

Examples
========

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

Parameters
==========

A : $m \times n$ ``Matrix`` of integers.

D : int, 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
=======

``Matrix``
    The HNF of matrix *A*.

Raises
======

DMDomainError
    If the domain of the matrix is not :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.)

)r;   r<   )r   Úof_typeÚintÚ_hnfÚ_repr   )ÚAr;   r<   s   &$$r   r	   r	   c   s=   € ðn 	‚}œRŸZšZ¨Ÿ]š]ÜŒs�1‹v‹JˆÜ�—‘˜!Ô3×=Ñ=Ó?Ð?r   r   )Ú__doc__Úsympy.polys.domains.integerringr   Úsympy.polys.polytoolsr   Úsympy.polys.matricesr   Ú sympy.polys.matrices.normalformsr   r   r   r"   r   r$   r   r6   r	   r@   r   r4   r   r   Ú<module>rH      sJ   ðÙ 2å .Ý &Ý -÷õ ôô ô&ô7ô&ð09@ ð 9@°ö 9@r   