{"id":35189353,"url":"https://github.com/lan496/hsnf","last_synced_at":"2025-12-29T05:30:37.857Z","repository":{"id":37940775,"uuid":"168330620","full_name":"lan496/hsnf","owner":"lan496","description":"Computing Hermite normal form and Smith normal form with transformation matrices","archived":false,"fork":false,"pushed_at":"2025-12-02T00:48:24.000Z","size":8731,"stargazers_count":20,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-12-04T16:05:12.864Z","etag":null,"topics":["matrix-functions","numpy","python"],"latest_commit_sha":null,"homepage":"https://hsnf.readthedocs.io/en/latest/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lan496.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-01-30T11:18:04.000Z","updated_at":"2025-12-02T00:48:28.000Z","dependencies_parsed_at":"2024-01-02T02:39:45.400Z","dependency_job_id":"43a3c29f-ea57-4fb7-a776-9f6ea5af13ba","html_url":"https://github.com/lan496/hsnf","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/lan496/hsnf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lan496%2Fhsnf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lan496%2Fhsnf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lan496%2Fhsnf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lan496%2Fhsnf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lan496","download_url":"https://codeload.github.com/lan496/hsnf/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lan496%2Fhsnf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28111051,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-29T02:00:07.021Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["matrix-functions","numpy","python"],"created_at":"2025-12-29T05:30:36.592Z","updated_at":"2025-12-29T05:30:37.852Z","avatar_url":"https://github.com/lan496.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hsnf\n[![testing](https://github.com/lan496/hsnf/actions/workflows/testing.yml/badge.svg?branch=master)](https://github.com/lan496/hsnf/actions/workflows/testing.yml)\n[![Documentation Status](https://readthedocs.org/projects/hsnf/badge/?version=latest)](https://hsnf.readthedocs.io/en/latest/?badge=latest)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/lan496/hsnf/master.svg)](https://results.pre-commit.ci/latest/github/lan496/hsnf/master)\n[![codecov](https://codecov.io/gh/lan496/hsnf/branch/master/graph/badge.svg?token=G0Z06OQR17)](https://codecov.io/gh/lan496/hsnf)\n[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/lan496/hsnf/blob/master/LICENSE)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hsnf)\n[![PyPI version](https://badge.fury.io/py/hsnf.svg)](https://badge.fury.io/py/hsnf)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/hsnf)\n\u003c!--![GitHub all releases](https://img.shields.io/github/downloads/lan496/hsnf/total) --\u003e\n\nComputing Hermite normal form and Smith normal form with transformation matrices.\n\n- Document: \u003chttps://hsnf.readthedocs.io/en/latest/\u003e\n- Document(develop): \u003chttps://lan496.github.io/hsnf/develop\u003e\n- Github: \u003chttps://github.com/lan496/hsnf\u003e\n- PyPI: \u003chttps://pypi.org/project/hsnf\u003e\n\n## Usage\n\n```python\nimport numpy as np\nfrom hsnf import column_style_hermite_normal_form, row_style_hermite_normal_form, smith_normal_form\n\n# Integer matrix to be decomposed\nM = np.array(\n    [\n        [-6, 111, -36, 6],\n        [5, -672, 210, 74],\n        [0, -255, 81, 24],\n    ]\n)\n\n# Smith normal form\nD, L, R = smith_normal_form(M)\n\"\"\"\nD = array([\n[   1    0    0    0]\n[   0    3    0    0]\n[   0    0 2079    0]])\n\"\"\"\nassert np.allclose(L @ M @ R, D)\nassert np.around(np.abs(np.linalg.det(L))) == 1  # unimodular\nassert np.around(np.abs(np.linalg.det(R))) == 1  # unimodular\n\n# Row-style hermite normal form\nH, L = row_style_hermite_normal_form(M)\n\"\"\"\nH = array([\n[     1      0    420  -2522]\n[     0      3   1809 -10860]\n[     0      0   2079 -12474]])\n\"\"\"\nassert np.allclose(L @ M, H)\nassert np.around(np.abs(np.linalg.det(L))) == 1  # unimodular\n\n# Column-style hermite normal form\nH, R = column_style_hermite_normal_form(M)\n\"\"\"\nH = array([\n[   3    0    0    0]\n[   0    1    0    0]\n[1185  474 2079    0]])\n\"\"\"\nassert np.allclose(np.dot(M, R), H)\nassert np.around(np.abs(np.linalg.det(R))) == 1  # unimodular\n```\n\n## Installation\n\nhsnf works with Python3.8+ and can be installed via PyPI:\n\n```shell\npip install hsnf\n```\n\nor in local:\n```shell\ngit clone git@github.com:lan496/hsnf.git\ncd hsnf\npip install -e .[dev,docs]\n```\n\n## References\n- http://www.dlfer.xyz/post/2016-10-27-smith-normal-form/\n  - I appreciate Dr. D. L. Ferrario's instructive blog post and his approval for referring his scripts.\n- [CSE206A: Lattices Algorithms and Applications (Spring 2014)](https://cseweb.ucsd.edu/classes/sp14/cse206A-a/index.html)\n- Henri Cohen, A Course in Computational Algebraic Number Theory (Springer-Verlag, Berlin, 1993).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flan496%2Fhsnf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flan496%2Fhsnf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flan496%2Fhsnf/lists"}