Gram Matrix (AᵀA)
Easy
~12 min
code completion
The Gram Matrix
The Gram matrix of a matrix A is defined as:
This appears throughout ML:
In NumPy:
G = A.T @ A
Your task:
Implement gram_matrix(A) that computes .
Example Tests
Identity input gives identity output
Input: {"A":[[1,0],[0,1]]}
Expected: [[1,0],[0,1]]
3x2 matrix gives 2x2 Gram matrix
Input: {"A":[[1,2],[3,4],[5,6]]}
Expected: [[35,44],[44,56]]
Result is always square (n x n)
Input: {"A":[[1,2,3],[4,5,6]]}
Expected: [3,3]