| Server IP : 35.80.110.71 / Your IP : 216.73.216.221 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/python3/dist-packages/sympy/matrices/__pycache__/ |
Upload File : |
�
M�Zd� � �f � d Z ddlmZ ddlmZ ddlmZ ddlmZ m
ZmZ
d
d�Zd
d�Zd
d �Z
dd
d�d�Zy)z,Functions returning normal forms of matrices� )�ZZ)�Poly)�DomainMatrix)�smith_normal_form�invariant_factors�hermite_normal_formNc � � t | dd� }| j d� � } t j | � }|xs |}|�|j |� }|S )zConvert Matrix to DomainMatrix�ringNc �F � t | t � r| j � S | S �N)�
isinstancer �as_expr)�es �</usr/lib/python3/dist-packages/sympy/matrices/normalforms.py�<lambda>z_to_domain.<locals>.<lambda> s � �Z��4�-@�a�i�i�k� �a� � )�getattr� applyfuncr �from_Matrix�
convert_to)�m�domainr
�dMs r �
_to_domainr
sS � � �1�f�d�#�D� ���G�H�A� � !� !�!� $�B�
�^�t�F�
��
�]�]�6�
"��
�Ir c �L � t | |� }t |� j � S )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�v� �B���8����r c �� ���� t | |� �t �� }t �fd�|D � � }t | d� r;| j j
r%| j ��fd��t �fd�|D � � }|S )a9
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 �T �K � | ] }�j j |� �� �! y �wr )r �to_sympy)�.0�fr s �r � <genexpr>z$invariant_factors.<locals>.<genexpr><