In linear algebra, the Gram matrix (or Gramian matrix, Gramian) of a set of vectors v 1 , … , v n {\displaystyle v_{1},\dots ,v_{n}} in an inner product space is the Hermitian matrix of inner products, whose entries are given by the inner product G i j = ⟨ v i , v j ⟩ {\displaystyle G_{ij}=\left\langle v_{i},v_{j}\right\rangle } . If the vectors v 1 , … , v n {\displaystyle v_{1},\dots ,v_{n}} are the columns of matrix X {\displaystyle X} then the Gram matrix is X † X {\displaystyle X^{\dagger }X} in the general case that the vector coordinates are complex numbers, which simplifies to X ⊤ X {\displaystyle X^{\top }X} for the case that the vector coordinates are real numbers.
An important application is to compute linear independence: a set of vectors are linearly independent if and only if the Gram determinant (the determinant of the Gram matrix) is non-zero.
It is named after Jørgen Pedersen Gram.