计算Hermite正交形式和Smith正交形式。
项目描述
hsnf
使用转换矩阵计算Hermite正交形式和Smith正交形式。
- 文档:https://hsnf.readthedocs.io/en/latest/
- 开发文档:https://lan496.github.io/hsnf/develop
- Github:https://github.com/lan496/hsnf
- PyPI:https://pypi.ac.cn/project/hsnf
使用方法
import numpy as np
from hsnf import column_style_hermite_normal_form, row_style_hermite_normal_form, smith_normal_form
# Integer matrix to be decomposed
M = np.array(
    [
        [-6, 111, -36, 6],
        [5, -672, 210, 74],
        [0, -255, 81, 24],
    ]
)
# Smith normal form
D, L, R = smith_normal_form(M)
"""
D = array([
[   1    0    0    0]
[   0    3    0    0]
[   0    0 2079    0]])
"""
assert np.allclose(L @ M @ R, D)
assert np.around(np.abs(np.linalg.det(L))) == 1  # unimodular
assert np.around(np.abs(np.linalg.det(R))) == 1  # unimodular
# Row-style hermite normal form
H, L = row_style_hermite_normal_form(M)
"""
H = array([
[     1      0    420  -2522]
[     0      3   1809 -10860]
[     0      0   2079 -12474]])
"""
assert np.allclose(L @ M, H)
assert np.around(np.abs(np.linalg.det(L))) == 1  # unimodular
# Column-style hermite normal form
H, R = column_style_hermite_normal_form(M)
"""
H = array([
[   3    0    0    0]
[   0    1    0    0]
[1185  474 2079    0]])
"""
assert np.allclose(np.dot(M, R), H)
assert np.around(np.abs(np.linalg.det(R))) == 1  # unimodular
安装
hsnf与Python3.8+兼容,可以通过PyPI安装
pip install hsnf
或本地安装
git clone git@github.com:lan496/hsnf.git
cd hsnf
pip install -e .[dev,docs]
参考资料
- http://www.dlfer.xyz/post/2016-10-27-smith-normal-form/
- 感谢D. L. Ferrario博士的指导性博客文章及其允许引用其脚本的批准。
 
- CSE206A: Lattices Algorithms and Applications (Spring 2014)
- Henri Cohen, A Course in Computational Algebraic Number Theory (Springer-Verlag, Berlin, 1993).
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源代码分发
         hsnf-0.3.16.tar.gz  (21.2 kB 查看哈希值)
      
    构建版本
         hsnf-0.3.16-py3-none-any.whl  (11.1 kB 查看哈希值)
      
    
    
       关闭
    
      
        
    
    
  
hsnf-0.3.16.tar.gz 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | ae4f99c89076f734969d6aedaa0d3390f667929a2aa4862c7e03c067cd063207 | |
| MD5 | 01ab86dd8c2e7b3a4cc6c80454787322 | |
| BLAKE2b-256 | 54887461240d61cfaa7301163e6fc6b78e8ac5ced3dbda2b708476cec2b6978b | 
    
       关闭
    
      
        
    
    
  
hsnf-0.3.16-py3-none-any.whl 的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 906d0ad4af691e1c45e51fd6c99d8b3ed0be1179cbcc21cbd4dda11cc97dc1e8 | |
| MD5 | ed345f6966cac753c11b0f29d100982e | |
| BLAKE2b-256 | b590f6f56e32a71a091ff0afa377f92a97a2a3804dc8ab8210134a94144e9bf8 |