# 埃尔米特标准形

**埃尔米特标准形**（Hermite normal form，HNF）是整数元素矩阵的一种典范的类阶梯形形式，通过将矩阵乘以一个幺模整数矩阵得到，所谓幺模整数矩阵即行列式为 ±1 的整数矩阵。它是行阶梯形在整数环上的类比：它保持原矩阵的行（或列）所生成的格或模不变，同时以唯一的代表元使这一结构显式化。<sup>[1](https://ncatlab.org/nlab/show/Hermite%2Bnormal%2Bform)</sup>

| 关键事实 | 详情 |
|---|---|
| 定义 | 一个整数矩阵处于 HNF，当且仅当每个非零行的第一个非零元素（主元）为正，且严格位于上一行主元的右侧；每个主元上方的元素非负且小于该主元；非主元列中的元素可以为负<sup>[1](https://ncatlab.org/nlab/show/Hermite%2Bnormal%2Bform)</sup><sup> • </sup><sup>[18](https://fredrikj.net/fdoc/html/algorithms/linear-algebra/hermite-smith.html)</sup> |
| 两种约定 | 行式形式为 H = LM，其中幺模矩阵 L 作用于行；列式形式为 H = MR，其中幺模矩阵 R 作用于列<sup>[2](https://hsnf.readthedocs.io/en/latest/definition.html)</sup> |
| 唯一性 | 对固定的约定，给定矩阵的 HNF 是唯一的；例如 FLINT 计算的是 A 的“唯一（行）埃尔米特标准形”<sup>[3](https://flintlib.org/doc/fmpz_mat.html)</sup> |
| 首个多项式时间算法 | 坎南与巴赫姆，《SIAM 计算杂志》8(4)，1979 年，将代数运算次数与所有中间数的二进制位数都以输入长度的多项式为界<sup>[4](https://people.tamu.edu/~rojas/kannanbachemhermitesmith79.pdf)</sup> |
| 模方法 | 多米奇、坎南与特罗特（1987）将整个计算在行列式模下进行，给出了以输入字符串长度为函数的多项式界<sup>[5](https://pubsonline.informs.org/doi/pdf/10.1287/moor.12.1.50)</sup> |
| 应用 | 整数规划、密码学、抽象代数 |
| 软件 | SymPy、SageMath、FLINT 与 Wolfram Language 都提供 HNF 例程，约定与算法选择各不相同<sup>[6](https://docs.sympy.org/latest/modules/matrices/normalforms.html)</sup><sup> • </sup><sup>[7](https://mathworld.wolfram.com/HermiteNormalForm.html)</sup> |

## 定义与约定

矩阵 \( H \in \mathrm{Mat}_{n \times m}(\mathbb{Z}) \) 处于埃尔米特标准形，当且仅当以下三个条件成立：每个非零行都排在所有零行之前；每个非零行的第一个非零元素 \( p_i \)（称为主元）为正，且所在列严格位于上一行主元所在列的右侧；每个主元上方的元素非负且严格小于该主元，即对 \( 1 \le i' < i \) 有 \( H_{i',j_i} < p_i \)，而非主元列中的元素可以为负。<sup>[1](https://ncatlab.org/nlab/show/Hermite%2Bnormal%2Bform)</sup><sup> • </sup><sup>[18](https://fredrikj.net/fdoc/html/algorithms/linear-algebra/hermite-smith.html)</sup> 有些作者采用略有不同的约定，例如要求非主元元素为负而非为正，或要求矩阵为上三角而非下三角。<sup>[1](https://ncatlab.org/nlab/show/Hermite%2Bnormal%2Bform)</sup><sup> • </sup><sup>[8](https://www.math.ucdavis.edu/~daddel/MATH22AL/Resources/Linear_Algebra_Glossary.html)</sup>

该形式有两种取向。在行式定义中，幺模矩阵 \( L \) 左乘 \( A \)，即 \( H = LM \)，变换作用于行；在列式定义中，幺模矩阵 \( R \) 作用于列，即 \( H = MR \)。<sup>[2](https://hsnf.readthedocs.io/en/latest/definition.html)</sup> 两种约定产生的结果看起来互为转置，不同软件采用的约定也不同：Wolfram Language 的 `HermiteDecomposition` 采用行约定，结果为上三角，并以关于对角元素的平衡余数取代主元条件。<sup>[7](https://mathworld.wolfram.com/HermiteNormalForm.html)</sup>

任何非奇异整数矩阵都可以通过一系列幺模列变换化为 HNF：将一列的整数倍加到另一列、交换两列、或将一列乘以 −1。<sup>[8](https://www.math.ucdavis.edu/~daddel/MATH22AL/Resources/Linear_Algebra_Glossary.html)</sup> 作为一个具体例子，矩阵

\[ \begin{pmatrix} 5 & 2 & 1 \\ -4 & 2 & 4 \\ 0 & -3 & 6 \end{pmatrix} \]

的埃尔米特标准形为

\[ \begin{pmatrix} 1 & 0 & 0 \\ 4 & 6 & 0 \\ 6 & 15 & 30 \end{pmatrix}. \]

<sup>[8](https://www.math.ucdavis.edu/~daddel/MATH22AL/Resources/Linear_Algebra_Glossary.html)</sup> SymPy 的文档给出了一个行式的例子，其中矩阵 \( \begin{pmatrix} 12 & 6 & 4 \\ 3 & 9 & 6 \\ 2 & 16 & 14 \end{pmatrix} \) 约化为 \( \begin{pmatrix} 10 & 0 & 2 \\ 0 & 15 & 3 \\ 0 & 0 & 2 \end{pmatrix} \)。<sup>[6](https://docs.sympy.org/latest/modules/matrices/normalforms.html)</sup>

HNF 与史密斯标准形密切相关但有所不同：后者将矩阵对角化，且在任何主理想整环上都存在；HNF 是类阶梯形而非对角形，正是 SageMath 所谓“整数环上的阶梯形”。<sup>[9](https://sagemath.gitlab.io/documentation/html/en/reference/matrices/sage/matrix/matrix_integer_dense.html)</sup>

## 保持的结构

乘以幺模矩阵改变的是矩阵的行（或列）所生成的整数格的基，而非格本身，因此 HNF 是该格的一个典范代表元。这正是它可用于表示格以及求解整数坐标线性方程组的原因：两个矩阵具有相同的 HNF，当且仅当它们生成相同的格。

行列式也随之保持。对于方阵非奇异输入，由于变换矩阵的行列式为 ±1，HNF 的行列式等于输入的行列式（差一个符号）。SymPy 在其接口中利用了这一点：可选参数 `D` 接受任何已知为 HNF 行列式倍数的正整数，当输入为满行秩时，例程便可使用一个在模 D 下工作的替代算法，以防止系数爆炸。<sup>[6](https://docs.sympy.org/latest/modules/matrices/normalforms.html)</sup>

## 算法

**系数爆炸问题。** 经典的消元式 HNF 算法会遭遇中间元素迅速增长的问题；布兰金希普根据经验观察到，在标准计算过程中中间数可能变得相当大。弗鲁姆金指出，当时已知的将整数矩阵化为史密斯或埃尔米特标准形的算法，没有一个被证明具有多项式时间的运行时间界。<sup>[4](https://people.tamu.edu/~rojas/kannanbachemhermitesmith79.pdf)</sup>

**坎南与巴赫姆，1979 年。** 时任卡内基-梅隆大学理论计算机科学家的 拉温德兰·坎南与阿希姆·巴赫姆 给出了新算法，其中代数运算次数与所有中间数的二进制位数都以二进制编码输入长度的多项式为界。他们的算法还计算乘子矩阵，该文首次证明了存在元素足够小的乘子。其方法通过依次将主子式化为 HNF 来计算整数矩阵的 HNF。<sup>[4](https://people.tamu.edu/~rojas/kannanbachemhermitesmith79.pdf)</sup><sup> • </sup><sup>[10](https://staff.itee.uq.edu.au/havas/TR0295.pdf)</sup> FLINT 对该方法的实现仍然依次将主子式化为埃尔米特标准形。<sup>[3](https://flintlib.org/doc/fmpz_mat.html)</sup>

**模行列式算术。** 多米奇、坎南与特罗特描述了一类 HNF 过程，所有算术都在结果的行列式模下进行，从而给出以输入字符串长度为函数的多项式时间复杂度界。<sup>[5](https://pubsonline.informs.org/doi/pdf/10.1287/moor.12.1.50)</sup> 这正是 FLINT 的 `fmpz_mat_hnf_modular` 背后的算法，它假定输入为满列秩，且 D 是结果非零行的行列式的正倍数；SymPy 的 `D` 参数也基于此。<sup>[3](https://flintlib.org/doc/fmpz_mat.html)</sup><sup> • </sup><sup>[6](https://docs.sympy.org/latest/modules/matrices/normalforms.html)</sup>

**空间与后续改进。** 2001 年以前，用当时最好的算法计算 \( n \times n \) 整数矩阵的 HNF 通常需要 \( O(n^{3} \log M) \) 空间，其中 M 界定了输入各列的长度。加州大学圣迭戈分校的密码学与计算数论研究者 达尼埃莱·米恰恩乔与博格丹·瓦林斯基 给出了一个算法，其空间本质上等于输入规模 \( O(n^{2} \log M) \)，同时在标准整数算术下与渐近最快的算法时间复杂性相当，并配有使其保持实用的启发式策略。<sup>[11](https://cseweb.ucsd.edu/~daniele/papers/HNFalg.html)</sup> 更近期的工作将代价推向矩阵乘法本身的代价：拉巴恩与施托约翰的一个拉斯维加斯随机算法计算方阵非奇异矩阵的埃尔米特形，所用的位运算次数与相乘两个同维数、同元素规模的矩阵大致相同，失败概率至多 1/2，但只要不报告失败就总是返回正确结果。<sup>[12](https://arxiv.org/abs/2605.07784)</sup>

**推广。** HNF 可推广到整数之外。对于多项式环 \( \mathbb{Z}[x] \) 上的矩阵，广义埃尔米特标准形等价于列所生成的模的约化格罗布纳基，一个使用亨泽尔提升的模算法利用了 \( \mathbb{Z}[x] \) 中理想的格罗布纳基结构；后来的一篇论文给出了该广义形式的第一个多项式时间算法。<sup>[13](https://doi.org/10.1016%2Fj.jsc.2016.12.005)</sup><sup> • </sup><sup>[14](https://www.sciencedirect.com/science/article/pii/S0304397518304845)</sup> 对于数域 K 的整数环 \( \mathcal{O}_K \) 上的模，亨利·科恩 1996 年的著作《计算代数数论教程》提出了一个基于模理想归约的模算法，并猜想其运行时间为多项式时间；比亚斯、菲克与霍夫曼修改了该方法以防止系数膨胀，并以输入规模和 K 的不变量严格评估了其复杂性。<sup>[15](https://www.sciencedirect.com/science/article/pii/S0747717116300736)</sup> 对于域上的单变量多项式矩阵，一个确定性算法以 \( \tilde{O}(n^{\omega} d) \) 次运算计算次数为 d 的方阵非奇异 \( n \times n \) 矩阵的 HNF。<sup>[16](https://arxiv.org/abs/1602.02049)</sup>

## 应用

HNF 用于整数规划、密码学与抽象代数。在整数规划中，明·S.·洪与沃尔特·O.·罗姆 1990 年发表于《线性代数及其应用》的论文直接发展了埃尔米特标准形在该领域的应用。<sup>[17](https://www.sciencedirect.com/science/article/pii/0024379590902285)</sup> 在一般的格计算中，该形式充当矩阵各行所生成的格的典范基，而格约化及相关密码学构造正是在这一表示上运作的。

## 软件实现

若干计算机代数系统以不同名称和约定提供 HNF。SageMath 称之为整数环上的阶梯形，提供带可选变换矩阵的 `hermite_form`，算法选项包括 flint 与 padic。<sup>[9](https://sagemath.gitlab.io/documentation/html/en/reference/matrices/sage/matrix/matrix_integer_dense.html)</sup> SymPy 在 `sympy.matrices.normalforms` 中提供 `hermite_normal_form`，若矩阵定义域不是 ZZ 则抛出 `DMDomainError`，若对行数多于列数的矩阵使用模 D 算法则抛出 `DMShapeError`；其文档引用了科恩的算法 2.4.5 与 2.4.8。<sup>[6](https://docs.sympy.org/latest/modules/matrices/normalforms.html)</sup> FLINT 根据输入矩阵的特征在经典实现、基于 xgcd 的实现与模实现之间选择。<sup>[3](https://flintlib.org/doc/fmpz_mat.html)</sup> Wolfram Language 的函数为 `HermiteDecomposition`。<sup>[7](https://mathworld.wolfram.com/HermiteNormalForm.html)</sup>

## References

1. [Hermite normal form, nLab](https://ncatlab.org/nlab/show/Hermite%2Bnormal%2Bform)
2. [Definition, hsnf documentation](https://hsnf.readthedocs.io/en/latest/definition.html)
3. [fmpz_mat.h – matrices over the integers, FLINT 3.7.0-dev documentation](https://flintlib.org/doc/fmpz_mat.html)
4. [Ravindran Kannan and Achim Bachem (1979). Polynomial Algorithms for Computing the Smith and Hermite Normal Forms of an Integer Matrix. SIAM Journal on Computing 8(4):499-507.](https://people.tamu.edu/~rojas/kannanbachemhermitesmith79.pdf)
5. [P. D. Domich, R. Kannan, L. E. Trotter, Jr. (1987). Hermite Normal Form Computation Using Modulo Determinant Arithmetic. Mathematics of Operations Research 12(1):50-59.](https://pubsonline.informs.org/doi/pdf/10.1287/moor.12.1.50)
6. [Matrix Normal Forms, SymPy 1.14.0 documentation](https://docs.sympy.org/latest/modules/matrices/normalforms.html)
7. [Hermite Normal Form, Wolfram MathWorld](https://mathworld.wolfram.com/HermiteNormalForm.html)
8. [Linear Algebra Glossary, UC Davis](https://www.math.ucdavis.edu/~daddel/MATH22AL/Resources/Linear_Algebra_Glossary.html)
9. [Dense matrices over the integer ring, Sage 9.4 Reference Manual](https://sagemath.gitlab.io/documentation/html/en/reference/matrices/sage/matrix/matrix_integer_dense.html)
10. [George Havas. Complexity of the Havas, Majewski, Matthews LLL Hermite Normal Form algorithm (report citing Kannan-Bachem method).](https://staff.itee.uq.edu.au/havas/TR0295.pdf)
11. [Daniele Micciancio, Bogdan Warinschi (2001). A linear space algorithm for computing the Hermite normal form. ISSAC 2001, pp. 231-236.](https://cseweb.ucsd.edu/~daniele/papers/HNFalg.html)
12. [George Labahn, Arne Storjohann. Computing bases in Hermite normal form of lattices of integer relations. arXiv:2605.07784.](https://arxiv.org/abs/2605.07784)
13. [Rui-Juan Jing, Chun-Ming Yuan (2017). A modular algorithm to compute the generalized Hermite normal form for Z[x]-lattices. Journal of Symbolic Computation 81:97-118.](https://doi.org/10.1016%2Fj.jsc.2016.12.005)
14. [A polynomial time algorithm to compute generalized Hermite normal forms of matrices over Z[x]. Journal of Symbolic Computation.](https://www.sciencedirect.com/science/article/pii/S0304397518304845)
15. [Jean-François Biasse, Claus Fieker, Tommy Hofmann (2017). On the computation of the HNF of a module over the ring of integers of a number field. Journal of Symbolic Computation 80:581-615.](https://www.sciencedirect.com/science/article/pii/S0747717116300736)
16. [A fast, deterministic algorithm for computing a Hermite Normal Form of a polynomial matrix. arXiv:1602.02049.](https://arxiv.org/abs/1602.02049)
17. [Ming S. Hung, Walter O. Rom (1990). An application of the Hermite normal form in integer programming. Linear Algebra and its Applications 140:163-179.](https://www.sciencedirect.com/science/article/pii/0024379590902285)
18. [Hermite and Smith normal forms, FLINT](https://fredrikj.net/fdoc/html/algorithms/linear-algebra/hermite-smith.html)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026; Oct 25, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 数与代数 › Computational and symbolic algebra › Symbolic and algebraic algorithms › Exact and symbolic linear algebra algorithms

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/hermite-normal-form

English original: https://www.edgepedia.org/hermite-normal-form
