# Gram矩阵

**Gram矩阵**是一个方阵 \( G(a_1, \dots, a_k) = \| g_{\alpha\beta} \| \)，其元素为一组向量 \( a_1, \dots, a_k \) 在（准）Hilbert空间中的两两内积 \( g_{\alpha\beta} = (a_\alpha, a_\beta) \)。<sup>[1](https://encyclopediaofmath.org/wiki/Gram_matrix)</sup> 它记录了内积所能表达的关于这些向量的一切信息：长度、夹角和线性相关性。该矩阵及其行列式以丹麦数学家约尔根·佩德森·Gram（Jørgen Pedersen Gram，1850–1916）命名，他1879年的博士论文中包含了如今被称为Gram–Schmidt正交化方法的技术。<sup>[2](https://mathshistory.st-andrews.ac.uk/Biographies//Gram/)</sup>

| 关键事实 | 详情 |
|---|---|
| 定义 | \( G_{\alpha\beta} = (a_\alpha, a_\beta) \)，即（准）Hilbert空间中向量的两两内积<sup>[1](https://encyclopediaofmath.org/wiki/Gram_matrix)</sup> |
| 矩阵形式 | 对于 \( \mathbb{R}^n \) 或 \( \mathbb{C}^n \) 中的 \( k \) 个列向量，\( G = \overline{A}^{\,T} A \)，其中 \( A \) 以这些向量为列<sup>[1](https://encyclopediaofmath.org/wiki/Gram_matrix)</sup> |
| 正定性 | 每个Gram矩阵都是非负定的；当且仅当 \( a_1, \dots, a_k \) 线性无关时，它是正定的<sup>[1](https://encyclopediaofmath.org/wiki/Gram_matrix)</sup> |
| 逆命题 | 任何非负（正）定 \( k \times k \) 矩阵都是某组向量的Gram矩阵（正定情形下定义向量线性无关）<sup>[1](https://encyclopediaofmath.org/wiki/Gram_matrix)</sup> |
| 秩 | 当向量线性相关时奇异；当向量无关时满秩 \( k \)<sup>[3](https://www.math.ucdavis.edu/~daddel/MATH22AL/Resources/Linear_Algebra_Glossary.html)</sup> |
| Gram行列式 | 向量线性无关当且仅当其Gram行列式不为零<sup>[4](https://encyclopediaofmath.org/wiki/Hilbert_space)</sup> |
| 机器学习中的作用 | 正定核的核矩阵 \( K_{ij} = k(x_i, x_j) \) 就是一个Gram矩阵；核PCA从其主特征向量计算特征<sup>[5](https://tropp.caltech.edu/notes/Tro22-Matrix-Analysis-LN.pdf)</sup> |

## 基本性质

对于 \( n \) 维欧几里得（或Hermite）空间中带通常标量积的 \( n \times k \) 矩阵 \( A \) 的 \( k \) 个列向量，Gram矩阵为 \( G = \overline{A}^{\,T} A \)，其中横线表示复共轭。<sup>[1](https://encyclopediaofmath.org/wiki/Gram_matrix)</sup> 这一分解使定义性质一目了然。该矩阵是对称的（复情形下为Hermite的），且对任意系数向量 \( c \)，

\[ c^{*} G c = \left\| \sum_{\alpha} c_\alpha a_\alpha \right\|^{2} \ge 0, \]<sup>[16](https://www.clinicalbiostats.com/tutorials/undergraduate-mathematics-linear-algebra/gram-matrices-as-orthonormality-tests/)</sup>

因此 \( G \) 总是半正定的。等号成立当且仅当线性组合 \( \sum_\alpha c_\alpha a_\alpha \) 为零，因此正定性等价于定义向量的线性无关性。<sup>[1](https://encyclopediaofmath.org/wiki/Gram_matrix)</sup> 相应地，当任一向量与其他向量线性相关时Gram矩阵奇异，当向量无关时满秩 \( k \)。<sup>[3](https://www.math.ucdavis.edu/~daddel/MATH22AL/Resources/Linear_Algebra_Glossary.html)</sup>

逆命题同样成立：任何非负定 \( k \times k \) 矩阵都是某组向量的Gram矩阵，任何正定矩阵都是线性无关向量的Gram矩阵。<sup>[1](https://encyclopediaofmath.org/wiki/Gram_matrix)</sup> 因此Gram矩阵恰好与对称半正定矩阵重合。

行列式 \( \det G \) 称为**Gram行列式**，度量向量张成的体积的平方。它恰在向量线性相关时为零。<sup>[4](https://encyclopediaofmath.org/wiki/Hilbert_space)</sup>

## 基变换下的行为

若基 \( (e_1, \dots, e_n) \) 通过变换 \( S \) 替换为 \( (\tilde{e}_1, \dots, \tilde{e}_n) \)，则两个基的Gram矩阵满足

\[ \tilde{G} = S' G S, \]

其中 \( S' \) 为 \( S \) 的转置。通过非奇异 \( S \) 以这种方式相关的矩阵称为合同的，因此基变换在Gram矩阵之间产生合同关系。<sup>[6](https://www.ese.wustl.edu/~nehorai/Porat_A_Gentle_Introduction_to_Tensors_2014.pdf)</sup> Sylvester惯性定律随即适用：每个实对称矩阵 \( G \) 都合同于一个对角矩阵 \( \Lambda \)，其元素为 \( +1 \)、\( -1 \) 或 \( 0 \)，且除对角元素的排列次序外，\( \Lambda \) 是唯一的。<sup>[6](https://www.ese.wustl.edu/~nehorai/Porat_A_Gentle_Introduction_to_Tensors_2014.pdf)</sup>

Gram矩阵还决定了向量本身的几何。具有相同Gram矩阵的两个有序向量组通过其线性张成空间上的等距变换相联系，并且在环境空间维数允许的条件下，逆命题也成立。<sup>[7](https://watanabe.you/wiki/Gram%20Matrix)</sup> 换言之，Gram矩阵在刚体运动意义下编码了向量的构型。

## 起源

约尔根·佩德森·Gram（1850年6月27日–1916年4月29日）在其整个职业生涯中平衡了纯数学与实际应用，包括林业、概率论和数值分析方面的工作。他1879年的博士论文以最小二乘法确定的级数展开为主题，包含了将一组平方可积函数正交化的方法——即如今所称的Gram–Schmidt方法——并在积分方程理论的发展中发挥了重要作用。<sup>[2](https://mathshistory.st-andrews.ac.uk/Biographies//Gram/)</sup><sup> • </sup><sup>[8](https://lex.dk/J%C3%B8rgen_Pedersen_Gram)</sup> Gram还是丹麦保险界颇具影响力的精算师，自1884年起执掌Skjold公司，1895年起担任Hafnia董事，1910年起主持丹麦保险理事会。<sup>[8](https://lex.dk/J%C3%B8rgen_Pedersen_Gram)</sup> 他在哥本哈根前往丹麦科学院参加会议途中被自行车撞倒身亡，享年六十五岁。<sup>[2](https://mathshistory.st-andrews.ac.uk/Biographies//Gram/)</sup>

## 核方法与核技巧

在机器学习中，Gram矩阵以**核矩阵**的形式出现。函数 \( k : \mathcal{X}^2 \to \mathbb{R} \) 是正定核，若对每个有限点集 \( x_1, \dots, x_n \)，以 \( K_{ij} = k(x_i, x_j) \) 为元素的矩阵 \( K \) 是半正定的。<sup>[9](https://www.stat.berkeley.edu/~bartlett/courses/2014spring-cs281bstat241b/lectures/20-notes.pdf)</sup> 当 \( k \) 为内积核 \( k(x, y) = \langle x, y \rangle \) 时，该矩阵恰为数据点的Gram矩阵 \( G = [\langle x_j, x_k \rangle] \)，而任何正定核的核矩阵都是它的深远推广。<sup>[5](https://tropp.caltech.edu/notes/Tro22-Matrix-Analysis-LN.pdf)</sup>

**核技巧**利用了这一结构。许多针对欧几里得数据的分析方法——包括主成分分析（PCA）、典型相关分析、线性判别分析和岭回归——仅通过Gram矩阵依赖于数据。用正定核矩阵替换Gram矩阵即产生这些方法的非线性版本，而无需显式计算高维特征向量。在核PCA中，核矩阵的主特征向量定义了形如 \( \varphi(x) = \sum_i u_i K(x, x_i) \) 的特征。<sup>[5](https://tropp.caltech.edu/notes/Tro22-Matrix-Analysis-LN.pdf)</sup> 对核方法的主要实际批评是，稠密 \( n \times n \) 矩阵上的线性代数运算妨碍了其在大数据集上的应用。<sup>[5](https://tropp.caltech.edu/notes/Tro22-Matrix-Analysis-LN.pdf)</sup>

Gram矩阵还将距离与内积联系起来。由Schoenberg定理，对于对角为零的平方距离对称矩阵 \( A \)，双中心化矩阵 \( \bar{A} = -P_e A P_e \) 半正定当且仅当 \( A \) 是欧几里得距离矩阵，且最小嵌入维数等于 \( \bar{A} \) 的秩。<sup>[10](https://groups.seas.harvard.edu/courses/cs281/papers/burges-2009.pdf)</sup>

## 大规模计算

构造完整的 \( n \times n \) Gram矩阵本身就是 \( O(N^2) \) 的操作，稠密地使用它对于大样本而言代价高昂。半正定性是一种强结构约束，使廉价近似成为可能。<sup>[11](https://jmlr.csail.mit.edu/papers/volume3/bach02a/bach02a.pdf)</sup>

**低秩近似。** 不完全Cholesky分解找到一个大小为 \( N \times M \)（\( M \) 较小）的因子 \( \tilde{G}_e \)，使得 \( K - \tilde{G}_e \tilde{G}_e^{T} \) 的范数低于选定精度 \( \eta \)，计算量为 \( O(M^2 N) \) 次运算，存储量为 \( O(MN) \)；只需在内存中保留 \( K \) 的对角线，其他元素按需计算。<sup>[11](https://jmlr.csail.mit.edu/papers/volume3/bach02a/bach02a.pdf)</sup> 对于具有高斯核的指数衰减输入分布，常数精度下秩 \( O(\log N) \) 即足够。<sup>[11](https://jmlr.csail.mit.edu/papers/volume3/bach02a/bach02a.pdf)</sup> Nyström方法从矩阵少量列和行的样本近似对称半正定矩阵，将核方法的时间复杂度从 \( O(n^3) \) 降至 \( O(\ell^2 n) \)，其中 \( \ell \) 为采样列数。<sup>[12](https://www.sciencedirect.com/science/article/abs/pii/S1566253515000317)</sup>

**随机近似。** 给定具有 \( n \) 列的实矩阵 \( A \)，Gram积 \( A A^T \) 可由 \( c \ll n \) 个 \( A \) 的列的加权外积近似。从 \( c \ge \mathrm{rank}(A) \) 个采样列精确恢复 \( A A^T \) 取决于 \( A \) 的右奇异向量矩阵，而蒙特卡洛采样方案对2-范数相对误差的概率界依赖于 \( A \) 的稳定秩或秩，而非矩阵维数。<sup>[13](https://arxiv.org/abs/1310.1502)</sup>

## 核之外的应用

三个单位向量（两两内积为 \( u \)、\( v \) 和 \( t \)）的Gram矩阵是半正定的，这等价于不等式 \( 1 + 2uvt - u^2 - v^2 - t^2 \ge 0 \)；这一约束是球面码的半定规划界的基础。<sup>[14](https://www.ams.org/journals/jams/2008-21-03/S0894-0347-07-00589-9/S0894-0347-07-00589-9.pdf)</sup> 固定秩半正定矩阵流形上的Gram矩阵轨迹已被用于人类行为理解中随时间比较形状，将空间协方差与仿射形状表示相结合，用于基于3D骨骼数据的动作识别和面部表情识别等任务。<sup>[15](https://arxiv.org/abs/1807.00676)</sup>

## References

1. [Gram matrix, Encyclopedia of Mathematics (L.P. Kuptsov, originator)](https://encyclopediaofmath.org/wiki/Gram_matrix)
2. [J J O'Connor and E F Robertson, "Jørgen Pedersen Gram," MacTutor History of Mathematics](https://mathshistory.st-andrews.ac.uk/Biographies//Gram/)
3. [Linear Algebra Glossary, UC Davis Mathematics](https://www.math.ucdavis.edu/~daddel/MATH22AL/Resources/Linear_Algebra_Glossary.html)
4. [Hilbert space, Encyclopedia of Mathematics](https://encyclopediaofmath.org/wiki/Hilbert_space)
5. [J. A. Tropp, Matrix Analysis, Caltech ACM 204 lecture notes, Lecture 18](https://tropp.caltech.edu/notes/Tro22-Matrix-Analysis-LN.pdf)
6. [A. Porat, "A Gentle Introduction to Tensors," §1.11.2 The Gram Matrix, Washington University in St. Louis](https://www.ese.wustl.edu/~nehorai/Porat_A_Gentle_Introduction_to_Tensors_2014.pdf)
7. [Gram Matrix, Watanabe Y. wiki](https://watanabe.you/wiki/Gram%20Matrix)
8. [Jesper Lützen, "Jørgen Pedersen Gram," Den Store Danske / Lex, Københavns Universitet](https://lex.dk/J%C3%B8rgen_Pedersen_Gram)
9. [Kernels and inner product spaces, UC Berkeley CS281B/STAT241B lecture notes](https://www.stat.berkeley.edu/~bartlett/courses/2014spring-cs281bstat241b/lectures/20-notes.pdf)
10. [C. J. C. Burges, "From RankNet to LambdaRank to LambdaMART," §3.2 Multidimensional Scaling](https://groups.seas.harvard.edu/courses/cs281/papers/burges-2009.pdf)
11. [F. R. Bach and M. I. Jordan, "Kernel Independent Component Analysis," Journal of Machine Learning Research 3 (2002) 1–48](https://jmlr.csail.mit.edu/papers/volume3/bach02a/bach02a.pdf)
12. ["A review of Nyström methods for large-scale machine learning," Information Fusion](https://www.sciencedirect.com/science/article/abs/pii/S1566253515000317)
13. [J. T. Holodnak and I. C. F. Ipsen, "Randomized Approximation of the Gram Matrix: Exact Computation and Probabilistic Bounds," arXiv:1310.1502](https://arxiv.org/abs/1310.1502)
14. [C. Bachoc and F. Vallentin, "New upper bounds for kissing numbers from semidefinite programming," Journal of the AMS 21 (2008)](https://www.ams.org/journals/jams/2008-21-03/S0894-0347-07-00589-9/S0894-0347-07-00589-9.pdf)
15. ["A Novel Geometric Framework on Gram Matrix Trajectories for Human Behavior Understanding," arXiv:1807.00676](https://arxiv.org/abs/1807.00676)
16. [Gram Matrices as Orthonormality Tests, clinicalbiostats.com](https://www.clinicalbiostats.com/tutorials/undergraduate-mathematics-linear-algebra/gram-matrices-as-orthonormality-tests/)

---
*Initially written Oct 15, 2026 · Edited: Oct 25, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 数与代数 › Linear and multilinear algebra › Matrix theory › Structured and special matrix classes

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/gram-matrix

English original: https://www.edgepedia.org/gram-matrix
